Skip to content
Pwnversity
NET-FWEVASIONadvanced · 5 min · upd. 2026-10

Firewall and IDS Evasion

Between you and the target there are usually network controls: firewalls (filter by IP/port/protocol), IDS/IPS (detect and block attack patterns) and proxies. Evasion means getting your traffic to the target without being blocked or recognized: hiding the scan, fragmenting packets, using allowed ports and protocols, or encrypting and obfuscating the content. You do not break the control; you pass where it is not looking.

Each control watches a different layer, so evasion is chosen according to which one is in the way. The firewall decides what passes by IP/port; the IDS recognizes signatures in the content; egress filtering limits what leaves. The cross-cutting idea is the same as in WAF evasion: keep the attack’s semantics while changing the form the control recognizes. All of this within an authorized test where evading controls is part of the agreed scope.

flowchart LR
    A[Attacker] --> FW["Firewall (IP/port)"]
    FW --> IDS["IDS/IPS (signatures)"]
    IDS --> T[Target]
    A -. "allowed port 443/53" .-> FW
    A -. "fragmentation/obfuscation" .-> IDS
    T -. "egress filtering limits C2 back" .-> A
  • Network firewall: decides which IPs, ports and protocols pass. Evasion = use what is allowed or look like it.
  • IDS/IPS (Snort, Suricata): detects attack signatures in the traffic. Evasion = make the payload not match the signature.
  • Application firewall (WAF): HTTP-specific (see WAF Bypass).
  • Egress filtering: limits outbound traffic, key for C2 and reverse shells.
Ventana de terminal
nmap -T1 target # slow, below the detection threshold
nmap --mtu 16 target # fragment (MTU multiple of 8); -f and --mtu can't be combined
nmap -D RND:10 target # decoys: mix your IP with lures
nmap -S <fake_ip> target # spoof the source (if you don't care about the reply)
nmap --source-port 53 target # exit from a "trusted" port
nmap --data-length 25 target # add random bytes
nmap -sA target # ACK scan: tells filtered from unfiltered ports

Passing through allowed ports and protocols

Section titled “Passing through allowed ports and protocols”

Almost always 80/443 and 53 (DNS) are open outbound, so malicious traffic disguises itself as legitimate:

  • C2 / reverse shell over 443: blends in with normal HTTPS.
  • DNS tunneling (iodine, dnscat2) if outbound DNS passes (see DNS Attacks).
  • HTTP/HTTPS tunneling and domain fronting over 443.
  • ICMP tunneling (ptunnel) if ICMP leaves.
Ventana de terminal
# discover which outbound ports the firewall allows.
# NOTE: use a host that LISTENS on all ports (e.g. portquiz.net); against 8.8.8.8 a failure
# may just mean there is no TCP service on that port, not that egress blocks it.
for p in 21 22 53 80 443 8080; do timeout 3 bash -c "echo > /dev/tcp/portquiz.net/$p" 2>/dev/null && echo "outbound $p allowed"; done

Classic techniques against signature-based detection:

  • Fragmentation and ambiguous reassembly: the IDS and the host reassemble differently, and the signature does not match.
  • Payload obfuscation/encoding so it does not match the signature (same principle as WAF, see WAF Bypass).
  • Encryption: a payload inside TLS is not inspectable without interception.
  • Timing: space out events so you don’t exceed thresholds like “N events in T time”.
  • Polymorphism: vary the payload on each attempt.

A reverse shell needs to leave the network. If egress is filtered, the usual ways out are: use the port that does leave (normally 443), tunnel over DNS or HTTP (see Pivoting and Tunneling and DNS Attacks), or resort to domain fronting and CDNs to disguise the real destination.

  • Default-deny on ingress and egress (strict egress filtering): cuts C2 and reverse shells.
  • Up-to-date IDS/IPS with normalized reassembly (defeats fragmentation evasion) and TLS inspection where feasible.
  • Rate-limiting and scan detection; SIEM correlation.
  • Segmentation and an allowlist of outbound destinations; Protective DNS to cut tunneling.
  • Assume the attacker will try 443 and DNS: inspect those channels too, not just trust that they are “allowed”.
  • Map firewall rules (ACK scan, which ports pass)
  • Evasive scan (timing, fragmentation, decoys, source-port)
  • Identify allowed outbound ports (egress)
  • C2/reverse shell over 443 or another allowed port
  • Tunneling over DNS/HTTP/ICMP if filtering is strict
  • IDS evasion via fragmentation/obfuscation/encryption
  • Blue: verify egress default-deny, normalized IDS, Protective DNS
  • Document which controls were evaded and how