Может, кому пригодиться. Автоматический скан сайтов Google SafeBrowsing v4 через API гугла
Код устанавливается на домен и редиректит юзера на чистый домен перед этим просканировав его через API.
Чекер пропускает паленный домен выбирает чистый и перекидывает туда юзера.
Код устанавливается на домен и редиректит юзера на чистый домен перед этим просканировав его через API.
Чекер пропускает паленный домен выбирает чистый и перекидывает туда юзера.
PHP:
<?php
function Lookup_GoogleSafeBrowsing_v4($url)
{
$data = '{
"client": {
"clientId": "Parse",
"clientVersion": "1.0"
},
"threatInfo": {
"threatTypes": ["MALWARE"],
"platformTypes": ["ALL_PLATFORMS"],
"threatEntryTypes": ["URL"],
"threatEntries": [
{"url": "'.$url.'"}
]
}
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://safebrowsing.googleapis.com/v4/threatMatches:find?key=AIzaSyCdg4Wuk0oTP2Cmznm3_68BMH_4kaYivKQ");
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", 'Content-Length: ' . strlen($data)));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = (array) json_decode(curl_exec($ch), true);
if($response == "Array"){return false;}
curl_close ($ch);
return ($response['matches'][0]['threatType']) ? true : false;
}
$a = array("http://malware.testing.google.test/testing/malware/","http://vk.com/", "http://yandex.ru/", "http://www.gumblar.cn/test/123");
foreach ($a as $v) {
if(!Lookup_GoogleSafeBrowsing_v4($v)){header('Location: '.$v);}
}
?>