Files
metasploit-gs/modules/post/windows/gather/resolve_sid.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.5 KiB
Ruby
Raw Normal View History

2011-02-22 20:49:44 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2011-02-22 20:49:44 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::Windows::Accounts
2013-08-30 16:28:54 -05:00
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Windows Gather Local User Account SID Lookup',
'Description' => %q{
This module prints information about a given SID from the perspective
of this session.
},
2023-02-08 13:47:34 +00:00
'License' => MSF_LICENSE,
'Author' => [ 'chao-mu'],
'Platform' => [ 'win' ],
'SessionTypes' => ['meterpreter'],
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [],
'SideEffects' => []
}
2023-02-08 13:47:34 +00:00
)
)
register_options([
OptString.new('SID', [ true, 'SID to lookup' ]),
OptString.new('SYSTEM_NAME', [ false, 'Where to search. If undefined, first local then trusted DCs' ]),
])
end
2013-08-30 16:28:54 -05:00
def run
sid = datastore['SID']
target_system = datastore['SYSTEM_NAME']
2013-08-30 16:28:54 -05:00
2023-02-08 13:47:34 +00:00
info = resolve_sid(sid, target_system || nil)
2013-08-30 16:28:54 -05:00
fail_with(Failure::Unknown, 'Unable to resolve SID. Giving up.') if info.nil?
2013-08-30 16:28:54 -05:00
sid_type = info[:type]
2013-08-30 16:28:54 -05:00
fail_with(Failure::BadConfig, 'Invalid SID provided') if sid_type == :invalid
2013-08-30 16:28:54 -05:00
fail_with(Failure::Unknown, 'No account found for the given SID') unless info[:mapped]
2013-08-30 16:28:54 -05:00
print_status("SID Type: #{sid_type}")
print_status("Name: #{info[:name]}")
print_status("Domain: #{info[:domain]}")
end
end