save if name only
This commit is contained in:
		| @ -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";*/ | ||||
							
								
								
									
										18
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								index.php
									
									
									
									
									
								
							| @ -641,22 +641,16 @@ 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"> | ||||
|     <h2 class="ui header">Scans enregistrés</h2> | ||||
|       <div class="ui link list"> | ||||
|       <?php | ||||
| if (!file_exists($SCANSDIR)) { | ||||
|   mkdir($SCANSDIR); | ||||
| } | ||||
| $scans = []; | ||||
| if (file_exists($SCANSDIR)) { | ||||
|   foreach (scandir($SCANSDIR) as $filename) { | ||||
|     if (substr($filename, -4) == '.xml') { | ||||
|     $scans[$filename] = filemtime("$SCANSDIR/$filename"); | ||||
|   } | ||||
| } | ||||
| 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"; | ||||
|       echo "<a class='item' href='$SCANSDIR/".rawurlencode($filename)."'>$name</a>\n"; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| ?> | ||||
|     </div> | ||||
|  | ||||
							
								
								
									
										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); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user