Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.68 KB | None | 0 0
  1. <?php
  2.  
  3. function sid($length) {
  4. $seeds = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  5. $chars = null;
  6. $seeds_count = strlen($seeds) - 1;
  7. $i = 0;
  8. if ($i < $length) {
  9. $chars .= $seeds[rand(0, $seeds_count)];
  10. ++$i;
  11. continue;
  12. }
  13. return $chars;
  14. }
  15.  
  16. function cmp($a, $b) {
  17. if ($a == $b) {
  18. return 0;
  19. }
  20. return $a < $b ? -1 : 1;
  21. }
  22.  
  23. function verify_tables() {
  24. global $mainTable;
  25. global $requiredTables;
  26. $db = null;
  27. require "./connect.php";
  28. $query = "SHOW TABLES FROM " . $db . ";";
  29. $result = mysql_query($query);
  30. if (!$result) {
  31. return false;
  32. }
  33. $tables = (array());
  34. while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
  35. $tables[] = $row[0];
  36. continue;
  37. }
  38. foreach ($requiredTables as $r) {
  39. if (!in_array($r, $tables)) {
  40. return false;
  41. }
  42. continue;
  43. }
  44. return true;
  45. }
  46.  
  47. function insert_query($table, $array) {
  48. $query = "" . "INSERT INTO " . $table . " ";
  49. $fieldnamelist = null;
  50. $fieldvaluelist = null;
  51. foreach ($array as $key => $value) {
  52. $fieldnamelist .= "" . "`" . $key . "`,";
  53. if ($value == "now()") {
  54. $fieldvaluelist .= "now(),";
  55. continue;
  56. }
  57. else {
  58. $fieldvaluelist .= "'" . $value . "',";
  59. continue;
  60. }
  61. continue;
  62. }
  63. $fieldnamelist = substr($fieldnamelist, 0, 0 - 1);
  64. $fieldvaluelist = substr($fieldvaluelist, 0, 0 - 1);
  65. $query .= "" . "(" . $fieldnamelist . ") VALUES (" . $fieldvaluelist . ")";
  66. $result = mysql_query($query);
  67. $mysql_errno = mysql_errno();
  68. $mysql_error = mysql_error();
  69. $rows = mysql_affected_rows();
  70. $mysql_query = (array());
  71. if (!$result) {
  72. $mysql_query["errno"] = $mysql_errno;
  73. $mysql_query["error"] = $mysql_error;
  74. }
  75. $mysql_query["rows"] = $rows;
  76. return $mysql_query;
  77. }
  78.  
  79. function ports() {
  80. $port_scan = preg_replace("/\\s{2,}/", " ", PORTS);
  81. $port_scan = explode(" ", $port_scan);
  82. $port_scan = remove_array_empty_values($port_scan);
  83. $ports = (array());
  84. foreach ($port_scan as $port) {
  85. if (valid_port($port)) {
  86. $ports[] = $port;
  87. }
  88. else {
  89. $tmp = explode("-", $port);
  90. $start = $tmp[0];
  91. $end = $tmp[1];
  92. if (valid_port($start) && valid_port($end)) {
  93. if ($end <= $start || $start == $end) {
  94. exit("[-] Invalid port range: " . $port . "\n");
  95. }
  96. $i = $start;
  97. while ($i <= $end) {
  98. $i++;
  99. continue;
  100. $ports[] = $i;
  101. continue;
  102. }
  103. }
  104. else {
  105. exit("[-] Invalid port range: " . $port . "\n");
  106. }
  107. }
  108. continue;
  109. }
  110. return $ports;
  111. }
  112.  
  113. function ports_random() {
  114. $port_range = preg_replace("/\\s{1,}/", "", PORT_RANGE);
  115. $numberOfPorts = NUMBER_OF_PORTS;
  116. if (!is_numeric($numberOfPorts) || !valid_port($numberOfPorts)) {
  117. exit("[-] NUMBER_OF_PORTS is not numeric \n");
  118. }
  119. $ports = (array());
  120. $tmp = explode("-", $port_range);
  121. $start = $tmp[0];
  122. $end = $tmp[1];
  123. if (valid_port($start) && valid_port($end)) {
  124. if ($end <= $start || $start == $end) {
  125. exit("[-] Invalid port range: " . $port_range . "\n");
  126. }
  127. $count = $end - $start;
  128. if ($count < $numberOfPorts) {
  129. exit("[-] There are not enough ports in your port range: " . $port_range . "\n");
  130. }
  131. $myPorts = 0;
  132. if ($myPorts < $numberOfPorts) {
  133. $port = rand($start, $end);
  134. if (!isset($ports[$port])) {
  135. $ports[$port] = $myPorts;
  136. $myPorts++;
  137. }
  138. continue;
  139. }
  140. }
  141. else {
  142. exit("[-] Invalid port range: " . $port_range . "\n");
  143. }
  144. $ports = array_flip($ports);
  145. usort(&$ports, "cmp");
  146. return $ports;
  147. }
  148.  
  149. function multi_thread($proxies) {
  150. global $async_connect_timeout;
  151. global $debug_mode;
  152. $status = (array());
  153. $sockets = (array());
  154. $sub_process = (array());
  155. if (!is_array($proxies) || count($proxies) < 1) {
  156. return false;
  157. }
  158. $id = 0;
  159. foreach ($proxies as $id => $proxy) {
  160. $tmp = explode(":", $proxy);
  161. $s = non_blocking_connect($tmp[0], $tmp[1], $errno = "", $errstr = "", $async_connect_timeout);
  162. if ($s) {
  163. $sockets[$id] = $s;
  164. }
  165. continue;
  166. }
  167. if (count($sockets)) {
  168. $read = $write = $sockets;
  169. $n = socket_select($read = null, $write, $_e = null, 0, $async_connect_timeout);
  170. if ($n === false) {
  171. break;
  172. }
  173. if (0 < $n) {
  174. if ($debug_mode == "Y") {
  175. foreach ($write as $w) {
  176. $id = array_search($w, $sockets);
  177. socket_set_option($w, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => 0));
  178. $send = socket_write($w, "", 1);
  179. if ($send === false) {
  180. $errno = socket_last_error($w);
  181. $errstr = socket_strerror($errno);
  182. $status[$id] = "[" . $errno . "] " . $errstr;
  183. }
  184. else {
  185. $status[$id] = "OK";
  186. }
  187. socket_close($w);
  188. unset($sockets[$id]);
  189. continue;
  190. }
  191. }
  192. else {
  193. foreach ($write as $w) {
  194. $id = array_search($w, $sockets);
  195. socket_set_option($w, SOL_SOCKET, SO_SNDTIMEO, array("sec" => 0, "usec" => 0));
  196. $send = socket_write($w, "", 1);
  197. if ($send === false) {
  198. $errno = socket_last_error($w);
  199. $errstr = socket_strerror($errno);
  200. $status[$id] = "[" . $errno . "] " . $errstr;
  201. }
  202. else {
  203. $sub_process[] = $proxies[$id];
  204. }
  205. socket_close($w);
  206. unset($sockets[$id]);
  207. continue;
  208. }
  209. }
  210. }
  211. else {
  212. if ($debug_mode == "Y") {
  213. $id = 0;
  214. foreach ($sockets as $id => $s) {
  215. $status[$id] = "timed out";
  216. continue;
  217. }
  218. }
  219. break;
  220. }
  221. continue;
  222. }
  223. $id = 0;
  224. if ($debug_mode == "Y") {
  225. foreach ($proxies as $id => $proxy) {
  226. echo "connect() " . $proxy . " " . $status[$id] . "\n";
  227. if ($status[$id] == "OK") {
  228. $sub_process[] = $proxy;
  229. }
  230. continue;
  231. }
  232. }
  233. return $sub_process;
  234. }
  235.  
  236. function test_proxy($proxy) {
  237. global $ip_country;
  238. global $connect_timeout;
  239. global $timeout;
  240. global $retries;
  241. global $g_ipaddr;
  242. global $mainTable;
  243. global $smtp_ipaddr;
  244. global $dest_addr;
  245. global $dest_port;
  246. global $url;
  247. global $protocol;
  248. global $connect;
  249. global $smtp;
  250. global $proxy_dns;
  251. global $resolve_hostnames;
  252. global $test_against_google;
  253. global $proxy_database;
  254. global $mark_exclusive;
  255. global $check_listed_public;
  256. global $keep_only_anonymous_proxies;
  257. global $keep_only_custom_site_passed;
  258. global $check_database_proxies;
  259. global $proxyData;
  260. global $scan_mode;
  261. global $custom_site_passed;
  262. global $proxies_txt;
  263. global $proxies_csv;
  264. $tmp = explode(":", $proxy);
  265. $ipaddr = $tmp[0];
  266. $port = $tmp[1];
  267. switch ($protocol) {
  268. case "HTTP": {
  269. $results = http_request($ipaddr, $port, $url);
  270. break;
  271. }
  272. case "SOCKS4": {
  273. $socks4 = socks4_request($ipaddr, $port, $dest_addr, $dest_port);
  274. if (is_array($socks4)) {
  275. $results = $socks4;
  276. if ($connect == "Y") {
  277. $res = socks4_request($ipaddr, $port, $g_ipaddr, 443);
  278. if (is_array($res)) {
  279. $results["connect"] = "Y";
  280. }
  281. }
  282. if ($smtp == "Y") {
  283. $res = socks4_request($ipaddr, $port, $smtp_ipaddr, 25);
  284. if (is_array($res)) {
  285. $results["smtp"] = "Y";
  286. }
  287. }
  288. }
  289. break;
  290. }
  291. case "SOCKS5": {
  292. $socks5 = socks5_request($ipaddr, $port, $dest_addr, $dest_port, "connect");
  293. if (is_array($socks5)) {
  294. $results = $socks5;
  295. if ($connect == "Y") {
  296. $res = socks5_request($ipaddr, $port, $g_ipaddr, 443, "connect");
  297. if (is_array($res)) {
  298. $results["connect"] = "Y";
  299. }
  300. }
  301. if ($smtp == "Y") {
  302. $res = socks5_request($ipaddr, $port, $smtp_ipaddr, 25, "connect");
  303. if (is_array($res)) {
  304. $results["smtp"] = "Y";
  305. }
  306. }
  307. if ($proxy_dns == "Y") {
  308. $res = socks5_request($ipaddr, $port, $dest_addr, $dest_port, "proxydns");
  309. if (is_array($res)) {
  310. $results["proxydns"] = "Y";
  311. }
  312. }
  313. }
  314. break;
  315. }
  316. case "SOCKS-AUTO": {
  317. $socks4 = socks4_request($ipaddr, $port, $dest_addr, $dest_port);
  318. if (is_array($socks4)) {
  319. $results = $socks4;
  320. $connect_time = $results["connect_time"];
  321. if ($connect == "Y") {
  322. $res = socks4_request($ipaddr, $port, $g_ipaddr, 443);
  323. if (is_array($res)) {
  324. $results["connect"] = "Y";
  325. }
  326. }
  327. if ($smtp == "Y") {
  328. $res = socks4_request($ipaddr, $port, $smtp_ipaddr, 25);
  329. if (is_array($res)) {
  330. $results["smtp"] = "Y";
  331. }
  332. }
  333. }
  334. $socks5 = socks5_request($ipaddr, $port, $dest_addr, $dest_port, "connect");
  335. if (is_array($socks5)) {
  336. $results = $socks5;
  337. if ($connect == "Y") {
  338. $res = socks5_request($ipaddr, $port, $g_ipaddr, 443, "connect");
  339. if (is_array($res)) {
  340. $results["connect"] = "Y";
  341. }
  342. }
  343. if ($smtp == "Y") {
  344. $res = socks5_request($ipaddr, $port, $smtp_ipaddr, 25, "connect");
  345. if (is_array($res)) {
  346. $results["smtp"] = "Y";
  347. }
  348. }
  349. if ($proxy_dns == "Y") {
  350. $res = socks5_request($ipaddr, $port, $dest_addr, $dest_port, "proxydns");
  351. if (is_array($res)) {
  352. $results["proxydns"] = "Y";
  353. }
  354. }
  355. }
  356. if (is_array($socks4) && is_array($socks5)) {
  357. $results["proxy_type"] = "SOCKS 4/5";
  358. }
  359. break;
  360. }
  361. default: {
  362. $results = http_request($ipaddr, $port, $url);
  363. if (is_array($results)) {
  364. else ;
  365. }
  366. $socks4 = socks4_request($ipaddr, $port, $dest_addr, $dest_port);
  367. if (is_array($socks4)) {
  368. $results = $socks4;
  369. if ($connect == "Y") {
  370. $res = socks4_request($ipaddr, $port, $g_ipaddr, 443);
  371. if (is_array($res)) {
  372. $results["connect"] = "Y";
  373. }
  374. }
  375. if ($smtp == "Y") {
  376. $res = socks4_request($ipaddr, $port, $smtp_ipaddr, 25);
  377. if (is_array($res)) {
  378. $results["smtp"] = "Y";
  379. }
  380. }
  381. }
  382. $socks5 = socks5_request($ipaddr, $port, $dest_addr, $dest_port, "connect");
  383. if (is_array($socks5)) {
  384. $results = $socks5;
  385. .................................................................
  386. .............................
  387. ........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement