Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. <?php
  2. //$cookiefile = "ck_".rand(1,10).(time()/3600); uncomment to run parallel threads
  3. $username = "adminpanel";
  4. $password = "ay7agayakos";
  5. $cookiefile = "ck_cookiefile";
  6. $inputfile = "input.txt";
  7. $output = "output.txt";
  8. $fh = fopen($cookiefile, 'w') or die("Permission error: couldn't generate the cookie file. The directory should be writable.");
  9. $useragents = array(
  10. "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36",
  11. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1",
  12. "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
  13. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
  14. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36",
  15. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36",
  16. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2"
  17. );
  18. $useragent = $useragents[array_rand($useragents)];
  19.  
  20. function refreshcookie()
  21. {
  22. global $cookiefile;
  23. $f = @fopen($cookiefile, "r+");
  24. if ($f !== false) {
  25. ftruncate($f, 0);
  26. fclose($f);
  27. }
  28. }
  29. function msgdump($msg)
  30. {
  31. global $output;
  32. echo $msg;
  33. file_put_contents($output, $msg, FILE_APPEND);
  34. }
  35. function curl($url)
  36. {
  37. global $useragent;
  38. global $cookiefile;
  39. $ch = curl_init();
  40. curl_setopt($ch, CURLOPT_URL, $url);
  41. curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
  42. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
  43. curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
  44. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  45. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  46. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47. $result = curl_exec ($ch);
  48. curl_close($ch);
  49. return $result;
  50. }
  51. $result = curl("https://account.shodan.io/login?username=".$username."&password=".$password."&grant_type=password&continue=https%3A%2F%2Faccount.shodan.io%2F&login_submit=Log+in");
  52. if (strpos($result, "Invalid username or password") === false)
  53. {
  54. $handle = @fopen($inputfile, "r");
  55. if ($handle)
  56. {
  57. while (($line = fgets($handle)) !== false)
  58. {
  59. $line = str_replace(PHP_EOL, "", $line);
  60. msgdump("\r\n --- BEGIN SEARCH FOR: ".$line." --- \r\n");
  61. $page = 1;
  62. while ($page < 3000)
  63. {
  64. $result = curl('https://www.shodan.io/search?query='.urlencode($line).'&page='.$page);
  65. if (strpos($result, "Result limit reached") === false) {
  66. preg_match_all('/a href=\"\/host(.*?)\"/', $result , $matches);
  67. msgdump ("\r\n".implode("\r\n", str_replace('a href=/host/', '', str_replace('"', '', $matches[0]))));
  68. $page++;
  69. }
  70. else
  71. {
  72. break;
  73. }
  74. }
  75. msgdump("\r\n --- END SEARCH FOR: ".$line." --- \r\n");
  76. }
  77. }
  78. }
  79. else
  80. {
  81. echo "Couldn't login: Invalid username or password.";
  82. exit();
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement