-
-
Save likecyber/a55e1ac8e6b8ca32f93b88e55b0bf835 to your computer and use it in GitHub Desktop.
| <?php | |
| /* | |
| Make sure to enter $anticaptcha_key before upload to server. | |
| Upload "auto_plesk_trial.php" file to "/home/centos/auto_plesk_trial.php" | |
| Then create Schedule Task in Root account of Plesk. | |
| Task Type: Run a PHP script | |
| Script path: /home/centos/auto_plesk_trial.php | |
| Use PHP version: 7.x.x / 8.x.x | |
| Run: Cron style * * * * * | |
| Notify: Errors only | |
| */ | |
| $update_frequency = 60 * 60 * 24 * 14; // Update Every 14 Days | |
| $anticaptcha_key = ""; // Anti-Recaptcha Key | |
| set_time_limit(600); | |
| $filename = dirname($_SERVER["PHP_SELF"])."/".pathinfo($_SERVER["PHP_SELF"], PATHINFO_FILENAME).".json"; | |
| function update_log ($text) { | |
| $fh = fopen(dirname($_SERVER["PHP_SELF"])."/".pathinfo($_SERVER["PHP_SELF"], PATHINFO_FILENAME).".log", "a"); | |
| fwrite($fh, date("[Y-m-d H:i:s] ").$text."\n"); | |
| fclose($fh); | |
| echo date("[Y-m-d H:i:s] ").$text."\n"; | |
| } | |
| $info = json_decode(@file_get_contents($filename), true); | |
| if (!is_array($info)) $info = array(); | |
| if (!isset($info["last_updated"])) $info["last_updated"] = 0; | |
| if ($info["last_updated"] + $update_frequency > time()) { | |
| exit(); | |
| } | |
| $curl_options = array( | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_USERAGENT => "AutoPleskTrial/2.0", | |
| CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
| CURLOPT_SSLVERSION => defined("CURL_SSLVERSION_TLSv1_3") ? CURL_SSLVERSION_TLSv1_3 : CURL_SSLVERSION_TLSv1_2 | |
| ); | |
| $ch = curl_init(); | |
| if (!isset($info["email_address"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "POST", | |
| CURLOPT_URL => "https://web2.temp-mail.org/mailbox" | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200) { | |
| $data = json_decode($response, true); | |
| if (isset($data["mailbox"]) && isset($data["token"])) { | |
| $info["email_address"] = $data["mailbox"]; | |
| $info["email_token"] = $data["token"]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: email_address = ".$info["email_address"]); | |
| } else { | |
| update_log("Error: email_address = null"); | |
| exit(); | |
| } | |
| } else { | |
| update_log("Error: email_address = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["task_id"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "POST", | |
| CURLOPT_URL => "https://api.anti-captcha.com/createTask", | |
| CURLOPT_HTTPHEADER => array( | |
| "Content-Type: application/json" | |
| ), | |
| CURLOPT_POSTFIELDS => json_encode(array( | |
| "clientKey" => $anticaptcha_key, | |
| "task" => array( | |
| "type" => "RecaptchaV2TaskProxyless", | |
| "websiteURL" => "https://www.plesk.com/plesk-free-download/", | |
| "websiteKey" => "6LfC_lQaAAAAAES5qQ5CZbVfE1_RoA_azMlBZQkN" | |
| ) | |
| )) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 200 && $result = json_decode($response, true)) { | |
| if (isset($result["errorId"]) && $result["errorId"] == 0 && isset($result["taskId"])) { | |
| $info["task_id"] = $result["taskId"]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: task_id = ".$info["task_id"]); | |
| exit(); | |
| } else { | |
| update_log("Error: task_id = null"); | |
| exit(); | |
| } | |
| } else { | |
| update_log("Error: task_id = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["g_recaptcha_response"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "POST", | |
| CURLOPT_URL => "https://api.anti-captcha.com/getTaskResult", | |
| CURLOPT_HTTPHEADER => array( | |
| "Content-Type: application/json" | |
| ), | |
| CURLOPT_POSTFIELDS => json_encode(array( | |
| "clientKey" => $anticaptcha_key, | |
| "taskId" => $info["task_id"] | |
| )) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 200 && $result = json_decode($response, true)) { | |
| if (isset($result["errorId"]) && $result["errorId"] == 0 && isset($result["status"])) { | |
| if ($result["status"] == "ready" && isset($result["solution"]["gRecaptchaResponse"])) { | |
| $info["g_recaptcha_response"] = $result["solution"]["gRecaptchaResponse"]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: g_recaptcha_response = ".$info["g_recaptcha_response"]); | |
| } elseif ($result["status"] !== "processing") { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: g_recaptcha_response = null"); | |
| exit(); | |
| } else { | |
| exit(); | |
| } | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: g_recaptcha_response = null"); | |
| exit(); | |
| } | |
| } else { | |
| update_log("Error: task_id = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["confirm_requested"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "POST", | |
| CURLOPT_URL => "https://www.plesk.com/plesk-free-download/", | |
| CURLOPT_POSTFIELDS => http_build_query(array( | |
| "input_1.3" => "John", | |
| "input_1.6" => "Scott", | |
| "input_2" => $info["email_address"], | |
| "input_15" => "Developer", | |
| "input_16" => "Junior", | |
| "input_17" => "Canada", | |
| "input_21.1" => "true", | |
| "g-recaptcha-response" => $info["g_recaptcha_response"], | |
| "is_submit_55" => "1", | |
| "gform_submit" => "55", | |
| "gf_zero_spam_key" => "eN4*@MnEel3KQ!o!zyCZK5j*Om\$wQ82kI10BI$*AW7\$IKutxZerPTGUoGTRKxor@" | |
| )), | |
| CURLOPT_HEADER => true | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 302 && preg_match("/[Ll]ocation: https:\/\/www\.plesk\.com\/free-trial-for-web-professionals-thank-you-page\//", $response)) { | |
| $info["confirm_requested"] = true; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: confirm_requested = true"); | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: confirm_requested = false"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["trial_requested"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => "https://www.plesk.com/free-trial-for-web-professionals-thank-you-page/", | |
| CURLOPT_HTTPHEADER => array( | |
| "Cookie: Plesk_TrialFormData=".urlencode(base64_encode(json_encode(array( | |
| "name" => "John", | |
| "lastname" => "Scott", | |
| "email" => $info["email_address"] | |
| )))) | |
| ), | |
| CURLOPT_HEADER => true | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 200 && preg_match("/[Ss]et-[Cc]ookie: Plesk_TrialForm_Status=1;/", $response)) { | |
| $info["trial_requested"] = true; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: trial_requested = true"); | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: trial_requested = false"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["email_id"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => "https://web2.temp-mail.org/messages", | |
| CURLOPT_HTTPHEADER => array( | |
| "Authorization: Bearer ".$info["email_token"] | |
| ) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200) { | |
| $data = json_decode($response, true); | |
| if (isset($data["messages"]) && is_array($data["messages"])) { | |
| foreach ($data["messages"] as $mail) { | |
| if ($mail["subject"] === "Please confirm your email address") { | |
| $info["email_id"] = $mail["_id"]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: email_id = ".$info["email_id"]); | |
| break; | |
| } | |
| } | |
| if (!isset($info["email_id"])) { | |
| exit(); | |
| } | |
| } else { | |
| exit(); | |
| } | |
| } else { | |
| update_log("Error: email_id = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["confirm_link"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => "https://web2.temp-mail.org/messages/".$info["email_id"], | |
| CURLOPT_HTTPHEADER => array( | |
| "Authorization: Bearer ".$info["email_token"] | |
| ) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200 && $data = json_decode($response, true)) { | |
| if (isset($data["bodyHtml"]) && preg_match("/please confirm your email address by clicking on the link below:(?:.*?)<a(?:.*?)href=\"(.*?)\"(?:.*?)>(?:.*?)CONFIRM MY EMAIL(?:.*?)<\/a>/s", $data["bodyHtml"], $matches)) { | |
| $info["confirm_link"] = $matches[1]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: confirm_link = ".$info["confirm_link"]); | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: confirm_link = null"); | |
| exit(); | |
| } | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: confirm_link = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["confirm_link2"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => $info["confirm_link"] | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200 && preg_match("/window\.location\.replace\(\"(.*?)\"\);/", $response, $matches)) { | |
| $info["confirm_link2"] = $matches[1]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: confirm_link2 = ".$info["confirm_link2"]); | |
| } else { | |
| update_log("Error: confirm_link2 = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["confirm_link3"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => $info["confirm_link2"], | |
| CURLOPT_HEADER => true | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 307 && preg_match("/[Ll]ocation: (https:\/\/api(.*)\.hubapi\.com\/email\/v1\/optin\/confirm\/doi\?(?:[^\r\n]*))/", $response, $matches)) { | |
| $info["confirm_link3"] = $matches[1]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: confirm_link3 = ".$info["confirm_link3"]); | |
| } else { | |
| update_log("Error: confirm_link3 = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["email_confirmed"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => $info["confirm_link3"], | |
| CURLOPT_HEADER => true | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code == 307 && preg_match("/[Ll]ocation: https:\/\/page\.plesk\.com\/confirmsubscribe/", $response)) { | |
| $info["email_confirmed"] = true; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: email_confirmed = true"); | |
| } else { | |
| update_log("Error: email_confirmed = false"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["email_id2"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => "https://web2.temp-mail.org/messages", | |
| CURLOPT_HTTPHEADER => array( | |
| "Authorization: Bearer ".$info["email_token"] | |
| ) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200) { | |
| $data = json_decode($response, true); | |
| if (isset($data["messages"]) && is_array($data["messages"])) { | |
| foreach ($data["messages"] as $mail) { | |
| if ($mail["subject"] === "Your Plesk Trial Activation Code") { | |
| $info["email_id2"] = $mail["_id"]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: email_id2 = ".$info["email_id2"]); | |
| break; | |
| } | |
| } | |
| if (!isset($info["email_id2"])) { | |
| exit(); | |
| } | |
| } else { | |
| exit(); | |
| } | |
| } else { | |
| update_log("Error: email_id2 = null"); | |
| exit(); | |
| } | |
| } | |
| if (!isset($info["activation_code"])) { | |
| curl_reset($ch); | |
| curl_setopt_array($ch, $curl_options + array( | |
| CURLOPT_CUSTOMREQUEST => "GET", | |
| CURLOPT_URL => "https://web2.temp-mail.org/messages/".$info["email_id2"], | |
| CURLOPT_HTTPHEADER => array( | |
| "Authorization: Bearer ".$info["email_token"] | |
| ) | |
| )); | |
| $response = curl_exec($ch); | |
| $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
| if ($http_code === 200 && $data = json_decode($response, true)) { | |
| if (isset($data["bodyHtml"]) && preg_match("/Now here's your unique activation code:(?:.*?)>([A-Z0-9]{6}-[A-Z0-9]{6}-[A-Z0-9]{6}-[A-Z0-9]{6}-[A-Z0-9]{6})</s", $data["bodyHtml"], $matches)) { | |
| $info["activation_code"] = $matches[1]; | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: activation_code = ".$info["activation_code"]); | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: activation_code = null"); | |
| exit(); | |
| } | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: activation_code = null"); | |
| exit(); | |
| } | |
| } | |
| $status = trim(shell_exec("/usr/sbin/plesk bin license --install ".$info["activation_code"])); | |
| if ($status === "The license key was successfully installed.") { | |
| $info = array( | |
| "last_updated" => time() | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Update: status = ".$status); | |
| update_log("Update: last_updated = ".$info["last_updated"]); | |
| } else { | |
| $info = array( | |
| "last_updated" => $info["last_updated"] | |
| ); | |
| file_put_contents($filename, json_encode($info)); | |
| update_log("Error: status = ".$status); | |
| } | |
| ?> |
The email. I tried and it doesn't work. Is there a way for someone to fix this?
The email. I tried and it doesn't work. Is there a way for someone to fix this?
Fix what?
Works fine for me great work ed96win
Error: email_address = null
Works fine for me great work ed96win
it xml works normally this script auto trial doesn't work
I get this message when I run the file Error: email_address = null
except Anti-Recaptcha Key I need to do something else in the email.
Hi, The webpage isn't working mate.
Hey.
We've received some complaints from Plesk and have to lay low for a while.
our private paid services are still available, though.
contact [email protected] for more info.
Hi,
I'm getting error code: 1020 when accessing the webpage.
2
our private paid services are still available, though.
contact [email protected] for more info.
This was a nice tool while it worked but you must register trail license on plesk website now.
What's the situation now?
There will be no update for the working version of this gist anymore.
I will leave this gist as proof of concept.
Are you interested in a Plesk WebHost license (unlimited domains) for your VPS or dedicated server at an affordable price?
The license is available for both Linux and Windows platforms.
For inquiries, feel free to contact me on Telegram: https://t.me/kh4l3quzz4m4n.
had a misconfiguration on my webserver. it's all fine now!