Last active
July 3, 2020 13:15
-
-
Save namnamir/485f7d4cc86faeda0e9d1c145d0ade29 to your computer and use it in GitHub Desktop.
Parse Nessus HTML report to get the list of live hosts details (OS, MAC Address, IP Address, NetBIOS Name, DNS Name, etc.). It is because Nessus filter doesn't have any criteria to filter the findings based on Host Information.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Version 1.0 | |
// Copyleft | |
// | |
// Ali Nikouei | |
// July 2020 | |
// take a look at this one as well; it may help | |
// https://community.tenable.com/s/article/Operating-System-identification-using-Plugin-11936 | |
// How to use it: | |
// 1- Export an HTML report | |
// 2- Open it in Chrome or Firefox | |
// 3- press F12 or right click on the page and select "Inspect Element" | |
// 4- Go to "Console" tab | |
// 5- Paste the following code to see the result in JSON format | |
// 6- It is possible to export it to csv or xlsx but I do not want to make it long, just search on the internet | |
////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// see also the other Gist parses the other format of host enumerations: | |
// https://gist.github.com/namnamir/f1a48a591cc2d25e3bac5fc261fb49b4 | |
////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// list of my devices to be excluded from the report | |
myDevices = new RegExp('(mydevice1|mydevice2|mydevice3)','g'); | |
// empty object | |
output = []; | |
// get all the tables | |
tables = document.querySelectorAll("div.table-wrapper.details"); | |
// iterate over each table to find the the OS, IP, MAC, NetBIOS name, etc. | |
for (i = 0; i < tables.length; i++) { | |
innerTable = tables[i].querySelectorAll("table")[0].innerHTML; | |
// check if the device is mine, ignore it | |
if (innerTable.match(myDevices)) { | |
continue | |
} // if | |
// if the table contains IP and MAC | |
// The ones have IP but no MAC are the ones which are not reachable (no ping) | |
if (innerTable.includes("IP") && innerTable.includes("MAC")) { | |
// get all the rows | |
rows = tables[i].querySelector("tbody").querySelectorAll("tr"); | |
// define a temp variable to convert table into json | |
temp = {}; | |
// iterate over each row of the inner table | |
for (j = 0; j < rows.length; j++) { | |
row = rows[j].querySelectorAll("td"); | |
temp[row[0].innerText.slice(0, -1)] = row[1].innerText | |
//console.log(row[0].innerText, row[1].innerText); | |
} | |
// add the jsonfied table to the output | |
output.push(temp); | |
} | |
} | |
// show the result | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment