Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/windows/gather/enum_domain.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Windows::Accounts78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Windows Gather Enumerate Domain',13'Description' => %q{14This module identifies the primary Active Directory domain name15and domain controller.16},17'License' => MSF_LICENSE,18'Platform' => ['win'],19'SessionTypes' => %w[meterpreter shell powershell],20'Author' => ['Joshua Abraham <jabra[at]rapid7.com>'],21'Notes' => {22'Stability' => [CRASH_SAFE],23'Reliability' => [],24'SideEffects' => []25},26'Compat' => {27'Meterpreter' => {28'Commands' => %w[29stdapi_net_resolve_host30]31}32}33)34)35end3637def resolve_host(host)38return host if Rex::Socket.dotted_ip?(host)3940return unless client.respond_to?(:net)4142vprint_status("Resolving host #{host}")4344result = client.net.resolve.resolve_host(host)4546return if result[:ip].blank?4748result[:ip]49end5051def run52domain = get_domain_name5354fail_with(Failure::Unknown, 'Could not retrieve domain name. Is the host part of a domain?') unless domain && !domain.empty?5556print_good("Domain FQDN: #{domain}")5758report_note(59host: session,60type: 'windows.domain',61data: { domain: domain },62update: :unique_data63)6465netbios_domain_name = domain.split('.').first.upcase6667print_good("Domain NetBIOS Name: #{netbios_domain_name}")6869domain_controller = get_primary_domain_controller7071fail_with(Failure::Unknown, 'Could not retrieve domain controller name') unless domain_controller && !domain_controller.empty?7273dc_ip = resolve_host(domain_controller)74if dc_ip.nil?75print_good("Domain Controller: #{domain_controller}")76else77print_good("Domain Controller: #{domain_controller} (IP: #{dc_ip})")78report_host({79host: dc_ip,80name: domain_controller,81info: "Domain controller for #{domain}"82})83end84end85end868788