Merhaba dostlarım,
bugün ddos atacağınız sitede kolayca ddos koruması olup olmadığını kontrol edebileceğiniz bir api yazdım.
işte api :
Kaynak Kodu :
konuyu beğenip yorum yaparsanız çok sevinirim. hayırlı günler
bugün ddos atacağınız sitede kolayca ddos koruması olup olmadığını kontrol edebileceğiniz bir api yazdım.
işte api :
Kaynak Kodu :
PHP:
<?php
header('Content-Type: application/json');
function get_http_headers_and_body($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers_raw = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($ch);
$headers = [];
foreach (explode("\r\n", $headers_raw) as $line) {
if (strpos($line, ":") !== false) {
list($k, $v) = explode(":", $line, 2);
$headers[trim($k)] = trim($v);
}
}
return [$headers, $body];
}
function get_asn_and_country($ip) {
$json = @file_get_contents("https://ipapi.co/{$ip}/json/");
if (!$json) return null;
return json_decode($json, true);
}
function get_dns_records($domain) {
return [
"A" => dns_get_record($domain, DNS_A),
"CNAME" => dns_get_record($domain, DNS_CNAME),
"NS" => dns_get_record($domain, DNS_NS),
];
}
function detect_ddos_in_body($body) {
$patterns = [
'Checking your browser before accessing',
'DDoS protection by Cloudflare',
'Please wait while we check your browser',
'Verifying your browser',
'DDoS-Guard',
'Sucuri Website Firewall - Access Denied',
'Incapsula incident ID'
];
foreach ($patterns as $pattern) {
if (stripos($body, $pattern) !== false) {
return $pattern;
}
}
return false;
}
if (!isset($_GET['domain'])) {
echo json_encode(["error" => "Lütfen ?domain=example.com parametresini girin."]);
exit;
}
$domain = $_GET['domain'];
if (!preg_match("/^https?:\/\//", $domain)) {
$domain = "http://$domain";
}
$host = parse_url($domain, PHP_URL_HOST);
$ip = gethostbyname($host);
$rdns = @gethostbyaddr($ip);
$asn_info = get_asn_and_country($ip);
$dns_records = get_dns_records($host);
list($headers, $body) = get_http_headers_and_body($domain);
$server_header = $headers['Server'] ?? 'Bilinmiyor';
$cdn_providers = ['cloudflare', 'ddos-guard', 'sucuri', 'incapsula', 'akamai', 'fastly', 'imperva', 'stackpath'];
$ddos_detected = false;
$detected_provider = [];
foreach ($cdn_providers as $provider) {
if (stripos($server_header, $provider) !== false || stripos($rdns, $provider) !== false) {
$ddos_detected = true;
$detected_provider[] = ucfirst($provider);
}
}
foreach ($headers as $key => $value) {
if (preg_match('/^(cf-|x-sucuri|x-ddos|x-cdn|x-iinfo|x-akamai|x-imperva)/i', $key)) {
$ddos_detected = true;
$detected_provider[] = $key;
}
}
$body_detection = detect_ddos_in_body($body);
if ($body_detection) {
$ddos_detected = true;
$detected_provider[] = $body_detection;
}
$response = [
"domain" => $host,
"ip" => $ip,
"rdns" => $rdns ?: "Yok",
"server_header" => $server_header,
"asn_org" => $asn_info['org'] ?? 'Bilinmiyor',
"country" => $asn_info['country_name'] ?? 'Bilinmiyor',
"dns_records" => $dns_records,
"ddos_protection_detected" => $ddos_detected,
"detected_providers" => array_unique($detected_provider),
];
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
konuyu beğenip yorum yaparsanız çok sevinirim. hayırlı günler
Son düzenleme:


