Parse command line arguments
()
| 68 | # ldap3 logging removed |
| 69 | |
| 70 | def parse_arguments(): |
| 71 | """Parse command line arguments""" |
| 72 | parser = argparse.ArgumentParser( |
| 73 | description='Query Domain Controller for computer information and generate OpenGraph JSON', |
| 74 | epilog=''' |
| 75 | Examples: |
| 76 | # Basic LDAP scan (password) |
| 77 | %(prog)s --dc 10.0.0.5 --domain corp.local --user administrator --password 'P@ssw0rd' --output corporate_topology.json |
| 78 | |
| 79 | # Full scan: enable port scanning, HTTP + SMB validation and SSL certificate extraction |
| 80 | %(prog)s --dc dc.corp.local --domain corp.local --user admin --password 'P@ss' --port-scan --valid-http --valid-smb --ssl --verbose |
| 81 | |
| 82 | # Use NTLM hashes instead of password (Impacket style LM:NT or NT-only) |
| 83 | %(prog)s --dc 10.1.1.10 --domain corp.local --user svc_account --hashes LMHASH:NTLMHASH --port-scan --valid-smb |
| 84 | |
| 85 | # Use Kerberos (requires KRB5CCNAME pointing to a ccache file) |
| 86 | export KRB5CCNAME=./admin.ccache |
| 87 | %(prog)s --dc dc.corp.local --domain corp.local --user admin -k --port-scan --valid-http |
| 88 | |
| 89 | # Manual network-only scan (CIDR, ranges and single IPs) - skip ping checks (-Pn) |
| 90 | %(prog)s --networks "192.168.1.0/24,10.0.1.1-10.0.1.50,172.16.5.10" -Pn --port-scan --ports 22,80,443 --scan-threads 50 |
| 91 | |
| 92 | # Manual IP-range scan with custom DNS server and specific ports |
| 93 | %(prog)s --networks "192.168.2.1-192.168.2.200" --dns 8.8.8.8 --ports 80,443,8080 --scan-timeout 5 --output web_scope.json |
| 94 | |
| 95 | # DNS over TCP (useful for proxy/firewall bypass) |
| 96 | %(prog)s --dc dc.corp.local --domain corp.local --user admin --password 'P@ss' --dns 8.8.8.8 --dns-tcp --verbose |
| 97 | |
| 98 | # Via proxychains with DNS over TCP |
| 99 | proxychains %(prog)s --dc dc.corp.local --domain corp.local --user admin --password 'P@ss' --dns-tcp --port-scan |
| 100 | |
| 101 | # Shadow-IT sweep across subnets (find non-domain devices) |
| 102 | %(prog)s --dc dc.corp.local --domain corp.local --user auditor --password 'Audit123' --shadow-it --port-scan --verbose |
| 103 | ''', |
| 104 | formatter_class=argparse.RawDescriptionHelpFormatter |
| 105 | ) |
| 106 | |
| 107 | # LDAP connection options (optional when using --networks) |
| 108 | parser.add_argument('--dc', help='Domain Controller hostname or IP address') |
| 109 | parser.add_argument('--domain', '-d', default='auto', help='Domain name (e.g., company.local) (use "auto" to extract from Kerberos ticket)') |
| 110 | parser.add_argument('--user', '-u', '--username', default='auto', help='Username for LDAP authentication (use "auto" to extract from Kerberos ticket)') |
| 111 | parser.add_argument('--password', '-p', help='Password for LDAP authentication') |
| 112 | |
| 113 | # Impacket-style authentication options |
| 114 | parser.add_argument('--hashes', help='NTLM hashes in LM:NT format (or NT-only 32-hex) to use instead of password') |
| 115 | parser.add_argument('-k', '--kerberos', action='store_true', help='Use Kerberos authentication (uses KRB5CCNAME environment variable)') |
| 116 | # ldap3 removed - using only impacket |
| 117 | |
| 118 | # Manual network specification (alternative to LDAP) |
| 119 | parser.add_argument('--networks', '-N', help='Comma-separated list of networks to scan. Supports: CIDR (192.168.1.0/24), IP ranges (192.168.1.1-192.168.1.50), single IPs (172.16.1.10)') |
| 120 | parser.add_argument('--dns', help='DNS server for ADIDNS queries (defaults to DC if not specified)') |
| 121 | parser.add_argument('--dns-tcp', action='store_true', help='Use TCP for DNS queries instead of UDP (useful for DNS over proxy/firewall)') |
| 122 | parser.add_argument('--output', '-o', default='network_opengraph.json', help='Output JSON file (default: network_opengraph.json)') |
| 123 | parser.add_argument('-Pn', action='store_true', help='Skip ping check, treat all hosts as online (same as nmap -Pn)') |
| 124 | parser.add_argument('--verbose', '-v', action='store_true', help='Enable verbose output with detailed resolution methods') |
| 125 | parser.add_argument('--port-scan', action='store_true', help='Enable TCP port scanning') |
| 126 | parser.add_argument('--ports', default='21,22,23,25,53,80,81,110,119,123,135,137,139,143,264,389,443,445,554,636,1433,1434,3306,3389,5060,5061,5222,5800,5801,5900,5901,5985,5986,8009,8080,8443,9200,44443', |
| 127 | help='Comma-separated list of ports to scan (default: common ports)') |