Module: Msf::Payload::Python
- Included in:
- BindTcp, MeterpreterLoader, ReverseTcp, ReverseTcpSsl
- Defined in:
- lib/msf/core/payload/python.rb
Defined Under Namespace
Modules: BindTcp, MeterpreterLoader, ReverseHttp, ReverseTcp, ReverseTcpSsl, SendUUID
Constant Summary collapse
- ForceDynamicCachedSize =
Mark the payload as dynamic, as the zlib compression with a single char change can lead to size changes even if the original payload is the same length
true
Class Method Summary collapse
-
.create_exec_stub(python_code) ⇒ String
Encode the given python command in base64 and wrap it with a stub that will decode and execute it on the fly.
Instance Method Summary collapse
Class Method Details
.create_exec_stub(python_code) ⇒ String
Encode the given python command in base64 and wrap it with a stub that will decode and execute it on the fly. The code will be condensed to one line and compatible with all Python versions supported by the Python Meterpreter stage.
16 17 18 19 20 21 |
# File 'lib/msf/core/payload/python.rb', line 16 def self.create_exec_stub(python_code) # Encoding is required in order to handle Python's formatting payload = Rex::Text.encode_base64(Rex::Text.zlib_deflate(python_code)) b64_stub = "exec(__import__('zlib').decompress(__import__('base64').b64decode(__import__('codecs').getencoder('utf-8')('#{payload}')[0])))" b64_stub end |
Instance Method Details
#py_create_exec_stub(python_code) ⇒ Object
23 24 25 |
# File 'lib/msf/core/payload/python.rb', line 23 def py_create_exec_stub(python_code) Msf::Payload::Python.create_exec_stub(python_code) end |