Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Created June 15, 2021 12:33
Show Gist options
  • Save woodwardtw/0cd2a847f07454831367b1ff6c308a3c to your computer and use it in GitHub Desktop.
Save woodwardtw/0cd2a847f07454831367b1ff6c308a3c to your computer and use it in GitHub Desktop.
<?php
$user = "root";
$token = "YOURTOKENHERE";
$query = "https://YOURIP:YOURPORT/json-api/listaccts?api.version=1";
//json-api/listaccts -- generic info, disk usage, start date, domain,
//get_disk_usage -- disk usage obviously
//showbw -- bandwidth
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$header[0] = "Authorization: whm $user:$token";
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($http_status != 200) {
echo "[!] Error: " . $http_status . " returned\n";
} else {
$json = json_decode($result);
echo $result;
// echo "[+] Current cPanel users on the system:\n";
// foreach ($json->{'data'}->{'acct'} as $userdetails) {
// echo "\t" . $userdetails->{'user'} . "</br>";
// }
}
curl_close($curl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment