fomanticui

This commit is contained in:
Adrien MALINGREY 2023-04-04 08:04:55 +02:00
parent d640f6144a
commit e152780a72
2 changed files with 67 additions and 62 deletions

27
ls.php
View File

@ -4,29 +4,30 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>lanScan</title> <title>lanScan</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></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> <style>
.navbar-brand img { #logo {
margin: 0 -8px 0 0; margin: 0 -.4rem 0 0;
} }
.card-body { .main.container {
padding: .4rem; margin-top: 5em;
} }
</style> </style>
</head> </head>
<body> <body>
<header> <header class="ui fixed centered blue inverted menu">
<nav class="navbar navbar-fixed-top navbar-nav navbar-dark bg-primary p-0 mb-3"> <div class="header item">lan<img id="logo" src="logo.svg" alt="S"/>can</div>
<div class="navbar-brand">lan<img src="logo.svg" alt="S"/>can</div>
</nav>
</header> </header>
<div class="container"> <div class="ui main text container">
<div class="list-group"> <div class="ui link list">
<?php foreach (scandir("./scans") as $file) { <?php foreach (scandir("./scans") as $file) {
if (strrpos($file, ".yaml")) { if (strrpos($file, ".yaml")) {
$site = str_replace(".yaml", "", $file); $site = str_replace(".yaml", "", $file);
echo " <a href='?site=$site' class='list-group-item list-group-item-action'>$site</a>\n"; if (file_exists("scans/$site.xml")) {
echo " <a href='?site=$site' class='item'>$site</a>\n";
}
} }
} ?> } ?>
</div> </div>

View File

@ -3,71 +3,78 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="300">
<title>lanScan - <?=$site?></title> <title>lanScan - <?=$site?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></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> <style>
.navbar-brand img { #logo {
margin: 0 -8px 0 0; margin: 0 -.4rem 0 0;
} }
.card-body { .main.container {
padding: .4rem; margin-top: 5em;
}
.ui.dropdown, .ui.dropdown .menu > .item {
font-size: .85714286rem;
}
.ui.label > .detail {
margin-left: .1em;
} }
</style> </style>
<script>
onload = function (event) {
$('.ui.dropdown').dropdown()
}
</script>
</head> </head>
<body> <body>
<header> <header class="ui fixed blue inverted menu">
<nav class="navbar navbar-fixed-top navbar-nav navbar-dark bg-primary p-0 mb-3"> <a href="." class="header item">lan<img id="logo" src="logo.svg" alt="S"/>can</a>
<a href="." class="navbar-brand">lan<img src="logo.svg" alt="S"/>can</a> <div class="item"><?=$site?></div>
</nav>
</header> </header>
<div class="container"> <div class="ui main text container">
<div class="mb-3"> <p><?=$scan->runstats->finished["summary"]?></p>
<h1><?=$site?></h1>
<?=$scan->runstats->finished["summary"]?>
</div>
<?php foreach($conf as $conf_groupname => $conf_hosts) { ?> <?php foreach($conf as $conf_groupname => $conf_hosts) { ?>
<h2><?=$conf_groupname?></h2> <h1 class="ui header"><?=$conf_groupname?></h1>
<div class="row row-cols-1 g-2"> <div class="ui cards">
<?php <?php
foreach($conf_hosts as $conf_address => $conf_services) { foreach($conf_hosts as $conf_address => $conf_services) {
echo " <!-- $conf_address -->\n"; echo " <!-- $conf_address -->\n";
$scan_host = $scan->xpath("host[hostnames/hostname/@name='$conf_address' or address/@addr='$conf_address']")[0]; $scan_host = $scan->xpath("host[hostnames/hostname/@name='$conf_address' or address/@addr='$conf_address']")[0];
$short_name = preg_match("/^[\d\.]+$/", $conf_address) ? $conf_address : strtok($conf_address, ".")." <small>(".$scan_host->address["addr"].")</small>";
$address = count($scan_host->xpath("hostnames/hostname/@name")) ? $scan_host->xpath("hostnames/hostname/@name")[0] : $scan_host->xpath("address/@addr")[0]; $address = count($scan_host->xpath("hostnames/hostname/@name")) ? $scan_host->xpath("hostnames/hostname/@name")[0] : $scan_host->xpath("address/@addr")[0];
if ($scan_host->status["state"] =="up") { if ($scan_host->status["state"] =="up") {
?> ?>
<div class="col col-sm-6 col-md-4 col-lg-3 mb-2"> <div class="ui card">
<div class="card h-100"> <div class="content">
<div class="card-body"> <div class="header"><?=strtok($scan_host->hostnames->hostname["name"], ".")?></div>
<div class="card-text" title="<?=$scan_host->hostnames->hostname["name"]?>"><?=$short_name?></div> <div class="meta"><?=$scan_host->address["addr"]?></div>
<?php <?php
foreach($conf_services as $conf_service) { foreach($conf_services as $conf_service) {
$scan_service = $scan_host->xpath("ports/port[service/@name='$conf_service' or @portid='$conf_service']")[0]; $scan_service = $scan_host->xpath("ports/port[service/@name='$conf_service' or @portid='$conf_service']")[0];
$state = $scan_service->state["state"] == "open" ? "text-bg-primary" : "text-bg-danger"; $state = $scan_service->state["state"] == "open" ? "primary" : "red";
switch($scan_service->service['name']) { switch($scan_service->service['name']) {
case "microsoft-ds": case "microsoft-ds":
case "netbios-ssn": case "netbios-ssn":
$shares = $scan_host->xpath("hostscript/script[@id='smb-enum-shares']/table[not(contains(@key, '$'))]"); $shares = $scan_host->xpath("hostscript/script[@id='smb-enum-shares']/table[not(contains(@key, '$'))]");
if (count($shares)) { if (count($shares)) {
?> ?>
<div class="dropdown"> <div class="ui dropdown <?=$state?> label">
<button class="badge rounded-pill dropdown-toggle <?=$state?>" dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"><?=$scan_service->service['name']?></button> <?=$scan_service->service['name']?>
<ul class="dropdown-menu"> <i class="dropdown icon"></i>
<div class="menu">
<?php <?php
foreach($shares as $share) { foreach($shares as $share) {
?> ?>
<li><a class='dropdown-item' href='file:////$address/<?=$share['key']?>'><?=$share['key']?></a></li> <a class='item' href='file:////$address/<?=$share['key']?>'><?=$share['key']?></a>
<?php <?php
} }
?> ?>
</ul> </div>
</div> </div>
<?php <?php
} else { } else {
?> ?>
<span title=":<?=$scan_service['portid']?>" class="badge rounded-pill <?=$state?>"><?=$scan_service->service['name']?></span> <div class="ui <?=$state?> label"><?=$scan_service->service['name']?><div class="detail">:<?=$scan_service['portid']?></div></div>
<?php <?php
} }
break; break;
@ -76,39 +83,37 @@
case "ssh": case "ssh":
case "http": case "http":
?> ?>
<a href="<?=$scan_service->service['name']?>://<?=$address?>:<?=$scan_service['portid']?>" class="badge rounded-pill <?=$state?>"><?=$scan_service->service['name']?></a> <a href="<?=$scan_service->service['name']?>://<?=$address?>:<?=$scan_service['portid']?>" class="ui <?=$state?> label"><?=$scan_service->service['name']?><div class="detail">:<?=$scan_service['portid']?></div></a>
<?php <?php
break; break;
case "https": case "https":
case "pve": case "pve":
case "arkeia": case "arkeia":
?> ?>
<a href="https://<?=$address?>:<?=$scan_service['portid']?>" class="badge rounded-pill <?=$state?>"><?=$scan_service->service['name']?></a> <a href="https://<?=$address?>:<?=$scan_service['portid']?>" class="ui <?=$state?> label"><?=$scan_service->service['name']?><div class="detail">:<?=$scan_service['portid']?></div></a>
<?php <?php
break; break;
case "ms-wbt-server": case "ms-wbt-server":
?> ?>
<a href="rdp.php?v=<?=$address?>:<?=$scan_service['portid']?>" class="badge rounded-pill <?=$state?>"><?=$scan_service->service['name']?></a> <a href="rdp.php?v=<?=$address?>:<?=$scan_service['portid']?>" class="ui <?=$state?> label"><?=$scan_service->service['name']?><div class="detail">:<?=$scan_service['portid']?></div></a>
<?php <?php
break; break;
default: default:
?> ?>
<span title=":<?=$scan_service['portid']?>" class="badge rounded-pill <?=$state?>"><?=$scan_service->service['name']?></span> <div class="ui <?=$state?> label"><?=$scan_service->service['name']?><div class="detail">:<?=$scan_service['portid']?></div></div>
<?php <?php
} }
} }
?> ?>
</div> </div>
</div> </div>
</div>
<?php <?php
} else { } else {
?> ?>
<div class="col col-sm-6 col-md-4 col-lg-3 mb-2"> <div class="ui red card">
<div class="card h-100 text-bg-danger"> <div class="content">
<div class="card-body"> <div class="header"><?=strtok($scan_host->hostnames->hostname["name"], ".")?></div>
<div class="card-text" title="<?=$scan_host->hostnames->hostname["name"]?>"><?=$short_name?></div> <div class="meta"><?=$scan_host->address["addr"]?></div>
</div>
</div> </div>
</div> </div>
<?php <?php
@ -119,6 +124,5 @@
<?php <?php
} }
?> ?>
</div>
</body> </body>
</html> </html>