Skip to content
Chethan Yadav_
Cybersecurity

SEC/Lesson 5 of 7/8 min read

Network Attacks and Defense

Reconnaissance and port scanning, sniffing, spoofing, ARP poisoning, man-in-the-middle, DNS attacks, DoS and DDoS, firewalls, IDS and IPS, VPNs, network segmentation and Wi-Fi security.


On this page

Attack phases

Network attacks usually follow a pattern (the cyber kill chain): reconnaissance, weaponization, delivery, exploitation, installation, command and control, actions on objectives. Defenders try to break the chain as early as possible.

Reconnaissance

Reconnaissance gathers information about a target.

  • Passive: no direct contact. WHOIS, DNS records, certificate transparency logs (subdomains), search engines, leaked credentials, job postings revealing the tech stack, Shodan.
  • Active: touches the target. Ping sweeps, port scans, banner grabbing, directory brute forcing.

Port Scanning

Port scanning finds which ports are open and which services and versions run on them.

ScanHowNotes
TCP connectFull three-way handshakeReliable, logged by the target
SYN (half-open)Send SYN, read SYN-ACK, reply RSTFaster, stealthier, needs raw sockets
UDPSend UDP, wait for ICMP unreachableSlow and ambiguous
FIN / NULL / XmasUnusual flag combinationsProbe firewall and OS behavior

Nmap

Nmap is the standard scanner.

nmap -sS -sV -O -p- 10.0.0.5     # SYN scan all ports, detect versions and OS
nmap -sn 10.0.0.0/24             # ping sweep: which hosts are up

Port states: open (service listening), closed (reachable, no service, RST), filtered (no response, a firewall drops it).

Only scan systems you own or have written permission to test. Unauthorized scanning can be illegal and violates most acceptable-use policies.

Packet Sniffing

Packet sniffing captures traffic on a network (Wireshark, tcpdump). On a shared medium or a hub everyone sees everything; on a switch an attacker must first redirect traffic (ARP spoofing, MAC flooding to make the switch fail open). Defense: encrypt everything (TLS, SSH, VPN), so captured packets are useless.

Spoofing

IP Spoofing

IP spoofing forges the source IP address of packets. Replies go to the forged address, so it is mostly used for one-way attacks: floods, reflection and amplification DDoS. Defense: ISPs apply ingress filtering (BCP 38) to drop packets with source addresses that cannot originate from that network.

ARP Spoofing

ARP has no authentication. In ARP spoofing (ARP poisoning), the attacker sends forged ARP replies claiming "the gateway's IP is at my MAC", so victims send their traffic through the attacker.

Defenses: Dynamic ARP Inspection on switches, static ARP entries for critical hosts, port security, and end-to-end encryption.

Man-in-the-Middle

In a man-in-the-middle (MITM) attack, the attacker secretly relays and possibly alters communication between two parties who believe they talk directly.

Ways in: ARP spoofing, rogue Wi-Fi access points (evil twin), DNS spoofing, compromised routers, malicious proxies.

  • SSL stripping: downgrade a user's HTTPS request to HTTP and proxy it. Stopped by HSTS (and HSTS preload).
  • Fake certificates: browsers warn, unless the user clicks through or a rogue root CA is installed.

Defenses: TLS everywhere with certificate validation, HSTS, certificate pinning for mobile apps, mutual TLS between services, and VPNs on untrusted networks.

DNS attacks

DNS Spoofing

DNS spoofing returns a forged answer for a domain, sending the victim to an attacker-controlled IP.

DNS Cache Poisoning

DNS cache poisoning injects forged records into a recursive resolver's cache, so every user of that resolver is redirected until the TTL expires. The 2008 Kaminsky attack made this practical by racing many forged responses guessing the 16-bit transaction ID.

Defenses: source port randomization (more entropy to guess), DNSSEC (cryptographically signed records), and encrypted DNS (DoH, DoT) between clients and resolvers.

Other DNS abuses: DNS tunneling (exfiltrating data in queries), domain hijacking (stolen registrar accounts), and subdomain takeover (a CNAME pointing to a deprovisioned cloud resource someone else can claim).

DoS

A denial of service (DoS) attack exhausts a resource (bandwidth, CPU, memory, connection tables, application threads) so legitimate users cannot be served.

DDoS

A distributed denial of service (DDoS) attack comes from many sources at once, usually a botnet of compromised devices (IoT cameras and routers, as with Mirai), so it cannot be blocked by a single IP.

LayerAttackTarget
Volumetric (L3/L4)UDP floods, amplificationBandwidth
Protocol (L4)SYN flood, Ping of Death, fragmentationConnection state tables
Application (L7)HTTP floods, Slowloris, expensive search queriesServer CPU and threads

Amplification Attack

An amplification attack sends small requests with a spoofed source IP (the victim's) to open servers that reply with much larger responses. The victim is flooded with replies.

ProtocolApproximate amplification
DNS (open resolvers, ANY queries)28 to 54x
NTP (monlist)~556x
Memcached (UDP)up to 51,000x

DDoS defenses

  • Absorb: anycast CDNs and scrubbing services (Cloudflare, AWS Shield, Akamai) with huge capacity.
  • Filter: rate limiting, SYN cookies, geo or ASN blocking, dropping malformed packets, upstream blackholing.
  • Design: autoscaling, caching, timeouts on slow clients, making expensive endpoints require authentication.
  • Do not run open resolvers, NTP or memcached reachable from the internet.

Firewall

A firewall filters traffic between networks by rules, default-deny ideally.

TypeInspectsNotes
Packet filter (stateless)Each packet's IPs, ports, protocolFast, simple ACLs; cannot tell replies from new connections
Stateful FirewallConnection stateAllows replies to established connections automatically
Proxy / application gatewayFull application protocolDeep control, slower
Next-generation (NGFW)Applications, users, threatsAdds DPI, IPS, TLS inspection
Host-basedTraffic on one machineiptables/nftables, Windows Firewall

Rules are processed top-down, first match wins; end with an explicit deny all. Filter egress too, to stop malware from calling home.

Web Application Firewall

A web application firewall (WAF) inspects HTTP traffic for attack patterns (SQL injection, XSS, known exploits) and blocks them at L7. Useful as a virtual patch and for bot mitigation, but bypassable with encoding tricks; it complements secure code, it does not replace it.

Intrusion Detection System

An intrusion detection system (IDS) monitors traffic or hosts and alerts on suspicious activity. An IPS (intrusion prevention system) sits inline and can block it.

Signature-basedAnomaly-based
HowMatches known attack patternsFlags deviation from a learned baseline
StrengthAccurate for known attacks, few false positivesCan catch new (zero-day) attacks
WeaknessMisses unknown attacksMore false positives
  • NIDS: watches network traffic (Snort, Suricata, Zeek).
  • HIDS: watches a host's logs, files and processes (OSSEC, Wazuh).

Alert outcomes: true positive (real attack caught), false positive (benign flagged), false negative (attack missed, the dangerous one), true negative.

VPN

A VPN creates an encrypted tunnel over an untrusted network.

  • Remote access VPN: a user's device to the corporate network.
  • Site-to-site VPN: links two networks (an office to a cloud VPC).
  • Protocols: IPsec (network layer; AH for integrity, ESP for encryption; tunnel vs transport mode), TLS/SSL VPNs (OpenVPN), WireGuard (modern, small, fast).

VPNs protect traffic in transit, but a VPN that grants access to the whole internal network is a big risk if a single laptop is compromised. Zero trust access gateways replace it with per-application access.

Network Segmentation

Network segmentation divides a network into zones (with VLANs, subnets and firewalls) so a compromise in one zone cannot spread freely (limits lateral movement). Examples: separate guest Wi-Fi, isolate payment systems (PCI DSS), put databases in private subnets reachable only from app servers.

DMZ

A DMZ (demilitarized zone) is a perimeter network for public-facing servers (web, mail, DNS). The internet can reach the DMZ, the DMZ can reach only specific internal services, and the internet cannot reach the internal network directly.

internet ── firewall ── DMZ (web, mail) ── firewall ── internal network

Wireless security

ProtocolStatus
WEPBroken (RC4, IV reuse); cracked in minutes
WPA (TKIP)Deprecated
WPA2 (AES-CCMP)Common; PSK networks vulnerable to offline handshake cracking with weak passphrases; KRACK attack (patched)
WPA3Current standard

WPA3

WPA3 replaces the pre-shared-key handshake with SAE (Simultaneous Authentication of Equals), which resists offline dictionary attacks and provides forward secrecy. Enterprise networks use 802.1X with RADIUS so each user has their own credentials.

Other wireless threats: evil twin access points, deauthentication attacks, WPS PIN brute force (disable WPS).

Quick revision

  • Recon: passive (OSINT, DNS, CT logs) then active (Nmap scans). Only scan with permission.
  • ARP spoofing and rogue Wi-Fi enable MITM; TLS, HSTS and certificate validation defeat it.
  • DNS cache poisoning is countered by randomization, DNSSEC and encrypted DNS.
  • DDoS: volumetric, protocol and application layer; amplification abuses spoofed UDP; absorb with anycast scrubbing.
  • Stateful firewalls track connections; WAFs filter HTTP attacks; default deny, filter egress.
  • IDS alerts, IPS blocks; signature-based misses zero-days, anomaly-based has more false positives.
  • VPNs encrypt tunnels (IPsec, WireGuard); segmentation and DMZs limit lateral movement.
  • Use WPA3 (SAE) or WPA2-Enterprise; WEP is broken.