Lab 01: Security Concepts & Web Prerequisites
Establish foundational security concepts, threat actor models, and target visibility methodologies. Master the 5 testing phases, network transport primitives, HTTP request/response headers, and browser DevTools interception workflows.
1. Fundamental Security Concepts
Ethical Hacking is the authorized simulation of cyberattacks to discover and remediate security vulnerabilities before malicious threat actors can exploit them.
Vulnerability Assessment
BREADTH-FIRST- Objective: Comprehensive catalog of all potential flaws.
- Method: Automated, non-intrusive scanning (Nessus, OpenVAS).
- Exploitation: None. You flag the weaknesses, you don't fire them.
- Output: Prioritized risk matrix and CVE score list.
- System Risk: Zero downtime, safe for live production.
Penetration Test
DEPTH-FIRST- Objective: Prove real-world business impact and compromise depth.
- Method: Active simulation of adversarial tactics & custom payloads.
- Exploitation: Active. You actually use the flaws to get a foothold.
- Output: Proof-of-concept shells, compromised data & remediation roadmap.
- System Risk: Controlled risk; requires formal Rules of Engagement.
Threat Actor Taxonomy
Hacking intent and legal authorization separate threat actors across a spectrum of risk:
White Hat
Ethical HackerGray Hat
Ambiguous HackerBlack Hat
Hostile Threat ActorScript Kiddie
Amateur AttackerTarget Visibility: The 3 Box Models
Assessments differ fundamentally by how much internal architecture is disclosed upfront:
- Perspective: External internet attacker
- Tester Given: Target domain or IP range only
- Simulation: Maximum real-world adversary accuracy
- Perspective: Malicious insider or compromised account
- Tester Given: Low-privilege user credentials & network diagram
- Simulation: Best balance of depth, time & budget efficiency
- Perspective: Security architect & lead auditor
- Tester Given: Full source code, API docs, root configs
- Simulation: Deepest audit with 100% code path coverage
The 5 Penetration Testing Domains
2. The 5 Core Phases of Penetration Testing
Standardized methodologies (NIST SP 800-115, PTES, OWASP) structure engagements into five sequential stages:
Map attack surface via OSINT, passive queries, and Nmap port scanning to identify open doors (ports 80, 443, 22).
Correlate running software versions with known CVEs, craft weaponized payloads in Metasploit, and secure shell access.
Erase artifacts and deliver clear CVSS risk ratings with actionable mitigation code to prevent black-hat breach.
3. Networking, Ports & Handshake Dynamics
In offensive operations, the internet is not theory: you locate a target (IP), knock on a service (Port), and open a session (TCP/UDP). Master this flow in 4 visual blocks:
3.1 The Hacker's 4-Layer Stack & Triage
Textbooks teach 7 OSI layers; the real world runs on TCP/IP. When a scan or exploit fails, diagnose down the stack in seconds:
| Layer | Role (Mental Model) | Attacker Weapon | Triage ("Which Layer Broke?") |
|---|---|---|---|
| L7 Application | The Payload (HTTP, SSH, DNS) | SQLi, XSS, RCE, Auth Bypass | curl -I <url> (403 WAF or bad headers) |
| L4 Transport | The Door (TCP, UDP) | Port scans, Reverse shells | nc -zv <ip> 80 (Port closed / RST) |
| L3 Network | The Address (IP, ICMP) | Ping sweeps (-sn), Spoofing |
ping <ip> / ip route (Host unreachable) |
| L2 Data Link | Local Hops (MAC, ARP) | ARP Poisoning, LAN sniffing | ip neigh (No MAC / switch isolation) |
3.2 Ports Demystified: The Apartment Analogy
192.168.56.101 gets packets to the machine. There is only 1 IP per server.
Web (HTTP/S)
SSH (Remote Shell)
SMB (File Sharing)
MySQL (Database)
DNS (Lookup)
3.3 TCP vs. UDP & The 3-Way Handshake
๐ TCP (Stateful)
100% RELIABLELike a certified phone call. Packets are acknowledged; lost bytes are resent. Mandatory for interactive reverse shells. Cannot spoof IP.
๐ข UDP (Stateless)
FIRE-AND-FORGETLike a megaphone in a stadium. Zero receipts, zero state. Trivial IP spoofing (DDoS amplification). Agonizingly slow to port-scan.
Service daemon is actively listening. Primary attack target!
Host is alive, but no program is bound to this port. Move on.
Firewall (iptables/ACL) dropped the packet silently.
When target returns SYN-ACK, Kali instantly sends RST instead of completing the handshake. The port is confirmed OPEN without writing a connection entry into web server logs!
3.4 Web Protocols: GET vs. POST & Header Leaks
Parameters in URL bar (?user=admin). Logged in browser history and proxy access logs. Never put credentials in a GET!
Payload tucked inside request body. Hidden from URL and default access logs. Used for logins and state modifications.
Host: Target virtual host domain.Cookie: Session passport (target for hijacking).Authorization: Base64 credentials for HTTP auth.
Server: Banner leak! (e.g. Apache/2.2.8 โ CVE lookup).Set-Cookie: Audit for missing HttpOnly / Secure flags.X-Powered-By: Leaks backend framework (PHP, Express).
3.5 The Web Request Lifecycle: From Click to Response
What actually happens when a user clicks a link or submits a form? Here's the full trip, and where an attacker can sit on each hop:
System: Checks browser cache, then OS /etc/hosts file.
Attacker: Local DNS override / phishing redirection.
System: Resolves target.lab to IP (192.168.56.101).
Attacker: DNS Spoofing & Cache Poisoning.
System: SYN โ SYN-ACK โ ACK opens port 80/443 socket.
Attacker: Port scanning (-sS), SYN floods, ARP MITM.
System: Sends HTTP verb, headers, cookies, payload.
Attacker: Burp Suite tampering & payload injection.
System: Web server executes code and queries database.
Attacker: SQL Injection (SQLi), SSRF, Remote Code Execution.
System: Returns HTTP 200 OK + HTML/JS body to browser.
Attacker: Reflected/Stored XSS execution & cookie theft.
4. Interactive Hands-on: Browser DevTools Guide
Before deploying heavy interception proxies like Burp Suite, pentesters utilize browser Developer Tools (F12) to intercept traffic, cookies, and tokens.
- Press
F12โ open Network tab. - Navigate to
https://httpbin.org/headers. - Click the
headersrequest โ inspect Headers. - Locate the
Server: gunicornbanner disclosure!
- Navigate to
https://httpbin.org/forms/post. - Submit sample credentials in the form.
- Select the logged
/postrequest โ open Payload tab. - Notice data is sent in the HTTP body, invisible in the URL bar.
Open the Console tab and execute: document.cookie.
If a session cookie has the HttpOnly attribute set by the server, JavaScript returns an empty string, neutralizing Cross-Site Scripting (XSS) cookie theft!
Request Replay: Browser to Terminal (cURL)
Right-click any request in the DevTools Network log โ Copy โ Copy as cURL to replay and fuzz parameters directly from Kali:
curl -X POST 'https://httpbin.org/post' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-raw 'username=admin_tester&action=auth'
5. Classroom Hands-On Exercises
You captured an HTTP Basic Auth header: Authorization: Basic dGVhY2hpbmc6aGFja2luZzEyMw==. Decode it:
echo "dGVhY2hpbmc6aGFja2luZzEyMw==" | base64 -d
Core Principle: Is Base64 an encryption algorithm?
No! Base64 is an encoding scheme, not encryption. It provides zero confidentiality. Any attacker intercepting cleartext HTTP can decode credentials in a fraction of a second (teaching:hacking123).
Extract HTTP response banners without downloading web page bodies:
curl -I http://example.com
Why is Server Banner leakage dangerous?
Disclosing web server versions (e.g. Apache/2.2.14) allows adversaries to query the CVE vulnerability database and execute targeted, off-the-shelf exploits in minutes.
Lab 01 Self-Assessment Quiz
dGVhY2hpbmc6aGFja2luZzEyMw==:
http://example.com:
192.168.56.101 returns 0% packet loss, but a connection to port 80 replies with an immediate [RST] (Connection Refused). What does this tell you about the network layers?