cURL
cURL is an invaluable tool in any webapp pentester's repertoire. If you're not familiar with it, allow me to introduce you. Simply put, cURL is a command-line tool that allows you to transfer data from one point to another. In pentesting, it is mostly used in the context of interacting with web servers.
This page covers some essential cURL commands, common flags, and their usage. For now, we will focus solely on the tool itself and omit automation or scripting with loops.
Basic Usage
Sending a Simple GET Request
This is the simplest usage of cURL. By replacing <targetip>
, <targetport>
, and <subdirectories>
with appropriate values, you can send a GET request to a website.
Useful Flags
-
-L
: Follow 3xx redirects. -
-k
: Continue even if an insecure SSL certificate is encountered. -
-u
: Use for basic authentication. -
-i
: Print response headers along with the content. -
-H
: Define a custom header. -
-A
: Set a custom user agent. -
-v
: Enable verbose output. Add morev
for increased verbosity (-vv
,-vvv
). -
--trace
: Dump a full trace of incoming and outgoing data.
Sending Data
Sending a POST Request
This sends data to the target web server.
Flags
-X
: Set the request method.-
HTTP methods:
GET
,HEAD
,PUT
,POST
,DELETE
. -
-d
: Define the body of the request.
Cookies
Capturing
This captures the cookie served by the web server and stores it in a file named cookie-jar.txt
.
-c
: Write cookies to the specified file (the "cookie jar").
Sending
This sends a cookie to the target server.
-b
: Specify raw cookie data to send.