This commit is contained in:
Adrien MALINGREY 2023-04-12 12:11:33 +02:00
parent f8c4ea0903
commit 0439aecb98
3 changed files with 58 additions and 37 deletions

View File

@ -32,16 +32,19 @@ local http = require "http"
local stdnse = require "stdnse"
action = function(host, port)
local path = ""
local scheme = ""
local hostaddress = (host.name ~= '' and host.name) or host.ip
local path = ""
if (port.service == "ssl") then
scheme = "https"
else
scheme = port.service
end
if(stdnse.get_script_args('http-get.path')) then
path = "/" .. stdnse.get_script_args('http-get.path')
end
if (port.service == "ssl") then scheme = "https"
else scheme = port.service
end
return http.get_url( scheme.."://"..(host.name or host.ip)..":"..port.number.."/"..path, {redirect_ok=true} )
return http.get_url(scheme.."://"..hostaddress..":"..port.number.."/"..path)
end

View File

@ -141,6 +141,10 @@
<xsl:value-of select="$scannedPort/service/@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/state/@state"/>
<xsl:if test="$scannedPort/script[@id='http-get']/elem[@key='status-line']">
<xsl:text> HTTP Statut </xsl:text>
<xsl:value-of select="$scannedPort/script[@id='http-get']/elem[@key='status-line']"/>
</xsl:if>
</xsl:variable>
<xsl:choose>
<xsl:when test="($scannedPort/service/@name='microsoft-ds' or $scannedPort/service/@name='netbios-ssn' or $scannedPort/service/@name='smb') and $scannedHost/hostscript/script[@id='smb-enum-shares']/table[not(contains(@key, '$'))]">
@ -149,7 +153,7 @@
<i class="dropdown icon"></i>
<div class="menu">
<xsl:apply-templates select="$scannedHost/hostscript/script[@id='smb-enum-shares']/table[not(contains(@key, '$'))]">
<xsl:with-param name="scannedHostAddress" select="$scannedHostAddress" />
<xsl:with-param name="scannedHost" select="$scannedHost"/>
</xsl:apply-templates>
</div>
</div>
@ -174,9 +178,21 @@
<xsl:template match="table">
<xsl:param name="scannedHostAddress" />
<a class="item" href="file:///{@key}" target="_blank" rel="noopener noreferrer">
<xsl:param name="scannedHost"/>
<xsl:variable name="path">
<xsl:choose>
<xsl:when test="$scannedHost/hostnames/hostname/@name and contains(@key, $scannedHost/address/@addr)">
<xsl:text>\\</xsl:text>
<xsl:value-of select="$scannedHost/hostnames/hostname/@name"/>
<xsl:value-of select="substring-after(@key, $scannedHost/address/@addr)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@key"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a class="item" href="file:///{$path}" target="_blank" rel="noopener noreferrer">
<xsl:value-of select="elem[@key='Comment']"/>
</a>
</xsl:template>

View File

@ -6,13 +6,15 @@ if (! function_exists('str_ends_with')) {
}
}
if (!file_exists(__DIR__."/scans")) mkdir(__DIR__."/scans");
if (!file_exists(__DIR__."/site")) mkdir(__DIR__."/site");
$__DIR__ = __DIR__;
foreach (scandir(__DIR__."/confs") as $file) {
if (!file_exists("$__DIR__/scans")) mkdir("$__DIR__/scans");
if (!file_exists("$__DIR__/site")) mkdir("$__DIR__/site");
foreach (scandir("$__DIR__/confs") as $file) {
if (str_ends_with($file, ".yaml")) {
$site = str_replace(".yaml", "", $file);
$yaml = yaml_parse_file(__DIR__."/confs/$file");
$yaml = yaml_parse_file("$__DIR__/confs/$file");
$targets = [];
$services = [];
@ -47,10 +49,10 @@ XML
$targets = join(array_keys($targets), " ");
$services = join(array_keys($services), ",");
exec("nmap -v -Pn -p $services --script smb-enum-shares,".__DIR__."/nmap -oX '".__DIR__."/scans/tmp.xml' $targets\n");
rename(__DIR__."/scans/tmp.xml", __DIR__."/scans/$site.xml");
exec("nmap -v -Pn -p $services --script smb-enum-shares,'$__DIR__/nmap' -oX '$__DIR__/scans/tmp.xml' $targets");
rename("$__DIR__/scans/tmp.xml", "$__DIR__/scans/$site.xml");
$xml->asXML(__DIR__."/site/$site.xml");
$xml->asXML("$__DIR__/site/$site.xml");
}
}
?>