TExcelTAD
Home › Network Security: Discovery, Segmentation, Firewalls, VPN & IDS › Scan Noise, Timing, Ethics and Rate Limits

Scan Noise, Timing, Ethics and Rate Limits

An authorised scan is still a load test that nobody asked for. Every probe is a packet the target must process, a connection a firewall must track, a log line someone may have to read. Fragile devices (old printers, building controllers, industrial PLCs, VoIP phones) have crashed from nothing more than a fast scan or a malformed version probe. This lesson is about how much you send: computing a scan's size before running it, choosing its rate, and making it visible to the right people and only to them.

The legal and contractual side is in Scope and Authorization for Network Assessments. The short version: the scope document sets the rate; this lesson shows how to stay within it.

How big is a scan?

A TCP scan sends at least one probe per host and port, plus retries for ports that don't answer. A first estimate is

probes ≈ hosts × ports × (1 + retries for silent ports), and time ≈ probes ÷ rate.

python · try it yourself
def scan_cost(hosts, ports, rate_pps, silent_share=0.95, retries=1):
    """Probes and duration of a TCP scan. Silent (filtered) ports are probed 1 + retries times."""
    probes = hosts * ports * (1 + silent_share * retries)
    return probes, probes / rate_pps

def fmt(seconds):
    for unit, n in (("days", 86400), ("h", 3600), ("min", 60)):
        if seconds >= n:
            return f"{seconds / n:.1f} {unit}"
    return f"{seconds:.0f} s"

cases = [
    ("one host, top 1000 ports", 1, 1000),
    ("lab /24, top 1000 ports", 254, 1000),
    ("lab /24, all 65535 ports", 254, 65535),
    ("a /16, top 100 ports", 65534, 100),
]
print(f"{'scan':28} {'probes':>12} {'at 100/s':>10} {'at 1000/s':>10}")
for name, h, p in cases:
    probes, t100 = scan_cost(h, p, 100)
    _, t1000 = scan_cost(h, p, 1000)
    print(f"{name:28} {probes:12,.0f} {fmt(t100):>10} {fmt(t1000):>10}")
scan                               probes   at 100/s  at 1000/s
one host, top 1000 ports            1,950       20 s        2 s
lab /24, top 1000 ports           495,300      1.4 h    8.3 min
lab /24, all 65535 ports       32,459,486   3.8 days      9.0 h
a /16, top 100 ports           12,779,130   1.5 days      3.5 h

A full-port scan of one small office network at the 100 probes per second written into the lab's scope takes about 4 days (3.8). That is why assessors scan in stages: discovery first, then the top ports on every live host, then all ports only on the hosts that matter, and UDP only on selected ports. It also shows why "just scan everything fast" is the wrong default: at 1,000 probes per second the same scan is still 9 hours of steady load on every firewall in the path.

The knobs Nmap gives you

Option Effect
-T0 … -T5 timing templates, from "paranoid" (-T0, one probe every 5 minutes) and "sneaky" (-T1, 15 s) through "polite" (-T2, 0.4 s between probes) and "normal" (-T3, the default) to "aggressive" (-T4) and "insane" (-T5, short timeouts, can miss ports)
--max-rate N / --min-rate N upper / lower bound on probes per second, the clearest way to honour a scope's limit
--scan-delay T fixed pause between probes to one host (e.g. 500ms)
--max-retries N retransmissions for silent ports (default up to 10, adaptively); fewer is faster but may miss ports on lossy links
--host-timeout T give up on a host after T
--max-parallelism N, --max-hostgroup N how many probes or hosts at once
-sn host discovery only, no port scan
--top-ports N the N most common ports from Nmap's frequency table

The session shows --max-rate working: 40 ports at a maximum of 20 probes per second can't finish in less than about 2 seconds, while the same scan without a limit is instant on loopback. (Durations vary between runs, so the session prints only whether the limit held.)

bash · try it yourself
python3 -m http.server 8000 --bind 127.0.0.1 >http.log 2>&1 &
for i in $(seq 50); do ss -Htln | grep -q ':8000' && break; sleep 0.1; done
timed() { local s=$(date +%s%N); "$@" >/dev/null; echo $(( ($(date +%s%N) - s) / 1000000 )); }
fast=$(timed nmap -sT -p 7980-8019 127.0.0.1)
slow=$(timed nmap -sT -p 7980-8019 --max-rate 20 127.0.0.1)
[ "$fast" -lt 1500 ] && echo "unlimited: under 1.5 s"
[ "$slow" -ge 1800 ] && echo "--max-rate 20: at least 1.8 s for 40 probes"
nmap -sT -p 7980-8019 --max-rate 20 127.0.0.1 | grep -E 'open|Not shown'
kill %1
unlimited: under 1.5 s
--max-rate 20: at least 1.8 s for 40 probes
Not shown: 39 closed tcp ports (conn-refused)
8000/tcp open  http-alt

Noise: what each choice looks like to the defender

python · try it yourself
# A defender's view: one source, distinct destination ports per 60-second window.
# Threshold: more than 20 distinct ports from one source in a window raises an alert.
def alerts(rate_pps, ports, window=60, threshold=20):
    per_window = min(ports, rate_pps * window)
    windows = int(-(-ports // per_window))     # ceiling division
    return per_window, windows, per_window > threshold

for label, rate in [("-T5 / 1000 pps", 1000), ("100 pps (scope limit)", 100),
                    ("-T2 polite, ~2.5 pps", 2.5), ("-T1 sneaky, 1 per 15 s", 1 / 15)]:
    pw, w, hit = alerts(rate, 1000)
    print(f"{label:24} {pw:7.0f} ports/window  {w:5} windows  alert: {'yes' if hit else 'no'}")
-T5 / 1000 pps              1000 ports/window      1 windows  alert: yes
100 pps (scope limit)       1000 ports/window      1 windows  alert: yes
-T2 polite, ~2.5 pps         150 ports/window      7 windows  alert: yes
-T1 sneaky, 1 per 15 s         4 ports/window    250 windows  alert: no

A simple threshold catches every reasonable scan; only the "sneaky" rate stays under it, and that scan of 1,000 ports takes over four hours per host. Real detectors also correlate over longer windows and across hosts. The point for an authorised assessor is not to hide: it is to be expected. Announce the source addresses and window, and ask the SOC to confirm that the alert fired. A scan that didn't raise an alert is a finding about the monitoring.

Ethics, in practice

  • Proportionality. Use the least intrusive technique that answers the question. Version detection and scripts (-sV, -sC) talk to services; run them on the hosts that need them, not on the whole range by default.
  • Fragile systems. Ask the owner which devices are fragile; scan them separately at -T2 or slower, outside business hours, with someone watching, or not at all (take the information from their configuration instead).
  • Shared infrastructure. A fast scan through a provider's firewall or a VPN concentrator loads devices that serve other customers.
  • Stop when asked, and when anything degrades. Note the time and what was running.
  • No "while I'm here". Interesting systems outside the scope are reported, not touched.

How unauthorised scans are detected and limited

  • Edge firewalls and IDS rules for port-scan patterns (distinct ports or hosts per source per window), with automatic short blocks at the edge for clearly hostile sources.
  • Rate limits on new connections per source (nftables limit rate and meter/set rules, Egress Filtering and Logging).
  • The SYN-flood protections of SYN Floods and SYN Cookies also protect against very fast scans.

Pitfalls

  • Copying -T4 -A -p- from a CTF write-up into a production assessment.
  • Forgetting retries in the estimate: filtered ports multiply the cost.
  • Scanning through a NAT or a stateful firewall at high rate: its connection table can fill up and drop legitimate traffic.
  • Believing a slow scan is invisible. It is only harder to see in short windows.

Practice

1. The scope allows 50 probes per second. Estimate a top-1000 scan of 30 live hosts with the program's assumptions.

scan_cost(30, 1000, 50) gives 58,500 probes and 1,170 s, about 20 minutes.

2. Which Nmap options enforce "at most 100 probes per second, give up on a host after 30 minutes"?

--max-rate 100 --host-timeout 30m (plus the scope's targets and --exclude list).

3. Your announced scan didn't trigger a single alert. Is that good news?

No: it means the monitoring doesn't detect port scans from inside (or the alert went nowhere). Report it as a detection gap.

Test yourself

Roughly how long does an all-ports TCP scan of 254 hosts take at 100 probes per second (95% silent ports, one retry)?

  1. About 10 minutes
  2. About 4 hours
  3. About 4 days
  4. About 4 years

Which option is the most direct way to honour a scope's probe-rate limit?

  1. -T5
  2. --max-rate
  3. -sV
  4. --top-ports

Why should an authorised scan not try to evade detection?

  1. Evasion is impossible
  2. Being expected (announced sources and window) is the goal, and a missed scan is itself a finding about monitoring
  3. Nmap can't evade
  4. Because SYN scans need root

What is the safest approach to a fragile building controller in scope?

  1. Scan it with -T5 to finish quickly
  2. Ask the owner, scan separately and slowly with someone watching, or review its configuration instead
  3. Skip telling anyone
  4. Run all NSE scripts against it