save if name only
This commit is contained in:
parent
0c72ceb620
commit
e423273752
@ -10,7 +10,7 @@ $tempoRegex = '/^\d+[smh]?$/';
|
||||
$fileNameRegex = '/^[^<>:\/|?]+$/';
|
||||
|
||||
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
|
||||
$preset = filter_input(INPUT_GET, "preset");
|
||||
$preset = filter_input(INPUT_GET, "preset", FILTER_SANITIZE_STRING);
|
||||
|
||||
if ($preset && isset($presets[$preset])) {
|
||||
$options = $presets[$preset];
|
||||
@ -116,6 +116,9 @@ if ($preset && isset($presets[$preset])) {
|
||||
], false) ?: $presets["default"];
|
||||
}
|
||||
|
||||
$options["--datadir"] = $DATADIR;
|
||||
$options["--script-args-file"] = $SCRIPTARGS;
|
||||
|
||||
/*echo "<!--";
|
||||
var_dump($options);
|
||||
echo "-->\n";*/
|
24
index.php
24
index.php
@ -641,23 +641,17 @@ foreach (scandir($SCANSDIR) as $filename) {
|
||||
<button type="submit" class="ui teal submit button">Démarrer</button>
|
||||
</form>
|
||||
|
||||
<h2 class="ui header">Derniers scans</h2>
|
||||
<div class="ui relaxed list">
|
||||
<?php
|
||||
if (!file_exists($SCANSDIR)) {
|
||||
mkdir($SCANSDIR);
|
||||
}
|
||||
$scans = [];
|
||||
foreach (scandir($SCANSDIR) as $filename) {
|
||||
if (substr($filename, -4) == '.xml') {
|
||||
$scans[$filename] = filemtime("$SCANSDIR/$filename");
|
||||
<h2 class="ui header">Scans enregistrés</h2>
|
||||
<div class="ui link list">
|
||||
<?php
|
||||
if (file_exists($SCANSDIR)) {
|
||||
foreach (scandir($SCANSDIR) as $filename) {
|
||||
if (substr($filename, -4) == '.xml') {
|
||||
$name = str_replace('!', '/', substr_replace($filename, '', -4));
|
||||
echo "<a class='item' href='$SCANSDIR/".rawurlencode($filename)."'>$name</a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
arsort($scans);
|
||||
foreach ($scans as $filename => $date) {
|
||||
$name = str_replace('!', '/', substr_replace($filename, '', -4));
|
||||
echo " <div class='item'><a class='header' href='$SCANSDIR/".rawurlencode($filename)."'>$name</a><div class='description'>".date(DATE_RFC7231, $date)."</div></div>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</main>
|
||||
|
14
scan.php
14
scan.php
@ -3,14 +3,10 @@
|
||||
include_once 'config.php';
|
||||
include_once 'filter_inputs.php';
|
||||
|
||||
$options["--datadir"] = $DATADIR;
|
||||
$options["--script-args-file"] = $SCRIPTARGS;
|
||||
|
||||
if (!file_exists($SCANSDIR)) mkdir($SCANSDIR);
|
||||
|
||||
if (!$options["name"]) $options["name"] = str_replace('/', '!', $targets);
|
||||
|
||||
//$command = ($options["sudo"]?? false ? "sudo " : "") . "nmap";
|
||||
$args = "";
|
||||
foreach ($options as $option => $value) {
|
||||
if (substr($option, 0, 1) == '-') {
|
||||
@ -30,9 +26,15 @@ foreach ($options as $option => $value) {
|
||||
}
|
||||
}
|
||||
|
||||
$path = "$SCANSDIR/{$options["name"]}.xml";
|
||||
|
||||
$command = "nmap $args -oX - $targets | tee '$path'";
|
||||
$command = "nmap $args -oX - $targets";
|
||||
|
||||
if (isset($options["sudo"])) $command = "sudo $command";
|
||||
|
||||
if (isset($options["name"])) {
|
||||
$path = "$SCANSDIR/{$options["name"]}.xml";
|
||||
$command .= " | tee '$path'"
|
||||
}
|
||||
|
||||
header('Content-type: text/xml');
|
||||
system($command, $retcode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user