Jump to content
Aerosol

SHODAN TOOL V-0.6

Recommended Posts

A simple script to search on Shodan with the following options:

Shodan-Tool-300x293.jpg

Simple tool to search in Shodan

[+] Search Results for IP

[+] Search Results for quantity

[+] Normal Search

[+] List the saved query

[+] Search the saved query that were already searched

[+] Add popular tags

[+] List all services shodan located

[+] DNS Lookup

[+] Reverse DNS Lookup

[+] Return your IP

[+] It gives you information about your API

They must have an API Key yours to use API Shodan.

Download

GitHub

Link to comment
Share on other sites


<?php

function curl_connect($url)
{
$headers[] = "Accept: text/html";
$headers[] = "Connection: Keep-Alive";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //che poi includo tutto nella var $exec
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$exec = curl_exec($ch);
if($exec)
curl_close($ch);

if(preg_match("/200 ok/i", $exec))
return true;
else
return false;
}

function login_shodan($user, $pass)
{
$headers[] = "Accept: text/html";
$headers[] = "Connection: Keep-Alive";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://account.shodan.io/login");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, true);
//curl_setopt($ch, CURLOPT_REFERRER, "");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //che poi includo tutto nella var $exec
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"username={$user}&password={$pass}&continue=https://www.shodan.io/");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
$exec = curl_exec($ch);
if($exec)
curl_close($ch);

if(preg_match("/200 ok/i", $exec))
return true;
else
return false;

}

function shodan_search($val, $pag)
{
$headers[] = "Accept: text/html";
$headers[] = "Connection: Keep-Alive";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.shodan.io/search?query=". urlencode("port:25") . "&page=" . intval($pag));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; rv:2.2) Gecko/20110201");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //che poi includo tutto nella var $exec
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
$exec = curl_exec($ch);
if($exec)
curl_close($ch);
//print $exec;
//<div class="results-count">Showing results 1 - 10 of 18,046,644</div>
//<div class="ip"><a href="/host/12.155.204.131">12.155.204.131</a>
//<pre>220 MCG-EX01.McGeeGroup.local Microsoft ESMTP MAIL Service ready at Tue, 11 Nov 2014 02:42:44 -0500</pre>
//<div class="search-result-summary"><span>204.15.253.98.icertified.net</span><br/><a href="/search?query=port%3A25+org%3A%22Certified+Hosting%22" class="os">Certified Hosting</a>
//<div class="search-result-summary"><a href="/search?query=port%3A25+org%3A%22S.H.A.+Trans+SRL%22" class="os">S.H.A. Trans SRL</a>

if(preg_match_all("/<div class=\"results-count\"\>Showing results (.*)<\/div\\>/i", $exec, $matches))
//print_r($matches);
print "Risultati: " . $matches[1][0] . "\n";
if(preg_match_all("/<div class=\"ip\"><a href=\"(.*)\">(.*)<\/a>\n<\/div>\n<div class=\"search-result-summary\"><span>(.*)<\/span><br\/>/i", $exec, $matches))
{
///preg_match_all("/<div class=\"search-result-summary\"><span>(.*)<\/span><br\/>/i", $exec, $host);
print_r($matches);
$c = 0;
preg_match_all("/<div class=\"ip\"><a href=\"(.*)\">(.*)<\/a>\n<\/div>\n<div class=\"search-result-summary\"><a href/i", $exec, $without);
print_r($without);

//print_r($matches);
echo "Echo i 10 risultati della pagina {$pag}:\n";
echo "Scrivo su shodan-page-{$pag}\n";
//$fp = fopen("shodan-page-{$pag}", "a+");
//fwrite($fp, "Page {$pag}\n");
preg_match_all("/([^<]*)<\/pre>/i", $exec, $match_banners);
foreach($without[2] as $ip)
{
$c++;
print $ip . " - " . $match_banners[1] . "\n";
//fwrite($fp, $without[2][$i] . " - " . $match_banners[1][$i] . "\n");
}
//fclose($fp);
echo "Scritti {$c} Dati\n";
//print_r($match_banners);

}
unlink("cookie.txt");
}

if(curl_connect("https://www.shodan.io"))
{
echo "Connesso a https://www.shodan.io\n";
echo "Login in corso...\n";
if(login_shodan("USER", "PASS"))
{
echo "Loggato con user USER\n";
echo "Ora cerco " . $argv[1] . "\n";
shodan_search($argv[1], $argv[2]);
} else{
echo "Errore Log In\n";
}


} else {
echo "Errore di connessione alla homepage di shodan.io";
}


?>

Mie imi place mai mult sa stau din terminal decat aplicatii Desktop, am facut asta pentru mine ceva timp in urma ca eu stau aproape non stop pe shodan si scanhub. API ce pun ei la dispozitie nu imi place cum lucreaza si asa ca miam facut eu scriptul asta pentru cautare si organizare a rezultatelor, poate ajuta pe cineva. :DDD

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...