Live Chat!

sending HTTP POST using curl command

* * * * * 1 votos

September 15th, 2007 mysurface Posted in Network, curl | Hits: 17792 |

Recently I was having fun with libcurl, discovered that with curl command I capable of doing HTTP POST with specified User-agent string. For those who have no idea what is curl, curl is a powerful client tool for accessing servers through FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE and LDAP, please find more info from cURL official site.

Mypapit has written a good post illustrate how to create a simple bot script using php with curl bindings. By calling curl function in php, you can do a HTTP POST to a web server’s page. Well, with curl command in bash, you can do the same, and it consist of just one line.

Mypapit is kind enough to provide his HTTP POST server’s script in php for testing purpose. Download his sample codes and load it to your apache server and you can try out the command lines shows later. What you need is target.php and target.txt, remember to chmod a+w target.txt.

To send HTTP POST request, you can do it with -F, I show you a simple example that sending username to the web server.

curl -F 'username=mysurface' http://127.0.0.1/target.php

And result returns

data was submitted successfully

Check out the target.txt, gives the line

username : mysurface (curl/7.15.5 (i486-pc-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8c zlib/1.2.3 libidn/0.6.5)

p.s mypapit’s target.php logs submitted username and it’s user-agent into file target.txt. The result showing above indicates that the submission was done by curl.

Well, you can override the default user-agent string by -A

curl -F 'username=mysurface' -A 'Mozilla/4.0' http://127.0.0.1/target.php

Therefore you have this in your target.txt

username : mysurface (Mozilla/4.0)

Having fun? curl command capable of doing a lots more!

One Response to “sending HTTP POST using curl command”

  1. [...] sending HTTP POST using curl command Recently I was having fun with libcurl, discovered that with curl command I capable of doing HTTP POST with specified Us… [...]

Leave a Reply