RedTeam guide for nmap opsec
Nmap is loud by default. Every technique below exists to reduce the signal you generate - in volume, in pattern, and in attribution - while still getting the recon you need. This post walks through the opsec stack from “don’t scan at all if you don’t have to” down to packet-level fingerprint evasion.
1. Minimize Active Scanning
The best scan is the one you don’t run.
- Passive recon first - pull as much as possible before touching the target:
- Shodan, Censys - pre-indexed port/service data
- crt.sh - certificate transparency logs (subdomains, infra hints)
- DNSDumpster - historical DNS records
- BGP.he.net - ASN/netblock mapping
- Resolve scope without noise
nslookup domain.com- only scan the resolved target IP, not the whole domain surface- Use a non-default, non-org DNS resolver for lookups (e.g.
nslookup @1.1.1.1) so you’re not leaking recon intent to the target’s own authoritative DNS logs
2. Timing & Rate Control
Fast scans trip thresholds. Slow, jittered scans look like background noise.
| Flag | Purpose |
|---|---|
-T1 / -T2 / -T3 |
Slow-and-steady timing templates - avoid -T4/-T5 for anything stealth-relevant |
--scan-delay 10s |
Fixed delay between probes |
--max-rate / --min-rate |
Cap or randomize packet rate |
| Jittered delay | Don’t use a single static --scan-delay - vary it between a min/max range. A perfectly even delay is itself a fingerprint |
Probe one port at a time where possible - sequential single-port sweeps look more like normal traffic than a broad parallel sweep.
3. Reduce Scan Footprint
-n- disable DNS resolution (fewer requests, less noise, faster)-Pn- skip host discovery (avoids ICMP/ARP pings that get logged separately)-p 22,80,443- scan only essential/expected ports instead of full range--randomize-hosts- for multi-target scans, break sequential-scan patterns that log correlation tools flag easily
4. Packet-Level Evasion
These target how firewalls, IDS, and stateful inspection devices parse your packets.
-f/--mtu- fragment packets to slip past inspection engines that don’t reassemble fragments before analysis-D RND:10- decoy scanning, mixes your real IP among generated noise- Caveat worth including in the post: many modern IDS defeat decoys via TTL/window-size inconsistency between the real source and decoys, so this is weaker than it used to be
--source-port 53/--source-port 88- spoof source port to mimic DNS/Kerberos replies, useful against naive stateless ACLs--badsum- send deliberately invalid checksums; real TCP/IP stacks silently drop these, so a response reveals a device doing shallow inspection (small IDS/firewall fingerprinting trick)-S <spoofed_IP>- spoof source IP for one-way, non-interactive probing (no return traffic to you, but can be used to trigger and observe IDS baselining behavior)--data-length 24- pad/obfuscate packet size so it doesn’t match Nmap’s default signature length--ttl <value>- manually set TTL to match the OS/hop-count you want to appear as- Linux default TTL: 64
- Windows default TTL: 128
- Important when tunneling - if your redirector’s real TTL doesn’t match the OS you’re supposedly scanning as, that mismatch is a tell
5. Fingerprint Minimization
Nmap itself has a recognizable wire signature, independent of the target.
--send-ethvs--send-ip- controls whether raw Ethernet or IP-layer packets are sent, affects L2 visibility--scanflags- customize TCP flag combinations so probes don’t match textbook Nmap SYN-scan signatures (MSS, timestamp, window-scale ordering are all keyed on by p0f-style fingerprinting)--spoof-mac 0,Dell,or--spoof-mac <random>- spoof the MAC vendor prefix to blend with the target’s expected hardware population (relevant for internal/on-segment engagements)--script-args http.useragent=STRING- rotate user-agent strings for HTTP-based NSE scripts- Reference list of realistic UAs: https://useragents.io/
6. Idle / Zombie Scanning
-sI <zombie_IP>- fully non-attributable scanning by bouncing off a third-party host with predictable IPID behavior- Worth a section on why this is harder today: most modern stacks randomize IPID per-connection rather than incrementing globally, which breaks the technique. Good zombie candidates are increasingly rare, but still worth explaining as the “gold standard” of attribution avoidance when it works
Reference: Fyodor’s original idle scan writeup - https://nmap.org/idlescan.html
7. Traffic Routing & Attribution Laundering
Proxy chains
- Proxychains + SSH/SOCKS redirector + residential proxy layering
- High-reputation domains and CDNs (e.g. Cloudflare) as a front, since traffic appears to originate from trusted infrastructure
- Residential proxy providers: https://www.webshare.io
- API abuse - tunnel scan traffic through legitimate API endpoints
- Serverless scanning - route through disposable cloud functions (AWS Lambda, Azure Functions) for cheap, rotating, hard-to-attribute egress IPs
- Tor - slow and frequently blocklisted, but worth mentioning as a last-resort option when residential proxies aren’t available
Worked example: Proxychains through SSH redirector + residential proxy
1. Gather required info
- SSH creds/IP for the redirector
- Residential proxy creds/IP
2. Configure proxychains
1 | sudo nano /etc/proxychains4.conf |
- Comment out
proxy_dns - Comment out
socks4 127.0.0.1 9050 - Add:
1 | socks5 127.0.0.1 1080 |
Example:
1 | http 30.30.30.134 3128 operator1 ProxyPassword1 |
3. Start the SOCKS tunnel to the SSH redirector
1 | ssh -N -D 127.0.0.1:1080 root@<ssh_redirector_IP> |
4. Run the scan through the chain
1 | sudo proxychains nmap -sT -n -Pn -p 445 <target_IP> |
Note: -sT (full TCP connect) is required here since proxychains can’t tunnel raw SYN packets - you lose -sS stealth scanning once you’re going through a SOCKS/HTTP proxy chain.
5. Proof of concept / validation
- Run Wireshark on the target
- Re-run the scan through proxychains
- Stop the capture
- Confirm the connect scan appears to originate from the residential proxy IP, not your real infrastructure
8. Challenges & Workarounds
Obstacle: Web Application Firewalls (WAFs) mask the real origin IP
Workarounds to find the real IP behind a WAF/CDN:
- Trigger the server to send outbound email (password reset, “contact us” forms, etc.) - mail headers sometimes leak origin IP
- Historical DNS records via DNSDumpster (pre-WAF/CDN adoption records)
- SSL certificate data - certs issued directly to the origin server before CDN onboarding sometimes still resolve
- Custom JA3 fingerprint spoofing to avoid TLS-based reputation blocking during any HTTPS-based probing
Tools for TLS/JA3 spoofing (useful beyond raw Nmap, for any HTTPS-based recon):
curl-impersonateutls(Go library) for custom ClientHello fingerprints
9. Operational Hygiene (Often Forgotten)
- Don’t write scan output (
-oA,-oN) to disk on infrastructure you don’t fully control - pipe-oX -to stdout directly, or scan from ephemeral/throwaway VMs and containers HISTFILE=/dev/null(or equivalent) on redirector boxes shared with others- Treat every layer of your proxy chain as potentially logged - assume the residential proxy provider retains connection logs, and plan retention/rotation accordingly
References
- Nmap official docs: https://nmap.org/book/man.html
- Nmap evasion chapter: https://nmap.org/book/man-bypass-firewalls-ids.html
- Nmap timing/performance: https://nmap.org/book/man-performance.html
- Nmap OS detection: https://nmap.org/book/osdetect.html
- Nmap idle scan writeup: https://nmap.org/idlescan.html
- NSE script database: https://nmap.org/nsedoc/
- Nmap Network Scanning — Gordon “Fyodor” Lyon
- MITRE ATT&CK T1595 (Active Scanning): https://attack.mitre.org/techniques/T1595/
- HackTricks — Pentesting Network methodology: https://book.hacktricks.xyz/generic-methodologies-and-resources/pentesting-network
- User-agent reference: https://useragents.io/
- Residential proxy provider (example): https://www.webshare.io