Advertisement
Guest User

HostkeyBootVps

a guest
Jul 27th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?php
  2. /*  php script
  3. *   first I login to my account to get the cookie
  4. *   next I open link (together with login cookie) with command to boot vps and return the response code in json
  5. *   fill out UsernameHere , PasswordHere and IdOfServiceHere
  6. */
  7. function getCookie($url){
  8.         $ch = curl_init($url);
  9.         curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'); // spoof
  10.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11.         //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  12.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  13.         curl_setopt($ch, CURLOPT_HEADER, true);
  14.         $output = curl_exec($ch);  
  15.         curl_close($ch);
  16.        
  17.         $regex = '/Set-Cookie: (.+?); path=\/; HttpOnly/';
  18.         preg_match($regex,$output,$match);
  19.         if(count($match) == 0){    
  20.             return "";
  21.         }
  22.         else{
  23.             return 'Cookie: '.$match[1];
  24.         }
  25.     }
  26.    
  27.     function curlWithCookie($url,$cookie){ 
  28.         $ch = curl_init($url);
  29.         curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'); // spoof
  30.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  31.         //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  32.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  33.         $headers = array();
  34.         $headers[] = $cookie;
  35.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  36.         $output = curl_exec($ch);
  37.         curl_close($ch);
  38.         return $output;
  39.     }
  40.    
  41.     function bootVPS(){
  42.         $cookie=getCookie("https://bill.hostkey.com/dologin.php?username=UsernameHere&password=PasswordHere");
  43.         if($cookie!=""){
  44.             $booting=curlWithCookie('https://bill.hostkey.com/clientarea.php?action=productdetails&id=IdOfServiceHere&json=1&page=home&subaction=startVM',$cookie);
  45.         }else{
  46.             $booting="No cookie found";
  47.         }
  48.         return $booting;
  49.     }
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement