Unstoppable Domains

Automated WHM account creation

Spaceship Spaceship
Watch

DeViAnThans3

Spamzor.com <img src="images/smilies/sleep.gif" boEstablished Member
Impact
17
A few days ago, when I got bored, I wrote this small bunch of code for automated WHM account creation.

It does works, but note that this is just a rough bunch of code; you'll have to change a lot of settings in order to get the script suit your needs.
There is also no checkup written into it to check if the account really is created

**NOTE 1: PHP Safe Mode must be turned off, in order to get this script working, else a few cURL options will issue an error.
**NOTE 2:cURL must be installed at your PHP server.
**NOTE 3:Create an empty cookie.txt file, upload it to your server, and make sure it is 777-CHMOD'ed

If you like the script, rep is appreciated :hehe:

whm-create.php
PHP:
<?php
/* HOW TO INSTALL
1 - Save this code as a PHP file (or any file, as long as the server recognizes it as PHP)
2 - Change the configuration part in this file, save it, and upload to your server
3 - Create an empty .txt file in notepad, call it cookie.txt, upload it to your server.
4 - Is your server a unix-like server? CHMOD that file to 777.
	This is not need for windows servers.
*/

// Configure
define("WHM_USER", "your-username"); // WHM username
define("WHM_PASS", "your-password"); // WHM password
define("WHM_DOMAIN", "127.0.0.1");   // IP or hostname could be enterred here

// The new account settings!
// Go to line 75 in this file, and change everything to suit your needs.


// cURL class: Thanks to Sean Huber
class CURL {
   var $callback = false;

function setCallback($func_name) {
   $this->callback = $func_name;
}

function doRequest($method, $url, $vars) {
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_HEADER, 1);
   curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
   curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
   if ($method == 'POST') {
       curl_setopt($ch, CURLOPT_POST, 1);
       curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
   }
   $data = curl_exec($ch);
   curl_close($ch);
   if ($data) {
       if ($this->callback)
       {
           $callback = $this->callback;
           $this->callback = false;
           return call_user_func($callback, $data);
       } else {
           return $data;
       }
   } else {
       return curl_error($ch);
   }
}

function get($url) {
   return $this->doRequest('GET', $url, 'NULL');
}

function post($url, $vars) {
   return $this->doRequest('POST', $url, $vars);
}
}

// Initialize cURL library
$curl = new CURL;

$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/");

// Create account now
// First going to this form; required, else wont work
$text = $curl->get("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/scripts2/wwwacctform");

// Fine! Set the options now.
$options = "sign=&plan=hansvdp_tp&domain=tgz33.com&username=tg33&password=test&quota=6&ip=0&cgi=1&frontpage=1&maxftp=unlimited&maxpop=unlimited&maxlst=unlimited&maxsql=unlimited&maxsub=unlimited&maxpark=5&maxaddon=3&bwlimit=50&cpmod=x&msel=n,y,unlimited,y,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,unlimited,y,0,0&[email protected]";

// And post it!
$text = $curl->post("http://" . WHM_USER . ":" . WHM_PASS . "@" . WHM_DOMAIN .":2086/scripts/wwwacct", $options);

// Eventually you can output the text here
echo $text;
?>

If you need any support with it, just reply to this topic, i'm watching it ;)

Cheers,
 
Last edited:
5
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Great Script And Very Useful ;) I'll test it out when i get a chance :yell:
 
0
•••
Yes very nice script, i will try too
 
0
•••
Okay, have fun with it :)
And if you have any problems with it, I'm here to help you lol ;)
 
0
•••
Nice little script, i have never used much of curl as i have never had a use for it but my upcoming project will so i will be sure to check it out :) Sounds like a powerful little package from what i hear.

+Rep added, i will try it when i get back onto WHM/Reseller.
 
0
•••
0
•••
0
•••
I could easily write with that code too, but I don't think it is necessary at this moment :)
The script works, and that's most important to me ;)
 
0
•••
Very nice Hans, this will come in handy :)

Bedankt!
 
0
•••
Geen probleem ;) (No problem)

Have fun with it!
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back