Some notes on cURL

Little powerful command-line tool by Daniel Stenberg for transferring data between computers in networks using various protocols such as http, https or ftp.

As i keep on forgetting boring things pretty fast, i will post some more or less useful cURL commands on this page just for myself. And for anyone else, as long as he or she might be as dumb as i am. You can do a lot more with cURL than described here: Proxies, Tunneling, SSL, Fileuploading. Please refer to the official docs or the man pages for complete options.

BASIC HTTP CALL

do a simple http call on index of example.com
curl http://www.example.com
be silent...
curl -s http://www.example.com
add some Port... yawn...
curl http://www.example.com:85/
include Header Output
curl --include http://www.example.com:85/
Verbose Mode
curl --verbose http://www.example.com

DICT

Get the definition of the word SOLARIS. For in-depth understanding of the DICT-Protocol, have a look at Wikipedia DICT and for more detailled informations refer to RFC2229
curl dict://dict.org/d:solaris

Insecure HTTPS

curl -k https://spielprinzip.com

Save OUTPUT in File

with flag -o you are able to save the output to a file on a disk
curl -o saveHere.html http://spielprinzip.com/blog
with flag --create-dirs cURL will even handle to create the local dir hierachy for you
curl -o path/to/some/not/existing/dir/saveHere.html --create-dirs http://spielprinzip.com/blog

Get some FTP File

curl ftp://user:pass@spielprinzip.com:21/coolfile.txt

Send a FTP NLSD command

list a directory on a FTP server
curl -l -u user:name ftp://spielprinzip.com:519

Upload some FTP File

curl -T /path/to/a/file -u user:pass ftp://spielprinzip.com:21

Send some Headers

curl --header "Connection:keep-alive" "--header "User-Agent: Warrior 01" http://example.com/someXML.xml

Send some custom Headers

curl --header "Secret:15412415" "--header "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1)" http://example.com/someXML.xml

GET some data

curl http://example.com?p=3&ut=helo

POST some data

curl --data "p=4&ut=helo" http://www.example.com/someDir/ curl --data "Information" http://www.example.com/someDir/

PUT some data without file

curl -X PUT -d "something=blabla&somethingelse=blaha" http://www.example.com

Pass HTACCESS

curl --user name:pass http://www.example.com curl -u name:pass http://spielprinzip.com/blog/secret-page/ curl http://name:pass@protected.example.com

Fake HTTP Referer

By the way, in RFC2068, the word Referrer is wrongly written as Referer [sic] and therefor now standard in the HTTP-Specification! This mistake was not adepted to the DOM Specifications. So this may explain the different notation.
curl --referer http://www.example.come http://www.example.com

FOLLOW LOCATION

When the server is sending in a redirect header (301, 302), cURL will follow
curl --location http://www.example.com

Send Cookies

For advanced Hacking, you often need to send some cookies. This one here is the simple method. Dig the web for more detailed informations about cookie handling with cURL
curl --cookie "name=Jack" http://www.example.com