Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //$cookiefile = "ck_".rand(1,10).(time()/3600); uncomment to run parallel threads
- $username = "adminpanel";
- $password = "ay7agayakos";
- $cookiefile = "ck_cookiefile";
- $inputfile = "input.txt";
- $output = "output.txt";
- $fh = fopen($cookiefile, 'w') or die("Permission error: couldn't generate the cookie file. The directory should be writable.");
- $useragents = array(
- "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36",
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1",
- "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
- "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
- "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",
- "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",
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2"
- );
- $useragent = $useragents[array_rand($useragents)];
- function refreshcookie()
- {
- global $cookiefile;
- $f = @fopen($cookiefile, "r+");
- if ($f !== false) {
- ftruncate($f, 0);
- fclose($f);
- }
- }
- function msgdump($msg)
- {
- global $output;
- echo $msg;
- file_put_contents($output, $msg, FILE_APPEND);
- }
- function curl($url)
- {
- global $useragent;
- global $cookiefile;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
- curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
- curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $result = curl_exec ($ch);
- curl_close($ch);
- return $result;
- }
- $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");
- if (strpos($result, "Invalid username or password") === false)
- {
- $handle = @fopen($inputfile, "r");
- if ($handle)
- {
- while (($line = fgets($handle)) !== false)
- {
- $line = str_replace(PHP_EOL, "", $line);
- msgdump("\r\n --- BEGIN SEARCH FOR: ".$line." --- \r\n");
- $page = 1;
- while ($page < 3000)
- {
- $result = curl('https://www.shodan.io/search?query='.urlencode($line).'&page='.$page);
- if (strpos($result, "Result limit reached") === false) {
- preg_match_all('/a href=\"\/host(.*?)\"/', $result , $matches);
- msgdump ("\r\n".implode("\r\n", str_replace('a href=/host/', '', str_replace('"', '', $matches[0]))));
- $page++;
- }
- else
- {
- break;
- }
- }
- msgdump("\r\n --- END SEARCH FOR: ".$line." --- \r\n");
- }
- }
- }
- else
- {
- echo "Couldn't login: Invalid username or password.";
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement