Sending HTTP POST with php cURL
|
|
As promised previously, I’m going to show you how to send HTTP POST request using php cURL extension.
The target form
Let’s say you have a html form like this :
And this is the source code of the html file :
You can see that the form will submit the query using HTTP POST to “target.php”. Now let’s say you want to write a php script (bot.php) that will automatically send the query bypassing the html form, this is one way to do it (with php libcurl extension)
< ?php //bot.php $url = "http://localhost/wtf/target.php"; $ch = curl_init(); // set the target url curl_setopt($ch, CURLOPT_URL,$url); // howmany parameter to post curl_setopt($ch, CURLOPT_POST, 1); // the parameter 'username' with its value 'johndoe' curl_setopt($ch, CURLOPT_POSTFIELDS,"username=johndoe"); $result= curl_exec ($ch); curl_close ($ch); print $result; ?>
This script will send a HTTP POST request to “target.php” pretending to be a real person sending the “username” parameter as “john doe”.
However this is not entirely convincing since the server side will automatically know that you are using a http script to send the HTTP POST request by analyzing the browser “user-agent” string. The default script will send “(HTTPRetriever/1.0)” as its user-agent.
With a little add-on, you can spoof the user-agent string inside your script just like this :
< ?php // // test HTTP POST submitter, using libcurl // // the target url which contains scripts that accepts post request $url = "http://localhost/wtf/target.php"; // we are spoofing Yahoo Seeker bot >:) $useragent="YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)"; $ch = curl_init(); // set user agent curl_setopt($ch, CURLOPT_USERAGENT, $useragent); // set the target url curl_setopt($ch, CURLOPT_URL,$url); // howmany parameter to post curl_setopt($ch, CURLOPT_POST, 1); // the parameter 'username' with its value 'johndoe' curl_setopt($ch, CURLOPT_POSTFIELDS,"username=johndoe"); // execute curl,fetch the result and close curl connection $result= curl_exec ($ch); curl_close ($ch); // display result print $result; ?>
so when your “bot.php” sends the request, the server logs will record that the query was sent by a “Yahoo Seeker bot” instead of a crudely coded php script.
You can spoof other browser as long as you know their user-agent string, refer to my previous post for a collection of browser user-agent strings.
No PHP cURL support?
In this case, you have a few options
- Use a server that support php cURL extension
- Compile/Install php cURL extension
- Use libcurlemu – php cURL extension written in pure php
Well that should cover the short crash course on how to use php cURL extension.
p/s : Although I won’t tell you how to write one directly, this is the basic of building spam bots and auto-submitter. So use your imagination (and the dark side of the force) to write the rest of the code. *evil*
You can download the source code of this tutorial here : http://mypapit.net/pub/libcurltest.zip
Keep updated with this website! : Subscribe to your email
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.














February 28th, 2006 at 10:27 am
Sending HTTP POST with php cURL Feb 28, 2006 4:40 AM – Mypapit’s blog @ Computers Although I won?t tell you how to write one directly, this is the basic of building spam bots and auto-submitter. So use your imagination (and the dark side of the
February 28th, 2006 at 10:27 am
Sending HTTP POST with php cURL Feb 28, 2006 4:40 AM – Mypapit’s blog @ Computers Although I won?t tell you how to write one directly, this is the basic of building spam bots and auto-submitter. So use your imagination (and the dark side of the
June 8th, 2006 at 5:03 am
Sending HTTP POST with php cURL ? (mypapit) New Media Musings: Give out phone number, stay anonymous On the Media –June 2, 2006 Chaos, Revisited A little while ago, Bob took out his crystal ball, and looked into the brave new media future. What he saw didn
April 14th, 2006 at 9:12 pm
provide chinese jade carve,furniture,wood carving,antique furniture,antique,antiques,bronze,carve panel,china jade carving,lamps arts,antique jade,curio,earring,sculpture,chinese furniture, sculpture, pendants, jade factory,jade provider,shanghai,beijing….
May 17th, 2006 at 2:50 am
lortab
June 5th, 2006 at 3:58 am
[...] ? Auto submitter – Find The Best Auto submitter Resources Online Auto submitter Top Auto submitter Resources Blog Submitter – ShoutBox Submitter Promotion tools, marketing Blog submitter, blog auto submitter, blog submission, blog auto submission, Blogs Submission mass blog spammer every blog auto submission it Softwares suggestions for suggest a site – A Public Forum Sponsored and Here are three suggestions 1) "suggest a site" step four: "Auto-submission software is a violation of this procedure. Sites submitted automatically are Free Web Submission: Free Search Engine Submission and Site PromotionFree Web Submission is the source for free search engine submission. We provide webmasters and site owners with free manual and auto submission to the Promoting Your Website, Josiesque Designs, website design, media You shouldn't use an auto submitter to submit to Yahoo and Open Directory. Take your time and craft your submissions carefully to these two important sites. Purdue University Cooperative Education:Other Areas, Purdue Posted by auto submitter on September 07, 2005 at 06:14:51:. Anyone can make a site popular. Not everyone will If you ever wished to be on the top of Iggys Filthy Files – Web LinksVisit rSubmitter – Auto Submitter Linkdumps Popular, Last Update: 2005/5/14 5:55 Visit Chameleon TGP and MGP Submitter – Auto, Manual TGP/MGP Submitter Free URL Submission Search Engine Add SiteThe search engines and directories are constantly changing their submission routines which causes auto-submission programs to quit functioning. Making the Most of Auto-Submitters – Part 1 – Webmaster JointWe will then take a look at several of the top auto-submission programs you Since the advent of the TGP Auto-Submitter, a great deal of controversy has Safelist Submitter – #1 Rated Auto-Safelist Submitter – SMASSAuto Safelist Submitter – Safelist Advertising – Safelist Script – Safelist Directory.FamilyReunion.com? | Resource Guide Auto-SubmissionConnect your family at the web's favorite family reunion destination.Purdue University Cooperative Education:Other Areas, Purdue auto submitter is just at your fingertips – auto submitter September 07, 2005 at 06:14:51. SPRING 2005 SUBLEASE close to campus – Jason Schlosser August 17, Adult Insider – Adult Webmaster ResourcesThe most powerfull adult webmaster submission tool. Auto submit to 700 sites. The Submission Assistant is not an auto submitter. Search Engine Submission Software Internet Marketing Dynamic With new manual submission features you have absolute control over the submission process. Some engines like Alta vista do not accept auto-submission unless Scripts and SoftwareFree Tgp Auto Submitter featuring 2 submissions modes (quick, normal). It also includes a free tgp list of 1500 sites with Email confirmer, gallery creator The-DDL.InFo – NEW Auto-SubmitterINFO ON YOUR PAGE OR YOU WILL BE BANNED FOREVER FROM USING THIS AUTO SUBMITTER. If you find your site is on/not on the list, feel free to contact me to get SafeListJunction.com – THE COMPLETE INTERNATIONAL ONLINE SAFELIST Auto safelist submitter for easy bulk email advertising. Over 1000 lists! Auto join, auto verify, auto send.Auto Submitter: Chameleon – Klixxx Forums: Adult Webmaster Message Old 03-22-2005, 01:45 PM. Raven. I Was Here First! Join Date: Jan 2002. Location: WA. Posts: 8419. Default Auto Submitter: Chameleon Script Library : CGI/PERL – URL SubmittersAuto-Submission-Pro utilizes its own built in domain spider to recognize the Auto URL Submitter Pro lets your visitors or customers submit their web Sending HTTP POST with php cURL ? (mypapit)p/s : Although I won?t tell you how to write one directly, this is the basic of building spam bots and auto-submitter. So use your imagination (and the dark Search Engine Esoterica: Context, Mispellings & Other Unnatural The reason you don't get one answer is that there are legion answers and that's too many to leave up to any auto-submitter. Content, best/most pragmatic Siteowners – webmaster forums – I think i blew my chance with all I would advise 'against' any auto submitter, do it by hand, manually submit to dmoz first, and be sure to get some healthy inbound links to your site & the Web Promotion Search Engine Submission & Internet Marketing SoftwareSome engines like Altavista, DMOZ etc. do not accept auto-submission unless you enter right submission code or choose correct category. SafelistBoys — FREE Safelists for you!SafelistBoys is a powerful automated SafelistPoster.Safelist Submitter – #1 Rated Smass Auto-Safelist Submitter BlasterOver the last 2 years we've been continually developing and releasing an auto-safelist submitter now commonly known as SMass?. With its many features our Boing Boing: A Directory of Wonderful Things(4) Our space lasers will vaporize your auto-submitter. Don't even think about using submission scripts. Only hand-crafted submissions from real humans get SMASS Auto Safelist Submitter free download. Discover the software SMASS Auto Safelist Submitter free download. Discover the software thousands of Internet marketers are using daily to generate more sales, referrals and ellbatads.com – Safelist Submitter – #1 Rated Auto-Safelist SubmitterAutomatically Blast Your Email Messages safely and legally to Thousands of Targeted Prospects using amazing set and forget technology, no monthly fees.Gallery TGP Submitter – free tgp submissions advanced submitter Auto TGP Submitter. Product Price:. Free or Premium. Product Version:. Server Edition v2.5. Product Usage:. TGP Submission Kick Azz Auto SubmitterKick Azz Auto Submitter. Welcome to the Kick Azz Auto Submitter We have developed an automatic safe list submitter that will blast your ads to thousands eBay: Submit your website 1 task with submission results to (item eVirtuWeb Auto-Submission System has been designed for membership, down-line, Mlm or any other website that would like to provide submission services for About This Auto submitter Site Welcome to this site dedicated to cushions and various related products. This site has been designed to provide a one stop resource for a wealth of information, this page is for Auto submitter related information. You can find more useful and new information from here. [...]
October 19th, 2006 at 5:17 pm
Good site I found … Plan on coming back later.
October 31st, 2006 at 9:53 pm
we are hiring a person,who is interested to work a simple home based research works.
its interesting ,your own environment,and sorrounding.
there is no selling,no recruting nor ads.
please visir
http://www.typeinternational.com/id=7900
November 8th, 2006 at 3:45 am
How do you send more than one field in your post? Thanks!
April 5th, 2007 at 4:28 am
[...] Jeg har selv kun gjort det gjennom PHP, som beskrevet i denne guiden: http://blog.mypapit.net/2006/02/sending-http-post-with-php-curl.html Men jeg ser ikke bort i fra at det kan gjøres direkte med curl også, altså uten PHP. Så setter du opp en cron-jobb som kjører PHP-scriptet, som enten logger deg inn hver 6. time, eller som bruker curl for å laste ned en ekstern side for å teste om forbindelsen er oppe. [...]
June 12th, 2007 at 6:46 am
great ideas, but what about cookie
? is this support it ?
July 18th, 2007 at 11:11 am
Thankz !
July 23rd, 2007 at 1:46 am
[...] Well you can go about this two, maybe 3 ways.The first way i would suggest is by using cURL to submit the form. A couple of examples for you:http://www.wagerank.com/2007/how-to-submit-forms-with-php/http://blog.mypapit.net/2006/02/sending-ht…h-php-curl.htmlThe second way is similar to the first but without cURL using steam_context_create. (Remember obviously recreate POST not GET )An example for you here:http://netevil.org/node.php?nid=937And the third, not very good way of doing it would be to use javascript to submit the form with an external action on your page load. However the first two would be much better, especially if wanting to spam someone Matt This post has been edited by Matthew.: Jun 2 2007, 08:41 AM ——————– – [...]
July 30th, 2007 at 7:50 pm
Thank You!
September 15th, 2007 at 7:38 am
[...] 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. [...]
September 25th, 2007 at 10:28 pm
1234
September 25th, 2007 at 10:47 pm
dd
September 25th, 2007 at 10:48 pm
asd
October 4th, 2007 at 10:00 pm
http://www.KankaSohbet.Net Türkiye’nin En KaliteLi Sohbet Sitesi.
October 13th, 2007 at 4:24 am
Hey buddy,
read the manual again!
your tut is bullshit!
April 12th, 2008 at 9:24 am
thnx
April 29th, 2008 at 8:42 pm
thanks
May 9th, 2008 at 8:11 pm
thankss
May 9th, 2008 at 8:11 pm
thanksss
May 9th, 2008 at 8:12 pm
thankssss
May 20th, 2008 at 11:33 pm
Great and excellent article it’s realy helpful. Thanks again.
May 26th, 2008 at 6:31 pm
Thanks
June 2nd, 2008 at 3:42 am
thankss
June 5th, 2008 at 8:33 pm
thanks
June 9th, 2008 at 1:36 am
http://www.ircrehberi.com
June 25th, 2008 at 12:45 am
look english no joke stone house student clean america frog you apple ugly
July 10th, 2008 at 5:14 pm
That’s exactly what I was looking for.
Thank you.
August 28th, 2008 at 8:07 pm
Hello my friend, your site is very good! http://xcgdhkhfvvkhgm.com
September 17th, 2008 at 9:41 am
thank you admin
November 19th, 2008 at 9:10 pm
Thanks webmaster very nice
January 21st, 2009 at 5:16 pm
thanks, cool script
February 27th, 2009 at 12:36 pm
ã•ã‚ã‚„ã‹ãªæ‹ã®äºˆæ„Ÿï¼
February 27th, 2009 at 3:01 pm
It actually solved my purpose…. guddos :)
June 5th, 2009 at 6:20 am
Amazing blog thanks admin
???
June 24th, 2009 at 6:55 am
I’m happy to see the team grow. If you guys ever open up a Whistler office let me know, I’m so in
July 4th, 2009 at 2:44 pm
Very cool app. Can you tell me where to download the Help files? Apparently they didn’t make it during the install process, so it won’t load them. Thanks!
August 16th, 2009 at 7:39 pm
Wow. This is a very useful and informative article. You definitely not only know your stuff, you know how to illustrate your point well. Great work.
August 20th, 2009 at 4:41 pm
verly coop thakns
October 10th, 2009 at 6:27 pm
The CasaModern your exclusive online design gallery and resource guide brings collections from modern, contemporary traditional, and other designer furniture manufacturers and showrooms in Italian and European interior designs for your home, office, villa, luxury apartment, service apartment, call center, hotel, cafe, pub, restaurant, and other fine living space requirement!
December 13th, 2009 at 12:11 am
other designer furniture manufacturers and showrooms in Italian and European interior designs for your home, office, villa, luxury apartment, service apartment, call center, hotel, cafe, pub, restaurant..