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