🔗
Networking concepts
  • Introduction
  • DNS
    • Introduction
    • DNS query
  • SSH
    • Introduction
    • Basics
    • SSH tunneling
      • Direct SSH tunnel
      • Reverse SSH tunnel
      • Dynamic SSH tunnel
    • SSH public key authentication
    • Port forwarding with virtual interface
    • sshd
    • scp/sftp
  • 🔫Networking tools
    • configuration & information
      • ip
      • netstat/netsh
      • ifconfig/ipconfig/iwconfig
      • arp
      • route
      • ps
      • ss
      • lsof
      • pgrep
      • nmcli
      • Information about services/processes & PID
    • monitoring & troubleshooting
      • ping
      • tracert/traceroute
      • mtr
      • iperf3
    • domain information
      • dig/nslookup
      • whois
      • host
    • capture & analysis
      • tcpdump
      • ngrep
      • wireshark
    • firewall & security
      • iptables
      • nft
    • services
      • dnsmasq
      • hostapd
      • RDP/VNC
      • ngrok
      • networking.service
      • NetworkManager.service
      • nginx
      • apache
      • nfs
    • miscellaneous
      • cURL
      • wget
      • netwox
      • netcat
      • openssl
      • socat
      • ftp
      • smbclient
    • proxy & tunneling
      • proxychains
    • Programming/scripting
      • Python
      • C
  • 🤩Interesting concepts
    • Simple tips & tricks
    • Network hole punching
    • SSH Over HTTPS
  • Network ports & services cheat sheet
    • 20/21/tcp ~ ftp
    • 22/tcp ~ ssh
    • 23/tcp ~ telnet
    • ...
  • For-fun projects
    • Raspberry pi + Windows machine experiments
Powered by GitBook
On this page
  • Basic commands:
  • Examples
  • POST
  • SOCKS5 proxy
  1. Networking tools
  2. miscellaneous

cURL

cURL which stands for "client for URL" is a useful networking tool that can be used in command lines or scripts for transferring data. It supports multiple protocols.

Basic commands:

# Basic
$ curl -X <method> <HTTP_URL>

# With headers
$ curl -X <method> -H <headers> <HTTP_URL>

# GET: no need to specify the -X flag
$ curl -H <headers> <HTTP_URL>

# VERBOSE: increasing level of output
$ curl ... -v
$ curl ... -vv
$ curl ... -vvv

Examples

Sending a GET request to https://domain.comwith query data

$ curl https://domain.com?key=value

POST

x-www-form-urlencoded

# no need to specify -X POST
$ curl -H "content-type:application/x-www-form-urlencoded" -d/--data <POST_data> <HTTP_URL> 

Eg. Sending a POST request to https://domain.com with some x-www-form-urlencoded data.

$ curl https://domain.com -H ... -d "key1=value1&key2=value2"
# OR
$ curl https://domain.com -H ... --data "key1=value1&key2=value2"

json

# no need to specify -X POST
$ curl -H 'application/json' -d/--data <POST_data> <HTTP_URL> 

Eg. Sending a POST request to https://domain.com with some json data.

$ curl https://domain.com -H ... -d '{"key1":"value1","key2":"value2"}'
# OR
$ curl https://domain.com -H ... --data '{"key1":"value1","key2":"value2"}'

Form-data

The @ and < symbols can be used to read contents from a file for file upload and text field respectively.

From the cURL documentation:

To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.

# no need to specify -X POST
$ curl -H <headers> -F/--form <form_data> <HTTP_URL>

# Eg.
$ curl -H <headers> -F "fileToUpload=@example.php;type=text/x-php" -F "submit=Upload" 

SOCKS5 proxy

$ curl --socks5 [addr]:[port] [url]
$ curl -x socks5://[addr]:[port] [url]

# eg. Connect to https://example.com while proxying traffic through 
# SOCKS5 proxy at 10.10.10.10 port 8888
$ curl --socks5 10.10.10.10:8888 https://example.com
$ curl -x socks5://10.10.10.10:8888 https://example.com

To make the proxy handle DNS resolutions, for privacy concerns, etc. This means that there will be no local address resolution.

The --socks5-hostname or -x socks5h:// options can be used instead.

$ curl --socks5-hostname [addr]:[port] [url]
$ curl -x socks5h://[addr]:[port] [url]

PreviousmiscellaneousNextwget

Last updated 18 days ago

🔫
READMEEverything curl
curl
curl documentation
Logo
curl(1): transfer URL - Linux man page
Logo
Logo