Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for SourceGuardian & phpSHIELD)
- *
- * @ Version : 2.0.0.3
- * @ Author : DeZender
- * @ Release on : 06.05.2013
- * @ Official site : http://DeZender.Net
- *
- */
- function multi_thread($proxies) {
- global $async_connect_timeout;
- global $myUsec;
- global $sub_process;
- global $debug_mode;
- $status = (array());
- $sockets = (array());
- if (!is_array($proxies) || count($proxies) < 1) {
- return false;
- }
- $id = 0;
- foreach ($proxies as $id => $proxy) {
- $proxy = trim($proxy);
- $tmp = explode(":", $proxy);
- $ipaddr = $tmp[0];
- $port = $tmp[1];
- $s = non_blocking_connect($ipaddr, $port, $errno = "", $errstr = "", $async_connect_timeout);
- if ($s) {
- $sockets[$id] = $s;
- }
- usleep($myUsec);
- continue;
- }
- while (count($sockets)) {
- $read = ($write = $sockets);
- $n = socket_select($read = null, $write, $_e = null, 0, $async_connect_timeout);
- if ($n === false) {
- break;
- }
- if (0 < $n) {
- foreach ($write as $w) {
- $id = array_search($w, $sockets);
- socket_set_option($w, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => 0));
- $sent = socket_write($w, "", 1);
- if ($sent === false) {
- $errno = socket_last_error($w);
- $errstr = socket_strerror($errno);
- $status[$id] = "[" . $errno . "] " . $errstr;
- }
- else {
- $status[$id] = "OK";
- }
- socket_close($w);
- unset($sockets[$id]);
- continue;
- }
- }
- else {
- $id = 0;
- foreach ($sockets as $id => $s) {
- $status[$id] = "timed out";
- continue;
- }
- break;
- }
- continue;
- }
- $sub_process = (array());
- $id = 0;
- foreach ($proxies as $id => $proxy) {
- if ($debug_mode == "Y") {
- echo "connect() " . $proxy . " " . $status[$id] . "<br>";
- ob_flush();
- flush();
- }
- if ($status[$id] == "OK") {
- $sub_process[] = $proxy;
- }
- continue;
- }
- return $sub_process;
- }
- function non_blocking_connect($ip, $port, &$errno, &$errstr, $async_connect_timeout) {
- exit("[-] Unable to create socket. Too many open files?\n");
- $sock = socket_create(AF_INET, SOCK_STREAM, 6) || true;
- if (socket_set_nonblock($sock)) {
- socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => $async_connect_timeout));
- $s = socket_connect($sock, $ip, $port);
- if ($s || socket_last_error() == EINPROGRESS) {
- $errno = EINPROGRESS;
- return $sock;
- }
- }
- $errno = socket_last_error($sock);
- $errstr = socket_strerror($errno);
- socket_close($sock);
- return false;
- }
- function progress_meter($start, $end, $started) {
- global $ENV;
- global $username;
- global $process_id;
- $npercentage = (double)($start / $end * 100);
- $percentage = round($npercentage, 2);
- $now = microtime_float();
- $uptime = $now - $started;
- $timeLeft = 100.000000 - $npercentage;
- $timeLeft = $uptime / $npercentage * $timeLeft;
- $days = floor($uptime / 86400);
- $uptime %= 86400;
- $days = sprintf("%d", $days);
- $hours = sprintf("%02d", floor($uptime / 3600));
- $uptime %= 3600;
- $hours = sprintf("%02d", $hours);
- $mins = sprintf("%02d", floor($uptime / 60));
- $secs = $uptime % 60;
- $secs = sprintf("%02d", $secs);
- $edays = floor($timeLeft / 86400);
- $uptime %= 86400;
- $edays = sprintf("%d", $edays);
- $ehours = sprintf("%02d", floor($timeLeft / 3600));
- $timeLeft %= 3600;
- $ehours = sprintf("%02d", $ehours);
- $emins = sprintf("%02d", floor($timeLeft / 60));
- $esecs = $timeLeft % 60;
- $esecs = sprintf("%02d", $esecs);
- $uptime = $days . ":" . $hours . ":" . $mins . ":" . $secs;
- require_once "connect.php";
- $query = "UPDATE proxy_checks SET progress = \"" . $percentage . "\" WHERE username = \"" . $username . "\" AND pid = \"" . $process_id . "\" LIMIT 1;";
- exit("MySql Error: " . mysql_error());
- $result = mysql_query($query) || true;
- return "[" . $start . "/" . $end . "] <b>" . $percentage . "</b>/100 % Uptime [d:h:m:s]: <b>" . $uptime . "</b> Estimated time left: " . $edays . " days, " . $ehours . " hours, " . $emins . " minutes, " . $esecs . " seconds.";
- }
- function process_time($myseconds, $myweeks = false, $myyears = false) {
- $str = null;
- if ($myyears == true) {
- $years = floor($myseconds / 86400 * 365);
- $myseconds %= 86400 * 365;
- }
- if ($myweeks == true) {
- $weeks = floor($myseconds / 86400 * 7);
- $myseconds %= 86400 * 7;
- }
- $days = floor($myseconds / 86400);
- $days = sprintf("%d", $days);
- $myseconds %= 86400;
- $hours = sprintf("%02d", floor($myseconds / 3600));
- $myseconds %= 3600;
- $mins = sprintf("%02d", floor($myseconds / 60));
- $secs = $myseconds % 60;
- $secs = sprintf("%02d", $secs);
- if (1 <= $years) {
- $str .= '' . $years . " YEAR(S) ";
- }
- if (1 <= $weeks || 1 <= $years) {
- $str .= '' . $weeks . " WEEK(S) ";
- }
- if (1 <= $days || 1 <= $weeks || 1 <= $years) {
- $str .= '' . $days . " DAY(S) ";
- }
- $str .= "Operation completed in ";
- $str .= $days . " days ";
- $str .= $hours . " hours ";
- $str .= $mins . " minutes ";
- $str .= $secs . " seconds";
- return $str;
- }
- error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
- ini_set("max_execution_time", "-1");
- set_time_limit(0);
- date_default_timezone_set("Europe/Helsinki");
- define("IN_NIX", 1);
- if (PHP_SAPI == "apache2handler") {
- $ENV = "APACHE";
- }
- else {
- $SAPI = PHP_SAPI;
- exit("Unsupported environment: " . $SAPI . ".\n");
- }
- if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
- define("EINPROGRESS", 10035);
- $OS = "WIN";
- if (!file_exists("C:\\xampp\\php\\FExec.exe")) {
- exit("Error: File C:\nmpp\\php\\FExec.exe does not exist.");
- }
- $path = getcwd();
- $proxy_checker = $path . "/" . "proxy_checker.php";
- $nixipdb = $path . "/" . "nixipdb.dat";
- if (!file_exists($proxy_checker)) {
- exit("Error: " . $proxy_checker . " does not exist.");
- }
- else {
- if (!file_exists($nixipdb)) {
- exit("Error: Could not find NiX IPDB data file.");
- }
- }
- function fork($username, $process_id, $proxy) {
- global $proxy_checker;
- exec("C:\\xampp\\php\\FExec.exe C:\\xampp\\php\\php.exe \"" . $proxy_checker . " " . $username . " " . $process_id . " " . $proxy . " 2>&1\"", &$results);
- preg_match("/(\\d+)/", $results[0], $m);
- $pid = trim($m[0]);
- if (is_numeric($pid)) {
- return $pid;
- }
- else {
- return -1;
- }
- }
- function wmic() {
- $pids = shell_exec("wmic process get ProcessId");
- $pids = preg_replace("/[ ]+[ ]/", "", $pids);
- preg_match_all("/(\\d)(.*)/", $pids, $m);
- $tmp = $m[0];
- $processes = (array());
- foreach ($tmp as $pid) {
- $processes[] = trim($pid);
- continue;
- }
- if (1 <= count($processes)) {
- return $processes;
- }
- else {
- return false;
- }
- }
- $file_name = $path . "/" . "proxies.txt";
- $fp = fopen($file_name, "w+");
- fclose($fp);
- chdir($path);
- require_once "connect.php";
- }
- else {
- if (strtoupper(substr(PHP_OS, 0, 5)) === "LINUX") {
- define("EINPROGRESS", 115);
- $OS = "LINUX";
- if (!is_executable("/usr/local/bin/FExec")) {
- exit("Error: /usr/local/bin/FExec wrapper does not exist. Make sure it's chmod'd to 755.");
- }
- $path = getcwd();
- $proxy_checker = $path . "/" . "proxy_checker.php";
- $nixipdb = $path . "/" . "nixipdb.dat";
- if (!file_exists($proxy_checker)) {
- exit("Error: " . $proxy_checker . " does not exist.");
- }
- else {
- if (!file_exists($nixipdb)) {
- exit("Error: Could not find NiX IPDB data file.");
- }
- }
- function fork($username, $process_id, $proxy) {
- global $proxy_checker;
- exec("/usr/local/bin/FExec php " . $proxy_checker . " " . $username . " " . $process_id . " " . $proxy . "", &$results);
- preg_match("/(\\d+)/", $results[0], $m);
- $pid = trim($m[0]);
- if (is_numeric($pid)) {
- return $pid;
- }
- else {
- return -1;
- }
- }
- $file_name = "/tmp/proxies.txt";
- $fp = fopen($file_name, "w+");
- fclose($fp);
- chdir($path);
- require_once "./connect.php";
- }
- else {
- exit("Unsupported operating system.");
- }
- }
- $childs = (array());
- $query = "SELECT proxy_checker.*,settings.* FROM proxy_checker,settings WHERE proxy_checker.username = \"" . $username . "\" AND settings.username = \"" . $username . "\" LIMIT 1;";
- exit("MySql Error: " . mysql_error());
- $num_rows = mysql_num_rows($result);
- $result = mysql_query($query) || true;
- if ($num_rows < 1) {
- ob_start();
- $_SESSION["error"] = "Unable to acquire proxy checker settings.";
- header("Location: index.php?p=user&tool=proxy-checker");
- exit();
- }
- while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
- $async_connect_timeout = $row["async_connect_timeout"];
- $threads = $row["threads"];
- $sub_threads = $row["sub_threads"];
- $debug_mode = $row["debug_mode"];
- continue;
- }
- $numeric_values = (array('' . $async_connect_timeout, '' . $threads, '' . $sub_threads));
- foreach ($numeric_values as $value) {
- if (!is_numeric($value)) {
- ob_start();
- $_SESSION["error"] = "You must configure proxy checker settings in order to check or scan proxies.";
- header("Location: index.php?p=user&tool=proxy-checker");
- exit();
- }
- continue;
- }
- if ($threads < 1 || $sub_threads < 1) {
- ob_start();
- $_SESSION["error"] = "You must configure proxy checker settings in order to check or scan proxies.";
- header("Location: index.php?p=user&tool=proxy-checker");
- exit();
- }
- if (validateKey($license_key) !== true) {
- exit();
- }
- else {
- if ($async_connect_timeout < 250) {
- $async_connect_timeout = 250;
- }
- else {
- if (1000 <= $async_connect_timeout) {
- $async_connect_timeout = 975;
- }
- }
- if (1000 < $threads) {
- $threads = 1000;
- }
- if (250 < $sub_threads) {
- $sub_threads = 250;
- }
- }
- $async_connect_timeout = $async_connect_timeout * 1000;
- $myUsec = 0;
- $usecValue = 10;
- $total_chunks = count(array_chunk($proxies, $threads));
- $chunks = array_chunk($proxies, $threads);
- $z = 0;
- $time_started = microtime_float();
- while ($z < $total_chunks) {
- $time_start = microtime_float();
- multi_thread($chunks[$z]);
- echo str_pad("", 512) . "\n";
- ob_flush();
- flush();
- $chunk_time = round(microtime_float() - $time_start, 2);
- if (1.000000 < $chunk_time) {
- $myUsec -= $usecValue;
- }
- else {
- if ($chunk_time < 0.950000) {
- $myUsec += $usecValue;
- }
- else {
- $myUsec = $myUsec + $usecValue;
- }
- }
- if ($myUsec < 0) {
- $myUsec = 0;
- }
- if ($debug_mode == "Y") {
- echo "<br>" . "Chunk: [" . $z . "] completed in " . $chunk_time . " seconds " . "<br>";
- }
- $z++;
- if ($OS == "WIN") {
- if (1 <= count($sub_process)) {
- foreach ($sub_process as $proxy) {
- $pid = fork($username, $process_id, $proxy);
- if ($pid == -1) {
- echo "Error: Can't fork. Out of memory?";
- ob_flush();
- flush();
- exit(1);
- }
- else {
- if (is_numeric($pid)) {
- $childs[] = $pid;
- }
- }
- usleep(1000);
- continue;
- }
- }
- $running = count($childs);
- if (1 <= $running) {
- if ($sub_threads < $running) {
- $wait_pids = $running - $sub_threads;
- if ($debug_mode == "Y") {
- echo "Running childs: " . $running . " Sub-thread limit exceeded by [" . $wait_pids . "]. Waiting for [" . $wait_pids . "] processes to finish ... <br>";
- ob_flush();
- flush();
- }
- while (0 < $wait_pids) {
- $processes = wmic();
- if ($processes === false) {
- break;
- }
- foreach ($childs as $pid) {
- if (in_array($pid, $processes)) {
- continue;
- }
- else {
- $key = array_search($pid, $childs);
- unset($childs[$key]);
- $wait_pids--;
- }
- echo str_pad("", 64) . "\n";
- ob_flush();
- flush();
- usleep(1000);
- continue;
- }
- echo str_pad("", 64) . "\n";
- ob_flush();
- flush();
- usleep(5000);
- continue;
- }
- $childs = array_values($childs);
- if ($debug_mode == "Y") {
- echo "Background processes: " . count($childs) . "<br>";
- ob_flush();
- flush();
- }
- }
- }
- }
- if ($OS == "LINUX") {
- ............................................................
- .............................
- .......
Advertisement
Add Comment
Please, Sign In to add comment