'shodan_username',
'password' => 'shodan_password',
'grant_type' => 'password',
'continue' => 'https://account.shodan.io/',
'login_submit' => 'Log+in'
);
fetchUrl('https://account.shodan.io/login', $loginArgs);
$summary = fetchUrl("https://www.shodan.io/search/_summary?query=$query");
preg_match_all('/
.*<\/a>.*/', $pageData, $matches);
if(count($matches[1]) == 0)
{
break;
}
foreach($matches[1] as $match)
{
$return[$country][] = $match;
}
}
if(count($matches[1]) == 0)
{
break;
}
}
echo serialize($return);
// FetchUrl Function
function fetchUrl($url, $data = '', $referer = '')
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_COOKIEJAR, __DIR__ . '/cookie');
curl_setopt($ch, CURLOPT_COOKIEFILE, __DIR__ . '/cookie');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if(is_array($data))
{
$fields = '';
foreach($data as $key => $value)
{
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}