How to use curl

Hackbydoing Academy tool guide · Web hacking · free, no login

What curl is, in plain words

Curl fetches or sends data at a web address from the command line — it is a web browser with no screen, used to talk to websites and APIs directly.

A working curl command

curl -s http://192.168.99.20/

This quietly downloads the front page of the web server at 192.168.99.20 and prints its HTML as text.

Every piece of the command, explained

--data-urlencodeThe next piece is form data to send with the request, written like name=value, with any special characters safely encoded for the trip (spaces and symbols converted so they cannot break the message). Like -d, it sends a POST unless you say otherwise.
-FThe next piece is one field of a multipart form — the kind a web upload form sends. Written like [email protected] it uploads that file; without the @ it sends plain text.
-HThe next piece, in quotes, is one extra header line to send, such as an authorisation token. Headers are the label lines on a web request; repeat -H for each extra line.
-IFetch only the headers — the label lines a server sends back, like its status and type — and not the page itself. Curl does this with a HEAD request.
-XThe next piece is the request method to use, such as GET, POST, PUT, PATCH or DELETE — the verb that tells the server what kind of request this is.
-bThe next piece supplies cookies to send: either a string of cookies or the name of a cookie file to read them from, so the server treats you as the same visitor who logged in earlier.
-cThe next piece is the name of a file to save (write) any cookies the server sends back into, so a later curl command can reuse that logged-in session with -b.
-dThe next piece is data to send in the body of the request, such as a login form's fields; using -d makes curl send a POST. Start the value with @ to read the data from a file instead.
-kInsecure: do not check the site's security certificate (the ID card behind HTTPS) and connect anyway. Fine for a lab box with a home-made certificate, risky anywhere else.
-oThe next piece is a filename to save the downloaded data into, instead of printing it on screen.
-sSilent: hide the progress meter and error messages, so you see only the data itself — good for scripts and for reading output cleanly.
-sSLA bundle of three letters: -s means silent (no progress meter), -S means still show an error message if it fails, and -L means follow redirects — if the server says 'moved, ask over there instead', go there automatically.
-wThe next piece, in quotes, is a format string printed after the transfer finishes, using codes like %{http_code} for the server's status number — a way to record just the result you care about.
-xThe next piece is the address of a proxy — a go-between server to send the request through, such as http://127.0.0.1:8080 for a local testing proxy that lets you watch the traffic.
URLThe last piece is the web address to fetch or send to.

Use it the legal way

Only run curl on systems you own or have explicit, written permission to test — at work that means a signed engagement, at home that means your own lab. Inside Hackbydoing Academy you practice on simulated networks and lab machines built for exactly this, where breaking things is the lesson and no one else's systems are involved. Learning how a tool works also teaches you what it looks like from the defender's chair: the logs it leaves, the traffic it makes, and the settings that shut it down.

✦ Practice curl hands-on in a guided lab

Reading about curl is step one. In the Academy you run it yourself, step by step, in guided labs on simulated networks — 185 rooms covering attack and defense, from your first scan to full operations, with a defender's debrief at the end of every room. Founding membership is $9.99/mo for the first 500 members.

Join Hackbydoing Academy →

Related tool guides

Free from the Hackbydoing Academy — learn cybersecurity by doing: real tools, guided labs, attack and defense, on simulated networks. More free material: Tool Guides index · Free Downloads Library · Hackbydoing Academy · Print this page (Ctrl/Cmd+P) for a clean paper copy.