Skip to content

Commit c91f0ca

Browse files
David MaloneyDavid Maloney
authored andcommitted
Adds the WQL execution module
1 parent b15c38f commit c91f0ca

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
17+
class Metasploit3 < Msf::Auxiliary
18+
19+
include Msf::Exploit::Remote::WinRM
20+
include Msf::Auxiliary::Report
21+
22+
23+
include Msf::Auxiliary::Scanner
24+
25+
def initialize
26+
super(
27+
'Name' => 'WinRM WQL Query Runner',
28+
'Version' => '$Revision$',
29+
'Description' => %q{
30+
This module runs WQL queries against remote WinRM Services.
31+
Authentication is required. Currently only works with NTLM auth.
32+
},
33+
'Author' => [ 'thelightcosine' ],
34+
'License' => MSF_LICENSE
35+
)
36+
37+
register_options(
38+
[
39+
OptString.new('WQL', [ true, "The WQL query to run", "Select Name,Status from Win32_Service" ]),
40+
OptString.new('USERNAME', [ true, "The username to authenticate as"]),
41+
OptString.new('PASSWORD', [ true, "The password to authenticate with"])
42+
], self.class)
43+
end
44+
45+
46+
def run_host(ip)
47+
unless accepts_ntlm_auth
48+
print_error "The Remote WinRM server (#{ip} does not appear to allow Negotiate(NTLM) auth"
49+
return
50+
end
51+
52+
resp,c = send_request_ntlm(winrm_wql_msg(datastore['WQL']))
53+
if resp.code == 401
54+
print_error "Login Failure! Recheck the supplied credentials."
55+
return
56+
end
57+
58+
unless resp.code == 200
59+
print_error "Got unexpected response from #{ip}: \n #{resp.to_s}"
60+
return
61+
end
62+
resp_tbl = parse_wql_response(resp)
63+
print_good resp_tbl.to_s
64+
store_loot("winrm.wql_results", "text/csv", ip, resp_tbl.to_csv, "winrm_wql_results.csv", "WinRM WQL Query Results")
65+
end
66+
67+
68+
69+
end

0 commit comments

Comments
 (0)