Compare commits

...

2 Commits

Author SHA1 Message Date
8537c2a0ca fix results 2023-04-13 21:14:27 +02:00
c6e1977ca2 fix scan_all.sh 2023-04-13 20:54:28 +02:00
4 changed files with 17 additions and 78 deletions

View File

@ -44,7 +44,7 @@ action = function(host, port)
answer = http.get_url(scheme.."://"..hostaddress..":"..port.number.."/"..path)
if (answer and answer.status == 200) then
favicon_relative_uri = parseIcon(answer.body) or "/favicon.ico"
favicon_relative_uri = parseIcon(answer.body) or "favicon.ico"
end
favicon_absolute_uri = scheme.."://"..hostaddress..":"..port.number.."/"..favicon_relative_uri

View File

@ -24,12 +24,10 @@
.ui.mini.button {
padding: 1em;
}
.icon {
display: flex !important;
align-items: center;
}
.icon > img {
width: 16px;
height: 16px;
@ -78,16 +76,16 @@
</xsl:choose>
</xsl:variable>
<div class="column">
<div>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$scannedHost/status/@state='up'">ui fluid mini left icon action input info</xsl:when>
<xsl:otherwise>ui fluid mini left icon action input error</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:variable name="status">
<xsl:choose>
<xsl:when test="$scannedHost/ports/port/script[@id='http-favicon-url']/@output">
<i class="icon"><img class="ui image" src="{$scannedHost/ports/port/script[@id='http-favicon-url']/@output}" alt=""/></i>
<xsl:when test="$scannedHost/status/@state='up'">info</xsl:when>
<xsl:otherwise>error</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<div class="ui fluid mini left icon action input {$status}">
<xsl:choose>
<xsl:when test="$scannedHost/ports/port/script[@id='http-get']/elem[@key='favicon']">
<i class="icon"><img class="ui image" src="{$scannedHost/ports/port/script[@id='http-get']/elem[@key='favicon']}" alt=""/></i>
</xsl:when>
<xsl:otherwise>
<i class="server icon"></i>
@ -124,7 +122,7 @@
<xsl:param name="scannedHost"/>
<xsl:param name="scannedHostAddress"/>
<xsl:variable name="serviceName" select="@name"/>
<xsl:variable name="scannedPort" select="$scannedHost/ports/port[service/@name=$serviceName or @portid=$serviceName]"/>
<xsl:variable name="scannedPort" select="$scannedHost/ports/port[service/@name=$serviceName or @portid=$serviceName][1]"/>
<xsl:variable name="state">
<xsl:choose>
<xsl:when test="$scannedPort/script[@id='http-get']/elem[@key='status']>=400">red</xsl:when>
@ -138,9 +136,9 @@
<xsl:text>/</xsl:text>
<xsl:value-of select="$scannedPort/@protocol"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/service/@name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/state/@state"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/service/@name"/>
<xsl:if test="$scannedPort/script[@id='http-get']/elem[@key='status-line']">
<xsl:text> </xsl:text>
<xsl:value-of select="$scannedPort/script[@id='http-get']/elem[@key='status-line']"/>

View File

@ -1,59 +0,0 @@
<?php
set_time_limit(0);
if (! function_exists('str_ends_with')) {
function str_ends_with(string $haystack, string $needle): bool {
$needle_len = strlen($needle);
return ($needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len));
}
}
$__DIR__ = __DIR__;
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");
$targets = [];
$services = [];
$xml = new SimpleXMLElement(<<<XML
<?xml version="1.0"?>
<?xml-stylesheet href='../results.xsl' type='text/xsl'?>
<lanScanConf/>
XML
);
$xml->addAttribute("scanpath", "scans/$site.xml");
foreach ($yaml as $key => $value) {
if ($key == "site") {
$xml->addAttribute("site", $value);
} else {
$xmlGroup = $xml->addChild("group");
$xmlGroup->addAttribute("name", $key);
foreach($value as $hostaddress => $servicesList) {
$targets[$hostaddress] = true;
$xmlHost = $xmlGroup->addChild("host");
$xmlHost->addAttribute("address", $hostaddress);
if ($servicesList) foreach ($servicesList as $service) {
$services[$service] = true;
$xmlService = $xmlHost->addChild("service");
$xmlService->addAttribute("name", $service);
}
}
}
}
$targets = join(array_keys($targets), " ");
$services = join(array_keys($services), ",");
`nmap -v -Pn -p $services --script smb-enum-shares,"$__DIR__/nmap" -oX "$__DIR__/scans/.~$site.xml" $targets && mv "$__DIR__/scans/.~$site.xml" "$__DIR__/scans/$site.xml"`;
$xml->asXML("$__DIR__/site/$site.xml");
}
}
?>

View File

@ -2,12 +2,12 @@
DIR="$(dirname -- "$0")"
mkdir -p "$DIR/scans"
mkdir -p "$DIR/site"
mkdir -p "$DIR"/scans
mkdir -p "$DIR"/site
for conf in "$DIR/confs/*.yaml"
for conf in "$DIR"/confs/*.yaml
do
site="basename ${conf/.yaml/}"
site="$(basename ${conf/.yaml/})"
php "$DIR/to_xml.php" $conf > "$DIR/site/$site.xml"
php "$DIR/nmap_cmd.php" $conf | sh
mv "$DIR/scans/.~$site.xml" "$DIR/scans/$site.xml"