cURL
Akilan RAkilan R
akilan@tcoe.iitm.ac.in
Sat, 13 Nov, 2010 2
cURL?
– http://curl.haxx.se/
Sat, 13 Nov, 2010 3
cURL?
curl - transfer a URL
– http://curl.haxx.se/
Sat, 13 Nov, 2010 4
cURL :
– http://curl.haxx.se/
Sat, 13 Nov, 2010 5
●
User + password
Authentication
– Basic
– Digest
– NTLM
– Negotiate
– Kerberos
●
Proxy
●
Resume
●
Cookies
●
Proxy tunneling
●
SSL certs
●
HTTP range requests
●
UA spoofing
●
Wireshark
●
gzip/deflate
cURL
Sat, 13 Nov, 2010 6
The real cURL
Sat, 13 Nov, 2010 7
●
HTTP
●
HTTPS
●
FTP
●
FTPS
●
SCP
●
SFTP
●
TFTP
●
TELNET
●
LDAP
●
DICT
●
POP
●
SMTP
●
RTMP
●
RTSP
The real cURL
Sat, 13 Nov, 2010 8
What it isn't
Sat, 13 Nov, 2010 9
What it isn't
Sat, 13 Nov, 2010 10
But you can build one...
Sat, 13 Nov, 2010 11
Get a file
$ curl protocol://example.com/path/to/file
$ curl ftps://example.com/path/to/file
$ curl blah://user:pass@example.com:port/file
$ curl -u user:pass scp://example.com/~/personal.txt
Sat, 13 Nov, 2010 12
more...
$ curl -u user:pass -x proxy:3128 
http://example.com/file
$ curl -u user:pass -x proxy:3128 -u user:pass 
http://example.com/file
Sat, 13 Nov, 2010 13
Upload
$ curl -T filename http://www.upload.com/myfile
$ curl -T – ftp://ftp.upload.com//myfile
Sat, 13 Nov, 2010 14
Trace
$ curl --trace tracefile http://www.example.com/
$ curl --trace-ascii tracefile http://www.example.com/
Sat, 13 Nov, 2010 15
Few cool features...
$ curl -e www.coolsite.com http://www.showme.com/
$ curl -A 'Konqueror/1.0' http://www.example.com/
$ curl --limit-rate 10K www.far-away-site.com
Sat, 13 Nov, 2010 16
Few cool features...
$ curl -H "X-some-header: yes" www.example.com
$ curl --interface eth0:1 http://www.netscape.com
$ curl -E /path/to/cert.pem:password 
https://secure.site.com
$curl telnet://remote.server.com
Sat, 13 Nov, 2010 17
FTP
$ curl -T – ftp://ftp.upload.com//myfile
$ curl --ftp-port <address> ftp://ftp.upload.com/myfile
$ curl -O ftp://download.com/coolfile -Q '-DELE
coolfile'
Sat, 13 Nov, 2010 18
SMTP
$ curl --mail-rcpt <address> 
--mail-from <akilan27@gmail.com> -u akilan27:pass 
--ssl smtp://smtp.gmail.com
Sat, 13 Nov, 2010 19
HTTP
$ curl “ google.com/search?q=ilugc”
Get requests are simple:
Sat, 13 Nov, 2010 20
HTTP
$ curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux
2.2.15 i686)" “ google.com/search?q=ilugc”
Get requests are simple:
Sat, 13 Nov, 2010 21
HTTP
$ curl --user-agent "Mozilla/5.0 [en] (X11; U; Linux
2.6.28 i386)" “ http://google.com/search?q=ilugc”
Get requests are simple:
Post requests are also simple with curl. ;-)
$ curl --data-urlencode input=value http://example.com/cgi
Sat, 13 Nov, 2010 22
HTTP
$ curl --proxy-user proxyuser:proxypassword curl.haxx.se
Proxy
Post requests are also simple with curl. ;-)
$ curl --data-urlencode input=value http://example.com/cgi
Sat, 13 Nov, 2010 23
Scripting cURL
curl
http://username:password@members.dyndns.org/nic/update?
hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=N
OCHG&backmx=NOCHG
Update your dyndns:
Sat, 13 Nov, 2010 24
Scripting cURL
curl -c mycookie --data-urlencode email=foo@bar.com
--data-urlencode pwd=password
http://example.com/ValidateEntry.php
Login to a website and perform requests
Sat, 13 Nov, 2010 25
Scripting cURL
curl -c cookie --data-urlencode email=foo@bar.com 
--data-urlencode pwd=password 
http://example.com/ValidateEntry.php
curl -b cookie --data-urlencode uid=bar – data-urlencode 
action=del http://example.com/usermanip.php
Login to a website and perform requests
Sat, 13 Nov, 2010 26
Scripting cURL
curl -c cookie --data-urlencode email=foo@bar.com 
--data-urlencode pwd=password 
http://example.com/ValidateEntry.php
curl -b cookie --data-urlencode uid=bar – data-urlencode 
action=del http://example.com/usermanip.php
rm cookie
Login to a website and perform requests

Ilugc curl

  • 1.
  • 2.
    Sat, 13 Nov,2010 2 cURL? – http://curl.haxx.se/
  • 3.
    Sat, 13 Nov,2010 3 cURL? curl - transfer a URL – http://curl.haxx.se/
  • 4.
    Sat, 13 Nov,2010 4 cURL : – http://curl.haxx.se/
  • 5.
    Sat, 13 Nov,2010 5 ● User + password Authentication – Basic – Digest – NTLM – Negotiate – Kerberos ● Proxy ● Resume ● Cookies ● Proxy tunneling ● SSL certs ● HTTP range requests ● UA spoofing ● Wireshark ● gzip/deflate cURL
  • 6.
    Sat, 13 Nov,2010 6 The real cURL
  • 7.
    Sat, 13 Nov,2010 7 ● HTTP ● HTTPS ● FTP ● FTPS ● SCP ● SFTP ● TFTP ● TELNET ● LDAP ● DICT ● POP ● SMTP ● RTMP ● RTSP The real cURL
  • 8.
    Sat, 13 Nov,2010 8 What it isn't
  • 9.
    Sat, 13 Nov,2010 9 What it isn't
  • 10.
    Sat, 13 Nov,2010 10 But you can build one...
  • 11.
    Sat, 13 Nov,2010 11 Get a file $ curl protocol://example.com/path/to/file $ curl ftps://example.com/path/to/file $ curl blah://user:pass@example.com:port/file $ curl -u user:pass scp://example.com/~/personal.txt
  • 12.
    Sat, 13 Nov,2010 12 more... $ curl -u user:pass -x proxy:3128 http://example.com/file $ curl -u user:pass -x proxy:3128 -u user:pass http://example.com/file
  • 13.
    Sat, 13 Nov,2010 13 Upload $ curl -T filename http://www.upload.com/myfile $ curl -T – ftp://ftp.upload.com//myfile
  • 14.
    Sat, 13 Nov,2010 14 Trace $ curl --trace tracefile http://www.example.com/ $ curl --trace-ascii tracefile http://www.example.com/
  • 15.
    Sat, 13 Nov,2010 15 Few cool features... $ curl -e www.coolsite.com http://www.showme.com/ $ curl -A 'Konqueror/1.0' http://www.example.com/ $ curl --limit-rate 10K www.far-away-site.com
  • 16.
    Sat, 13 Nov,2010 16 Few cool features... $ curl -H "X-some-header: yes" www.example.com $ curl --interface eth0:1 http://www.netscape.com $ curl -E /path/to/cert.pem:password https://secure.site.com $curl telnet://remote.server.com
  • 17.
    Sat, 13 Nov,2010 17 FTP $ curl -T – ftp://ftp.upload.com//myfile $ curl --ftp-port <address> ftp://ftp.upload.com/myfile $ curl -O ftp://download.com/coolfile -Q '-DELE coolfile'
  • 18.
    Sat, 13 Nov,2010 18 SMTP $ curl --mail-rcpt <address> --mail-from <akilan27@gmail.com> -u akilan27:pass --ssl smtp://smtp.gmail.com
  • 19.
    Sat, 13 Nov,2010 19 HTTP $ curl “ google.com/search?q=ilugc” Get requests are simple:
  • 20.
    Sat, 13 Nov,2010 20 HTTP $ curl --user-agent "Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)" “ google.com/search?q=ilugc” Get requests are simple:
  • 21.
    Sat, 13 Nov,2010 21 HTTP $ curl --user-agent "Mozilla/5.0 [en] (X11; U; Linux 2.6.28 i386)" “ http://google.com/search?q=ilugc” Get requests are simple: Post requests are also simple with curl. ;-) $ curl --data-urlencode input=value http://example.com/cgi
  • 22.
    Sat, 13 Nov,2010 22 HTTP $ curl --proxy-user proxyuser:proxypassword curl.haxx.se Proxy Post requests are also simple with curl. ;-) $ curl --data-urlencode input=value http://example.com/cgi
  • 23.
    Sat, 13 Nov,2010 23 Scripting cURL curl http://username:password@members.dyndns.org/nic/update? hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=N OCHG&backmx=NOCHG Update your dyndns:
  • 24.
    Sat, 13 Nov,2010 24 Scripting cURL curl -c mycookie --data-urlencode email=foo@bar.com --data-urlencode pwd=password http://example.com/ValidateEntry.php Login to a website and perform requests
  • 25.
    Sat, 13 Nov,2010 25 Scripting cURL curl -c cookie --data-urlencode email=foo@bar.com --data-urlencode pwd=password http://example.com/ValidateEntry.php curl -b cookie --data-urlencode uid=bar – data-urlencode action=del http://example.com/usermanip.php Login to a website and perform requests
  • 26.
    Sat, 13 Nov,2010 26 Scripting cURL curl -c cookie --data-urlencode email=foo@bar.com --data-urlencode pwd=password http://example.com/ValidateEntry.php curl -b cookie --data-urlencode uid=bar – data-urlencode action=del http://example.com/usermanip.php rm cookie Login to a website and perform requests