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

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

52 lines
1.3 KiB
Ruby
Raw Normal View History

2011-11-03 03:00:51 +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-11-03 03:00:51 +00:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
2013-09-05 14:30:08 -05:00
include Msf::Post::Windows::NetAPI
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Windows Gather Domain Enumeration',
'Description' => %q{
This module enumerates currently the domains a host can see and the domain
controllers for that domain.
},
'License' => MSF_LICENSE,
'Author' => [ 'mubix' ],
'Platform' => [ 'win' ],
'SessionTypes' => [ 'meterpreter' ]
)
)
2013-09-05 14:30:08 -05:00
end
def run
domains = net_server_enum(SV_TYPE_DOMAIN_ENUM)
return if domains.nil?
2013-09-05 14:30:08 -05:00
domains.each do |domain|
print_status("Enumerating DCs for #{domain[:name]}")
dcs = net_server_enum(SV_TYPE_DOMAIN_BAKCTRL | SV_TYPE_DOMAIN_CTRL, domain[:name])
if dcs.count == 0
2023-02-08 13:47:34 +00:00
print_error('No Domain Controllers found...')
2013-09-05 14:30:08 -05:00
next
end
dcs.each do |dc|
print_good("Domain Controller: #{dc[:name]}")
report_note(
2023-02-08 13:47:34 +00:00
host: session,
type: 'domain.hostnames',
data: dc[:name],
update: :unique_data
2013-09-05 14:30:08 -05:00
)
end
end
end
2011-11-03 03:00:51 +00:00
end