This commit is contained in:
2024-10-10 02:07:00 +02:00
parent 3c9978569b
commit bcb63b3d0f
3 changed files with 183 additions and 205 deletions

View File

@ -22,14 +22,15 @@ include_once 'filter_inputs.php';
<body>
<nav class="ui inverted teal fixed menu">
<a class="header item" href=".">
lan
<?php include 'logo.svg'; ?>can
lan<?php include 'logo.svg'; ?>can
</a>
</nav>
<main class="ui main container">
<h1 class="header">Scanner un réseau avec Nmap</h1>
<form id="newScanForm" class="ui form" method="get" action="scan.php">
<h1 class="header">Scanner un réseau avec Nmap</h1>
<!--<div class="field">
<label for="nameInput">Nom</label>
<input id="nameInput" type="text" name="name" placeholder="Réseau local" pattern='[^&lt;&gt;:&quot;\\\/\|@?]+'
@ -38,8 +39,8 @@ include_once 'filter_inputs.php';
</div>-->
<div class="required field">
<label for="targetsInput">Cibles</label>
<input id="targetsInput" type="text" name="targets" placeholder="Cibles" required=""
pattern="[a-zA-Z0-9._\/ \-]+" value="<?= htmlspecialchars($targets); ?>" list="targetsList"
<input id="targetsInput" type="text" name="targets" placeholder="Cibles" required
pattern="[a-zA-Z0-9._\/ \-]+" value="<?= $targets; ?>" list="targetsList"
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>
@ -48,117 +49,109 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24 <?=$_SERVER['SERVER_NAME']; ?> 10.0-
<div class="title"><i class="icon dropdown"></i>Spécification des cibles</div>
<div class="content">
<div class="field">
<label class="inline field">
<div class="ui checkbox">
<input type="checkbox" id="excludeCheckbox" onchange="excludeInput.disabled = !this.checked"/>
<label for="excludeCheckbox">Exclure les hôtes ou réseaux</label>
</div>
</label>
<input type="text" id="excludeInput" name="--exclude" placeholder="Hôte/réseau" list="targetsList" disabled
pattern="[a-zA-Z0-9._\/,\-]*" value=""
<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']?? "" ?>"
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>
</div>
<div class="title"><i class="icon dropdown"></i>Découverte des hôtes</div>
<div class="title"><i class="icon dropdown"></i>Découverte des hôtes actifs</div>
<div class="content">
<div class="inline field">
<div class="ui checkbox">
<input type="checkbox" id="sPCheckbox" name="-sP"/>
<label for="sPCheckbox">N'effectuer que la découverte des hôtes actifs</label>
<div class="ui toggle checkbox">
<input type="checkbox" id="sPCheckbox" name="sP" <?=$options['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 checkbox">
<input type="checkbox" id="PECheckbox" name="-PE"/>
<label for="PECheckbox">Considérer tous les hôtes comme actifs</label>
<div class="ui toggle checkbox">
<input type="checkbox" id="PnCheckbox" name="Pn" <?=$options['Pn']?? false? 'checked' : ''; ?>/>
<label for="PnCheckbox">Considérer tous les hôtes comme actifs (saute la découverte des hôtes)</label>
</div>
</div>
<div class="field">
<label class="inline field">
<div class="ui checkbox">
<input type="checkbox" id="PSCheckbox" onchange="PSInput.disabled = !this.checked"/>
<label for="PSCheckbox">Ping TCP SYN</label>
</div>
</label>
<input type="text" id="PSInput" name="-PS" placeholder="Ports" list="servicesList" disabled
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="80"
title="Liste de ports ex: 22,23,25,80,113,1050,35000">
<div class="fields">
<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']?? "" ?>"
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']?? "" ?>"
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']?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
</div>
<div class="field">
<label>
<div class="ui checkbox">
<input type="checkbox" id="PACheckbox" onchange="PAInput.disabled = !this.checked"/>
<label for="PACheckbox">Ping TCP ACK</label>
</div>
</label>
<input type="text" id="PAInput" name="-PA" placeholder="Ports" list="servicesList" disabled
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="80"
title="Liste de ports ex: 22,23,25,80,113,1050,35000">
</div>
<div class="field">
<label>
<div class="ui checkbox">
<input type="checkbox" id="PUCheckbox" onchange="PUInput.disabled = !this.checked"/>
<label for="PUCheckbox">Ping UDP</label>
</div>
</label>
<input type="text" id="PUInput" name="-PU" placeholder="Ports" list="servicesList" disabled
pattern="([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*" value="31338"
title="Liste de ports ex: 22,23,25,80,113,1050,35000">
</div>
<div class="inline fields">
<label>Ping ICMP</label>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="PECheckbox" name="-PE"/>
<label for="PECheckbox">Echo request</label>
<div class="inline fields">
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PECheckbox" name="PE" <?=$options['PE']?? false? 'checked' : ''; ?>/>
<label for="PECheckbox">Echo request</label>
</div>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="PPCheckbox" name="-PP"/>
<label for="PPCheckbox">Timestamp request</label>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PPCheckbox" name="PP" <?=$options['PP']?? false? 'checked' : ''; ?>/>
<label for="PPCheckbox">Timestamp request</label>
</div>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="PMCheckbox" name="-PM"/>
<label for="PMCheckbox">Mask request</label>
<div class="field">
<div class="ui toggle checkbox">
<input type="checkbox" id="PMCheckbox" name="PM" <?=$options['PM']?? false? 'checked' : ''; ?>/>
<label for="PMCheckbox">Mask request</label>
</div>
</div>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="PRCheckbox" name="-PR"/>
<div class="ui toggle checkbox">
<input type="checkbox" id="PRCheckbox" name="PR" <?=$options['PR']?? false? 'checked' : ''; ?>/>
<label for="PRCheckbox">Ping ARP</label>
</div>
</div>
<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']?? "" ?>"
title="Liste de ports ex: 22,23,25,80,200-1024,60000-">
</div>
</div>
<div class="title"><i class="icon dropdown"></i>Techniques de scan</div>
<div class="content">
<div class="field">
<label>
<div class="ui checkbox">
<input type="checkbox" id="pCheckbox" onchange="pInput.disabled = !this.checked"/>
<label for="pCheckbox">Scanner les ports</label>
</div>
</label>
<input type="text" id="pInput" name="-p" placeholder="Ports" list="servicesList" disabled
pattern="(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*" value="1-1024"
title="Liste de ports ex: ssh,ftp,U:53,111,137,T:21-25,80,139,8080">
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="FCheckbox" name="-F"/>
<label for="FCheckbox">Scanner les ports connus</label>
<div class="ui toggle checkbox">
<input type="checkbox" id="FCheckbox" name="F" <?=$options['F']?? false? 'checked' : ''; ?>/>
<label for="FCheckbox">Scanner que les ports connus</label>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input type="checkbox" id="rCheckbox" name="-r"/>
<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']?? "" ?>"
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' : ''; ?>/>
<label for="rCheckbox">Ne pas mélanger les ports</label>
</div>
</div>
@ -166,7 +159,7 @@ Exemples: <?=$_SERVER['REMOTE_ADDR']; ?>/24,<?=$_SERVER['SERVER_NAME']; ?>,10.0-
</div>
<button type="submit" class="ui fluid teal submit button">Démarrer</button>
<button type="submit" class="ui teal submit button">Démarrer</button>
</form>
<datalist id='targetsList'>
@ -178,7 +171,7 @@ if (!file_exists($SCANS_DIR)) {
mkdir($SCANS_DIR);
}
foreach (scandir($SCANS_DIR) as $scan) {
if (substr($scan, -4) == '.xml') {
if ('.xml' == substr($scan, -4)) {
$targets = str_replace('!', '/', substr_replace($scan, '', -4));
echo " <option value='$targets'></option>\n";
}
@ -190,12 +183,12 @@ foreach (scandir($SCANS_DIR) as $scan) {
$nmap_services = file("$NMAP_DATADIR/nmap-services");
$services = [];
foreach ($nmap_services as $service) {
if (strpos($service, '#') !== 0) {
if (0 !== strpos($service, '#')) {
[$name, $port] = explode("\t", $service);
$services[$name] = $port;
$services[$name] = explode("/", $port);
}
}
foreach ($services as $name => $port) {
foreach ($services as $name => [$portid, $protocol]) {
echo " <option value='$name'></option>\n";
}
?>
@ -209,61 +202,46 @@ const joinWithCommas = tags => tags.map(tag => tag.value).join(',')
$('.ui.accordion').accordion()
var targetsTagify = new Tagify(targetsInput, {
new Tagify(targetsInput, {
delimiters: " |,",
originalInputValueFormat: joinWithSpaces,
whitelist: targetsWhitelist,
})
var excludeTagify = new Tagify(excludeInput, {
new Tagify(excludeInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: targetsWhitelist,
})
excludeCheckbox.onchange = (event) => {
excludeInput.disabled = !excludeCheckbox.checked
excludeTagify.setDisabled(!excludeCheckbox.checked)
}
var PSTagify = new Tagify(PSInput, {
new Tagify(PSInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
PSCheckbox.onchange = () => {
PSInput.disabled = !PSCheckbox.checked
PSTagify.setDisabled(!PSCheckbox.checked)
}
var PATagify = new Tagify(PAInput, {
new Tagify(PAInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
PACheckbox.onchange = () => {
PAInput.disabled = !PACheckbox.checked
PATagify.setDisabled(!PACheckbox.checked)
}
var PUTagify = new Tagify(PUInput, {
new Tagify(PUInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
PUCheckbox.onchange = () => {
PUInput.disabled = !PUCheckbox.checked
PUTagify.setDisabled(!PUCheckbox.checked)
}
var pTagify = new Tagify(pInput, {
new Tagify(P0Input, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas
})
new Tagify(pInput, {
delimiters: " |,",
originalInputValueFormat: joinWithCommas,
whitelist: servicesWhitelist,
})
pCheckbox.onchange = () => {
pInput.disabled = !pCheckbox.checked
pTagify.setDisabled(!pCheckbox.checked)
}
newScanForm.onsubmit = function (event) {
if (this.checkValidity()) {