Compare commits
88 Commits
v1
..
c85c175416
| Author | SHA1 | Date | |
|---|---|---|---|
| c85c175416 | |||
| 08187df3a8 | |||
| e42c1342eb | |||
| e577ccb4c1 | |||
| 5e4fb1aa61 | |||
| 556268b1e1 | |||
| 8cb8a6cb04 | |||
| 8098697c4d | |||
| 2f3bb6c4f3 | |||
| d6207258ac | |||
| 0ffd304d2d | |||
| a3c06ef825 | |||
| bbee70cef8 | |||
| e2e255f690 | |||
| 5378e16e24 | |||
| c3082c9442 | |||
| e1bde27789 | |||
| 330205b297 | |||
| 2505c1d974 | |||
| 36b7a91c48 | |||
| 7354c2158a | |||
| 88edeee596 | |||
| 3d1a0ac214 | |||
| ff9f5b3b33 | |||
| 272d97ebf7 | |||
| 8973dc8979 | |||
| 874e5bb833 | |||
| 6eb3eb434d | |||
| c70d24a837 | |||
| 8bfd90a8c4 | |||
| c6cc4aad16 | |||
| d676af67e2 | |||
| 823a78f0ed | |||
| 1383944787 | |||
| 0027932ecd | |||
| fbd0f19ced | |||
| d9d996e081 | |||
| 17c5c02818 | |||
| 8537c2a0ca | |||
| c6e1977ca2 | |||
| fad7c6164e | |||
| d4af5b181f | |||
| 48d6a52931 | |||
| ea98cd9903 | |||
| 6e0e3b60e3 | |||
| 12a0a5ac93 | |||
| 0439aecb98 | |||
| f8c4ea0903 | |||
| ba3c1e1b8a | |||
| c2d62a5ccb | |||
| 72ad03b03b | |||
| 6eac85d5ad | |||
| cdf14a09d9 | |||
| fee3f2a043 | |||
| b3aa55c9b4 | |||
| 6243bc66e5 | |||
| a552a3cc06 | |||
| 72a9c62d4a | |||
| 61486d7dab | |||
| c2bd2ee679 | |||
| 7d25fd2472 | |||
| c6691ed1d2 | |||
| 4822ad3e5d | |||
| a640f71c7e | |||
| 0d8d3d0c7b | |||
| e37ba4993e | |||
| 64d2dece69 | |||
| a09777bdc4 | |||
| 32423db827 | |||
| e6b9a7a6be | |||
| 15e33765e5 | |||
| 98b7fab684 | |||
| 3a162f4568 | |||
| c7b85862e6 | |||
| 24c32fa513 | |||
| 7b66313c01 | |||
| d3b5a014e1 | |||
| 7592b803fb | |||
| 3a5d60e1c0 | |||
| 69f4127f9e | |||
| 4d06c3407b | |||
| 01c4b662d5 | |||
| 9b3e6537d5 | |||
| e152780a72 | |||
| d640f6144a | |||
| 4aac159021 | |||
| d259b626d5 | |||
| e93d37cacd |
+4
-27
@@ -1,27 +1,4 @@
|
||||
# ---> CakePHP
|
||||
# CakePHP 3
|
||||
|
||||
/vendor/*
|
||||
/config/app.php
|
||||
|
||||
/tmp/cache/models/*
|
||||
!/tmp/cache/models/empty
|
||||
/tmp/cache/persistent/*
|
||||
!/tmp/cache/persistent/empty
|
||||
/tmp/cache/views/*
|
||||
!/tmp/cache/views/empty
|
||||
/tmp/sessions/*
|
||||
!/tmp/sessions/empty
|
||||
/tmp/tests/*
|
||||
!/tmp/tests/empty
|
||||
|
||||
/logs/*
|
||||
!/logs/empty
|
||||
|
||||
# CakePHP 2
|
||||
|
||||
/app/tmp/*
|
||||
/app/Config/core.php
|
||||
/app/Config/database.php
|
||||
/vendors/*
|
||||
|
||||
nse/script-args.ini
|
||||
configs/
|
||||
scans/
|
||||
site/
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# lanScan
|
||||
|
||||
Scanne des hôtes avec `nmap`
|
||||
et affiche le résultat dans une page web.
|
||||
|
||||
* Créer un fichier de configuration YAML dans un sous-dossier ./configs/ (voir l'exemple ci-dessous).
|
||||
Il peut être généré en scannant un réseau avec : `./discover <CIDR>`.
|
||||
* Scanner avec le script `./scan_all` (utiliser une tâche cron !).
|
||||
* Voir les résultats en ouvrant `.\index.php` dans le navigateur web.
|
||||
|
||||
## Exemple
|
||||
```yaml
|
||||
---
|
||||
site: Nom du site
|
||||
|
||||
hosts:
|
||||
- name: Nom du premier groupe
|
||||
host:
|
||||
- address: host1.local
|
||||
services: [ssh, http]
|
||||
- address: 192.168.1.100
|
||||
services: [ftp, https, 5432]
|
||||
- name: Nom du 2ème groupe
|
||||
host:
|
||||
- adress: host3.local
|
||||
services: [ssh, ftp, 8006]
|
||||
```
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
# LanScan
|
||||
# lanScan
|
||||
|
||||
Scan hosts with `nmap` and display results in webpage.
|
||||
|
||||
* Create a configuration yaml file in ./configs/ subdirectory (see example below).
|
||||
It may be generated by scanning a network with `./discover <CIDR>`.
|
||||
* Scan with `./scan_all` (use a cron task!).
|
||||
* Open `.\index.php` in web browser to see results.
|
||||
|
||||
## Example
|
||||
```yaml
|
||||
---
|
||||
site: Nom du site
|
||||
|
||||
hosts:
|
||||
- name: Nom du premier groupe
|
||||
host:
|
||||
- address: host1.local
|
||||
services: [ssh, http]
|
||||
- address: 192.168.1.100
|
||||
services: [ftp, https, 5432]
|
||||
- name: Nom du 2ème groupe
|
||||
host:
|
||||
- adress: host3.local
|
||||
services: [ssh, ftp, 8006]
|
||||
```
|
||||
|
||||
Web UI for nmap
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
###
|
||||
#
|
||||
# Scan un réseau avec nmap pour créer un fichier de configuration
|
||||
# Usage : ./discover <reseau> avec reseau en notation CIDR XXX.XXX.XXX.XXX/XX
|
||||
#
|
||||
###
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo -e "Usage : ./discover <CIDR>\navec <CIDR> l'adresse réseau en notation CIDR (XXX.XXX.XXX.XXX/XX)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$(dirname -- "$0")" > /dev/null
|
||||
network="$1"
|
||||
site="${network/\//_}"
|
||||
|
||||
mkdir -p "scans"
|
||||
nmap -F -oX "scans/$site.xml" $network
|
||||
mkdir -p "configs"
|
||||
xsltproc --stringparam network "$network" to_config.xsl "scans/$site.xml" > "configs/$site.yaml"
|
||||
php to_XML.php "configs/$site.yaml" > "site/$site.xml"
|
||||
|
||||
popd > /dev/null
|
||||
@@ -0,0 +1,46 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>lanScan</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>
|
||||
<style>
|
||||
#logo {
|
||||
margin: 0 -.4rem 0 0;
|
||||
}
|
||||
.main.container {
|
||||
margin-top: 5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="ui fixed centered blue inverted menu">
|
||||
<div class="header item">lan<img id="logo" src="logo.svg" alt="S"/>can</div>
|
||||
</header>
|
||||
<div class="ui main text container">
|
||||
<div class="ui link selection list">
|
||||
<?php
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (scandir("./site") as $file) {
|
||||
if (str_ends_with($file, ".xml")) {
|
||||
$site = str_replace(".xml", "", $file);
|
||||
if (file_exists("scans/$site.xml")) {
|
||||
echo " <a href='site/$site.xml' class='item'>$site</a>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,53 @@
|
||||
<svg class="logo" style="margin: 0 -8px 0 0; fill: white;" version="1.1" id="Layer_1" x="0px" y="0px"
|
||||
viewBox="0 0 24 24" xml:space="preserve" width="40" height="40" xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs id="defs206" />
|
||||
<g id="g998" transform="matrix(0,0.04687491,-0.04687491,0,24,2.2682373e-5)">
|
||||
<g id="g147">
|
||||
<g id="g145">
|
||||
<path
|
||||
d="m 322.065,92.046 c -46.24,0 -83.851,37.619 -83.851,83.857 v 168.712 c 0,25.224 -21.148,45.745 -46.372,45.745 -25.224,0 -46.372,-20.521 -46.372,-45.745 V 199.464 h -38.114 v 145.151 c 0,46.24 38.246,83.859 84.486,83.859 46.24,0 84.486,-37.619 84.486,-83.859 V 175.903 c 0,-25.223 20.514,-45.743 45.737,-45.743 25.223,0 45.737,20.521 45.737,45.743 v 134.092 h 38.114 V 175.903 c 0,-46.239 -37.611,-83.857 -83.851,-83.857 z"
|
||||
id="path143" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="g153">
|
||||
<g id="g151">
|
||||
<path
|
||||
d="M 144.198,0 H 108.625 C 98.101,0 89.568,8.746 89.568,19.271 c 0,1.157 0.121,2.328 0.318,3.598 h 73.052 c 0.197,-1.27 0.318,-2.441 0.318,-3.598 C 163.256,8.746 154.723,0 144.198,0 Z"
|
||||
id="path149" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="g159">
|
||||
<g id="g157">
|
||||
<path
|
||||
d="m 420.183,486.591 h -71.731 c -0.626,2.541 -0.978,4.077 -0.978,6.176 0,10.525 8.532,19.234 19.057,19.234 h 35.573 c 10.525,0 19.057,-8.709 19.057,-19.234 0,-2.098 -0.352,-3.635 -0.978,-6.176 z"
|
||||
id="path155" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="g165">
|
||||
<g id="g163">
|
||||
<rect x="87.027" y="41.925999" width="80.040001" height="138.481" id="rect161" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="g171">
|
||||
<g id="g169">
|
||||
<rect x="344.93301" y="329.052" width="80.040001" height="138.481" id="rect167" />
|
||||
</g>
|
||||
</g>
|
||||
<g id="g173"></g>
|
||||
<g id="g175"></g>
|
||||
<g id="g177"></g>
|
||||
<g id="g179"></g>
|
||||
<g id="g181"></g>
|
||||
<g id="g183"></g>
|
||||
<g id="g185"></g>
|
||||
<g id="g187"></g>
|
||||
<g id="g189"></g>
|
||||
<g id="g191"></g>
|
||||
<g id="g193"></g>
|
||||
<g id="g195"></g>
|
||||
<g id="g197"></g>
|
||||
<g id="g199"></g>
|
||||
<g id="g201"></g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,35 @@
|
||||
<?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:output method="text" encoding="UTF-8" indent="yes" />
|
||||
|
||||
<xsl:param name="site"/>
|
||||
|
||||
<xsl:template match="lanScan">
|
||||
<xsl:text>nmap -v -T4 -p </xsl:text>
|
||||
<xsl:apply-templates select="//service[not(.=preceding::*)]" />
|
||||
<xsl:text> --script nse/ --datadir nse/ --script-args-file script-args.ini -oX "</xsl:text>
|
||||
<xsl:value-of select="@scanpath"/>
|
||||
<xsl:text>.tmp" </xsl:text>
|
||||
<xsl:apply-templates select="//host"/>
|
||||
<xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="service">
|
||||
<xsl:value-of select="." />
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>,</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="host">
|
||||
<xsl:value-of select="@address" />
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,110 @@
|
||||
local shortport = require "shortport"
|
||||
|
||||
description = [[
|
||||
Get and return a page info
|
||||
]]
|
||||
|
||||
---
|
||||
-- @args http-get.path Path to get. Default /.
|
||||
--
|
||||
-- @usage nmap -p80 --script http-info.nse --script-args http-info.path=/ <host>
|
||||
--
|
||||
-- @output
|
||||
-- status: 200
|
||||
-- status-line: HTTP/1.1 200 OK\x0D
|
||||
---
|
||||
|
||||
categories = {"discovery", "intrusive"}
|
||||
author = "Adrien Malingrey"
|
||||
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
||||
|
||||
portrule = shortport.service({"http", "https", "ssl"})
|
||||
|
||||
|
||||
local http = require "http"
|
||||
local stdnse = require "stdnse"
|
||||
|
||||
action = function(host, port)
|
||||
local scheme = ""
|
||||
local hostaddress = (host.name ~= '' and host.name) or host.ip
|
||||
local path = "/"
|
||||
local uri
|
||||
local favicon_relative_uri = "/favicon.ico"
|
||||
local favicon
|
||||
|
||||
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-info.path')
|
||||
end
|
||||
|
||||
uri = scheme.."://"..hostaddress..":"..port.number..path
|
||||
stdnse.debug1("Try to download %s", uri)
|
||||
local answer = http.get_url(uri, {})
|
||||
|
||||
local info = {status=answer.status, ["status-line"]=answer["status-line"]}
|
||||
|
||||
if (answer and answer.status == 200) then
|
||||
stdnse.debug1("[SUCCESS] Load page %s", uri)
|
||||
-- Taken from http-title.nse by Diman Todorov
|
||||
local title = string.match(answer.body, "<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")
|
||||
if (title) then
|
||||
info.title = title
|
||||
end
|
||||
stdnse.debug1("[INFO] Try favicon %s", favicon_relative_uri)
|
||||
favicon_relative_uri = parseIcon(answer.body) or "favicon.ico"
|
||||
else
|
||||
stdnse.debug1("[ERROR] Can't load page %s", uri)
|
||||
end
|
||||
|
||||
favicon_absolute_uri = scheme.."://"..hostaddress..":"..port.number..favicon_relative_uri
|
||||
favicon = http.get_url(favicon_absolute_uri, {})
|
||||
|
||||
if (favicon and favicon.status == 200) then
|
||||
stdnse.debug1("[SUCCESS] Load favicon %s", favicon_absolute_uri)
|
||||
info.favicon = favicon_absolute_uri
|
||||
else
|
||||
stdnse.debug1("[ERROR] Can't load favicon %s", favicon_absolute_uri)
|
||||
end
|
||||
|
||||
return info
|
||||
end
|
||||
|
||||
--- function taken from http_favicon.nse by Vlatko Kosturjak
|
||||
|
||||
function parseIcon( body )
|
||||
local _, i, j
|
||||
local rel, href, word
|
||||
|
||||
-- Loop through link elements.
|
||||
i = 0
|
||||
while i do
|
||||
_, i = string.find(body, "<%s*[Ll][Ii][Nn][Kk]%s", i + 1)
|
||||
if not i then
|
||||
return nil
|
||||
end
|
||||
-- Loop through attributes.
|
||||
j = i
|
||||
while true do
|
||||
local name, quote, value
|
||||
_, j, name, quote, value = string.find(body, "^%s*(%w+)%s*=%s*([\"'])(.-)%2", j + 1)
|
||||
if not j then
|
||||
break
|
||||
end
|
||||
if string.lower(name) == "rel" then
|
||||
rel = value
|
||||
elseif string.lower(name) == "href" then
|
||||
href = value
|
||||
end
|
||||
end
|
||||
for word in string.gmatch(rel or "", "%S+") do
|
||||
if string.lower(word) == "icon" then
|
||||
return href
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
smbuser =
|
||||
smbpassword =
|
||||
@@ -0,0 +1,197 @@
|
||||
local stdnse = require "stdnse"
|
||||
local smb = require "smb"
|
||||
local msrpc = require "msrpc"
|
||||
local bin = require "bin"
|
||||
|
||||
description = [[
|
||||
Return free and total size in octets of each SMB shares
|
||||
]]
|
||||
|
||||
---
|
||||
-- @args See the documentation for the smbauth library.
|
||||
--
|
||||
-- @usage nmap -p445 --script smb-shares-size.nse <host>
|
||||
--
|
||||
-- @output
|
||||
-- Host script results:
|
||||
-- | smb-shares-size:
|
||||
-- | data:
|
||||
-- | FreeSize: 38495883264
|
||||
-- | TotalSize: 500961574912
|
||||
-- |_ IPC$: NT_STATUS_ACCESS_DENIED
|
||||
---
|
||||
|
||||
categories = {"discovery", "intrusive"}
|
||||
author = "Adrien Malingrey"
|
||||
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
|
||||
|
||||
hostrule = function(host)
|
||||
return smb.get_port(host) ~= nil
|
||||
end
|
||||
|
||||
action = function(host)
|
||||
local status, shares, extra
|
||||
local response = stdnse.output_table()
|
||||
|
||||
-- Try and do this the good way, make a MSRPC call to get the shares
|
||||
stdnse.debug1("SMB: Attempting to log into the system to enumerate shares")
|
||||
status, shares = msrpc.enum_shares(host)
|
||||
if(status == false) then
|
||||
return stdnse.format_output(false, string.format("Couldn't enumerate shares: %s", shares))
|
||||
end
|
||||
|
||||
-- Get more information on each share
|
||||
for i = 1, #shares, 1 do
|
||||
local share = shares[i]
|
||||
if (share ~= nil) then
|
||||
local status, result = get_share_info(host, share)
|
||||
if (status) then
|
||||
response[share] = result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return response
|
||||
end
|
||||
|
||||
TRANS2_QUERY_FS_INFORMATION = 0x0003
|
||||
SMB_QUERY_FS_SIZE_INFO = 0x0103
|
||||
---Attempts to retrieve additional information about a share. Will fail unless we have
|
||||
-- administrative access.
|
||||
--
|
||||
--@param host The host object.
|
||||
--@return Status (true or false).
|
||||
--@return A table of information about the share (if status is true) or an an error string (if
|
||||
-- status is false).
|
||||
function get_share_info(host, share)
|
||||
local status, smbstate, err
|
||||
local hostaddress = (host.name ~= '' and host.name) or host.ip
|
||||
local path = "\\\\" .. hostaddress .. "\\" .. share
|
||||
|
||||
status, smbstate = smb.start(host)
|
||||
status, err = smb.negotiate_protocol(smbstate, {})
|
||||
status, err = smb.start_session(smbstate, {})
|
||||
status, err = smb.tree_connect(smbstate, path, {})
|
||||
|
||||
stdnse.debug1("SMB: Getting information for share: %s", path)
|
||||
|
||||
local status, err = send_transaction2(smbstate, TRANS2_QUERY_FS_INFORMATION, bin.pack("<S", SMB_QUERY_FS_SIZE_INFO))
|
||||
if ( not(status) ) then
|
||||
status, err = smb.stop(smbstate)
|
||||
return false, "Failed to send data to server: send_transaction2"
|
||||
end
|
||||
|
||||
local status, response = receive_transaction2(smbstate)
|
||||
if ( not(status) ) then
|
||||
status, err = smb.stop(smbstate)
|
||||
return false, response
|
||||
end
|
||||
|
||||
local pos, totalAllocationUnits, totalFreeAllocationUnits, sectorsPerAllocationUnit, bytesPerSector = bin.unpack("<LLII", response.data)
|
||||
|
||||
status, err = smb.stop(smbstate)
|
||||
|
||||
return true, {
|
||||
TotalSize = totalAllocationUnits * sectorsPerAllocationUnit * bytesPerSector,
|
||||
FreeSize = totalFreeAllocationUnits * sectorsPerAllocationUnit * bytesPerSector
|
||||
}
|
||||
end
|
||||
|
||||
-- Taken from smb lib
|
||||
|
||||
function send_transaction2(smbstate, sub_command, function_parameters, function_data, overrides)
|
||||
overrides = overrides or {}
|
||||
local header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, pid, mid
|
||||
local header, parameters, data
|
||||
local parameter_offset = 0
|
||||
local parameter_size = 0
|
||||
local data_offset = 0
|
||||
local data_size = 0
|
||||
local total_word_count, total_data_count, reserved1, parameter_count, parameter_displacement, data_count, data_displacement, setup_count, reserved2
|
||||
local response = {}
|
||||
|
||||
-- Header is 0x20 bytes long (not counting NetBIOS header).
|
||||
header = smb.smb_encode_header(smbstate, smb.command_codes['SMB_COM_TRANSACTION2'], overrides) -- 0x32 = SMB_COM_TRANSACTION2
|
||||
|
||||
if(function_parameters) then
|
||||
parameter_offset = 0x44
|
||||
parameter_size = #function_parameters
|
||||
data_offset = #function_parameters + 33 + 32
|
||||
end
|
||||
|
||||
-- Parameters are 0x20 bytes long.
|
||||
parameters = bin.pack("<SSSSCCSISSSSSCCS",
|
||||
parameter_size, -- Total parameter count.
|
||||
data_size, -- Total data count.
|
||||
0x000a, -- Max parameter count.
|
||||
0x3984, -- Max data count.
|
||||
0x00, -- Max setup count.
|
||||
0x00, -- Reserved.
|
||||
0x0000, -- Flags (0x0000 = 2-way transaction, don't disconnect TIDs).
|
||||
0x00001388, -- Timeout (0x00000000 = return immediately).
|
||||
0x0000, -- Reserved.
|
||||
parameter_size, -- Parameter bytes.
|
||||
parameter_offset, -- Parameter offset.
|
||||
data_size, -- Data bytes.
|
||||
data_offset, -- Data offset.
|
||||
0x01, -- Setup Count
|
||||
0x00, -- Reserved
|
||||
sub_command -- Sub command
|
||||
)
|
||||
|
||||
local data = "\0\0\0" .. (function_parameters or '')
|
||||
.. (function_data or '')
|
||||
|
||||
-- Send the transaction request
|
||||
stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2")
|
||||
local result, err = smb.smb_send(smbstate, header, parameters, data, overrides)
|
||||
if(result == false) then
|
||||
return false, err
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function receive_transaction2(smbstate)
|
||||
|
||||
-- Read the result
|
||||
local status, header, parameters, data = smb.smb_read(smbstate)
|
||||
if(status ~= true) then
|
||||
return false, header
|
||||
end
|
||||
|
||||
-- Check if it worked
|
||||
local pos, header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, tid, pid, uid, mid = bin.unpack("<CCCCCICSSlSSSSS", header)
|
||||
if(header1 == nil or mid == nil) then
|
||||
return false, "SMB: ERROR: Server returned less data than it was supposed to (one or more fields are missing); aborting [29]"
|
||||
end
|
||||
if(status ~= 0) then
|
||||
if(smb.status_names[status] == nil) then
|
||||
return false, string.format("Unknown SMB error: 0x%08x\n", status)
|
||||
else
|
||||
return false, smb.status_names[status]
|
||||
end
|
||||
end
|
||||
|
||||
-- Parse the parameters
|
||||
local pos, total_word_count, total_data_count, reserved1, parameter_count, parameter_offset, parameter_displacement, data_count, data_offset, data_displacement, setup_count, reserved2 = bin.unpack("<SSSSSSSSSCC", parameters)
|
||||
if(total_word_count == nil or reserved2 == nil) then
|
||||
return false, "SMB: ERROR: Server returned less data than it was supposed to (one or more fields are missing); aborting [30]"
|
||||
end
|
||||
|
||||
-- Convert the parameter/data offsets into something more useful (the offset into the data section)
|
||||
-- - 0x20 for the header, - 0x01 for the length.
|
||||
parameter_offset = parameter_offset - 0x20 - 0x01 - #parameters - 0x02;
|
||||
-- - 0x20 for the header, - 0x01 for parameter length, the parameter length, and - 0x02 for the data length.
|
||||
data_offset = data_offset - 0x20 - 0x01 - #parameters - 0x02;
|
||||
|
||||
-- I'm not sure I entirely understand why the '+1' is here, but I think it has to do with the string starting at '1' and not '0'.
|
||||
local function_parameters = string.sub(data, parameter_offset + 1, parameter_offset + parameter_count)
|
||||
local function_data = string.sub(data, data_offset + 1, data_offset + data_count)
|
||||
|
||||
local response = {}
|
||||
response['parameters'] = function_parameters
|
||||
response['data'] = function_data
|
||||
|
||||
return true, response
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
header("Content-Disposition: attachment; filename=".str_replace(":", "_", $_GET["v"]).".rdp");
|
||||
header("Content-Type: application/rdp");
|
||||
print "full address:s:${_GET[v]}\n";
|
||||
exit();
|
||||
?>
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
<?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:output method="html" encoding="UTF-8" indent="yes"/>
|
||||
|
||||
<xsl:variable name="scan" select="document(string(lanScan/@scanpath))/nmaprun"/>
|
||||
|
||||
<xsl:template match="lanScan">
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<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>
|
||||
<style>
|
||||
#logo {
|
||||
margin: 0 -.4rem 0 0;
|
||||
}
|
||||
.main.container {
|
||||
margin-top: 5em;
|
||||
}
|
||||
.ui.mini.button {
|
||||
padding: 1em;
|
||||
}
|
||||
.icon {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
}
|
||||
.icon > img {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.button.share-size {
|
||||
--bg: #21ba45;
|
||||
}
|
||||
|
||||
.item.share-size {
|
||||
--bg: white;
|
||||
}
|
||||
|
||||
.share-size {
|
||||
--free-ratio: calc(var(--free) / var(--total));
|
||||
--used-percent: calc(100% - 100%*var(--free-ratio));
|
||||
--color: hsl(calc(120*var(--free-ratio)) 100% 50%);
|
||||
background: linear-gradient(to right, var(--color) var(--used-percent), var(--bg) var(--used-percent), var(--bg)) !important;
|
||||
}
|
||||
</style>
|
||||
<meta http-equiv="refresh" content="60"/>
|
||||
</head>
|
||||
<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="header center item"><xsl:value-of select="@site"/></div>
|
||||
</header>
|
||||
<div class="ui main container">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$scan/runstats/finished/@errormsg">
|
||||
<div class="ui negative icon message">
|
||||
<i class="exclamation triangle icon"></i>
|
||||
<div class="content">
|
||||
<div class="header" style="text-transform: capitalize"><xsl:value-of select="$scan/runstats/finished/@exit"/></div>
|
||||
<p><xsl:value-of select="$scan/runstats/finished/@errormsg"/></p>
|
||||
</div>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:when test="$scan/runstats/finished/@summary">
|
||||
<div class="ui icon message">
|
||||
<i class="sitemap icon"></i>
|
||||
<div class="content">
|
||||
<div class="header" style="text-transform: capitalize"><xsl:value-of select="$scan/runstats/finished/@exit"/></div>
|
||||
<p><xsl:value-of select="$scan/runstats/finished/@summary"/></p>
|
||||
</div>
|
||||
</div>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="hosts"/>
|
||||
</div>
|
||||
<script>
|
||||
$('.ui.dropdown').dropdown()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="hosts">
|
||||
<h1 class="ui header"><xsl:value-of select="@name"/></h1>
|
||||
<div class="ui doubling stackable four column compact grid">
|
||||
<xsl:apply-templates select="host"/>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="host">
|
||||
<xsl:variable name="address" select="@address"/>
|
||||
<xsl:variable name="scannedHost" select="$scan/host[hostnames/hostname/@name=$address or address/@addr=$address]"/>
|
||||
<xsl:variable name="scannedHostAddress">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$scannedHost/hostnames/hostname/@name">
|
||||
<xsl:value-of select="$scannedHost/hostnames/hostname/@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$scannedHost/address/@addr">
|
||||
<xsl:value-of select="$scannedHost/address/@addr"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$address"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="name">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
|
||||
<xsl:when test="$scannedHost/hostnames/hostname/@name"><xsl:value-of select="substring-before($scannedHost/hostnames/hostname/@name, '.')"/></xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<div class="column">
|
||||
<xsl:variable name="status">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$scannedHost/status/@state='up'">success</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-info']/elem[@key='favicon']">
|
||||
<i class="icon"><img class="ui image" src="{$scannedHost/ports/port/script[@id='http-info']/elem[@key='favicon']}" alt=""/></i>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<i class="server icon"></i>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<input type="text" readonly="" value="{$name}" placeholder="{$scannedHost/address/@addr}"
|
||||
title="{@comment} {$scannedHost/hostnames/hostname/@name} ({$scannedHost/address/@addr}) "
|
||||
onfocus="this.value='{$scannedHostAddress}'; this.select()" onblur="this.value='{$name}'"
|
||||
/>
|
||||
<xsl:apply-templates select="service">
|
||||
<xsl:with-param name="scannedHost" select="$scannedHost"/>
|
||||
<xsl:with-param name="scannedHostAddress" select="$scannedHostAddress"/>
|
||||
</xsl:apply-templates>
|
||||
</div>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="service">
|
||||
<xsl:param name="scannedHost"/>
|
||||
<xsl:param name="scannedHostAddress"/>
|
||||
<xsl:variable name="serviceName" select="."/>
|
||||
<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-info']/elem[@key='status']>=500">red</xsl:when>
|
||||
<xsl:when test="$scannedPort/script[@id='http-info']/elem[@key='status']>=400">yellow</xsl:when>
|
||||
<xsl:when test="$scannedPort/state/@state='filtered'">yellow</xsl:when>
|
||||
<xsl:when test="$scannedPort/state/@state='open'">green</xsl:when>
|
||||
<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/state/@state"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$scannedPort/service/@name"/>
|
||||
<xsl:if test="$scannedPort/script[@id='http-info']"><xsl:text>
|
||||
</xsl:text><xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='status-line']"/>
|
||||
<xsl:value-of select="$scannedPort/script[@id='http-info']/elem[@key='title']"/>
|
||||
</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-shares-size']">
|
||||
<div class="ui {$state} dropdown mini button share-size" title="{$title}" style="--free:{$scannedHost/hostscript/script[@id='smb-shares-size']/table/elem[@key='FreeSize']}; --total:{$scannedHost/hostscript/script[@id='smb-shares-size']/table/elem[@key='TotalSize']}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<!-- xsl:apply-templates select="$scannedHost/hostscript/script[@id='smb-shares-size']/table[not(contains(@key, '$'))]" -->
|
||||
<xsl:apply-templates select="$scannedHost/hostscript/script[@id='smb-shares-size']/table">
|
||||
<xsl:with-param name="scannedHostAddress" select="$scannedHostAddress"/>
|
||||
</xsl:apply-templates>
|
||||
</div>
|
||||
</div>
|
||||
</xsl:when>
|
||||
<xsl:when test="$scannedPort/service/@name='ms-wbt-server' or $scannedPort/service/@name='msrpc'">
|
||||
<a class="ui {$state} mini button" href="../rdp.php?v={$scannedHostAddress}:{$scannedPort/@portid}" title="{$title}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
</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="{$title}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
</a>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<a class="ui disabled {$state} mini button" title="{$title}">
|
||||
<xsl:value-of select="$serviceName"/>
|
||||
</a>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="table">
|
||||
<xsl:param name="scannedHostAddress"/>
|
||||
<a class="item share-size" href="file://///{$scannedHostAddress}/{@key}" target="_blank" rel="noopener noreferrer" style="--free:{elem[@key='FreeSize']}; --total:{elem[@key='TotalSize']}">
|
||||
<xsl:value-of select="@key"/>
|
||||
</a>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: ./scan <config>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$(dirname -- "$0")" > /dev/null
|
||||
site="$(basename ${1/.yaml/})"
|
||||
|
||||
php "to_XML.php" "configs/$site.yaml" > "site/$site.xml" \
|
||||
&& eval $(xsltproc "nmap_cmd.xsl" "site/$site.xml") \
|
||||
&& mv "scans/$site.xml.tmp" "scans/$site.xml"
|
||||
|
||||
popd > /dev/null
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pushd "$(dirname -- $0)" > /dev/null
|
||||
|
||||
mkdir -p scans
|
||||
mkdir -p site
|
||||
|
||||
for config in configs/*.yaml
|
||||
do
|
||||
site="$(basename ${config/.yaml/})"
|
||||
echo "Scan $site"
|
||||
./scan "$site"
|
||||
done
|
||||
|
||||
popd > /dev/null
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
<?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="2.0">
|
||||
<xsl:output method="html" encoding="UTF-8" />
|
||||
<xsl:output indent="yes" />
|
||||
<xsl:strip-space elements="*" />
|
||||
|
||||
<xsl:template match="nmaprun">
|
||||
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title><xsl:value-of select="./@args" /></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style>
|
||||
.btn {
|
||||
margin: 2px;
|
||||
padding: 2px 6px !important;
|
||||
}
|
||||
|
||||
.badge {
|
||||
margin: 0px;
|
||||
padding: 2px 4px !important;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/b-2.2.3/b-html5-2.2.3/b-print-2.2.3/cr-1.5.6/fc-4.1.0/fh-3.2.3/r-2.3.0/rr-1.2.8/sc-2.0.6/datatables.min.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table id="scanResults" class="table table-striped table-hover compact caption-top" style="width:100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Adresse IP</th>
|
||||
<th>Nom DNS</th>
|
||||
<th>Services</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<xsl:for-each select="host[status/@state='up']">
|
||||
<tr>
|
||||
<td>
|
||||
<xsl:value-of select="address/@addr" />
|
||||
</td>
|
||||
<td>
|
||||
<xsl:value-of select="hostnames/hostname/@name" />
|
||||
</td>
|
||||
<td>
|
||||
<xsl:for-each select="ports/port[state/@state='open']">
|
||||
<a target="_blank" style="text-transform:uppercase;" type="button" class="btn btn-success btn-sm">
|
||||
<xsl:variable name="protocol">
|
||||
<xsl:choose>
|
||||
<xsl:when test="service/@name='http' or service/@name='https' or service/@name='http-alt' or @portid = 8006 or @portid = 9292 or @portid = 20618">
|
||||
<xsl:choose>
|
||||
<xsl:when test="service/@tunnel='ssl' or script[@id='ssl-cert'] or script[@id='ssl-date']">
|
||||
<xsl:text>https://</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>http://</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="service/@name='ftp' or service/@name='ssh' or service/@name='telnet'">
|
||||
<xsl:value-of select="service/@name" />
|
||||
<xsl:text>://</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="service/@name = 'microsoft-ds' or service/@name = 'netbios-ssn'">
|
||||
<xsl:text>file://///</xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$protocol != ''">
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="$protocol" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(../../hostnames/hostname) > 0">
|
||||
<xsl:value-of select="../../hostnames/hostname/@name" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="../../address/@addr" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>:</xsl:text>
|
||||
<xsl:value-of select="@portid"/>
|
||||
</xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="class">
|
||||
btn btn-success btn-sm disabled
|
||||
</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:attribute name="title">
|
||||
<xsl:for-each select="service/@*">
|
||||
<xsl:value-of select="concat(name(), ': ', ., ', ')"/>
|
||||
</xsl:for-each>
|
||||
</xsl:attribute>
|
||||
<span class="badge bg-secondary rounded-pill"><xsl:value-of select="@portid"/></span>
|
||||
<xsl:value-of select="service/@name" />
|
||||
</a>
|
||||
</xsl:for-each>
|
||||
</td>
|
||||
</tr>
|
||||
</xsl:for-each>
|
||||
</tbody>
|
||||
<caption>
|
||||
<pre class="mb-0" style="white-space:pre-wrap; word-wrap:break-word;">
|
||||
<xsl:value-of select="/nmaprun/@args" />
|
||||
</pre>
|
||||
<time>
|
||||
<xsl:value-of select="/nmaprun/@startstr" />
|
||||
</time> - <time>
|
||||
<xsl:value-of select="/nmaprun/runstats/finished/@timestr" />
|
||||
</time><br />
|
||||
<small>
|
||||
<xsl:value-of select="/nmaprun/@scanner" /> v
|
||||
<xsl:value-of select="/nmaprun/@version" />
|
||||
</small>
|
||||
</caption>
|
||||
|
||||
</table>
|
||||
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.6.0.min.js"
|
||||
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
|
||||
crossorigin="anonymous">
|
||||
</script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/jq-3.6.0/dt-1.12.1/b-2.2.3/b-html5-2.2.3/b-print-2.2.3/cr-1.5.6/fc-4.1.0/fh-3.2.3/r-2.3.0/rr-1.2.8/sc-2.0.6/datatables.min.js"></script>
|
||||
<script>
|
||||
$(document).ready( function() {
|
||||
$('#scanResults').DataTable({
|
||||
fixedHeader: true,
|
||||
lengthMenu: [
|
||||
[256, 512, 1024, 2048, -1],
|
||||
[256, 512, 1024, 2048, "All"]
|
||||
],
|
||||
scrollCollapse: true,
|
||||
paging: false,
|
||||
responsive: true,
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
$file = $argv[1];
|
||||
$site = basename($file, ".yaml");
|
||||
$__DIR__ = __DIR__;
|
||||
|
||||
$conf = yaml_parse_file($file);
|
||||
|
||||
$xml = new DomDocument("1.0", "utf-8");
|
||||
$xml->preserveWhiteSpace = false;
|
||||
$xml->formatOutput = true;
|
||||
$xml->appendChild($xml->createProcessingInstruction("xml-stylesheet", "href='../results.xsl' type='text/xsl'"));
|
||||
$root = $xml->appendChild($xml->createElement("lanScan"));
|
||||
$root->setAttribute("scanpath", "./scans/$site.xml");
|
||||
|
||||
function appendArray($document, $node, $array) {
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $vkey => $vvalue) {
|
||||
if (is_string($vkey)) {
|
||||
if (is_array($vvalue)) {
|
||||
$child = $document->createElement($vkey);
|
||||
toXML($document, $child, $vvalue);
|
||||
} else {
|
||||
$child = $document->createElement($vkey, $vvalue);
|
||||
}
|
||||
$node->appendChild($child);
|
||||
} else {
|
||||
if (is_array($vvalue)) {
|
||||
$child = $document->createElement($key);
|
||||
appendArray($document, $child, $vvalue);
|
||||
} else {
|
||||
$child = $document->createElement($key, $vvalue);
|
||||
}
|
||||
$node->appendChild($child);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
$node->setAttribute($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendArray($xml, $root, $conf);
|
||||
|
||||
print $xml->saveXML();
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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:output method="text" encoding="UTF-8" indent="yes" />
|
||||
|
||||
<xsl:param name="network"/>
|
||||
|
||||
<xsl:template match="nmaprun">
|
||||
<xsl:text>---
|
||||
site: Nom du site
|
||||
|
||||
hosts:
|
||||
- name: Réseau </xsl:text><xsl:value-of select="$network"/><xsl:text>
|
||||
host:
|
||||
</xsl:text>
|
||||
<xsl:apply-templates select="host"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="host">
|
||||
<xsl:text> - address: </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>
|
||||
</xsl:choose>
|
||||
service: [<xsl:apply-templates select="ports/port"/>]
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="port">
|
||||
<xsl:value-of select="service/@name" />
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Reference in New Issue
Block a user