cURL

cURL

cURLarrow-up-right (client URL) is a command-line tool and library that primarily supports HTTP along with many other protocols. It can be used for sending various types of web requests from the command line, which is necessary for many types of web penetration tests.

cURL commands

Get Help

curl -h

Basic GET request

curl www.example.com

Download file

curl -s -O www.example.com/index.html
  • -O : output or save the file locally

Skip SSL check

Here, -k flag helps to skip the SSL certificate check for https.

Verbose output

Fetch only response headers

  • -I : fetch only the headers without the body (HEAD request)

Fetch response headers and body

  • -i : include the headers in the output along with the body

Add Custom User-Agent

  • -A : specify the User-Agent

Basic authentication

Here, -u flag is used to include the user data in the command that is normally used in the body of POST request and username and password are also specified, separated by colon.

Send POST data

  • -X : specify the HTTP method

  • -d : specify the HTTP request data

Here, this specifies the username and password values with their respective parameters in the body of the HTTP request.

Set request headers

  • -H : specify the HTTP header

Here, this command is also used for authentication with the specification of Authorization header that contains Base64 encoded value as token for authentication.

Pass GET parameters

Here, GET parameters are specified with values in the query string.

Send JSON data

Here, the JSON data is specified with -d flag and -H flag is used to specify that the content of the data is of the type JSON.

Set Cookies

  • -b : directly specifies the cookie

Alternatively, this can also be done with -H header to specify the cookie and its value as header.

Read all entries of API data

  • -s : tells curl to operate in silent mode suppressing the progress information and error messages

  • jq : a command-line utility used to parse, filter, and format JSON data, it makes the output more readable by indenting and coloring the JSON structure

Add an entry to API data

This adds a new entry to the JSON data in API.

Update an entry of API data

This updates and replaces the entry related to 'london' in the JSON data of the API.

Delete an entry of API data

This deletes the API entry for city JSON and city name as New_ABC_City.

Last updated