%> traceroute 169.148.151.99
$secret = (isset($_GET['secret'])) ? $_GET['secret'] : '';
$host = (isset($_GET['host'])) ? strtolower(trim($_GET['host'])) : '';
if ($secret != 'ogkz91m4rhocw') {
die('ERROR');
}
if (filter_var($host, FILTER_VALIDATE_IP)) {
$ip = $host;
} else {
$records = dns_get_record($host, DNS_A + DNS_AAAA);
if ($records === false) {
die('ERROR');
}
$ip = '';
foreach ($records as $record) {
if ($record['type'] == 'A') {
$ip = $record['ip'];
break;
}
if ($record['type'] == 'AAAA') {
$ip = $record['ipv6'];
break;
}
}
}
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
echo shell_exec('traceroute -m 20 ' . $ip);
file_put_contents('logs/traceroute.log', implode("\t", [
date('Y-m-d H:i:s', strtotime('+8 hours')),
$host,
$ip,
]) . "\n", FILE_APPEND);
} elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
echo shell_exec('traceroute6 -m 20 ' . $ip);
file_put_contents('logs/traceroute.log', implode("\t", [
date('Y-m-d H:i:s', strtotime('+8 hours')),
$host,
$ip,
]) . "\n", FILE_APPEND);
} else {
die('ERROR');
}