1. INTRODUCTION
curl is a command-line tool used to make HTTP requests, test APIs, download files, send forms, authenticate, and debug web applications.
It supports HTTP, HTTPS, FTP, SFTP, SMB, SMTP, and more.
Essential for pentesting, bug bounty, API testing, and automation.
2. BASIC REQUESTS
GET request:
curl http://target.com
Show response headers:
curl -I http://target.com
Follow redirects:
curl -L http://target.com
3. SAVING OUTPUT
Save to file:
curl http://target.com -o output.html
Append output:
curl http://target.com >> saved.html
4. VIEW FULL RESPONSE
Verbose mode (shows connection details):
curl -v http://target.com
Silent mode (no progress bar):
curl -s http://target.com
Show only response body:
curl -s -o - http://target.com
5. CUSTOM HEADERS
Add User-Agent:
curl -H "User-Agent: Mozilla/5.0" http://target.com
Add cookies:
curl -H "Cookie: session=abc123" http://target.com
Add multiple headers:
curl -H "X-Test: 1" -H "X-Debug: true" http://target.com
6. POST REQUESTS
POST form data:
curl -X POST -d "user=admin&pass=1234" http://target.com/login
POST JSON:
curl -X POST -H "Content-Type: application/json" -d '{"user":"admin"}' http://api.target.com
POST file upload:
curl -X POST -F "file=@shell.php" http://target.com/upload
7. AUTHENTICATION
Basic Auth:
curl -u admin:password http://target.com
Bearer token:
curl -H "Authorization: Bearer TOKEN123" http://api.target.com
API key:
curl -H "X-API-Key: 12345" http://target.com
8. FILE TRANSFERS
Download file:
curl -O http://target.com/file.zip
Upload via FTP:
curl -T file.txt ftp://user:pass@target.com/
9. PROXY USAGE
Use Burp Suite as proxy:
curl -x http://127.0.0.1:8080 http://target.com
Ignore SSL errors:
curl -k https://target.com
10. RATE LIMITING & TIMING
Limit download speed:
curl --limit-rate 100K http://target.com
Timeout:
curl --max-time 5 http://target.com
11. FILTERING OUTPUT
Show only HTTP status code:
curl -o /dev/null -s -w "%{http_code}" http://target.com
Show only IP address resolved:
curl -s -o /dev/null -w "%{remote_ip}" http://target.com
12. API TESTING WORKFLOW
List resources:
curl -H "Accept: application/json" http://api.target.com/items
Create new entry:
curl -X POST -d '{"name":"test"}' -H "Content-Type: application/json" http://api.target.com/items
Update entry:
curl -X PUT -d '{"name":"updated"}' http://api.target.com/items/1
Delete entry:
curl -X DELETE http://api.target.com/items/1
13. REAL PENTEST & CTF EXAMPLES
Check if SQLi triggers error:
curl -G --data-urlencode "id=' OR 1=1--" http://target.com/item
Check XSS:
curl -G --data-urlencode "search=alert(1)" http://target.com
Bypass login with forged header:
curl -X POST -d "user=admin&pass=wrong" -H "X-Forwarded-For: 127.0.0.1" http://target.com/login
Brute-force parameter:
for i in {1..20}; do curl -s http://target.com/item?id=$i; done
← Back to tutorial