refreshPeriod input

This commit is contained in:
Adrien MALINGREY 2024-10-14 23:37:57 +02:00
parent 9cb008785c
commit f8f1183fe7
6 changed files with 50 additions and 28 deletions

View File

@ -20,3 +20,4 @@ $SCANSDIR = 'scans';
$DATADIR = '/usr/share/nmap'; $DATADIR = '/usr/share/nmap';
$sudo = true; $sudo = true;
$refreshPeriod = 60;

View File

@ -7,12 +7,12 @@ $portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/";
$tempoRegex = "/^\d+[smh]?$/"; $tempoRegex = "/^\d+[smh]?$/";
$fileNameRegex = '/^[^<>:"\/|?]+$/'; $fileNameRegex = '/^[^<>:"\/|?]+$/';
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); $targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]);
$lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); $lan = filter_input(INPUT_GET, 'lan', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]);
$host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]); $host = filter_input(INPUT_GET, 'host', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex]]);
$saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]); $saveAs = filter_input(INPUT_GET, 'saveAs', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $fileNameRegex]]);
$compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL); $compareWith = filter_input(INPUT_GET, 'compareWith', FILTER_VALIDATE_URL);
$refreshPeriod = filter_input(INPUT_GET, 'refreshPeriod', FILTER_VALIDATE_INT, ['options' => ['min_range' => 0]]) ?? $refreshPeriod;
if ($lan) { if ($lan) {
$targets = $lan; $targets = $lan;
@ -22,7 +22,7 @@ if ($lan) {
$inputs = $HOSTSCAN_OPTIONS; $inputs = $HOSTSCAN_OPTIONS;
} else { } else {
$inputs = filter_input_array(INPUT_GET, [ $inputs = filter_input_array(INPUT_GET, [
'iR' => FILTER_VALIDATE_INT, 'iR' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0]],
'exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'exclude' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]],
'sL' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]], 'sL' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]],

View File

@ -9,8 +9,13 @@
<xsl:strip-space elements='*'/> <xsl:strip-space elements='*'/>
<xsl:param name="saveAs" select=""/> <xsl:param name="saveAs" select=""/>
<xsl:param name="scansDir" select="scans"/>
<xsl:param name="compareWith" select=""/> <xsl:param name="compareWith" select=""/>
<xsl:param name="refreshPeriod" select="0"/>
<xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/>
<xsl:variable name="init" select="document($compareWith)/nmaprun"/>
<xsl:variable name="nextCompareWith"> <xsl:variable name="nextCompareWith">
<xsl:choose> <xsl:choose>
<xsl:when test="$saveAs"><xsl:value-of select="$saveAs"/></xsl:when> <xsl:when test="$saveAs"><xsl:value-of select="$saveAs"/></xsl:when>
@ -18,10 +23,6 @@
<xsl:otherwise></xsl:otherwise> <xsl:otherwise></xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/>
<xsl:variable name="init" select="document($compareWith)/nmaprun"/>
<xsl:template match="nmaprun"> <xsl:template match="nmaprun">
<xsl:variable name="targets" select="substring-after(@args, '.xml ')"/> <xsl:variable name="targets" select="substring-after(@args, '.xml ')"/>
@ -41,12 +42,15 @@
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta http-equiv="refresh"> <xsl:if test="$refreshPeriod > 0">
<xsl:attribute name="content"> <meta http-equiv="refresh">
<xsl:text>60;URL=</xsl:text> <xsl:attribute name="content">
<xsl:value-of select="$refreshURL"/> <xsl:value-of select="$refreshPeriod"/>
</xsl:attribute> <xsl:text>;URL=</xsl:text>
</meta> <xsl:value-of select="$refreshURL"/>
</xsl:attribute>
</meta>
</xsl:if>
<title> <title>
<xsl:text>lanScan - </xsl:text> <xsl:text>lanScan - </xsl:text>
<xsl:value-of select="$targets"/> <xsl:value-of select="$targets"/>
@ -82,6 +86,7 @@ Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254"/>
<i class="satellite dish icon"></i> <i class="satellite dish icon"></i>
</div> </div>
<input type="hidden" name="compareWith" value="{$nextCompareWith}"/> <input type="hidden" name="compareWith" value="{$nextCompareWith}"/>
<input type="hidden" name="refreshPeriod" value="{$refreshPeriod}"/>
<button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button> <button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button>
</div> </div>
<div class="item"> <div class="item">

View File

@ -10,6 +10,12 @@
<xsl:param name="savedAs" select=""/> <xsl:param name="savedAs" select=""/>
<xsl:param name="compareWith" select=""/> <xsl:param name="compareWith" select=""/>
<xsl:param name="refreshPeriod" select="0"/>
<xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/>
<xsl:variable name="init" select="document($compareWith)/nmaprun"/>
<xsl:variable name="nextCompareWith"> <xsl:variable name="nextCompareWith">
<xsl:choose> <xsl:choose>
<xsl:when test="$savedAs"><xsl:value-of select="$savedAs"/></xsl:when> <xsl:when test="$savedAs"><xsl:value-of select="$savedAs"/></xsl:when>
@ -17,10 +23,6 @@
<xsl:otherwise></xsl:otherwise> <xsl:otherwise></xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="current" select="./nmaprun"/>
<xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'),'&quot;')"/>
<xsl:variable name="basedir" select="concat($stylesheetURL, '/..')"/>
<xsl:variable name="init" select="document($compareWith)/nmaprun"/>
<xsl:template match="nmaprun"> <xsl:template match="nmaprun">
<xsl:variable name="targets" select="substring-after(@args, '.xml ')"/> <xsl:variable name="targets" select="substring-after(@args, '.xml ')"/>
@ -40,12 +42,15 @@
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta http-equiv="refresh"> <xsl:if test="$refreshPeriod > 0">
<xsl:attribute name="content"> <meta http-equiv="refresh">
<xsl:text>60;URL=</xsl:text> <xsl:attribute name="content">
<xsl:value-of select="$refreshURL"/> <xsl:value-of select="$refreshPeriod"/>
</xsl:attribute> <xsl:text>;URL=</xsl:text>
</meta> <xsl:value-of select="$refreshURL"/>
</xsl:attribute>
</meta>
</xsl:if>
<title> <title>
<xsl:text>lanScan - </xsl:text> <xsl:text>lanScan - </xsl:text>
<xsl:value-of select="$targets"/> <xsl:value-of select="$targets"/>
@ -85,6 +90,7 @@ Exemples: 192.168.1.0/24 scanme.nmap.org 10.0-255.0-255.1-254"/>
<i class="satellite dish icon"></i> <i class="satellite dish icon"></i>
</div> </div>
<input type="hidden" name="compareWith" value="{$nextCompareWith}"/> <input type="hidden" name="compareWith" value="{$nextCompareWith}"/>
<input type="hidden" name="refreshPeriod" value="{$refreshPeriod}"/>
<button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button> <button style="display: none;" type="submit" formmethod="get" formaction="{$basedir}/scan.php"></button>
</div> </div>
<div class="item"> <div class="item">

View File

@ -246,6 +246,15 @@ foreach (scandir($SCANSDIR) as $filename) {
?> ?>
</select> </select>
</div> </div>
<div class="field">
<label for="refreshPeriodInput">Rafraîchir toutes les</label>
<div class="ui right labeled input">
<input type="number" min="0" id="refreshPeriodInput" name="refreshPeriod" placeholder="Période"
value="<?= $refreshPeriod ?? "" ?>">
<div class="ui label">secondes</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -41,6 +41,7 @@ $xml->load($tempPath);
$saveAsURL = $saveAs? "$BASEDIR/$SCANSDIR/$saveAs.xml" : ""; $saveAsURL = $saveAs? "$BASEDIR/$SCANSDIR/$saveAs.xml" : "";
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='savedAs' value='".htmlentities($saveAsURL, ENT_QUOTES)."'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='savedAs' value='".htmlentities($saveAsURL, ENT_QUOTES)."'"), $xml->documentElement);
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($compareWith, ENT_QUOTES)."'"), $xml->documentElement); $xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='compareWith' value='".htmlentities($compareWith, ENT_QUOTES)."'"), $xml->documentElement);
$xml->insertBefore($xml->createProcessingInstruction('xslt-param', "name='refreshPeriod' value='".htmlentities($refreshPeriod, ENT_QUOTES)."'"), $xml->documentElement);
if ($saveAs) { if ($saveAs) {
$path = "$SCANSDIR/$saveAs.xml"; $path = "$SCANSDIR/$saveAs.xml";