--- title: "Cheatsheet - Infrastructure Enumeration Tools 1" description: "curl -s \"https://crt.sh/?q=TARGET.com&output=json\" | jq -r '.[].name_value' | sort -u" category: enumeration tags: ["enumeration"] tools: ["Gitleaks", "TruffleHog"] difficulty: intermediate updated: "2026-08-10" source: "vault:Enumeration/Cheatsheet - Infrastructure Enumeration Tools 1.md" --- # Basic query — good starting point curl -s "https://crt.sh/?q=TARGET.com&output=json" | jq -r '.[].name_value' | sort -u # Output *.TARGET.com admin.TARGET.com blog.TARGET.com mail.TARGET.com vpn.TARGET.com www.TARGET.com ``` > [!info]+ Command Breakdown > 1. **jq -r '.[].name_value'** — extracts ONLY the `name_value` field from every array entry using `-r` (raw output, no quotes) > 2. This is cleaner than the `grep | cut | awk` chain in the original notes — fewer failure points > 3. **sort -u** — deduplicates; wildcard entries like `*.TARGET.com` are preserved as-is --- ```bash # Strip wildcards and get clean hostnames only curl -s "https://crt.sh/?q=TARGET.com&output=json" \ | jq -r '.[].name_value' \ | sed 's/\*\.//g' \ | sort -u \ | grep -v "^TARGET.com$" > subdomains.txt cat subdomains.txt admin.TARGET.com blog.TARGET.com mail.TARGET.com vpn.TARGET.com www.TARGET.com ``` > [!info]+ Command Breakdown > 1. **sed 's/\*\.//g'** — strips the `*.` wildcard prefix to leave a clean hostname > 2. **grep -v "^TARGET.com$"** — removes the bare root domain from the list (you already know it) > 3. **> subdomains.txt** — saves to file for use in the next steps (host loop, Shodan loop) > 4. *This output feeds directly into the `host` bulk resolution loop* --- ```bash # Query for EXPIRED certs too — these reveal old subdomains that may still be live curl -s "https://crt.sh/?q=%25.TARGET.com&output=json" | jq -r '.[].name_value' | sort -u ``` > [!info]+ Command Breakdown > 1. **%25.TARGET.com** — URL-encoded `%` wildcard; matches ALL subdomains ever issued a cert, including expired ones > 2. Expired subdomains are often forgotten by admins — they may still resolve and run old, unpatched services > 3. *Cross-reference this list against your `host` resolution output to see which old subdomains are still live* --- > [!warning]+ crt.sh Gotchas > 1. Results include **third-party issued certs** — a subdomain listed here is NOT guaranteed to be company-owned infrastructure > 2. Wildcard certs (`*.TARGET.com`) confirm the domain uses wildcard SSL but don't enumerate actual subdomains — use other methods to enumerate what lives under the wildcard > 3. **Rate limiting** — if querying many domains, add `sleep 2` between requests or use the Shodan/Subfinder pipeline instead > 4. Results can lag by hours after a new cert is issued — not real-time --- ## curl + jq — API Querying and JSON Parsing > [!tip]+ jq is More Powerful Than Used in the Notes > The original notes use `jq .` (pretty print only). Here are more useful filters: ```bash # Extract only specific fields — issuer + subdomain + expiry curl -s "https://crt.sh/?q=TARGET.com&output=json" \ | jq -r '.[] | [.issuer_name, .name_value, .not_after] | @tsv' # Output (tab-separated) C=US, O=Let's Encrypt, CN=R3 mail.TARGET.com 2025-12-01T00:00:00 C=US, O=Cloudflare, Inc. www.TARGET.com 2026-01-15T00:00:00 ``` > [!info]+ Command Breakdown > 1. **'.[] | ...'** — iterates over every element in the array > 2. **[.issuer_name, .name_value, .not_after]** — selects three specific fields into an array > 3. **@tsv** — formats the array as tab-separated values — easy to `cut`, `grep`, or import into a spreadsheet > 4. *The issuer column immediately tells you if a subdomain uses Cloudflare, Let's Encrypt, DigiCert etc. — Cloudflare = WAF/proxy likely in front* --- ```bash # Count how many unique subdomains exist curl -s "https://crt.sh/?q=TARGET.com&output=json" | jq '[.[].name_value] | unique | length' # Output 47 ``` > [!info]+ Command Breakdown > 1. **[.[].name_value]** — collects all name values into a new array > 2. **unique** — deduplicates the array > 3. **length** — returns the count > 4. *Use this as a quick "how big is the attack surface" indicator before diving in* --- > [!tip]+ curl Best Practices > 1. Always use **-s** (silent) to suppress the progress bar — it pollutes piped output > 2. Add **-A "Mozilla/5.0"** to spoof a browser User-Agent if a service rejects `curl` requests > 3. Use **-o /dev/null -w "%{http_code}"** to test if a URL is reachable without dumping the body > 4. Add **--max-time 10** to prevent curl hanging indefinitely on slow hosts --- ## dig — DNS Enumeration > [!tip]+ Query Specific Record Types — Don't Always Use ANY > Many resolvers block or ignore `dig any` queries. Query record types directly for reliable results: ```bash # A records — IPv4 addresses dig A TARGET.com +short # AAAA records — IPv6 addresses dig AAAA TARGET.com +short # MX records — mail servers dig MX TARGET.com +short # NS records — name servers dig NS TARGET.com +short # TXT records — the intelligence goldmine dig TXT TARGET.com +short # SOA record — primary DNS authority dig SOA TARGET.com +short # CNAME — canonical name (reveals CDN, load balancer names) dig CNAME www.TARGET.com +short ``` > [!info]+ Command Breakdown > 1. **+short** — suppresses all header/footer output, returns only the answer — much cleaner than default output > 2. Query each record type **separately** — `dig any` often returns incomplete or filtered results from modern resolvers > 3. **CNAME records** are especially useful — they often reveal the CDN or load balancer in use (e.g., `target.cloudflare.net`, `target.azurefd.net`) > 4. *MX pointing to Google = Google Workspace. MX pointing to outlook.com = Microsoft 365. Both have implications for cloud access.* --- ```bash # Use a specific DNS resolver — bypass internal resolver caching dig TXT TARGET.com @8.8.8.8 +short # Google dig TXT TARGET.com @1.1.1.1 +short # Cloudflare dig TXT TARGET.com @9.9.9.9 +short # Quad9 ``` > [!info]+ Command Breakdown > 1. **@8.8.8.8** — directs the query to a specific resolver instead of your system's default > 2. Use this when your local resolver returns stale/cached results or when testing from behind a corporate network > 3. Comparing responses between resolvers can reveal **split-horizon DNS** — different answers for internal vs external queries > 4. *Split-horizon DNS is a strong indicator of an internal network — note it for the Gateway layer* --- ```bash # Attempt a zone transfer — almost always fails externally but worth trying dig AXFR TARGET.com @ns.TARGET.com # If it works, output dumps ALL DNS records at once: ; <<>> DiG 9.16.1-Ubuntu <<>> AXFR TARGET.com @ns.TARGET.com TARGET.com. 3600 IN SOA ns1.TARGET.com. hostmaster.TARGET.com. admin.TARGET.com. 3600 IN A 10.10.10.5 dev.TARGET.com. 3600 IN A 10.10.10.12 vpn.TARGET.com. 3600 IN A 10.10.10.1 ``` > [!info]+ Command Breakdown > 1. **AXFR** — DNS zone transfer request; asks the name server to send ALL records for the zone > 2. Requires knowing the authoritative NS server — get this from `dig NS TARGET.com +short` first > 3. Modern DNS servers reject AXFR from untrusted IPs, but misconfigured or older servers may allow it > 4. *A successful zone transfer is a critical finding — it immediately hands you the entire internal DNS map* > [!warning]+ dig vs host vs nslookup > | Tool | Best For | Avoid When | > |---|---|---| > | `dig` | Full record queries, scripting, verbose output | You just need a quick IP lookup | > | `host` | Fast bulk lookups, simple A record resolution | You need specific record types or JSON output | > | `nslookup` | Windows environments | Scripting — its output format is inconsistent | --- ## host — Bulk Subdomain Resolution > [!tip]+ Going Further Than the Notes ```bash # Reverse DNS lookup — IP to hostname host 10.129.24.93 93.24.129.10.in-addr.arpa domain name pointer blog.TARGET.com. ``` > [!info]+ Command Breakdown > 1. Pass an **IP address** to `host` instead of a hostname for reverse lookup > 2. Reveals hostnames you may not have found in forward DNS enumeration > 3. *Run this on every IP returned by Shodan — you may discover additional virtual hosts pointing to the same IP* --- ```bash # Query a specific record type with host host -t MX TARGET.com host -t TXT TARGET.com host -t NS TARGET.com ``` > [!info]+ Command Breakdown > 1. **-t [TYPE]** — specifies the record type to query > 2. Output is simpler than `dig` — useful for quick checks but less detail > 3. *Use `dig` for full output with TTL and authority sections; use `host -t` for fast piped workflows* --- ```bash # Better bulk resolution loop — saves both hostname and IP, skips failed lookups while read subdomain; do result=$(host "$subdomain" 2>/dev/null | grep "has address" | awk '{print $1, $4}') [ -n "$result" ] && echo "$result" done < subdomains.txt | tee resolved.txt # Output blog.TARGET.com 10.129.24.93 mail.TARGET.com 10.129.127.22 www.TARGET.com 10.129.127.33 ``` > [!info]+ Command Breakdown > 1. **while read subdomain** — cleaner than `for i in $(cat file)` — handles spaces in lines safely > 2. **2>/dev/null** — suppresses error output for subdomains that don't resolve > 3. **[ -n "$result" ]** — only prints if the result is non-empty (skips dead subdomains silently) > 4. **tee resolved.txt** — prints to terminal AND saves to file simultaneously > 5. *`resolved.txt` becomes your definitive list of live, company-hosted targets for active testing* --- ## Shodan — Passive IP and Service Intelligence > [!important]+ Setup First — Easy to Skip ```bash # Install the Shodan CLI pip3 install shodan # Initialise with your API key (free account works for basic queries) shodan init YOUR_API_KEY_HERE # Verify it works shodan info # Output: # Query credits available: 100 # Scan credits available: 0 ``` > [!info]+ Command Breakdown > 1. **shodan init** — stores your API key locally so you don't have to pass it every command > 2. Free accounts get 100 query credits — enough for a standard engagement's passive recon > 3. *Get your API key at https://account.shodan.io/ — just needs a free registration* --- ```bash # The basic host lookup from the notes shodan host 10.129.24.93 # Better: search by organisation name — finds ALL IPs registered to the company shodan search --fields ip_str,port,org,hostnames "org:\"InlaneFreight\"" # Output 10.129.24.93 80 InlaneFreight blog.inlanefreight.com 10.129.27.33 443 InlaneFreight www.inlanefreight.com 10.129.127.22 25 InlaneFreight matomo.inlanefreight.com ``` > [!info]+ Command Breakdown > 1. **"org:\"InlaneFreight\""** — Shodan search filter for organisation name; quotes inside the string are escaped > 2. **--fields ip_str,port,org,hostnames** — limits output to only the useful columns > 3. *This finds IPs you may have missed entirely in DNS enumeration — Shodan indexes based on what it scans, not what DNS says* --- ```bash # Find all subdomains Shodan has seen for a domain shodan search --fields ip_str,port,hostnames "hostname:TARGET.com" # Find only SSL-enabled services — check for weak ciphers shodan search "hostname:TARGET.com ssl.version:TLSv1" # Find specific open ports across the org shodan search "org:\"InlaneFreight\" port:22" shodan search "org:\"InlaneFreight\" port:3389" # RDP — always worth noting shodan search "org:\"InlaneFreight\" port:445" # SMB — goldmine # Find services with default/vendor credentials (Shodan tags these) shodan search "org:\"InlaneFreight\" has_screenshot:true" ``` > [!info]+ Command Breakdown > 1. **hostname:TARGET.com** — finds all IPs where Shodan has observed the domain in the SSL cert or reverse DNS > 2. **ssl.version:TLSv1** — filters for hosts still running deprecated TLS 1.0 — a vulnerability > 3. **port:3389** / **port:445** — RDP and SMB exposed to the internet are high-priority findings > 4. **has_screenshot:true** — Shodan captures screenshots of HTTP services — you can see login panels, admin interfaces, and dashboards without sending a single packet to the target --- > [!tip]+ Shodan Filters Quick Reference | Filter | Example | What It Finds | |---|---|---| | `org:` | `org:"Target Corp"` | All IPs registered to that organisation | | `hostname:` | `hostname:target.com` | IPs with that hostname in cert/DNS | | `port:` | `port:22` | Services on a specific port | | `country:` | `country:GB` | Restrict by country | | `ssl.version:` | `ssl.version:TLSv1` | Weak SSL/TLS versions | | `product:` | `product:Apache` | Specific software | | `os:` | `os:"Windows Server 2016"` | Specific OS versions | | `has_screenshot:` | `has_screenshot:true` | Services with captured screenshots | | `http.title:` | `http.title:"Login"` | Pages with specific HTML titles | --- ## Google Dorks — Cloud and File Discovery > [!tip]+ Beyond the Basic inurl/intext Combo > The notes cover `inurl:` and `intext:`. Here is the full operator toolkit: ``` # Find exposed files by type on the company's domain site:TARGET.com filetype:pdf site:TARGET.com filetype:xlsx site:TARGET.com filetype:docx site:TARGET.com filetype:env site:TARGET.com filetype:sql site:TARGET.com filetype:log ``` > [!info]+ Command Breakdown > 1. **site:TARGET.com** — restricts ALL results to the specified domain and its subdomains > 2. **filetype:** — filters by file extension — find documents, spreadsheets, SQL dumps, log files > 3. `.env` files indexed by Google are an instant win — they almost always contain secrets > 4. `.sql` files may contain database dumps with credentials and PII --- ``` # Find login panels and admin interfaces site:TARGET.com intitle:"login" site:TARGET.com intitle:"admin" site:TARGET.com inurl:"/admin" site:TARGET.com inurl:"/wp-admin" site:TARGET.com inurl:"/phpmyadmin" site:TARGET.com inurl:"/dashboard" ``` > [!info]+ Command Breakdown > 1. **intitle:** — searches the HTML `