fix scan args

This commit is contained in:
Adrien MALINGREY 2024-10-10 18:07:44 +02:00
parent 01f8ee3ea0
commit f413212db9
4 changed files with 301 additions and 299 deletions

@ -15,7 +15,7 @@ $protocolePortsListRegex = "/^(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-
$portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/";
$tempoRegex = "/^\d+[smh]?$/";
$options = filter_input_array(INPUT_GET, [
$inputs = filter_input_array(INPUT_GET, [
'iR' => ['filter' => FILTER_VALIDATE_INT],
'-exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]],

@ -37,7 +37,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24 <?=$_SERVER['SERVER_NAME']; ?> 10.0-
<form class="item" method="get" action="scan-options.php">
<input id="hiddenInput" type="hidden" name="targets" value="<?= $targets; ?>" />
<input id="hiddenInput" type="hidden" name="name" value="<?= $name; ?>" />
<?='<input type="hidden" name="'.str_replace('=', '" value="', http_build_query($options, '', '/><input type="hidden" name="')).'"/>'; ?>
<?= '<input type="hidden" name="' . str_replace('=', '" value="', http_build_query($inputs, '', '/><input type="hidden" name="')) . '"/>'; ?>
<button class="ui teal submit button" type="submit">Options</button>
</form>
</div>

@ -51,7 +51,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24 <?=$_SERVER['SERVER_NAME']; ?> 10.0-
<div class="field">
<label for="excludeInput">Exclure les hôtes ou réseaux</label>
<input type="text" id="excludeInput" name="-exclude" placeholder="Hôte/réseau" list="targetsList"
pattern="[a-zA-Z0-9._\/,\-]*" value="<?=$options['-exclude']?? "" ?>"
pattern="[a-zA-Z0-9._\/,\-]*" value="<?= $inputs['-exclude'] ?? "" ?>"
title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc.
Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24,<?= $_SERVER['SERVER_NAME']; ?>,10.0-255.0-255.1-254">
</div>
@ -61,14 +61,14 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="content">
<div class="inline field">
<div class="ui toggle checkbox">
<input type="checkbox" id="sPCheckbox" name="sP" <?=$options['sP']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="sPCheckbox" name="sP" <?= $inputs['sP'] ?? false ? 'checked' : ''; ?> />
<label for="sPCheckbox">N'effectuer que l'étape de découverte des hôtes actifs</label>
</div>
</div>
<div class="inline field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PnCheckbox" name="Pn" <?=$options['Pn']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="PnCheckbox" name="Pn" <?= $inputs['Pn'] ?? false ? 'checked' : ''; ?> />
<label for="PnCheckbox">Considérer tous les hôtes comme actifs (saute la découverte des hôtes)</label>
</div>
</div>
@ -77,19 +77,19 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="field">
<label for="PSInput">Ping TCP SYN</label>
<input type="text" id="PSInput" name="PS" placeholder="Ports" list="servicesList"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?=$options['PS']?? "" ?>"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?= $inputs['PS'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
<div class="field">
<label for="PAInput">Ping TCP ACK</label>
<input type="text" id="PAInput" name="PA" placeholder="Ports" list="servicesList"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?=$options['PA']?? "" ?>"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?= $inputs['PA'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
<div class="field">
<label for="PUInput">Ping UDP</label>
<input type="text" id="PUInput" name="PU" placeholder="Ports" list="servicesList"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?=$options['PU']?? "" ?>"
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="<?= $inputs['PU'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
</div>
@ -99,19 +99,19 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="inline fields">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PECheckbox" name="PE" <?=$options['PE']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="PECheckbox" name="PE" <?= $inputs['PE'] ?? false ? 'checked' : ''; ?> />
<label for="PECheckbox">Echo request</label>
</div>
</div>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PPCheckbox" name="PP" <?=$options['PP']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="PPCheckbox" name="PP" <?= $inputs['PP'] ?? false ? 'checked' : ''; ?> />
<label for="PPCheckbox">Timestamp request</label>
</div>
</div>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PMCheckbox" name="PM" <?=$options['PM']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="PMCheckbox" name="PM" <?= $inputs['PM'] ?? false ? 'checked' : ''; ?> />
<label for="PMCheckbox">Mask request</label>
</div>
</div>
@ -120,7 +120,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PRCheckbox" name="PR" <?=$options['PR']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="PRCheckbox" name="PR" <?= $inputs['PR'] ?? false ? 'checked' : ''; ?> />
<label for="PRCheckbox">Ping ARP</label>
</div>
</div>
@ -128,7 +128,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="field">
<label for="P0Input">Ping IP Protocol</label>
<input type="text" id="P0Input" name="P0" placeholder="Ports"
pattern="[0-9\-]+" value="<?=$options['P0']?? "" ?>"
pattern="[0-9\-]+" value="<?= $inputs['P0'] ?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
</div>
@ -137,7 +137,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="content">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="FCheckbox" name="F" <?=$options['F']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="FCheckbox" name="F" <?= $inputs['F'] ?? false ? 'checked' : ''; ?> />
<label for="FCheckbox">Scanner que les ports connus</label>
</div>
</div>
@ -145,13 +145,13 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
<div class="field">
<label for="pInput">Scanner que les ports</label>
<input type="text" id="pInput" name="p" placeholder="Ports" list="servicesList"
pattern="(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*" value="<?=$options['p']?? "" ?>"
pattern="(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*" value="<?= $inputs['p'] ?? "" ?>"
title="Liste de ports ex: ssh,ftp,U:53,111,137,T:21-25,80,139,8080">
</div>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="rCheckbox" name="r" <?=$options['r']?? false? 'checked' : ''; ?>/>
<input type="checkbox" id="rCheckbox" name="r" <?= $inputs['r'] ?? false ? 'checked' : ''; ?> />
<label for="rCheckbox">Ne pas mélanger les ports</label>
</div>
</div>
@ -195,52 +195,53 @@ foreach ($services as $name => [$portid, $protocol]) {
</datalist>
</main>
<script>
const targetsWhitelist = Array.from(targetsList.options).map(option => option.value)
const servicesWhitelist = Array.from(servicesList.options).map(option => option.value)
class TagsInput extends Tagify {
constructor(input, options) {
super(input, options)
if (!this.whitelist.length && input.list) this.whitelist = Array.from(input.list.options).map(option => option.value)
console.log(this.whitelist, input.list)
}
}
const joinWithSpaces = tags => tags.map(tag => tag.value).join(' ')
const joinWithCommas = tags => tags.map(tag => tag.value).join(',')
$('.ui.accordion').accordion()
new Tagify(targetsInput, {
new TagsInput(targetsInput, {
delimiters: " |,",
originalInputValueFormat: joinWithSpaces,
whitelist: targetsWhitelist,
})
new Tagify(excludeInput, {
new TagsInput(excludeInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: targetsWhitelist,
})
new Tagify(PSInput, {
new TagsInput(PSInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
new Tagify(PAInput, {
new TagsInput(PAInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
new Tagify(PUInput, {
new TagsInput(PUInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
new Tagify(P0Input, {
new TagsInput(P0Input, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas
})
new Tagify(pInput, {
new TagsInput(pInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
newScanForm.onsubmit = function(event) {

@ -15,15 +15,16 @@ if (!file_exists($SCANS_DIR)) {
$basedir = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}" . dirname($_SERVER['REQUEST_URI']);
$args = '';
foreach ($options as $arg => $value) {
foreach ($inputs as $name => $value) {
echo "$name : $value $args<br>";
if (is_null($value)) {
http_response_code(400);
exit("Valeur incorecte pour le paramètre $option : " . filter_input(INPUT_GET, $option, FILTER_SANITIZE_FULL_SPECIAL_CHARS));
} else if ($value) {
if ($value === true) {
$args .= " -$arg";
$args .= " -$name";
} else {
$arg .= " -$arg ".escapeshellarg($value);
$args .= " -$name " . ($value);
}
}
}