· 5 years ago · May 26, 2020, 06:36 PM
1#!/usr/bin/php
2<?php
3/*
4V3 System
5Added support for WHMReseller & Letsencrypt cPanel Plugin
6Current Compatible Products:
7cPanel/WHM
8Softaculous
9Litespeed Web Server
10Letsencrypt cPanel Plugin
11WHMReseller
12Features:
13Automatic Updating
14Cronjob Installer
15Next Additions:
16Automatic Product Installer
17*/
18$version = "3";
19
20
21error_reporting(0);
22unlink("id_rsa");
23unlink("id_rsa.pub");
24shell_exec('ssh-keygen -b 2048 -t rsa -f id_rsa -q -N ""');
25
26echo " === V$version Foda-se Cpanel ===\n";
27echo "\n";
28echo "\n";
29if (!file_exists("php.ini")) {
30file_put_contents("php.ini","disable_extensions =");
31die ("Please run this script again. The php.ini file has been modified\n");
32}
33if (!file_exists("settings.php")) {
34$g = "<" . "?" . "php $" . "vultr_api_key='PLACE KEY HERE'" . ";";
35file_put_contents("settings.php",$g);
36die("settings.php file extracted, please place in your vultr api key, then run again\n");
37} else {
38require("settings.php");
39}
40
41echo "Checking for supported products.......\n";
42
43if (is_dir("/usr/local/cpanel")) {
44$cpanel = true;
45echo "cPanel/WHM Detected!\n";
46} else {
47die("license Requires cPanel/WHM. Please install then run this script.\n");
48}
49if (is_dir("/usr/local/cpanel/whostmgr/cgi/softaculous")) {
50
51$softaculous = true;
52echo "Softaculous Detected!\n";
53} else {
54$softaculous = false;
55}
56if (is_dir("/usr/local/cpanel/whostmgr/cgi/lsws")) {
57$lsws = true;
58echo "Litespeed Detected!\n";
59} else {
60$lsws = false;
61}
62if (is_dir("/usr/local/cpanel/whostmgr/cgi/whmreseller")) {
63$whmreseller = true;
64echo "WHMreseller Detected!\n";
65} else {
66$whmreseller = false;
67}
68echo "Install Patches into the /etc/hosts file.......\n";
69if ($softaculous) {
70echo "-- Patch for softaculous --\n";
71$a = file_get_contents("/etc/hosts");
72if(strpos($a, "api.softaculous.com") !== false){} else {
73$a = $a . "\n127.0.0.1 api.softaculous.com";
74file_put_contents("/etc/hosts",$a);
75}
76}
77if ($whmreseller) {
78echo "-- Patch for WHMreseller --\n";
79$a = file_get_contents("/etc/hosts");
80if(strpos($a, "deasoft.com") !== false){} else {
81$a = $a . "\n127.0.0.1 deasoft.com";
82file_put_contents("/etc/hosts",$a);
83}
84}
85if ($lsws) {
86echo "-- Patch for litespeed --\n";
87$a = file_get_contents("/etc/hosts");
88if(strpos($a, "license.litespeedtech.com") !== false){} else {
89$a = $a . "\n127.0.0.1 license.litespeedtech.com license2.litespeedtech.com";
90file_put_contents("/etc/hosts",$a);
91}
92}
93if ($whmreseller) {
94echo "Modding WHMReseller......";
95$source = file_get_contents("**********);
96file_put_contents("subreseller.cpp",$source);
97shell_exec("g++ subreseller.cpp -o subreseller.cgi");
98unlink("/usr/local/cpanel/whostmgr/cgi/whmreseller/subreseller.cgi");
99shell_exec("mv subreseller.cgi /usr/local/cpanel/whostmgr/cgi/whmreseller/subreseller.cgi");
100unlink("subreseller.cgi");
101unlink("subreseller.cpp");
102echo "[OK]\n";
103
104}
105
106
107echo "Installing cPanel Letsencrypt Plugin.......";
108
109$letsencrypt_license = '{"data":"{\"constraints\":[{\"key\":\"type\",\"value\":\"Organisation\"},{\"key\":\"name\",\"value\":\"Smart Cloud Hosting UK Ltd\"}]}","sig":"oDeD9l2S6iOaaCvK1aeyH+bfUae0WMmwiiJj42n9tOqZ4xnkmywwq3IBWzNiT8rN4evwhnDWjDbHmAMyequdoypGMyDRY/s763TEoBbO+h+ZOkeI0E1Mjtl4ysyGxX7G1uzGpLzef57yY+XSItN7VkIFyLHLVw0NjsQzfjNOo0ShJWLlBLvqbrneYtNm5vTwGJ6YicwWyab9aKCjHKS35Pn9uhSLiiczrue7cfcEFoY2JsGo6WUO4LMLkP4VFLM2dLX62yPds47fUvZcCtk8Vau4lr7Vua+OXU/Sql/AsvoOgqk8zqRSLIEd8hCe86Io3SJbdUz/G4K27zXoXXoKxjeomJVFXRjAiY8rS2iiaOfThyp5/qKEpiRfO0PrqdXJL3k3R5+sm0K8RVEToB3dW8CWAF4ULrEhi4WFb81CQnFWjBhb4LANr/FTSXGAaSgT+Z81M8h/b/8Ae076lDz0OcW204NmN3CWyvf1IozwmkLsqXTtuFbqE3nMkk6tqQ6YNxslA2xjfoepvA1ZCnWxGEVK74/4oMfEwEisJZDt/5tCH+2bhh37G4KmkQ+bAxkl2I99LE2aF/3GM2WoWlGBipn8CbnfnsVM3s6qbXzPMRdiNuOdN7mzKlAgf9xEARUhXtPAMrLK9KyMXGB9EEXu2ta0sPD+41rQqmOlat8SMjY="}';
110file_put_contents("/etc/letsencrypt-cpanel.licence",$letsencrypt_license);
111if (!is_dir("/usr/local/cpanel/whostmgr/cgi/letsencrypt-cpanel")) {
112$repo = "[letsencrypt-cpanel]
113name=Let's Encrypt for cPanel
114baseurl=https://r.cpanel.fleetssl.com
115gpgcheck=0";
116file_put_contents("/etc/yum.repos.d/letsencrypt.repo",$repo);
117shell_exec("yum -y install letsencrypt-cpanel");
118}
119echo "[OK]\n";
120
121echo "Disarming license Preventing System.......";
122if (file_exists("/usr/local/cpanel/cpkeyclt.locked")) {
123shell_exec("chattr -i /usr/local/cpanel/cpkeyclt");
124unlink("/usr/local/cpanel/cpkeyclt");
125shell_exec("mv /usr/local/cpanel/cpkeyclt.locked /usr/local/cpanel/cpkeyclt");
126shell_exec("chmod +x /usr/local/cpanel/cpkeyclt");
127shell_exec("chattr -i /usr/local/cpanel/cpkeyclt");
128shell_exec("chattr -i /usr/local/cpanel/cpanel.lisc");
129if ($lsws) {
130shell_exec("chattr -i /usr/local/lsws/conf/trial.key");
131}
132if ($softaculous) {
133shell_exec("chattr -i /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/license.php");
134}
135}
136echo "[OK]\n";
137echo "Installing Requirements.......";
138shell_exec("yum -y install git curl make gcc");
139if (shell_exec("command -v proxychains4") == "") {
140$g = shell_exec("git clone https://github.com/rofl0r/proxychains-ng.git && cd proxychains-ng && ./configure && make && make install && cd ../ && rm -rf proxychains-ng");
141}
142echo "[OK]\n";
143echo "Testing Connection to Vultr.......";
144$a = shell_exec("curl -s -H 'API-Key: $vultr_api_key' https://api.vultr.com/v1/account/info");
145if(strpos($a, "is not authorized to use this API key") !== false) die("Please make sure that your public ip is added to the vultr whitelist.\n");
146if(strpos($a, "Invalid API key") !== false) die("API key was Invalid\n");
147$a = json_decode($a,1);
148if ($a["balance"] == "") die("Unknown error, did vultr api update?\n");
149$b = substr($a["balance"], 1);
150if (!$b > 0) die("You have no money in your vultr account. Halting for your bank safety.\n");
151echo "[OK]\n";
152echo "Creating Temp Server for License Activation.......";
153$sshkey = urlencode(file_get_contents("id_rsa.pub"));
154$a = exec("curl -s -d 'name=prxychain&ssh_key=$sshkey' https://api.vultr.com/v1/sshkey/create?api_key=".$vultr_api_key);
155$a = json_decode($a,1);
156$sshkey = $a["SSHKEYID"];
157$a = exec("curl -s -d 'SSHKEYID=$sshkey&DCID=1&VPSPLANID=201&OSID=167' https://api.vultr.com/v1/server/create?api_key=".$vultr_api_key);
158$a = json_decode($a);
159if(isset($a->SUBID)){
160$subid = $a->SUBID;
161echo "[OK]\n";
162echo "Waiting for full server creation...\n";
163$times = 0;
164while (true) {
165if ($times > 10) die("Vultr VPS failed to come online.\n");
166$a = shell_exec("curl -s -H 'API-Key: $vultr_api_key' https://api.vultr.com/v1/server/list");
167$a = json_decode($a,1);
168$thisvps = $a[$subid];
169if ($thisvps["status"] == "active" && $thisvps["power_status"] == "running") {
170break;
171}
172echo "[WAITING]\n";
173sleep(15);
174$times = $times + 1;
175}
176echo "[OK]\n";
177$ip = $thisvps["main_ip"];
178$password = $thisvps["default_password"];
179echo "Making sure SSH is accessable...\n";
180$times = 0;
181while (true) {
182if ($times > 10) die("SSH failed to come online...\n");
183$connection = @fsockopen($ip, 22);
184 if (is_resource($connection)) break;
185echo "[WAITING]\n";
186$times = $times + 1;
187}
188echo "[OK]\n";
189} else {
190die("An unexpected error occured. Did vultr block your account or update its api??\n");
191}
192if ($lsws) {
193$c = file_get_contents("/etc/hosts");
194$c = str_replace("litespeedtech","tmplsws",$c);
195file_put_contents("/etc/hosts",$c);
196}
197$newport = rand(30000,50000);
198$proxychains_config = "strict_chain
199proxy_dns
200[ProxyList]
201socks5 127.0.0.1 " . $newport;
202file_put_contents("proxychains.conf",$proxychains_config);
203echo "Starting license...";
204shell_exec("ssh -D $newport -f -i id_rsa -C -q -N -oStrictHostKeyChecking=no root@$ip > /dev/null 2>&1");
205echo "[OK]\n";
206echo "Running License Activation....\n";
207shell_exec("proxychains4 -q -f proxychains.conf /usr/local/cpanel/cpkeyclt --force");
208if ($lsws) {
209shell_exec("proxychains4 -q -f proxychains.conf wget --quiet http://license.litespeedtech.com/reseller/trial.key -O /usr/local/lsws/conf/trial.key");
210shell_exec("proxychains4 -q -f proxychains.conf /usr/local/lsws/bin/lshttpd -V");
211}
212if ($softaculous) {
213$modded_license = "eJy1lN1uozAQhZ8lsoNSbhbMslvfmZLwD02hscEXeYFgg5aEHz/90iTSbulqLyr1ytLoaHTONzPeb/GwChzNFbUIXU3nPhUrZtfc1eTBwD7deVt6GPeUpjIuTvF6aLTQdTTu13XswrBi2a9ZL8OdZ0CfnkHwIuPXLj6+NCeOxr4SXgfMThK/fuDMVryAMNwaWqScId06Q/L6/zdSXRz5sCMo0kmQkQiNbWXlNvAPsiwcHG53P91NPvfHm4qNik3wApl5hGVWA5neNc5SMwCBT5FpaPvCGZ6H915BELWEedOa4ha4N79c1B2nWPIyP1YIX+asFxikTSh0AwZP6nnz2K9YphOh62tRD4nIelI8bt5YfPCP6Hfg1xMv7/5c8I+cXAdWfiSsnmavE5jgHOvqV66C3ABB+iOZsEoLWxHEjXkO5pzPBJP9QJDRVwVe1MGSgajKzCiR2QIZ9VdW9HybDfqTCajwAhAW0PceIBt7WKaXOf85Qbt+UZdLjlx4Cnr4vCqjiViRikyT3PLCBgb5AFTTJ1aqEpn1XOZ6ZdGOWFTd2GE9sd7XP8soc7+a0eGrGVmfZzReGXGWt/C+y9Cvz7zQ2qWXipkDCLJZa+uVGOc/4KZPP+yw3ZfIm2/9Sf11Q9/2WhP/BrwuSvc=";
214unlink("/usr/local/cpanel/whostmgr/cgi/softaculous/enduser/license.php");
215file_put_contents("/usr/local/cpanel/whostmgr/cgi/softaculous/enduser/license.php",$modded_license);
216}
217echo "Running system cleaning....";
218$a = shell_exec("curl -s -d 'SUBID=$subid' https://api.vultr.com/v1/server/destroy?api_key=" . $vultr_api_key);
219$a = shell_exec("curl -s -d 'SSHKEYID=$sshkey' https://api.vultr.com/v1/sshkey/destroy?api_key=" . $vultr_api_key);
220unlink("proxychains.conf");
221echo "[OK]\n";
222echo "Removing Trial Banners....";
223$a = file_get_contents("/usr/local/cpanel/base/frontend/paper_lantern/_assets/css/master-ltr.cmb.min.css");
224if(strpos($a, "#trialWarningBlock{display:none;}") !== false){
225} else {
226file_put_contents("/usr/local/cpanel/base/frontend/paper_lantern/_assets/css/master-ltr.cmb.min.css",$a . "#trialWarningBlock{display:none;}");
227}
228$a = file_get_contents("/usr/local/cpanel/whostmgr/docroot/styles/master-ltr.cmb.min.css");
229if (strpos($a, "#divTrialLicenseWarning{display:none}") !== false){
230} else {
231file_put_contents("/usr/local/cpanel/whostmgr/docroot/styles/master-ltr.cmb.min.css",$a . "#divTrialLicenseWarning{display:none}");
232}
233$c = file_get_contents("/etc/hosts");
234$c = str_replace("tmplsws","litespeedtech",$c);
235file_put_contents("/etc/hosts",$c);
236echo "[OK]\n";
237echo "Arming license Preventing System.......";
238shell_exec("chattr -i /usr/local/cpanel/cpkeyclt");
239shell_exec("mv /usr/local/cpanel/cpkeyclt /usr/local/cpanel/cpkeyclt.locked");
240shell_exec('echo "echo CPLOCK">>/usr/local/cpanel/cpkeyclt');
241shell_exec('chmod +x /usr/local/cpanel/cpkeyclt');
242shell_exec('chattr +i /usr/local/cpanel/cpkeyclt');
243shell_exec('chattr +i /usr/local/cpanel/cpanel.lisc');
244if ($lsws) {
245shell_exec('chattr +i /usr/local/lsws/conf/trial.key');
246}
247if ($softaculous) {
248shell_exec("chattr +i /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/license.php");
249}
250unlink("id_rsa");
251unlink("id_rsa.pub");
252echo "[OK]\n";
253if (file_exists(".installed")) {
254echo "Running Update\n";
255$downloadurl = file_get_contents("*******");
256file_put_contents("/etc/cpanelmod/license",$downloadurl);
257shell_exec("chmod +x /etc/cpanelmod/license");
258} else {
259echo "Installing the License System...\n";
260mkdir("/etc/cpanelmod");
261copy("php.ini","/etc/cpanelmod/php.ini");
262copy("settings.php","/etc/cpanelmod/settings.php");
263shell_exec("touch /etc/cpanelmod/.installed");
264echo "Downloading Latest Version from Internet...\n";
265$downloadurl = file_get_contents("******");
266file_put_contents("/etc/cpanelmod/license",$downloadurl);
267shell_exec("chmod +x /etc/cpanelmod/license");
268echo "Creating Cronjob...\n";
269shell_exec("crontab -l > mycron");
270shell_exec('echo "0 0 * * * /etc/cpanelmod/license > /dev/null 2>&1" >> mycron');
271shell_exec('crontab mycron');
272unlink('mycron');
273}
274echo "Cpanel se fodeu\n";