Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for getCaptchaGoogleAudio.php

This php script gets 1000 CAPTCHA audio files from Google's Audio CAPTCHA system and saves them to the subfolder /googleaudio/. This is meant to get a sampling size for testing your CAPTCHA breaking algorithms.

getCaptchaGoogleAudio.php
Wednesday, March 12th, 2008 at 7:30:57am MDT 

  1. <?php
  2.         //This script pulls CAPTCHAs URL from $urlGoogleAudio, then gets the CAPTCHA and saves them to folder $saveGoogleAudio from the range $startSound to $endSound.
  3.         $urlGoogleAudio = "https://www.google.com/accounts/NewAccount?service=mail&continue=http%3A%2F%2Fmail.google.com%2Fmail%2Fe-11-10ba05aeaa8e9b701e5151437f9a44d3-64aeae753cc34f1c864f7edc97a046ccdc96987b&type=2";
  4.         $saveGoogleAudio = "googleaudio/";
  5.         $startSound = 0;
  6.         $endSound = 999;
  7.  
  8.         //Make carraige returns appear correctly in all browsers. (ideally)
  9.         echo "<PRE>";
  10.         //These two lines force the output to be constantly flushed and updated for the user. (ideally)
  11.         ob_implicit_flush(true);
  12.         ob_end_flush();
  13.         echo "Script Started.\n";
  14.  
  15.  
  16.         //Pull in the CAPTCHA image as a string with cURL, and save to a file. The curl extension must first be enabled in php.ini.
  17.         for ($i=$startSound;$i<=$endSound;$i++) {
  18.                 //First extract a unique URL for each CAPTCHA from the $urlGoogleAudio.
  19.                 $ch = curl_init();
  20.                 curl_setopt($ch, CURLOPT_URL, $urlGoogleAudio."&rand=".$i);
  21.                 curl_setopt($ch, CURLOPT_HEADER, 0);
  22.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  23.                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  24.                 //If you're having difficulties with SSL, this may need to be enabled.
  25.                 //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  26.                 $result = curl_exec($ch);
  27.                 //Enable this if you're having difficulties.
  28.                 //echo "Error is: ".curl_error($ch);
  29.                 curl_close($ch);
  30.  
  31.                 //Parse out the URL, and retrieve the CAPTCHA for it.
  32.                 $result = substr($result,strpos($result,"wavURL"));
  33.                 $resultArray = explode('"',$result);
  34.                 $ch = curl_init();
  35.                 curl_setopt($ch, CURLOPT_URL, str_replace('\75',"=",$resultArray[1]));
  36.                 curl_setopt($ch, CURLOPT_HEADER, 0);
  37.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  38.                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  39.                 //If you're having difficulties with SSL, this may need to be enabled.
  40.                 //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  41.                 $sound = curl_exec($ch);
  42.                 //Enable this if you're having difficulties.
  43.                 //echo "Error is: ".curl_error($ch);
  44.                 curl_close($ch);
  45.  
  46.                 //Save CAPTCHA to a file with the same name as $i.
  47.                 if(!is_dir($saveGoogleAudio)) mkdir($saveGoogleAudio);
  48.                 if(strlen($sound) > 146) {
  49.                         $fh = fopen($saveGoogleAudio.$i.".wav","w");
  50.                         fwrite($fh,$sound);
  51.                         fclose($fh);
  52.                 }
  53.                 else $i--;
  54.  
  55.                 //Don't allow it to timeout.
  56.                 set_time_limit(40);
  57.                 //Output occasional progress.
  58.                 if ($i%10 == 0) {
  59.                         echo $i." CAPTCHA captured.\n";
  60.                         flush();
  61.                 }
  62.         }
  63.  
  64.  
  65.         echo "Script Complete.";
  66.         //-maluc
  67. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right fantasy-obligation
fantasy-obligation