traceroute

This commit is contained in:
2025-02-04 22:57:44 +01:00
parent c2268c4f00
commit 55f6be594a
4 changed files with 73 additions and 79 deletions

View File

@ -7,33 +7,13 @@ $targetsListRegex = '/^[\da-zA-Z-. \/]+$/';
$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
if ($lan) {
$cmd = "$NMAP $LANSCANOPTIONS $lan";
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
$filename = str_replace("/", "!", $lan);
$path = "$SCANSDIR/$filename.xml";
if (!file_exists($path)) $cmd .= " | tee '$path'";
header('Content-type: text/xml');
system("$cmd", $retcode);
exit();
}
$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
if ($host) {
$cmd = "$NMAP $HOSTSCANOPTIONS $host";
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
$filename = str_replace("/", "!", $host);
$path = "$SCANSDIR/$filename.xml";
if (!file_exists($path)) $cmd .= " | tee '$path'";
header('Content-type: text/xml');
system("$cmd", $retcode);
exit();
}
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
@ -173,10 +153,11 @@ if ($targets) {
}
$cmd = "$NMAP$options $targets";
echo "<!--$cmd-->\n";
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
$filename = str_replace("/", "!", $targets);
}
if ($cmd) {
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
$path = "$SCANSDIR/$filename.xml";
if (!file_exists($path)) $cmd .= " | tee '$path'";