Guest User

Untitled

a guest
Nov 10th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.87 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for SourceGuardian & phpSHIELD)
  6. *
  7. * @ Version : 2.0.0.3
  8. * @ Author : DeZender
  9. * @ Release on : 06.05.2013
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function multi_thread($proxies) {
  15. global $async_connect_timeout;
  16. global $myUsec;
  17. global $sub_process;
  18. global $debug_mode;
  19. $status = (array());
  20. $sockets = (array());
  21. if (!is_array($proxies) || count($proxies) < 1) {
  22. return false;
  23. }
  24. $id = 0;
  25. foreach ($proxies as $id => $proxy) {
  26. $proxy = trim($proxy);
  27. $tmp = explode(":", $proxy);
  28. $ipaddr = $tmp[0];
  29. $port = $tmp[1];
  30. $s = non_blocking_connect($ipaddr, $port, $errno = "", $errstr = "", $async_connect_timeout);
  31. if ($s) {
  32. $sockets[$id] = $s;
  33. }
  34. usleep($myUsec);
  35. continue;
  36. }
  37. while (count($sockets)) {
  38. $read = ($write = $sockets);
  39. $n = socket_select($read = null, $write, $_e = null, 0, $async_connect_timeout);
  40. if ($n === false) {
  41. break;
  42. }
  43. if (0 < $n) {
  44. foreach ($write as $w) {
  45. $id = array_search($w, $sockets);
  46. socket_set_option($w, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => 0));
  47. $sent = socket_write($w, "", 1);
  48. if ($sent === false) {
  49. $errno = socket_last_error($w);
  50. $errstr = socket_strerror($errno);
  51. $status[$id] = "[" . $errno . "] " . $errstr;
  52. }
  53. else {
  54. $status[$id] = "OK";
  55. }
  56. socket_close($w);
  57. unset($sockets[$id]);
  58. continue;
  59. }
  60. }
  61. else {
  62. $id = 0;
  63. foreach ($sockets as $id => $s) {
  64. $status[$id] = "timed out";
  65. continue;
  66. }
  67. break;
  68. }
  69. continue;
  70. }
  71. $sub_process = (array());
  72. $id = 0;
  73. foreach ($proxies as $id => $proxy) {
  74. if ($debug_mode == "Y") {
  75. echo "connect() " . $proxy . " " . $status[$id] . "<br>";
  76. ob_flush();
  77. flush();
  78. }
  79. if ($status[$id] == "OK") {
  80. $sub_process[] = $proxy;
  81. }
  82. continue;
  83. }
  84. return $sub_process;
  85. }
  86.  
  87. function non_blocking_connect($ip, $port, &$errno, &$errstr, $async_connect_timeout) {
  88. exit("[-] Unable to create socket. Too many open files?\n");
  89. $sock = socket_create(AF_INET, SOCK_STREAM, 6) || true;
  90. if (socket_set_nonblock($sock)) {
  91. socket_set_option($sock, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => $async_connect_timeout));
  92. $s = socket_connect($sock, $ip, $port);
  93. if ($s || socket_last_error() == EINPROGRESS) {
  94. $errno = EINPROGRESS;
  95. return $sock;
  96. }
  97. }
  98. $errno = socket_last_error($sock);
  99. $errstr = socket_strerror($errno);
  100. socket_close($sock);
  101. return false;
  102. }
  103.  
  104. function progress_meter($start, $end, $started) {
  105. global $ENV;
  106. global $username;
  107. global $process_id;
  108. $npercentage = (double)($start / $end * 100);
  109. $percentage = round($npercentage, 2);
  110. $now = microtime_float();
  111. $uptime = $now - $started;
  112. $timeLeft = 100.000000 - $npercentage;
  113. $timeLeft = $uptime / $npercentage * $timeLeft;
  114. $days = floor($uptime / 86400);
  115. $uptime %= 86400;
  116. $days = sprintf("%d", $days);
  117. $hours = sprintf("%02d", floor($uptime / 3600));
  118. $uptime %= 3600;
  119. $hours = sprintf("%02d", $hours);
  120. $mins = sprintf("%02d", floor($uptime / 60));
  121. $secs = $uptime % 60;
  122. $secs = sprintf("%02d", $secs);
  123. $edays = floor($timeLeft / 86400);
  124. $uptime %= 86400;
  125. $edays = sprintf("%d", $edays);
  126. $ehours = sprintf("%02d", floor($timeLeft / 3600));
  127. $timeLeft %= 3600;
  128. $ehours = sprintf("%02d", $ehours);
  129. $emins = sprintf("%02d", floor($timeLeft / 60));
  130. $esecs = $timeLeft % 60;
  131. $esecs = sprintf("%02d", $esecs);
  132. $uptime = $days . ":" . $hours . ":" . $mins . ":" . $secs;
  133. require_once "connect.php";
  134. $query = "UPDATE proxy_checks SET progress = \"" . $percentage . "\" WHERE username = \"" . $username . "\" AND pid = \"" . $process_id . "\" LIMIT 1;";
  135. exit("MySql Error: " . mysql_error());
  136. $result = mysql_query($query) || true;
  137. 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.";
  138. }
  139.  
  140. function process_time($myseconds, $myweeks = false, $myyears = false) {
  141. $str = null;
  142. if ($myyears == true) {
  143. $years = floor($myseconds / 86400 * 365);
  144. $myseconds %= 86400 * 365;
  145. }
  146. if ($myweeks == true) {
  147. $weeks = floor($myseconds / 86400 * 7);
  148. $myseconds %= 86400 * 7;
  149. }
  150. $days = floor($myseconds / 86400);
  151. $days = sprintf("%d", $days);
  152. $myseconds %= 86400;
  153. $hours = sprintf("%02d", floor($myseconds / 3600));
  154. $myseconds %= 3600;
  155. $mins = sprintf("%02d", floor($myseconds / 60));
  156. $secs = $myseconds % 60;
  157. $secs = sprintf("%02d", $secs);
  158. if (1 <= $years) {
  159. $str .= '' . $years . " YEAR(S) ";
  160. }
  161. if (1 <= $weeks || 1 <= $years) {
  162. $str .= '' . $weeks . " WEEK(S) ";
  163. }
  164. if (1 <= $days || 1 <= $weeks || 1 <= $years) {
  165. $str .= '' . $days . " DAY(S) ";
  166. }
  167. $str .= "Operation completed in ";
  168. $str .= $days . " days ";
  169. $str .= $hours . " hours ";
  170. $str .= $mins . " minutes ";
  171. $str .= $secs . " seconds";
  172. return $str;
  173. }
  174.  
  175. error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
  176. ini_set("max_execution_time", "-1");
  177. set_time_limit(0);
  178. date_default_timezone_set("Europe/Helsinki");
  179. define("IN_NIX", 1);
  180. if (PHP_SAPI == "apache2handler") {
  181. $ENV = "APACHE";
  182. }
  183. else {
  184. $SAPI = PHP_SAPI;
  185. exit("Unsupported environment: " . $SAPI . ".\n");
  186. }
  187. if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
  188. define("EINPROGRESS", 10035);
  189. $OS = "WIN";
  190. if (!file_exists("C:\\xampp\\php\\FExec.exe")) {
  191. exit("Error: File C:\nmpp\\php\\FExec.exe does not exist.");
  192. }
  193. $path = getcwd();
  194. $proxy_checker = $path . "/" . "proxy_checker.php";
  195. $nixipdb = $path . "/" . "nixipdb.dat";
  196. if (!file_exists($proxy_checker)) {
  197. exit("Error: " . $proxy_checker . " does not exist.");
  198. }
  199. else {
  200. if (!file_exists($nixipdb)) {
  201. exit("Error: Could not find NiX IPDB data file.");
  202. }
  203. }
  204. function fork($username, $process_id, $proxy) {
  205. global $proxy_checker;
  206. exec("C:\\xampp\\php\\FExec.exe C:\\xampp\\php\\php.exe \"" . $proxy_checker . " " . $username . " " . $process_id . " " . $proxy . " 2>&1\"", &$results);
  207. preg_match("/(\\d+)/", $results[0], $m);
  208. $pid = trim($m[0]);
  209. if (is_numeric($pid)) {
  210. return $pid;
  211. }
  212. else {
  213. return -1;
  214. }
  215. }
  216. function wmic() {
  217. $pids = shell_exec("wmic process get ProcessId");
  218. $pids = preg_replace("/[ ]+[ ]/", "", $pids);
  219. preg_match_all("/(\\d)(.*)/", $pids, $m);
  220. $tmp = $m[0];
  221. $processes = (array());
  222. foreach ($tmp as $pid) {
  223. $processes[] = trim($pid);
  224. continue;
  225. }
  226. if (1 <= count($processes)) {
  227. return $processes;
  228. }
  229. else {
  230. return false;
  231. }
  232. }
  233. $file_name = $path . "/" . "proxies.txt";
  234. $fp = fopen($file_name, "w+");
  235. fclose($fp);
  236. chdir($path);
  237. require_once "connect.php";
  238. }
  239. else {
  240. if (strtoupper(substr(PHP_OS, 0, 5)) === "LINUX") {
  241. define("EINPROGRESS", 115);
  242. $OS = "LINUX";
  243. if (!is_executable("/usr/local/bin/FExec")) {
  244. exit("Error: /usr/local/bin/FExec wrapper does not exist. Make sure it's chmod'd to 755.");
  245. }
  246. $path = getcwd();
  247. $proxy_checker = $path . "/" . "proxy_checker.php";
  248. $nixipdb = $path . "/" . "nixipdb.dat";
  249. if (!file_exists($proxy_checker)) {
  250. exit("Error: " . $proxy_checker . " does not exist.");
  251. }
  252. else {
  253. if (!file_exists($nixipdb)) {
  254. exit("Error: Could not find NiX IPDB data file.");
  255. }
  256. }
  257. function fork($username, $process_id, $proxy) {
  258. global $proxy_checker;
  259. exec("/usr/local/bin/FExec php " . $proxy_checker . " " . $username . " " . $process_id . " " . $proxy . "", &$results);
  260. preg_match("/(\\d+)/", $results[0], $m);
  261. $pid = trim($m[0]);
  262. if (is_numeric($pid)) {
  263. return $pid;
  264. }
  265. else {
  266. return -1;
  267. }
  268. }
  269. $file_name = "/tmp/proxies.txt";
  270. $fp = fopen($file_name, "w+");
  271. fclose($fp);
  272. chdir($path);
  273. require_once "./connect.php";
  274. }
  275. else {
  276. exit("Unsupported operating system.");
  277. }
  278. }
  279. $childs = (array());
  280. $query = "SELECT proxy_checker.*,settings.* FROM proxy_checker,settings WHERE proxy_checker.username = \"" . $username . "\" AND settings.username = \"" . $username . "\" LIMIT 1;";
  281. exit("MySql Error: " . mysql_error());
  282. $num_rows = mysql_num_rows($result);
  283. $result = mysql_query($query) || true;
  284. if ($num_rows < 1) {
  285. ob_start();
  286. $_SESSION["error"] = "Unable to acquire proxy checker settings.";
  287. header("Location: index.php?p=user&tool=proxy-checker");
  288. exit();
  289. }
  290. while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  291. $async_connect_timeout = $row["async_connect_timeout"];
  292. $threads = $row["threads"];
  293. $sub_threads = $row["sub_threads"];
  294. $debug_mode = $row["debug_mode"];
  295. continue;
  296. }
  297. $numeric_values = (array('' . $async_connect_timeout, '' . $threads, '' . $sub_threads));
  298. foreach ($numeric_values as $value) {
  299. if (!is_numeric($value)) {
  300. ob_start();
  301. $_SESSION["error"] = "You must configure proxy checker settings in order to check or scan proxies.";
  302. header("Location: index.php?p=user&tool=proxy-checker");
  303. exit();
  304. }
  305. continue;
  306. }
  307. if ($threads < 1 || $sub_threads < 1) {
  308. ob_start();
  309. $_SESSION["error"] = "You must configure proxy checker settings in order to check or scan proxies.";
  310. header("Location: index.php?p=user&tool=proxy-checker");
  311. exit();
  312. }
  313. if (validateKey($license_key) !== true) {
  314. exit();
  315. }
  316. else {
  317. if ($async_connect_timeout < 250) {
  318. $async_connect_timeout = 250;
  319. }
  320. else {
  321. if (1000 <= $async_connect_timeout) {
  322. $async_connect_timeout = 975;
  323. }
  324. }
  325. if (1000 < $threads) {
  326. $threads = 1000;
  327. }
  328. if (250 < $sub_threads) {
  329. $sub_threads = 250;
  330. }
  331. }
  332. $async_connect_timeout = $async_connect_timeout * 1000;
  333. $myUsec = 0;
  334. $usecValue = 10;
  335. $total_chunks = count(array_chunk($proxies, $threads));
  336. $chunks = array_chunk($proxies, $threads);
  337. $z = 0;
  338. $time_started = microtime_float();
  339. while ($z < $total_chunks) {
  340. $time_start = microtime_float();
  341. multi_thread($chunks[$z]);
  342. echo str_pad("", 512) . "\n";
  343. ob_flush();
  344. flush();
  345. $chunk_time = round(microtime_float() - $time_start, 2);
  346. if (1.000000 < $chunk_time) {
  347. $myUsec -= $usecValue;
  348. }
  349. else {
  350. if ($chunk_time < 0.950000) {
  351. $myUsec += $usecValue;
  352. }
  353. else {
  354. $myUsec = $myUsec + $usecValue;
  355. }
  356. }
  357. if ($myUsec < 0) {
  358. $myUsec = 0;
  359. }
  360. if ($debug_mode == "Y") {
  361. echo "<br>" . "Chunk: [" . $z . "] completed in " . $chunk_time . " seconds " . "<br>";
  362. }
  363. $z++;
  364. if ($OS == "WIN") {
  365. if (1 <= count($sub_process)) {
  366. foreach ($sub_process as $proxy) {
  367. $pid = fork($username, $process_id, $proxy);
  368. if ($pid == -1) {
  369. echo "Error: Can't fork. Out of memory?";
  370. ob_flush();
  371. flush();
  372. exit(1);
  373. }
  374. else {
  375. if (is_numeric($pid)) {
  376. $childs[] = $pid;
  377. }
  378. }
  379. usleep(1000);
  380. continue;
  381. }
  382. }
  383. $running = count($childs);
  384. if (1 <= $running) {
  385. if ($sub_threads < $running) {
  386. $wait_pids = $running - $sub_threads;
  387. if ($debug_mode == "Y") {
  388. echo "Running childs: " . $running . " Sub-thread limit exceeded by [" . $wait_pids . "]. Waiting for [" . $wait_pids . "] processes to finish ... <br>";
  389. ob_flush();
  390. flush();
  391. }
  392. while (0 < $wait_pids) {
  393. $processes = wmic();
  394. if ($processes === false) {
  395. break;
  396. }
  397. foreach ($childs as $pid) {
  398. if (in_array($pid, $processes)) {
  399. continue;
  400. }
  401. else {
  402. $key = array_search($pid, $childs);
  403. unset($childs[$key]);
  404. $wait_pids--;
  405. }
  406. echo str_pad("", 64) . "\n";
  407. ob_flush();
  408. flush();
  409. usleep(1000);
  410. continue;
  411. }
  412. echo str_pad("", 64) . "\n";
  413. ob_flush();
  414. flush();
  415. usleep(5000);
  416. continue;
  417. }
  418. $childs = array_values($childs);
  419. if ($debug_mode == "Y") {
  420. echo "Background processes: " . count($childs) . "<br>";
  421. ob_flush();
  422. flush();
  423. }
  424. }
  425. }
  426. }
  427. if ($OS == "LINUX") {
  428. ............................................................
  429. .............................
  430. .......
Advertisement
Add Comment
Please, Sign In to add comment