Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
freenom_renewer
<?php
$username = '';//email
$password = '';//password
$months = '1';//months (1-12)
if(!$username || !$password){
die("freenom_renewer: no username or password...\n");
}
if($months <1){
$months = 1;
}elseif($months >12){
$months = 12;
}
function scurl(string $url = "localhost", string $type = "get", array $header = [], array $data = [], bool $return_header = false, bool $nobody = false, bool $follow_location = true): string {
$ch = curl_init();
$options = [
CURLOPT_URL => $url,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => $follow_location,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => $header,
CURLOPT_HEADER => $return_header,
CURLOPT_NOBODY => $nobody
];
if(strtolower($type) == "post"){
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = http_build_query($data);
}
curl_setopt_array($ch, $options);
return curl_exec($ch);
}
//first request
preg_match_all('/Set-Cookie: ([^;]+);/',scurl('https://my.freenom.com/clientarea.php', "get", [], [], true, true, false), $getCookie);
$Cookies = '';
foreach ($getCookie[1] as $key) {
$Cookies .= $key.';';
}
//get token
preg_match('/name="token" value="([^"]+)"/', scurl('https://my.freenom.com/clientarea.php', "get", ["Cookie: {$Cookies}"]), $b);
$token = $b[1];
echo "freenom_renewer: logining...\n";
preg_match_all('/Set-Cookie: (.+);/U',scurl('https://my.freenom.com/dologin.php', "post", ["Cookie: {$Cookies}", "Referer: https://my.freenom.com/clientarea.php"], ["token" => $token , "username" => $username , "password" => $password , "rememberme" => true], true, true, false), $getCookie);
foreach ($getCookie[1] as $key) {
$Cookies .= $key.';';
}
$a = scurl('https://my.freenom.com/domains.php?a=renewals', "get", ["Cookie: {$Cookies}"]);
preg_match_all('/<tr><td>(.*)<\/td><td>Active<\/td><td>/iU',$a,$b);
preg_match_all('/>([0-9]+) Days<\/span>/iU',$a,$e);
preg_match_all('/href="domains.php\?a=renewdomain&domain=([0-9]+)"/iU',$a,$d);
$x = 0;
$bd = [];
foreach ($e[1] as $day) {
if ($day <= 14) {
$bd[] = [$b[1][$x],$d[1][$x]];
}
$x++;
}
if (count($bd) == 1) {
echo "freenom_renewer: 1 domain is renewable...\n";
} elseif(count($bd) > 1) {
echo "freenom_renewer: " . count($bd) . " domains are renewable...\n";
} else{
echo "freenom_renewer: no renewable domain...\n";
}
foreach ($bd as $key) {
preg_match('/name="token" value="([^"]+)"/', scurl('https://my.freenom.com/domains.php?a=renewdomain&domain=' . $key[1], "get", ["Cookie: {$Cookies}"]),$b);
$token = $b[1];
if (preg_match('/Location: cart.php\?a=complete/', scurl('https://my.freenom.com/domains.php?submitrenewals=true', "post", ["Cookie: {$Cookies}"], ["token" => $token , "renewalid" => $key[1],"renewalperiod[" . $key[1] . "]" => $months . 'M', "paymentmethod" => "credit"], true, true))) {
echo $key[0].": success\n";
} else {
echo $key[0].": false\n";
}
}
@BANKA2017

This comment has been minimized.

Copy link
Owner Author

BANKA2017 commented Feb 16, 2019

设置 $username $password $months 后运行即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.