change yaml format
This commit is contained in:
parent
ba3c1e1b8a
commit
f8c4ea0903
11
init.sh
11
init.sh
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
###
|
||||
#
|
||||
@ -6,9 +6,14 @@
|
||||
#
|
||||
###
|
||||
|
||||
DIR="$(dirname -- "$0")"
|
||||
|
||||
echo "Nom du site ?"
|
||||
read site
|
||||
filename="${site/ /_}"
|
||||
echo "Adresse réseau CIDR (xxx.xxx.xxx.xxx/xx) ?"
|
||||
read network
|
||||
nmap --script smb-enum-shares.nse -oX "scans/$site.xml" $network
|
||||
xsltproc --stringparam site "$site" --stringparam network $network toyaml.xsl "scans/$site.xml" > "confs/$site.yaml"
|
||||
|
||||
|
||||
nmap --script smb-enum-shares.nse -oX "scans/$filename.xml" $network
|
||||
xsltproc --stringparam site "$site" --stringparam network $network toyaml.xsl "$DIR/scans/$filename.xml" > "$DIR/confs/$filename.yaml"
|
||||
|
23
results.xsl
23
results.xsl
@ -5,12 +5,12 @@
|
||||
version="1.1">
|
||||
<xsl:output method="html" encoding="UTF-8" indent="yes" />
|
||||
|
||||
<xsl:variable name="scan" select="document(string(lanScanConf/scan/@path))/nmaprun"/>
|
||||
<xsl:variable name="scan" select="document(string(lanScanConf/@scanpath))/nmaprun"/>
|
||||
|
||||
<xsl:template match="lanScanConf">
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<title>lanScan - <xsl:value-of select="@name"/></title>
|
||||
<title>lanScan - <xsl:value-of select="@site"/></title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.css" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/fomantic-ui@2.9.2/dist/semantic.min.js"></script>
|
||||
@ -41,7 +41,7 @@
|
||||
<body>
|
||||
<header class="ui fixed blue inverted menu">
|
||||
<a href="." class="header item">lan<img id="logo" src="../logo.svg" alt="S"/>can</a>
|
||||
<div class="item"><xsl:value-of select="@name"/></div>
|
||||
<div class="item"><xsl:value-of select="@site"/></div>
|
||||
</header>
|
||||
<div class="ui main container">
|
||||
<p><xsl:value-of select="$scan/runstats/finished/@summary"/></p>
|
||||
@ -133,9 +133,18 @@
|
||||
<xsl:otherwise>red</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="title">
|
||||
<xsl:value-of select="$scannedPort/@portid"/>
|
||||
<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: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, '$'))]">
|
||||
<div class="ui {$state} dropdown mini button" title="{$scannedPort/@protocol}/{$scannedPort/@portid} {$scannedPort/service/@name} {$scannedPort/state/@state}">
|
||||
<div class="ui {$state} dropdown mini button" title="{$title}">
|
||||
<div class="text"><xsl:value-of select="@name"/></div>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
@ -146,17 +155,17 @@
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:when test="$scannedPort/service/@name='ms-wbt-server' or $scannedPort/service/@name='rdp'">
|
||||
<a class="ui {$state} mini button" href="../rdp.php?v={$scannedHostAddress}:{$scannedPort/@portid}" title="{$scannedPort/@protocol}/{$scannedPort/@portid} {$scannedPort/service/@name} {$scannedPort/state/@state}">
|
||||
<a class="ui {$state} mini button" href="../rdp.php?v={$scannedHostAddress}:{$scannedPort/@portid}" title="{$title}">
|
||||
<xsl:value-of select="@name"/>
|
||||
</a>
|
||||
</xsl:when>
|
||||
<xsl:when test="$scannedPort/service/@name='ftp' or $scannedPort/service/@name='ssh' or $scannedPort/service/@name='http' or $scannedPort/service/@name='https'">
|
||||
<a class="ui {$state} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank" title="{$scannedPort/@protocol}/{$scannedPort/@portid} {$scannedPort/service/@name} {$scannedPort/state/@state}">
|
||||
<a class="ui {$state} mini button" href="{$scannedPort/service/@name}://{$scannedHostAddress}:{$scannedPort/@portid}" target="_blank" title="{$title}">
|
||||
<xsl:value-of select="@name"/>
|
||||
</a>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<a class="ui disabled {$state} mini button" title="{$scannedPort/@protocol}/{$scannedPort/@portid} {$scannedPort/service/@name} {$scannedPort/state/@state}">
|
||||
<a class="ui disabled {$state} mini button" title="{$title}">
|
||||
<xsl:value-of select="@name"/>
|
||||
</a>
|
||||
</xsl:otherwise>
|
||||
|
17
scan_all.php
17
scan_all.php
@ -23,14 +23,15 @@ foreach (scandir(__DIR__."/confs") as $file) {
|
||||
<lanScanConf/>
|
||||
XML
|
||||
);
|
||||
$xml->addChild("scan path='scans/$site.xml'");
|
||||
|
||||
foreach ($yaml as $siteName => $groups) {
|
||||
$xml->addAttribute("name", $siteName);
|
||||
if ($groups) foreach ($groups as $groupName => $hosts) {
|
||||
$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", $groupName);
|
||||
if ($hosts) foreach($hosts as $hostaddress => $servicesList) {
|
||||
$xmlGroup->addAttribute("name", $key);
|
||||
foreach($value as $hostaddress => $servicesList) {
|
||||
$targets[$hostaddress] = true;
|
||||
$xmlHost = $xmlGroup->addChild("host");
|
||||
$xmlHost->addAttribute("address", $hostaddress);
|
||||
@ -46,7 +47,7 @@ XML
|
||||
$targets = join(array_keys($targets), " ");
|
||||
$services = join(array_keys($services), ",");
|
||||
|
||||
exec("nmap -v -Pn -p $services --script smb-enum-shares,./http-get.nse,./http-favicon-url.nse -oX '".__DIR__."/scans/tmp.xml' $targets\n");
|
||||
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");
|
||||
|
||||
$xml->asXML(__DIR__."/site/$site.xml");
|
||||
|
@ -10,14 +10,15 @@
|
||||
|
||||
<xsl:template match="nmaprun">
|
||||
<xsl:text>---
|
||||
site: </xsl:text><xsl:value-of select="$site" /><xsl:text>
|
||||
|
||||
</xsl:text><xsl:value-of select="$network" /><xsl:text>:
|
||||
</xsl:text>
|
||||
<xsl:value-of select="$site" />:
|
||||
<xsl:text> </xsl:text><xsl:value-of select="$network" />:
|
||||
<xsl:apply-templates select="host"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="host">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="hostnames/hostname/@name"><xsl:value-of select="hostnames/hostname/@name" /></xsl:when>
|
||||
<xsl:otherwise> <xsl:value-of select="address/@addr" /></xsl:otherwise>
|
||||
|
Reference in New Issue
Block a user