manual nmap scan

a little less PHP/POST and a little more JS. the nmap scan now also works via the presence page
This commit is contained in:
leiweibau
2022-06-28 23:04:14 +02:00
parent 334eea8592
commit 169d69251c
3 changed files with 11 additions and 4 deletions

View File

@@ -436,13 +436,19 @@
<!-- Datatable Session --> <!-- Datatable Session -->
<div style="width:100%; text-align: center;"> <div style="width:100%; text-align: center;">
<button type="button" class="btn btn-default pa-btn" style="margin: auto;" onclick="loadDoc()">execute quick scan on <?php echo $_REQUEST['lastip'];?></button> <script>
setTimeout(function(){
document.getElementById('piamanualnmap').innerHTML='execute quick scan on ' + document.getElementById('txtLastIP').value;
}, 2000);
</script>
<button type="button" id="piamanualnmap" class="btn btn-default pa-btn" style="margin: auto;" onclick="loadDoc(document.getElementById('txtLastIP').value)">... loading</button>
</div> </div>
<div id="scanoutput" style="margin-top: 30px;"></div> <div id="scanoutput" style="margin-top: 30px;"></div>
<script> <script>
function loadDoc() { function loadDoc(targetip) {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() { xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
@@ -451,7 +457,7 @@
}; };
xhttp.open("POST", "./php/server/nmap_scan.php", true); xhttp.open("POST", "./php/server/nmap_scan.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("scan=<?php echo $_REQUEST['lastip'];?>"); xhttp.send("scan=" + targetip);
} }
</script> </script>

View File

@@ -222,7 +222,7 @@ function initializeDatatable () {
// Device Name // Device Name
{targets: [0], {targets: [0],
'createdCell': function (td, cellData, rowData, row, col) { 'createdCell': function (td, cellData, rowData, row, col) {
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[10] +'&lastip='+ rowData[7] +'" class="">'+ cellData +'</a></b>'); $(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[10] +'" class="">'+ cellData +'</a></b>');
} }, } },
// Favorite // Favorite

View File

@@ -2,6 +2,7 @@
$PIA_HOST_IP = $_REQUEST['scan']; $PIA_HOST_IP = $_REQUEST['scan'];
exec('nmap '.$PIA_HOST_IP, $output); exec('nmap '.$PIA_HOST_IP, $output);
echo 'Scan Results of the target: '.$PIA_HOST_IP;
echo '<pre style="border: none;">'; echo '<pre style="border: none;">';
foreach($output as $line){ foreach($output as $line){
echo $line . "\n"; echo $line . "\n";