Ravindra BagaleCourses & study guides मराठी Track your progress

42. Evading IDS, Firewalls and Honeypots – Detection Games

42.4 Slow Scans, Timing, Port Knocking – Nmap vs Blue Rate Alerts

Nmap timing (-T0 … -T5) aapan Chapter 19 lab madhe OWN target var baghitla. Red hope: slow = below IDS "scan" burst rule. Blue hope: longer window + firewall logs + Zeek/Suricata by_src thresholds + netflow.

Port knocking (concept): real SSH port stays filtered until a secret sequence of closed-port hits; then firewalld/iptables opens 22 for that IP. Sounds clever; actually security through obscurity if it replaces keys/MFA. Blue still sees the knocks in pcap. Don't hide production SSH only behind a knock; do use VPN + key + firewalld source allow-list.

Blue detections that actually work in SME lab:

  • Suricata / Snort rules for "many unique ports from one src" (threshold / detection_filter)
  • firewalld --set-log-denied=all then read /var/log/messages
  • Nmap -T2 against OWN box should still leave denied / alert crumbs – prove it
  • Rate-limit SSH with firewalld / fail2ban (hardening chapter) – complementary
# Kali → OWN lab only (standard educational scan, not an evasion kit)
nmap -sS -T2 -p 21,22,80,443,3306 192.168.56.20
# Optional slightly broader but still polite – OWN target only
nmap -sS -T3 -p 1-100 192.168.56.40
Red team (attacker) does Blue team (defender) detects / stops
Slow SYN scan hoping burst SIDs stay quiet Long-window unique-port counts; netflow; keep denied logs
Port-knock then SSH with stolen key Log knocks; prefer VPN + key + MFA; no knock-only
Scans from many IPs (lab: don't) Correlate in SIEM; block lists with care (false drop risk)

Ravindra Bagale's Tip

Students think -T0 means "stealth". Stealth ≠ invisible; stealth = just slower. A SOC with 24-hour unique-dport charts still sees it. In interviews: "I use -T2 on my lab to test whether logs catch slow scans." Remember this.

Lab

From Kali 192.168.56.10, nmap -sS -T2 -p 22,80 192.168.56.20 (host-only). On Blue VM, sudo tail firewall denied log or Suricata fast.log. Paste 5 matching lines into notes with timestamp. If empty – promiscuous / wrong interface / HOME_NET – debug Blue, don't add evasion flags.

Extended teaching notes

Why this lesson matters

Hardening is deleting unnecessary risk: fewer packages, fewer open ports, fewer privileged accounts, faster patches, better logs.

Hardening related services

[('SSH', 'Key auth, no root login, Fail2ban or equivalent, SG limited to your IP/VPN.', '', ''), ('SMB / NFS / LDAP / SNMP', 'Do not expose to the internet; patch; strong auth; disable unused versions (e.g. SMBv1).', '', ''), ('SMTP', 'Authenticated relay only; SPF/DKIM/DMARC for your domains.', '', ''), ('DNS', 'Restrict zone transfers; monitor for unexpected records (crt.sh for certs).', '', ''), ('Firewalls', 'Host firewall + cloud SG/NSG; default deny; document every allow.', '', '')]

Real examples

Global: CIS Benchmarks exist for Linux, Windows and clouds. Indian company (sample): a Pune team requires SSH keys only and weekly patch windows for internet-facing hosts.

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.