Cosa fa#
Manda richieste HTTP/HTTPS da riga di comando e mostra la risposta. Permette di vedere header, status code, body e debuggare qualsiasi servizio web senza aprire un browser.
TL;DR#
curl https://example.com # GET base — mostra il body
curl -i https://example.com # include gli header nella risposta
curl -I https://example.com # solo header (HEAD request)
curl -v https://example.com # verbose — tutto: request + responseComandi essenziali#
| Comando | Flag | Significato flag | Cosa fa |
|---|---|---|---|
curl URL | — | — | GET base, mostra il body |
curl -i URL | -i | include — include header | Mostra header + body insieme |
curl -I URL | -I | head — solo header | Manda HEAD request, niente body |
curl -v URL | -v | verbose — dettagliato | Mostra tutto: request, header, response |
curl -u user:pass URL | -u | user — credenziali | HTTP Basic Authentication |
curl -X POST URL | -X | request — metodo HTTP | Specifica il metodo (POST, PUT, DELETE) |
curl -d "data" URL | -d | data — corpo richiesta | Manda dati nel body (POST) |
curl -H "Header: val" URL | -H | header — header custom | Aggiunge header alla richiesta |
curl -o file URL | -o | output — salva su file | Salva la risposta su file |
curl -L URL | -L | location — segui redirect | Segue i redirect automaticamente |
curl -s URL | -s | silent — silenzioso | Nessun output di progresso |
curl -i vs telnet#
Entrambi permettono di vedere la risposta grezza di un server HTTP, ma con approcci diversi:
# curl -i — fa una vera richiesta HTTP, mostra header + body
curl -i http://example.com
# telnet — connessione raw TCP, devi scrivere la richiesta a mano
telnet example.com 80
GET / HTTP/1.0
Host: example.com
[invio due volte]curl -i e' lo strumento giusto per ispezionare header e status code rapidamente. telnet e' utile per capire il protocollo a basso livello o per banner grabbing su porte non-HTTP.
Combinazioni utili#
# Testa se un servizio risponde sulla porta 80
curl -i http://localhost:80
# Vedi gli header di risposta di un sito
curl -I https://google.com
# Accedi a un sito con autenticazione Basic
curl -u username:password http://ctf.labs.overthewire.org
# Manda una POST con dati JSON
curl -X POST -H "Content-Type: application/json" \
-d '{"user":"test"}' https://api.example.com/login
# Segui redirect e salva il risultato
curl -L -o output.html https://example.comRicognizione Directory (Directory Listing)#
La slash finale (/) è fondamentale: senza di essa, il server potrebbe non mostrare l'indice della cartella.
# 1. Controlla se il Directory Listing è attivo (nota la slash finale)
curl -u user:pass http://target.com/files/
# 2. Estrai rapidamente i nomi dei file dall'HTML (Trick da Analyst)
curl -s -u user:pass http://target.com/files/ | grep -oE 'href="([^"#]+)"' | cut -d'"' -f2Scenario Reale#
Durante un assessment, un analista vuole vedere cosa espone un server web negli header di risposta — versione del server, tecnologie usate, header di sicurezza presenti o assenti:
curl -I https://target.com
# Server: nginx/1.18.0 ← versione esposta (info leakage)
# X-Powered-By: PHP/7.4 ← tecnologia esposta
# X-Frame-Options: SAMEORIGIN ← header di sicurezza presente
# Strict-Transport-Security: ← HSTS presente o assente?Assenza di X-Frame-Options → vulnerabile a clickjacking.
Assenza di Strict-Transport-Security → vulnerabile a downgrade HTTPS.
curl -I e' piu' veloce di -i quando ti interessano solo gli header — manda una HEAD request che non trasferisce il body.
Collegato a#
- http-in-detail — il protocollo che curl parla
- netcat — alternativa raw per banner grabbing
- network — categoria
- system — categoria
- wget


