Lucene search
K

Windows Gather Enumerate Domain

🗓️ 03 Oct 2011 21:05:54Reported by Joshua Abraham <[email protected]>Type 
metasploit
 metasploit
🔗 www.rapid7.com👁 33 Views

Identify Active Directory domain and domain controller for Windows

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Post
  include Msf::Post::Windows::Accounts

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Windows Gather Enumerate Domain',
        'Description' => %q{
          This module identifies the primary Active Directory domain name
          and domain controller.
        },
        'License' => MSF_LICENSE,
        'Platform' => ['win'],
        'SessionTypes' => %w[meterpreter shell powershell],
        'Author' => ['Joshua Abraham <jabra[at]rapid7.com>'],
        'Notes' => {
          'Stability' => [CRASH_SAFE],
          'Reliability' => [],
          'SideEffects' => []
        },
        'Compat' => {
          'Meterpreter' => {
            'Commands' => %w[
              stdapi_net_resolve_host
            ]
          }
        }
      )
    )
  end

  def resolve_host(host)
    return host if Rex::Socket.dotted_ip?(host)

    return unless client.respond_to?(:net)

    vprint_status("Resolving host #{host}")

    result = client.net.resolve.resolve_host(host)

    return if result[:ip].blank?

    result[:ip]
  end

  def run
    domain = get_domain_name

    fail_with(Failure::Unknown, 'Could not retrieve domain name. Is the host part of a domain?') unless domain && !domain.empty?

    print_good("Domain FQDN: #{domain}")

    report_note(
      host: session,
      type: 'windows.domain',
      data: { domain: domain },
      update: :unique_data
    )

    netbios_domain_name = domain.split('.').first.upcase

    print_good("Domain NetBIOS Name: #{netbios_domain_name}")

    domain_controller = get_primary_domain_controller

    fail_with(Failure::Unknown, 'Could not retrieve domain controller name') unless domain_controller && !domain_controller.empty?

    dc_ip = resolve_host(domain_controller)
    if dc_ip.nil?
      print_good("Domain Controller: #{domain_controller}")
    else
      print_good("Domain Controller: #{domain_controller} (IP: #{dc_ip})")
      report_host({
        host: dc_ip,
        name: domain_controller,
        info: "Domain controller for #{domain}"
      })
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

08 Sep 2022 18:35Current
0.5Low risk
Vulners AI Score0.5
33