Compare commits

...

3 Commits

Author SHA1 Message Date
a7c67292ed --script-args 2024-10-20 12:33:50 +02:00
dfd89a5add remove quotes on value 2024-10-20 12:30:09 +02:00
c6b8005958 split command parsing 2024-10-20 12:22:24 +02:00
7 changed files with 143 additions and 373 deletions

View File

@ -2,11 +2,11 @@
include_once "config.php";
$targetsListRegex = "/^[\da-zA-Z-. \/]+$/";
$hostsListRegex = "/^[\da-zA-Z-.,:\/]+$/";
$protocolePortsListRegex = "/^(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*$/";
$portsListRegex = "/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/";
$tempoRegex = "/^\d+[smh]?$/";
$targetsListRegex = '/^[\da-zA-Z-. \/]+$/';
$hostsListRegex = '/^[\da-zA-Z-.,:\/]+$/';
$protocolePortsListRegex = '/^(([TU]:)?[0-9\-]+|[a-z\-]+)(,([TU]:)?[0-9\-]+|,[a-z\-]+)*$/';
$portsListRegex = '/^([0-9\-]+|[a-z\-]+)(,[0-9\-]+|,[a-z\-]+)*$/';
$tempoRegex = '/^\d+[smh]?$/';
$fileNameRegex = '/^[^<>:"\/|?]+$/';
$targets = filter_input(INPUT_GET, 'targets', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $targetsListRegex], "flags" => FILTER_NULL_ON_FAILURE]);
@ -46,8 +46,8 @@ if ($preset && isset($presets[$preset])) {
'-sN' => FILTER_VALIDATE_BOOLEAN,
'-sX' => FILTER_VALIDATE_BOOLEAN,
'-sU' => FILTER_VALIDATE_BOOLEAN,
'--scanflags' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^(URG|ACK|PSH|RST|SYN|FIN|,)+|[1-9]?[0-9]|[1-2][0-9][0-9]$/"]],
'-sI' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-zA-Z\d:.-]+(:\d+)?$/"]],
'--scanflags' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^(URG|ACK|PSH|RST|SYN|FIN|,)+|[1-9]?[0-9]|[1-2][0-9][0-9]$/']],
'-sI' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[a-zA-Z\d:.-]+(:\d+)?$/']],
'-sO' => FILTER_VALIDATE_BOOLEAN,
'-b' => FILTER_VALIDATE_URL,
'--traceroute' => FILTER_VALIDATE_BOOLEAN,
@ -65,8 +65,9 @@ if ($preset && isset($presets[$preset])) {
'--version-all' => FILTER_VALIDATE_BOOLEAN,
'--version-trace' => FILTER_VALIDATE_BOOLEAN,
// SCRIPT SCAN:
'-sC' => FILTER_VALIDATE_BOOLEAN,
'--script' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-z][a-z0-9,\-\.\/]*$/"]],
'-sC' => FILTER_VALIDATE_BOOLEAN,
'--script' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[a-z][a-z0-9,\-\.\/]*$/']],
'--script-args' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^([a-zA-Z][a-zA-Z0-9\-_]*=[^"]+(,[a-zA-Z][a-zA-Z0-9\-_]*=[^"]+)?)$/']],
// OS DETECTION:
'-O' => FILTER_VALIDATE_BOOLEAN,
'--osscan-limit' => FILTER_VALIDATE_BOOLEAN,
@ -90,11 +91,11 @@ if ($preset && isset($presets[$preset])) {
'--mtu' => FILTER_VALIDATE_INT,
'-D' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => $hostsListRegex]],
'-S' => ['filter' => FILTER_VALIDATE_IP],
'-e' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^[a-z\d]+$/"]],
'-e' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^[a-z\d]+$/']],
'-g' => FILTER_VALIDATE_INT,
'--source-port' => FILTER_VALIDATE_INT,
'--data-length' => FILTER_VALIDATE_INT,
'--ip-options' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => "/^\"(R|T|U|L [\da-zA-Z-.: ]+|S [\da-zA-Z-.: ]+|\\\\x[\da-fA-F]{1,2}(\*[\d]+)?|\\\\[0-2]?[\d]{1,2}(\*[\d]+)?)\"$/"]],
'--ip-options' => ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => '/^\"(R|T|U|L [\da-zA-Z-.: ]+|S [\da-zA-Z-.: ]+|\\\\x[\da-fA-F]{1,2}(\*[\d]+)?|\\\\[0-2]?[\d]{1,2}(\*[\d]+)?)\"$/']],
'--ttl' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 0, 'max_range' => 255]],
'--spoof-mac' => FILTER_VALIDATE_MAC,
'--badsum' => FILTER_VALIDATE_BOOLEAN,

View File

@ -349,6 +349,13 @@ Exemples: <?= $_SERVER['REMOTE_ADDR']; ?>/24 <?= $_SERVER['SERVER_NAME']; ?> 10.
title="<catégories|répertoire|nom|all>" list="scripts" pattern="[a-z][a-z0-9\-\.\/]*"
value="<?= htmlentities($options["--script"] ?? "", ENT_QUOTES); ?>">
</div>
<div class="field">
<label for="scriptArgsInput" title="--script-args">Arguments des scripts</label>
<input type="text" id="scriptArgsInput" name="--script-args" placeholder="nom=valeur"
pattern='[a-zA-Z][a-zA-Z0-9\-_]*=[^"]+(,[a-zA-Z][a-zA-Z0-9\-_]*=[^"]+)?' value="<?= $options['--script-args'] ?? "" ?>"
title="<n1=v1,[n2=v2,...]>">
</div>
</div>
<div class="title"><i class="icon dropdown"></i>Détection du système d'exploitation</div>
@ -557,8 +564,8 @@ foreach ([$DATADIR, $NMAPDIR] as $dir) {
<script>
class TagsInput extends Tagify {
constructor(input, options={}, delim = ",") {
options.delimiters = " |,"
options.originalInputValueFormat = tags => tags.map(tag => tag.value).join(delim)
if (!options.delimiters) options.delimiters = " |,"
if (!options.originalInputValueFormat) options.originalInputValueFormat = tags => tags.map(tag => tag.value).join(delim)
if (input.list) options.whitelist = Array.from(input.list.options).map(option => option.value)
super(input, options)
}
@ -585,6 +592,7 @@ foreach ([$DATADIR, $NMAPDIR] as $dir) {
new TagsInput(dnsServersInput)
new TagsInput(scanflagsInput)
new TagsInput(scriptInput, {enforceWhitelist: true})
new TagsInput(scriptArgsInput, {delimiters: ','})
newScanForm.onsubmit = function(event) {
if (this.checkValidity()) {

View File

@ -4,6 +4,8 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:import href="parseCommand.xsl"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:output indent="yes"/>
<xsl:strip-space elements='*'/>
@ -40,7 +42,7 @@
<xsl:text>/scan.php?targets=</xsl:text>
<xsl:value-of select="$targets"/>
<xsl:text>&amp;</xsl:text>
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="true()"/>
</xsl:call-template>
@ -79,7 +81,7 @@
<xsl:text>can</xsl:text>
</a>
<form id="lanScanForm" class="right menu">
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="false()"/>
</xsl:call-template>
@ -371,92 +373,4 @@ function hostScanning(link) {
</a>
</xsl:template>
<xsl:template name="optionsList">
<xsl:param name="argList" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="nextArgs" select="substring-after($argList, ' -')"/>
<xsl:variable name="argAndValue">
<xsl:choose>
<xsl:when test="$nextArgs">
<xsl:value-of select="substring-before($argList, ' -')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$argList"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, '-')">
<xsl:choose>
<xsl:when test="contains($argAndValue, ' ')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring-before($argAndValue, ' ')"/>
<xsl:with-param name="value" select="substring-after($argAndValue, ' ')"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="$argAndValue"/>
<xsl:with-param name="value" select="on"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, 'P') or starts-with($argAndValue, 's') or starts-with($argAndValue, 'o')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 2)"/>
<xsl:with-param name="value" select="substring($argAndValue, 3)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 1)"/>
<xsl:with-param name="value" select="substring($argAndValue, 2)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nextArgs">
<xsl:call-template name="optionsList">
<xsl:with-param name="argList" select="$nextArgs"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="input">
<xsl:param name="name"/>
<xsl:param name="value" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:choose>
<xsl:when test="$asURL">
<xsl:text>-</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>=</xsl:text>
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="-{$name}">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@ -4,6 +4,8 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:import href="parseCommand.xsl"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:output indent="yes"/>
<xsl:strip-space elements='*'/>
@ -40,7 +42,7 @@
<xsl:text>/scan.php?targets=</xsl:text>
<xsl:value-of select="$targets"/>
<xsl:text>&amp;</xsl:text>
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="true()"/>
</xsl:call-template>
@ -93,7 +95,7 @@
<xsl:text>can</xsl:text>
</a>
<form id="lanScanForm" class="right menu">
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="false()"/>
</xsl:call-template>
@ -358,92 +360,4 @@ function hostScanning(link) {
</a>
</xsl:template>
<xsl:template name="optionsList">
<xsl:param name="argList" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="nextArgs" select="substring-after($argList, ' -')"/>
<xsl:variable name="argAndValue">
<xsl:choose>
<xsl:when test="$nextArgs">
<xsl:value-of select="substring-before($argList, ' -')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$argList"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, '-')">
<xsl:choose>
<xsl:when test="contains($argAndValue, ' ')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring-before($argAndValue, ' ')"/>
<xsl:with-param name="value" select="substring-after($argAndValue, ' ')"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="$argAndValue"/>
<xsl:with-param name="value" select="on"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, 'P') or starts-with($argAndValue, 's') or starts-with($argAndValue, 'o')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 2)"/>
<xsl:with-param name="value" select="substring($argAndValue, 3)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 1)"/>
<xsl:with-param name="value" select="substring($argAndValue, 2)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nextArgs">
<xsl:call-template name="optionsList">
<xsl:with-param name="argList" select="$nextArgs"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="input">
<xsl:param name="name"/>
<xsl:param name="value" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:choose>
<xsl:when test="$asURL">
<xsl:text>-</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>=</xsl:text>
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="-{$name}">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@ -4,6 +4,8 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:import href="parseCommand.xsl"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:output indent="yes"/>
<xsl:strip-space elements='*'/>
@ -40,7 +42,7 @@
<xsl:text>/scan.php?targets=</xsl:text>
<xsl:value-of select="$targets"/>
<xsl:text>&amp;</xsl:text>
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="true()"/>
</xsl:call-template>
@ -79,7 +81,7 @@
<xsl:text>can</xsl:text>
</a>
<form id="lanScanForm" class="right menu">
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="false()"/>
</xsl:call-template>
@ -402,92 +404,4 @@ function hostScanning(link) {
</a>
</xsl:template>
<xsl:template name="optionsList">
<xsl:param name="argList" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="nextArgs" select="substring-after($argList, ' -')"/>
<xsl:variable name="argAndValue">
<xsl:choose>
<xsl:when test="$nextArgs">
<xsl:value-of select="substring-before($argList, ' -')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$argList"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, '-')">
<xsl:choose>
<xsl:when test="contains($argAndValue, ' ')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring-before($argAndValue, ' ')"/>
<xsl:with-param name="value" select="substring-after($argAndValue, ' ')"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="$argAndValue"/>
<xsl:with-param name="value" select="on"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, 'P') or starts-with($argAndValue, 's') or starts-with($argAndValue, 'o')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 2)"/>
<xsl:with-param name="value" select="substring($argAndValue, 3)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 1)"/>
<xsl:with-param name="value" select="substring($argAndValue, 2)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nextArgs">
<xsl:call-template name="optionsList">
<xsl:with-param name="argList" select="$nextArgs"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="input">
<xsl:param name="name"/>
<xsl:param name="value" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:choose>
<xsl:when test="$asURL">
<xsl:text>-</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>=</xsl:text>
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="-{$name}">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

105
templates/parseCommand.xsl Normal file
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:template name="parseCommand">
<xsl:param name="argList" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="nextArgs" select="substring-after($argList, ' -')"/>
<xsl:variable name="argAndValue">
<xsl:choose>
<xsl:when test="$nextArgs">
<xsl:value-of select="substring-before($argList, ' -')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$argList"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, '-')">
<xsl:choose>
<xsl:when test="contains($argAndValue, ' ')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring-before($argAndValue, ' ')"/>
<xsl:with-param name="value" select="substring-after($argAndValue, ' ')"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="$argAndValue"/>
<xsl:with-param name="value" select="on"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, 'P') or starts-with($argAndValue, 's') or starts-with($argAndValue, 'o')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 2)"/>
<xsl:with-param name="value" select="substring($argAndValue, 3)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 1)"/>
<xsl:with-param name="value" select="substring($argAndValue, 2)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nextArgs">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="$nextArgs"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="input">
<xsl:param name="name"/>
<xsl:param name="value" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="valueWithoutQuotes">
<xsl:choose>
<xsl:when test="substring-after($value, '&quot;')">
<xsl:value-of select="substring-before(substring-after($value, '&quot;'), '&quot;')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$asURL">
<xsl:text>-</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>=</xsl:text>
<xsl:choose>
<xsl:when test="$valueWithoutQuotes"><xsl:value-of select="$valueWithoutQuotes"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="-{$name}">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$valueWithoutQuotes"><xsl:value-of select="$valueWithoutQuotes"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@ -4,6 +4,8 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.1">
<xsl:import href="parseCommand.xsl"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:output indent="yes"/>
<xsl:strip-space elements='*'/>
@ -40,7 +42,7 @@
<xsl:text>/scan.php?targets=</xsl:text>
<xsl:value-of select="$targets"/>
<xsl:text>&amp;</xsl:text>
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="true()"/>
</xsl:call-template>
@ -79,7 +81,7 @@
<xsl:text>can</xsl:text>
</a>
<form id="lanScanForm" class="right menu" onsubmit="targetsInputDiv.classList.add('loading')">
<xsl:call-template name="optionsList">
<xsl:call-template name="parseCommand">
<xsl:with-param name="argList" select="substring-before(substring-after(@args, ' -'), ' -oX')"/>
<xsl:with-param name="asURL" select="false()"/>
</xsl:call-template>
@ -362,92 +364,4 @@ function hostScanning(link) {
</xsl:template>
<xsl:template name="optionsList">
<xsl:param name="argList" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:variable name="nextArgs" select="substring-after($argList, ' -')"/>
<xsl:variable name="argAndValue">
<xsl:choose>
<xsl:when test="$nextArgs">
<xsl:value-of select="substring-before($argList, ' -')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$argList"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, '-')">
<xsl:choose>
<xsl:when test="contains($argAndValue, ' ')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring-before($argAndValue, ' ')"/>
<xsl:with-param name="value" select="substring-after($argAndValue, ' ')"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="$argAndValue"/>
<xsl:with-param name="value" select="on"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="starts-with($argAndValue, 'P') or starts-with($argAndValue, 's') or starts-with($argAndValue, 'o')">
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 2)"/>
<xsl:with-param name="value" select="substring($argAndValue, 3)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="input">
<xsl:with-param name="name" select="substring($argAndValue, 1, 1)"/>
<xsl:with-param name="value" select="substring($argAndValue, 2)"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$nextArgs">
<xsl:call-template name="optionsList">
<xsl:with-param name="argList" select="$nextArgs"/>
<xsl:with-param name="asURL" select="$asURL"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="input">
<xsl:param name="name"/>
<xsl:param name="value" select=""/>
<xsl:param name="asURL" select="false()"/>
<xsl:choose>
<xsl:when test="$asURL">
<xsl:text>-</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>=</xsl:text>
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<input type="hidden" name="-{$name}">
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="$value"><xsl:value-of select="$value"/></xsl:when>
<xsl:otherwise>on</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>