From 175cc9392fdfd73fe1a241acd3b1c2687f7b56c6 Mon Sep 17 00:00:00 2001
From: adrien <adrien@malingrey.fr>
Date: Mon, 10 Feb 2025 11:35:09 +0100
Subject: [PATCH] small changes

---
 config.php                  |  6 ++----
 index.php                   |  4 ++--
 options.php                 | 42 ++++++++++++++++++++-----------------
 stylesheets/hostDetails.xsl |  6 ++++++
 stylesheets/lanTable.xsl    | 19 ++++++++++++-----
 stylesheets/lib/head.xsl    |  1 +
 stylesheets/lib/nav.xsl     |  5 ++++-
 stylesheets/lib/toast.xsl   |  6 +++---
 8 files changed, 55 insertions(+), 34 deletions(-)

diff --git a/config.php b/config.php
index 14f3ac0..ebd58f5 100644
--- a/config.php
+++ b/config.php
@@ -1,14 +1,12 @@
 <?php
+$NMAP              = "sudo nmap"; # nmap command, E.g. 'nmap', 'sudo nmap' for root privileges or '/usr/bin/nmap' if not in PATH
+$NMAPDIR           = dirname(`which nmap`) . "/../share/nmap";
 $port              = (($_SERVER['REQUEST_SCHEME'] == "http" && $_SERVER['SERVER_PORT'] == 80) || ($_SERVER['REQUEST_SCHEME'] == "https" && $_SERVER['SERVER_PORT'] == 443)) ? "" : ":{$_SERVER['SERVER_PORT']}";
 $BASEDIR           = "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}$port" . dirname($_SERVER['SCRIPT_NAME']);
 $SCANSDIR          = "scans";
 $STYLESHEETSDIR    = "stylesheets";
-$NMAP              = "sudo nmap"; # nmap command, E.g. 'nmap', 'sudo nmap' for root privileges or '/usr/bin/nmap' if not in PATH
-$NMAPDIR           = dirname(`which nmap`) . "/../share/nmap";
 $DATADIR           = ".";
 $SCRIPTARGSFILE    = "script-args.ini";
-$LANSCANOPTIONS    = "-PSmicrosoft-ds -F -T5 --datadir '$DATADIR' --script http-info,smb-shares-size --script-args-file '$SCRIPTARGSFILE'";
-$HOSTSCANOPTIONS   = "-A -T5 --datadir '$DATADIR' --script http-info,smb-shares-size --script-args-file '$SCRIPTARGSFILE'";
 $COMMONOPTIONS     = [
     "--datadir" => $DATADIR,
     "--script-args-file" => $SCRIPTARGSFILE,
diff --git a/index.php b/index.php
index 866eca3..d39657a 100644
--- a/index.php
+++ b/index.php
@@ -48,10 +48,10 @@
 
         <form id="scanForm" class="ui large form initial inverted" action="scan.php" method="get">
           <div class="ui left aligned raised segment inverted">
-            <h4 class="ui header">Découvrir ou superviser un réseau</h4>
+            <h2 class="ui header">Découvrir ou superviser un réseau</h2>
             <div class="inverted field">
               <div class="ui large input">
-                <input id="nameInput" type="text" name="target" placeholder="<?= $_SERVER['REMOTE_ADDR']; ?>"
+                <input id="nameInput" type="text" name="target" placeholder="<?= $_SERVER['REMOTE_ADDR']; ?>/24"
                   list="targetList" pattern="[a-zA-Z0-9._\/ \-]+" required 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>
diff --git a/options.php b/options.php
index 4442190..288459f 100755
--- a/options.php
+++ b/options.php
@@ -41,7 +41,7 @@
         <div class="inverted field">
           <label for="targetInput" 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">Cibles</label>
-          <input id="targetInput" type="text" name="target" placeholder="Cibles" spellcheck="false"
+          <input id="targetInput" type="text" name="target" placeholder="Cibles" spellcheck="false" required
             pattern="[a-zA-Z0-9._\/ \-]+" list="targetList" 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>
@@ -544,10 +544,19 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
 
           <div class="title"><i class="icon dropdown"></i>Évitement de pare-feux/IDS et mystification</div>
           <div class="content">
-            <div class="inverted field">
-              <div class="ui toggle inverted checkbox">
-                <input id="fInput" type="checkbox" name="-f">
-                <label for="fInput" title="-f">Fragmentation des paquets</label>
+
+            <div class="two inverted fields">
+              <div class="inverted field">
+                <div class="ui toggle inverted checkbox">
+                  <input id="fInput" type="checkbox" name="-f">
+                  <label for="fInput" title="-f">Fragmentation des paquets</label>
+                </div>
+              </div>
+              <div class="inverted field">
+                <div class="ui toggle inverted checkbox">
+                  <input id="badsumCheckbox" type="checkbox" name="--badsum">
+                  <label for="badsumCheckbox" title="--badsum">Checksum incorrect</label>
+                </div>
               </div>
             </div>
 
@@ -563,11 +572,6 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
               </div>
             </div>
 
-            <div class="inverted field">
-              <label for="gInput" title="-g">Port source</label>
-              <input id="gInput" type="number" name="-g" min="0" max="65535">
-            </div>
-
             <div class="inverted field">
               <label for="dataLengthInput" title="--data-length">Longueur des données</label>
               <input id="dataLengthInput" type="number" name="--data-length" min="0">
@@ -575,12 +579,18 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
 
             <div class="inverted field">
               <label for="DInput" title="-D">Leurre</label>
-              <input id="DInput" type="text" name="-D">
+              <input id="DInput" type="text" name="-D" pattern="[a-zA-Z0-9._,\-]*"
+                placeholder="decoy1[,decoy2][,ME],..." title="decoy1[,decoy2][,ME],...">
             </div>
 
             <div class="inverted field">
               <label for="SInput" title="-S">Usurpation d'adresse IP</label>
-              <input id="SInput" type="text" name="-S">
+              <input id="SInput" type="text" name="-S" pattern="[0-9.]*">
+            </div>
+
+            <div class="inverted field">
+              <label for="gInput" title="-g">Port source</label>
+              <input id="gInput" type="number" name="-g" min="0" max="65535">
             </div>
 
             <div class="inverted field">
@@ -592,13 +602,6 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
               <label for="scanDelayInput" title="--scan-delay">Délai entre les scans</label>
               <input id="scanDelayInput" type="number" name="--scan-delay" min="0">
             </div>
-
-            <div class="inverted field">
-              <div class="ui checkbox">
-                <input id="badsumCheckbox" type="checkbox" name="--badsum">
-                <label for="badsumCheckbox" title="--badsum">Checksum incorrect</label>
-              </div>
-            </div>
           </div>
         </div>
 
@@ -736,6 +739,7 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
       new TagsInput(scriptArgsInput, {
         delimiters: ','
       })
+      new TagsInput(DInput)
 
       newScanForm.onsubmit = function (event) {
         if (this.checkValidity()) {
diff --git a/stylesheets/hostDetails.xsl b/stylesheets/hostDetails.xsl
index 221cbc6..ba262b5 100644
--- a/stylesheets/hostDetails.xsl
+++ b/stylesheets/hostDetails.xsl
@@ -29,6 +29,7 @@
 
       <body class="inverted">
         <xsl:apply-templates select="." mode="nav">
+          <xsl:with-param name="target" select="$target" />
           <xsl:with-param name="name" select="$name" />
         </xsl:apply-templates>
 
@@ -39,6 +40,11 @@
           </xsl:apply-templates>
         </main>
 
+        <footer class="ui footer inverted segment">
+            Résultat de la commande :<br/>
+            <code><xsl:value-of select="@args"/></code>
+        </footer>
+
         <script src="script.js"></script>
         <script>
 $('.ui.tree.accordion').accordion()
diff --git a/stylesheets/lanTable.xsl b/stylesheets/lanTable.xsl
index f9d48a1..9ca48d7 100644
--- a/stylesheets/lanTable.xsl
+++ b/stylesheets/lanTable.xsl
@@ -28,6 +28,7 @@
 
       <body class="inverted">
         <xsl:apply-templates select="." mode="nav">
+          <xsl:with-param name="target" select="$target" />
           <xsl:with-param name="name" select="$name" />
         </xsl:apply-templates>
 
@@ -70,6 +71,11 @@
             </tbody>
           </table>
         </main>
+        
+        <footer class="ui footer inverted segment">
+            Résultat de la commande :<br/>
+            <code><xsl:value-of select="@args"/></code>
+        </footer>
 
         <script src="script.js"></script>
         <script>
@@ -89,7 +95,7 @@ var table = $('#scanResultsTable').DataTable({
                 'print',
                 {
                     extend: 'collection',
-                    text: 'Exporter',
+                    text: 'Export',
                     buttons: ['csv', 'excel', 'pdf']
                 },
             ],
@@ -167,9 +173,11 @@ $('.ui.dropdown').dropdown()
           <xsl:value-of select="substring-after(hostnames/hostname/@name, '.')" />
         </xsl:if>
       </td>
-      <td>
-        <xsl:value-of select="address[@addrtype='mac']/@vendor" />
-      </td>
+      <xsl:if test="../host/address[@addrtype='mac']/@vendor">
+        <td>
+          <xsl:value-of select="address[@addrtype='mac']/@vendor" />
+        </td>
+      </xsl:if>
       <td>
         <xsl:apply-templates select="ports/port | $initHost/ports/port[not(state/@state='closed')][not(@portid=$currentHost/ports/port/@portid)]" mode="service">
           <xsl:with-param name="initHost" select="$initHost" />
@@ -181,7 +189,8 @@ $('.ui.dropdown').dropdown()
       </td>
       <td>
         <a class="ui mini icon teal icon button" target="_blank" title="Scan intensif">
-          <xsl:attribute name="href">scan.php?target=<xsl:value-of select="$hostAddress" />&amp;preset=host</xsl:attribute>
+          <xsl:attribute name="href">scan.php?target=<xsl:value-of select="$hostAddress" />
+&amp;preset=host</xsl:attribute>
           <i class="search plus icon"></i>
         </a>
       </td>
diff --git a/stylesheets/lib/head.xsl b/stylesheets/lib/head.xsl
index d83bc52..10b4c83 100644
--- a/stylesheets/lib/head.xsl
+++ b/stylesheets/lib/head.xsl
@@ -28,6 +28,7 @@
                         <xsl:value-of select="$target" />
                     </xsl:otherwise>
                 </xsl:choose>
+                <xsl:text> - lanScan</xsl:text>
             </title>
             <link rel="icon" href="favicon.ico" />
             <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.3/dist/semantic.min.css" />
diff --git a/stylesheets/lib/nav.xsl b/stylesheets/lib/nav.xsl
index 0cae758..44d978f 100644
--- a/stylesheets/lib/nav.xsl
+++ b/stylesheets/lib/nav.xsl
@@ -3,6 +3,7 @@
   xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.1">
 
   <xsl:template match="nmaprun" mode="nav">
+    <xsl:param name="target" />
     <xsl:param name="name" />
 
     <nav class="ui inverted secondary menu">
@@ -58,10 +59,12 @@
       <div class="ui right aligned category search item">
         <form id="scanForm" action="scan.php" method="get">
           <div class="ui inverted icon input" id="targetInputDiv">
-            <input name="lan" class="prompt" type="text" placeholder="Scanner un réseau" pattern="[a-zA-Z0-9._\/ \-]+" title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc.
+            <input name="target" class="prompt" type="text" placeholder="Scanner un réseau" pattern="[a-zA-Z0-9._\/ \-]+" value="{$target}"
+            title="Les cibles peuvent être spécifiées par des noms d'hôtes, des adresses IP, des adresses de réseaux, etc.
 Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254" />
             <i class="satellite dish icon"></i>
           </div>
+          <input type="hidden" name="preset" value="lanScan" />
         </form>
         <a class="ui icon button item" href="options.php" title="Options avancées">
           <i class="settings icon"></i>
diff --git a/stylesheets/lib/toast.xsl b/stylesheets/lib/toast.xsl
index 38ce1b5..d8ed49a 100644
--- a/stylesheets/lib/toast.xsl
+++ b/stylesheets/lib/toast.xsl
@@ -14,7 +14,7 @@ $.toast({
     showIcon   : 'calendar',
     displayTime: 0,
     closeIcon  : true,
-    position   : 'bottom right',
+    position   : 'bottom left',
 })
             </xsl:if>
             <xsl:if test="finished/@summary">
@@ -24,7 +24,7 @@ $.toast({
     showIcon   : 'satellite dish',
     displayTime: 0,
     closeIcon  : true,
-    position   : 'bottom right',
+    position   : 'bottom left',
 })
             </xsl:if>
             <xsl:if test="finished/@errormsg">
@@ -35,7 +35,7 @@ $.toast({
     class      : 'error',
     displayTime: 0,
     closeIcon  : true,
-    position   : 'bottom right',
+    position   : 'bottom left',
 })
             </xsl:if>
         </script>