Code:
<?php set_time_limit(0);
// Determin if the script was called from command line or web browser
$terminal = false;
if (php_sapi_name() == "cli") {
$terminal = true;
}
//Set this to false if you dont want it to generate a randon name for the mule
$set_name = true;
// Set this to false if you dont want it to set the mules security ansers
$set_security_answers = true;
// Set this to false if you dont want the script to try and check your email for you
$check_email = true;
// Set these variables to be used in the script
$base_email = "YOUR_GMAIL";
$gmail_pass = "GMAIL_PASSWORD"; // dont need this unless you have $check_email set as true
$start_num = 1;
$total = 10;
// API Base URL
$base_url = "http://realmofthemadgod.appspo*****m/";
// Location of accounts.js file
$accountsjs = "PATH/TO/accounts.js";
// Security Answers that will get set if $set_security_answers is true
$security_answers = array(
base64_encode("security answer 1"),
base64_encode("security answer 2"),
base64_encode("security answer 3")
);
/* Uncomment this block if you want the script to take arguments when it runs instead of having the values hardcoded above this
// Check if this script was called with arguments
if (isset($argv) && is_array($argv)) {
// Make sure there are 3 arguments after the script name
if (count($argv) < 4) {
echo "This script takes 3 arguments. The email without the domain, the starting number, and the total number of accounts to create.\n";
exit();
} else {
$base_email = $argv[1];
$start_num = $argv[2];
$total = $argv[3];
}
} else {
// Make sure the email is set
if (empty( $_REQUEST['e'])) {
die( 'No email provided.' );
} else {
$base_email = urldecode($_REQUEST['e']);
}
// Make sure the starting number is set
if (empty($_REQUEST['s'])) {
die( 'Missing starting number.' );
} else {
$start_num = $_REQUEST['s'];
}
// Make sure the number of accounts is set
if (empty($_REQUEST['q'])) {
die( 'Missing number of accounts to create.' );
} else {
$total = $_REQUEST['q'];
}
}
*/
// Make sure the email doesnt have the domain attached
if (stripos($base_email, '@') !== FALSE) {
list($base_email, $domain) = explode('@', $base_email);
}
// Create cURL handle
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Array to hold new accounts
$new_accounts = array();
for ($i = 0; $i < $total; $i++) {
// Create the email
$email = $base_email . '+' . str_pad($i + $start_num, 4, '0', STR_PAD_LEFT) . '@gmail.com';
// Generate a random password 11 characters long
$pass = randomValue(11, array('lower','upper','number','symbol'));
// Account info
$info = array(
'guid' => randomValue(26, array('upper','number')), // This is just a random (and useless?) value
'newGUID' => $email,
'ignore' => randomValue(4, array('number')),
'newPassword' => $pass,
'isAgeVerified' => 1
);
// Create full url
$acc_url = $base_url . 'account/register?' . http_build_query($info);
echo "Creating \"$email:$pass\"....";
curl_setopt($ch, CURLOPT_URL, $acc_url);
$data = curl_exec($ch);
if (stripos($data, 'Success') !== FALSE) {
echo "Success! ";
$new_accounts[] = array($email, $pass);
if ($set_name) {
// Create a random name for the account
$name = randomValue(10, array('lower'));
$info = array(
'guid' => $email,
'password' => $pass,
'ignore' => randomValue(4, array('number')),
'name' => $name
);
$name_url = $base_url . 'account/setName?' . http_build_query($info);
curl_setopt($ch, CURLOPT_URL, $name_url);
$data = curl_exec($ch);
if (stripos($data, 'Success')) {
echo "New name set as \"$name\"!\n";
} else {
echo "Failed to set new name: $data\n";
}
}
if ($set_security_answers) {
// Set the security answers for the mule to the answers defined at the top
$info = array(
'guid' => $email,
'password' => $pass,
'signedRequest' => '',
'answers' => implode("|", $security_answers)
);
$security_url = $base_url . 'account/saveSecurityQuestions?' . http_build_query($info);
curl_setopt($ch, CURLOPT_URL, $security_url);
$data = curl_exec($ch);
if( stripos($data, 'Success')) {
echo "Security answers saved!\n";
} else {
echo "Failed to save security answers: $data\n";
}
}
} else {
echo "Failed: $data\n";
}
}
curl_close($ch);
// Make sure the accounts.js file exists, that we can read it and write to it
if (file_exists($accountsjs) && is_readable($accountsjs) && is_writable($accountsjs)) {
// Create new accounts.js
$old = file_get_contents($accountsjs);
// Locate the end of the accounts variable
$pos = 0;
$lines = explode( "\n", $old );
foreach( $lines as $key => $line ) {
if( stripos($line, "}// don't delete this line!") !== FALSE ) {
$pos = $key;
break;
}
}
// Find the very last email:password line in the accounts variable
while( empty( trim( $lines[ $pos-1 ] ))) $pos--;
$new = array();
for($i = 0; $i < $pos; $i++ ) {
$new[] = $lines[$i];
}
foreach( $new_accounts as $acc ) {
$new[] = "'{$acc[0]}':'{$acc[1]}',";
}
for($i = $pos; $i < count($lines); $i++ ) {
$new[] = $lines[$i];
}
$new_accountsjs = implode("\n", $new);
file_put_contents( $accountsjs, $new_accountsjs );
}
// Check the email to get all the new "verify your email" messages
if ($check_email) {
// Make sure the IMP extension is loaded
if (extension_loaded('imap')) {
echo PHP_EOL . "Checking GMail. This may take awhile." . PHP_EOL;
if(!$terminal) {
// This isnt from a terminal so lets try to flush all the output above
ob_flush();
flush();
}
// Sleep for a few seconds so we dont check the mailbox before any emails have arrived
sleep(5);
$inbox = imap_open('{imap.gmail.com:993/imap/ssl}INBOX', $base_email, $gmail_pass) or die('Cannot connect to Gmail: ' . imap_last_error());
$emails = imap_search($inbox, 'FROM "noreply@wildshadow.com"'); // Only find emails we need
if ($emails) {
foreach ($emails as $id) {
// Get the email overview before we get the entire message
$overview = imap_fetch_overview($inbox, $id);
// Check if it is a new "Verify Email" message
if (stripos($overview[0]->subject, "Verify email") !== false && !$overview[0]->seen) {
$message = imap_fetchbody($inbox, $id, 1);
// Break the message body into lines so we can find the link
$lines = explode("\n", $message);
foreach ($lines as $line) {
if (stripos($line, "realmofthemadgod.appspo*****m") !== false) {
if ($terminal) {
// Open web browser to the verify link
shell_exec( "start chrome \"$line\"");
} else {
// Output a link to click since we cant use shell_exec from the browser
echo "<a href=\"$line\" target=\"_blank\">$line</a> |";
}
break;
}
}
}
}
} else {
echo "Didnt find any emails.";
}
} else {
echo "You are missing the IMAP extension.";
}
}
// Function to generate a random value
function randomValue( $length, $base = array( 'lower' )) {
$char_array = array();
foreach( $base as $val ) {
if( $val == 'lower' ) {
$char_array[] = 'abcdefghijklmnopqrstuvwxyz';
} elseif( $val == 'upper' ) {
$char_array[] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
} elseif( $val == 'number' ) {
$char_array[] = '0123456789';
} elseif( $val == 'symbol' ) {
$char_array[] = '_-!#$@';
}
}
$chars = implode($char_array);
$charLength = strlen($chars) - 1;
$return = array();
$good = false;
while( !$good ) {
$return = array();
for ($i = 0; $i < $length; $i++) {
$n = rand(0, $charLength);
$return[] = $chars[$n];
}
// If number was specified, then make sure the return value has atleast 1 number in it
if( in_array('number', $base)) {
for($i = 0; $i < count( $return ); $i++ ) {
if( is_numeric( $return[$i] )) {
$good = true;
break;
}
}
} else {
$good = true;
}
}
return implode( $return );
}
?>