ReCom.org
Programming and Web Development Web monks and programmers welcomed

Auto Gmail Signup Script

Reply
 
Thread Tools
azlanhussain Male
Super Junior Member
 
azlanhussain's Avatar
 
Join Date: Nov 2008
Posts: 44
  #1 Old 21-11-2008 Thumbs up Auto Gmail Signup Script

Just thought of sharing this script that I've been using for quite sometimes. I got it from some other forum, hence credits is mention within..
Help yourself..
gmail-signup.php - main file
Code:
<?php
/*
##  Title:  gMail Signup Script V00.00.01
##  Author(s): Jack Ketch
##  Last Update: 06-14-2008
##
##   Semi-automatic script to generate free GMail accounts,
##
##  Modified: Anand (netmktg / netmktg7)
##  Last Update: Oct-12-2008
##  This script is an extensively modified version of the original script
##
*/
require_once('opendb.php');
require_once('mailsignup-functions.php');
error_reporting(E_ALL ^ E_NOTICE);
$tmpdir = 'tmp/';
$tmpdir_abs = dirname($_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']) .'/refererx/'. $tmpdir;
$submitted = isset($_POST['Create_Account']);
if ($submitted) {
 unlink($_POST['captcha_tmpfile']);
 $formLocation = urldecode($_POST['formlocation']);
 $firstname = $_POST['firstname']; 
 $lastname = $_POST['lastname']; 
 $username = $_POST['username']; 
 $password = $_POST['password']; 
 $alt_email = $_POST['alt_email']; 
 $captcha = $_POST['captcha'];
 $postQuery = $_POST['params'];
 $ref = $_POST['ref'];
 
 // $write_to_file = $_POST['write_to_file'];
 // if (empty($write_to_file)) { $write_to_file = 'new-gmails.txt'; }
 // the CAPTCHA is placed in the parameters, and then all the parameters are placed //
 // in a single string, each one separated by '&' //
 $captcha_array_key = array_search('newaccountcaptcha=',$postQuery);
 $postQuery [$captcha_array_key] .= $captcha;
 $query = $postQuery[0];
 for ($x = 1; $x < count($postQuery); $x++) { $query .= "&" . $postQuery[$x]; }
 $ch = curl_init();
 $cookiefile = $tmpdir_abs . '_cookie.txt';
 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
 curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
 curl_setopt($ch, CURLOPT_HEADER, 1);
 curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
 curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
 $headers[] = "Cookie: X=abc; GoogleAccountsLocale_session=en; TZ=-330";
 $headers[] = "Content-Type: application/x-www-form-urlencoded";
 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 curl_setopt($ch, CURLOPT_URL, $formLocation);
   curl_setopt($ch, CURLOPT_REFERER, $ref);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
 $page = curl_exec($ch);
 if ( strpos($page, 'but the following usernames are') ) {
  print '<font color="#0000FF"><b>Gmail User NOT Available</b></font>';
  return;
 }
 if ( strpos($page, 'characters you entered didn') ) { $captcha_msg = '<font color="#FF0000"><b>WRONG Captcha</b></font><br>'; }
 if ( strpos($page, 'enter the letters as they are shown in the new image') ) { $captcha_msg = '<font color="#0000FF"><b>ADDITIONAL Captcha</b></font><br>'; }

 $chk_pos = strpos($page, '<form id="createaccount"');
 if ($chk_pos > 0)
 {
  // Gmail wants us to enter Addtional Captcha
  $page = substr($page, $chk_pos);
  
  $ref = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
  $parameters = parse_gmail_fields($page, $username, $password, $firstname, $lastname, $alt_email);
  $formLocation = array_pop($parameters);
  $captchatoken = array_pop($parameters);
  $captcha_tmpfile = save_captcha($ch, $captchatoken, $tmpdir, $tmpdir_abs);
  curl_close($ch);
  // Display CAPTCHA to solve
  $currentUrl = $PHP_SELF;
  $hidden = '';
  foreach($parameters as $param){
   $hidden .= "<input type='hidden' name='params[]' value='$param'>\n"; 
  }
  $form = <<<INPUT_MYTEXT
 <center> <table> <tr> <td>
 <form method='post' action='$currentUrl'>
 
  $hidden
  <input type='hidden' name='ref' value='$ref'>
  <input type='hidden' name='firstname' value='$firstname'>
  <input type='hidden' name='lastname' value='$lastname'> 
  <input type='hidden' name='username' value='$username'> 
  <input type='hidden' name='password' value='$password'> 
  <input type='hidden' name='alt_email' value='$alt_email'> 
  <input type='hidden' name='formlocation' value='$formLocation'> 
  <input type='hidden' name='captcha_tmpfile' value='$tmpdir_abs$captcha_tmpfile'> 
  <table>
  <tr>
   <td align="center" colspan="2">$captcha_msg</td>
  </tr>
  <tr> <td align="center" colspan="2">&nbsp;</td> </tr>
  <tr>
   <td>Username:</td>
   <td><b>$username</b>@gmail.com</td>
  </tr>
  <tr>
   <td>Password:</td>
   <td><b>$password</b></td>
  </tr>
  <tr>
   <td>Name:</td>
   <td><b>$firstname $lastname</b></td>
  </tr>
  <tr>
   <td>&nbsp;</td>
   <td><img src="$tmpdir$captcha_tmpfile"></td>
  </tr>
  <tr>
   <td>Captcha:</td>
   <td><input type="text" name="captcha" id="captcha"></td>
  </tr>
  <tr>
   <td align="center" colspan="2"><input type="submit" name="Create_Account" value="Create Account"></td>
  </tr>
  </table>
 </form>
 </td> </tr> </table> </center>
 <script type="text/javascript">
  document.getElementById('captcha').focus()
 </script>
INPUT_MYTEXT;
  echo $form;
  return;
 }
  
 if ( strpos($page, '<meta http-equiv') ) {
  // Follow the Meta redirect
  $google_meta_regex = '/\<meta http-equiv.+?refresh.+?(http:\/\/[^\'^\"^\>]+?)('){0,1}(\"){0,1}\>/i';
  preg_match($google_meta_regex,$page,$m);
  $curl_url = $m[1];
  $curl_url = str_replace('&amp;', '&', $curl_url);
  $headers[] = "Cookie: X=abc; GoogleAccountsLocale_session=en; TZ=-330";
  $headers[] = "Content-Type: application/x-www-form-urlencoded";
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_URL, $curl_url);
  curl_setopt($ch, CURLOPT_POST, 0);
         $page = curl_exec($ch);
 }
 curl_close($ch);
 $succeeded = stripos($page, "Congratulations!");
 if ($succeeded) {
  @ unlink($cookiefile);
  $info = <<<INPUT_MYTEXT
   <center> <table>
   <tr>
    <td>Username:</td>
    <td><input type='text' id='username' name='username' value='$username@gmail.com' onClick="javascript:x = document.getElementById('username');x.focus();x.select();"></td>
   </tr>
   <tr>
    <td>Password:</td>
    <td><input type='text' id='password' name='password' value='$password' onClick="javascript:x = document.getElementById('password');x.focus();x.select();"></td>
   </tr>
   <tr>
    <td>Name:</td>
    <td><input type='text' id='name' name='name' value='$firstname $lastname' onClick="javascript:x = document.getElementById('password');x.focus();x.select();"></td>
   </tr>
   <tr>
    <td align="center" colspan="2"><font color="#00CC00"><b>????&nbsp; GMail SUCCESS &nbsp;????</b></font></td>
   </tr>
   <tr> <td align="center" colspan="2">&nbsp;</td> </tr>
   <tr> <td align="center" colspan="2">&nbsp;</td> </tr>
   </table>
   
   </center>
INPUT_MYTEXT;
  echo $info;
  //$sqlquery  = "INSERT IGNORE INTO emails (email,email_password,email_name) VALUES ('$username@gmail.com', '$password', '$firstname $lastname')";
  //mysql_query($sqlquery);
  
  // Write Signup data to existing file; on error use new filename
  $write_str = "$username@gmail.com,$password,$firstName $lastName\n";
  $fh = false;
  @ $fh = fopen($write_to_file, 'a');
  if (!$fh) {
   $write_to_file = 'new-gmails_' . rand(1000,100000) . '.txt';
   $fh = fopen($write_to_file, 'a');
  }
  fwrite($fh, $write_str);
  fclose($fh);
  print "</br>Written Login Data to $write_to_file</br></br>\n";
  
 }
 else {
  print '</br></br><font color="#FF0000"><b>Signup process FAILED</b></font>';
  print $page;
  return;
 }
}

$ch = curl_init();
$cookiefile = $tmpdir_abs . '_cookie.txt';
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$url = 'http://mail.google.com/mail/signup';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 0);
$page = curl_exec($ch);
// Get the Last effective Url to set Referer in subsequent Curl operations
$ref = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
// Generates random user profile for email signup
$gProfile = new profile();
$gProfile->__construct();
$firstname = $gProfile->getName("f");
$lastname = $gProfile->getName("l");
$username = $gProfile->getUsername();
$password = $gProfile->getPassword();
$alt_email = $gProfile->getAlternateEmail();
$parameters = parse_gmail_fields($page, $username, $password, $firstname, $lastname, $alt_email);
$formLocation = array_pop($parameters);
$captchatoken = array_pop($parameters);
$captcha_tmpfile = save_captcha($ch, $captchatoken, $tmpdir, $tmpdir_abs);
curl_close($ch);
  // Display CAPTCHA to solve
  $currentUrl = $PHP_SELF;
  $hidden = '';
  foreach($parameters as $param){
 $hidden .= "<input type='hidden' name='params[]' value='$param'>\n"; 
  }
  $form = <<<INPUT_MYTEXT
 <center> <table> <tr> <td>
 <form method='post' action='$currentUrl'>
  $hidden
  <input type='hidden' name='ref' value='$ref'>
  <input type='hidden' name='firstname' value='$firstname'>
  <input type='hidden' name='lastname' value='$lastname'> 
  <input type='hidden' name='username' value='$username'> 
  <input type='hidden' name='password' value='$password'> 
  <input type='hidden' name='alt_email' value='$alt_email'> 
  <input type='hidden' name='formlocation' value='$formLocation'> 
  <input type='hidden' name='captcha_tmpfile' value='$tmpdir_abs$captcha_tmpfile'> 
  <table>
  <tr>
   <td>Username:</td>
   <td><b>$username</b>@gmail.com</td>
  </tr>
  <tr>
   <td>Password:</td>
   <td><b>$password</b></td>
  </tr>
  <tr>
   <td>Name:</td>
   <td><b>$firstname $lastname</b></td>
  </tr>
  <tr>
   <td>&nbsp;</td>
   <td><img src="$tmpdir$captcha_tmpfile"></td>
  </tr>
  <tr>
   <td>Captcha:</td>
   <td><input type="text" name="captcha" id="captcha"></td>
  </tr>
  <tr>
   <td align="center" colspan="2"><input type="submit" name="Create_Account" value="Create Account"></td>
  </tr>
  </table>
 </form>
 </td> </tr> </table> </center>
 <script type="text/javascript">
  document.getElementById('captcha').focus()
 </script>
INPUT_MYTEXT;
echo $form;

//  ###  End Main Routine  ###

function parse_gmail_fields($page, $username, $password, $firstname, $lastname, $alt_email)
{
  // removes new lines, and multiple spaces to for proper Regex matching
  $page = clean_whitespace($page);
  preg_match("/<form id=\"createaccount\" name=\"createaccount\" action='(.+?)'/", $page, $m);
  $formLocation = urlencode($m[1]);
  preg_match("/<input type=\"hidden\" name=\"type\" id=\"type\" value=\"(.+?)\"/", $page, $m);
  $parameters[] = "type=" . $m[1];
  $parameters[] = "loc=US";
  preg_match("/<input type=\"hidden\" name=\"dsh\" id=\"dsh\" value=\"(.+?)\"/", $page, $m);
  $parameters[] = "dsh=" . $m[1];
  $parameters[] = "ktl=";
  $parameters[] = "ktf=";
  $parameters[] = "FirstName=" . $firstname;
  $parameters[] = "LastName=" . $lastname;
  $parameters[] = "UsernameSelector=header";
  $parameters[] = "Email=" . $username;
  preg_match("/<input type=\"hidden\" id='edk' name='edk' value='(.+?)'/", $page, $m);
  $parameters[] = "edk=" . $m[1];
  $parameters[] = "Passwd=" . $password;
  $parameters[] = "PasswdAgain=" . $password;
  $parameters[] = "rmShown=1";
  $parameters[] = "nshk=1";
  $parameters[] = "selection=" . urlencode("What was your first teacher's name");
  $parameters[] = "ownquestion=";
  $parameters[] = "IdentityAnswer=" . $firstname;
  $parameters[] = "SecondaryEmail=" . urlencode($alt_email);
  $parameters[] = "loc=US";
  // get CAPTCHA token
  preg_match("/<input type=\"hidden\" name=\"newaccounttoken\" id=\"newaccounttoken\" value=\"(.+?)\"/", $page, $m);
  $captchatoken = $m[1];
  $parameters[] = "newaccounttoken=" . urlencode($captchatoken);
  // get CAPTCHA url
  preg_match("/<input type=\"hidden\" name=\"newaccounturl\" id=\"newaccounturl\" value=\"(.+?)\"/", $page, $m);
  $parameters[] = "newaccounturl=" . urlencode($m[1]);
  // get Audio CAPTCHA token
  preg_match("/<input type=\"hidden\" name=\"newaccounttoken_audio\" id=\"newaccounttoken_audio\" value=\"(.+?)\"/", $page, $m);
  $parameters[] = "newaccounttoken_audio=" . urlencode($m[1]);
  // get Audio CAPTCHA url
  preg_match("/<input type=\"hidden\" name=\"newaccounturl_audio\" id=\"newaccounturl_audio\" value=\"(.+?)\"/", $page, $m);
  $parameters[] = "newaccounturl_audio=" . urlencode($m[1]);
  $parameters[] = "newaccountcaptcha=";
  $parameters[] = "program_policy_url=http%3A%2F%2Fmail.google.com%2Fmail%2Fhelp%2Fprogram_policies.html";
  $parameters[] = "privacy_policy_url=http%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fprivacy.html";
  $parameters[] = "requested_tos_location=US";
  $parameters[] = "requested_tos_language=en";
  preg_match('/<input type=\"hidden\" id=\'served_tos_location\' name=\'served_tos_location\' value=\'(.+?)\'/', $page, $m);
  $parameters[] = "served_tos_location=" . $m[1];
  $parameters[] = "served_tos_language=en";
  $parameters[] = "submitbutton=" . urlencode('I accept. Create my account.');
  $parameters[] = $captchatoken;
  $parameters[] = $formLocation;
  return $parameters;
}

function save_captcha($ch, $captchatoken, $tmpdir, $tmpdir_abs)
{
  // Save Captcha image
  $url = "https://www.google.com/accounts/Capt...=$captchatoken";
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, 0);
  $page = curl_exec($ch);
  $captcha_tmpfile = 'captcha-' . rand(1000,10000) . '.jpg';
  $fp = fopen($tmpdir_abs . $captcha_tmpfile,'w');
  fwrite($fp, $page);
  fclose($fp);
  
  return $captcha_tmpfile;
}

?>
mailsignup-functions.php - supporting file
Code:
<?php
/*
## Title:  Random Stirng Function V01.00.00
## Author(s): Jack Ketch
##
##  Return a random stirng of lower case characters.
## Parameter(s):
##   $min, $max - minimum/maximum length of string
##   $useNumbers - sets the use of numbers (TRUE or FALSE, default = FALSE)
##   $useUpper - sets the use of upper case characters (TRUE or FALSE, default = FALSE)
##
##
## Modified: Anand (netmktg)
## Last Update: Oct-12-2008
##
*/
// If PHP doesnt have stripos function
if(!function_exists('stripos'))
{
   function stripos($haystack,$needle,$offset = 0)
   {
     return(strpos(strtolower($haystack),strtolower($needle),$offset));
   }
}
function randomString($min, $max, $useNumbers = FALSE, $useUpper = FALSE)
{
 $charSet = "abcdefghijklmnopqrstuvwxyz";
 if ($useNumbers) { $charSet .= "0123456789"; }
 if ($useUpper) { $charSet .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
 
 ## checks if the min and max are reversed. ##
 if ($min > $max) { $length = mt_rand($max, $min); }
 else { $length = mt_rand($min, $max); }
 $randStr = '';
 $setLength = strlen($charSet) - 1;
 for ($i = 0; $i < $length; $i++) { $randStr .= $charSet[mt_rand(0, $setLength)]; }
 return $randStr;
}

function clean_whitespace($input_str, $repl_arr = array(" ", "\n", "\r", "\t"))
{
 $input_str = str_replace($repl_arr, ' ', $input_str);
 $input_str = preg_replace('/ +/', ' ', $input_str);
 return $input_str;
}

/*
##
## Title: Profile Class V01.00.00
## Author: Jack Ketch
##
## Generate random data to be use for automatic registrations of websites.
##
##
## Modified: Anand (netmktg)
## Last Update: Oct-12-2008
##
*/
class profile {
 var $_gender;
 var $_firstName;
 var $_lastName;
 var $_username;
 var $_password;
 var $_alternateEmail;
 var $_securityQuestion = "Where did you meet your spouse";
 var $_answer = "College";
 
 var $_usernameMinLength = 5;
 var $_usernameMaxLength = 14;
 var $_randomStringLength = 4;
 // separates the name from the random characters
 var $_separator = '';
 
 function __construct() {
  $gender = mt_rand(0, 1);
  $surnames = explode("\n", file_get_contents("names_last.txt"));
  if ($gender == 0) {
   $this->_gender = "m";
   $names = explode("\n", file_get_contents("names_male.txt"));
  }
  else {
   $this->_gender = "f";
   $names = explode("\n", file_get_contents("names_female.txt"));
  }
  $this->_lastName = trim(ucfirst($surnames[array_rand($surnames)]));
  
  $minNameLength = $this->_usernameMinLength - $this->_randomStringLength - strlen($this->_separator);
  $maxNameLength = $this->_usernameMaxLength - $this->_randomStringLength - strlen($this->_separator);  
  do {
   $this->_firstName = trim(ucfirst($names[array_rand($names)]));
  } while ( (strlen($this->_firstName) <= $minNameLength) || (strlen($this->_firstName) >= $maxNameLength) );
  
  $this->_username = strtolower($this->_firstName) . $this->_separator . randomString($this->_randomStringLength, $this->_randomStringLength, TRUE);
  $this->_password = randomString(8, 10);
  
  $this->_alternateEmail = randomString(6,8) . "@" . randomString(6,9) . ".com";
 }
 
 function getGender() {
  return $this->_gender;
 }
 
 function getName($type) {
  if ($type == "f") {
   return $this->_firstName;
  }
  else if ($type == "l") {
   return $this->_lastName;
  }
 }
 
 function getUsername() {
  return $this->_username;
 }
 function getPassword() {
  return $this->_password;
 }
 
 function getAlternateEmail() {
  return $this->_alternateEmail;
 }
 
 function getSecurityQuestion($type = "q") {
  if ($type == "q") {
   return $this->_securityQuestion;
  }
  else if ($type == "a") {
   return $this->_answer;
  }
 }
}
?>
azlanhussain is offline   Reply With Quote
luke Male
KittyLover
Administrator
 
luke's Avatar
 
Join Date: Nov 2003
Posts: 1,878
  #2 Old 21-11-2008 Default Re: Auto Gmail Signup Script

Err .. is this legit? I can't think of any need to create GMail accounts through a script other than to create multiple accounts for the purpose of spamming.

There are tons of other ideas on ethical programs/scripts to develop.
__________________
luke is offline   Reply With Quote
azlanhussain Male
Super Junior Member
 
azlanhussain's Avatar
 
Join Date: Nov 2008
Posts: 44
  #3 Old 21-11-2008 Default Re: Auto Gmail Signup Script

well it's all depends on individual perception..
azlanhussain is offline   Reply With Quote
youngyew Male
ReCom Addict
Administrator
 
youngyew's Avatar
 
Join Date: May 2004
Posts: 5,738
  #4 Old 21-11-2008 Default Re: Auto Gmail Signup Script

Regardless of what its intended use is, Gmail policy clearly states that automated registration is not allowed, so using this script to register email accounts is illegal.
__________________
[][][][flickr]

Check out our ReCom wiki!
Do contribute by writing or editing the existing articles so that everyone now and in the future can benefit from it!
youngyew is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
1GB Gmail account to be given away kelvinlym Social and Entertainment Corner 161 31-12-2006 10:23 PM
2005 Auto Tax Policy chenchow Malaysia Today 5 25-12-2004 02:26 AM
3x 1 GB Gmail account to be given away kelvinlym Alles Deutschland 0 13-06-2004 12:44 AM
hIRC Script da-hype Programming and Web Development 0 07-01-2004 12:20 PM


All times are GMT +8. The time now is 05:40 AM.


Powered by vBulletin® Version 3.7.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

ReCom stands for Reborn Community. It has no affiliation with other organizations that may share the same name. The views expressed in this website solely represent the authors point of view and do not necessarily reflect the views of ReCom Anchors and other ReCom users.


 

Page generated in 0.08953 seconds with 14 queries