Skip to content

Commit 04a80e0

Browse files
David MaloneyDavid Maloney
authored andcommitted
Fixes to the WMI setup
1 parent 208e706 commit 04a80e0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/msf/core/exploit/winrm.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def initialize(info = {})
2727
OptString.new('URI', [ true, "The URI of the WinRM service", "/wsman" ]),
2828
OptString.new('USERNAME', [ false, 'A specific username to authenticate as' ]),
2929
OptString.new('PASSWORD', [ false, 'A specific password to authenticate with' ]),
30-
OptString.new('NAMESPACE', [true, 'The WMI namespace to use for queries', '/root/cimv2/'])
3130
], self.class
3231
)
3332

@@ -324,6 +323,12 @@ def target_url
324323
end
325324
end
326325

326+
def wmi_namespace
327+
return datastore['NAMESPACE'] if datastore['NAMESPACE']
328+
return @namespace_override if @namespace_override
329+
return "/root/cimv2/"
330+
end
331+
327332

328333
private
329334

@@ -434,7 +439,7 @@ def winrm_header(data)
434439
def winrm_uri_action(type)
435440
case type
436441
when "wql"
437-
return %Q{<w:ResourceURI mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi#{datastore['NAMSPACE']}*</w:ResourceURI>
442+
return %Q{<w:ResourceURI mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi#{wmi_namespace}*</w:ResourceURI>
438443
<a:Action mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action>}
439444
when "create_shell"
440445
return %q{<w:ResourceURI mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>

modules/auxiliary/scanner/winrm/winrm_wql.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def initialize
4040
[
4141
OptString.new('WQL', [ true, "The WQL query to run", "Select Name,Status from Win32_Service" ]),
4242
OptString.new('USERNAME', [ true, "The username to authenticate as"]),
43-
OptString.new('PASSWORD', [ true, "The password to authenticate with"])
43+
OptString.new('PASSWORD', [ true, "The password to authenticate with"]),
44+
OptString.new('NAMESPACE', [true, 'The WMI namespace to use for queries', '/root/cimv2/'])
4445
], self.class)
4546
end
4647

0 commit comments

Comments
 (0)