Last active
July 27, 2018 13:48
-
-
Save coreypurcell/bfc2c3b7e202d545d6d4d413471231f0 to your computer and use it in GitHub Desktop.
Ryan's Script for Parsing Nesus Vulnerabilities Reports
This file contains hidden or 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
| // Download this script into a file, ex. nessus_scan.js | |
| // install nodejs $ brew install node | |
| // install packages | |
| // $ npm install -g jsdom | |
| // $ npm install -g jquery | |
| // rename the by host scan to "by_host.html" | |
| // run this script with lots of extra memory | |
| // $ node --max_old_space_size=15000 nessus_scan.js | |
| // the vulnerable ips are stored in the file "vuln" | |
| var jsdom = require('jsdom'), | |
| jquery = require('jquery'), | |
| fs = require('fs'); | |
| const { JSDOM } = jsdom; | |
| console.log("Loading File") | |
| const html = fs.readFileSync( __dirname + '/by_host.html') | |
| console.log("Creating DOM") | |
| let dom = new JSDOM(html.toString()); | |
| console.log("Loading jQuery") | |
| let $ = jquery(dom.window); | |
| console.log("Finding divs") | |
| let divs = $('div[style="font-size: 22px; font-weight: bold; padding: 10px 0;"]'); | |
| console.log("Hosts: " + divs.length) | |
| console.log("Finding Vulnerables") | |
| let vulnerables = divs.filter(function() { | |
| let div = $(this); | |
| try { | |
| let critical = parseInt(div.next().find('table > tbody > tr:first-child > td:first-child > div').text()) | |
| let high = parseInt(div.next().find('table > tbody > tr:first-child > td:nth-child(2) > div').text()) | |
| let medium = parseInt(div.next().find('table > tbody > tr:first-child > td:nth-child(3) > div').text()) | |
| let total = critical + high + medium | |
| console.log(total) | |
| return total > 0 | |
| } catch(e) { | |
| return false | |
| } | |
| }) | |
| console.log("Vulnerables: " + vulnerables.length) | |
| let hosts = [] | |
| vulnerables.each(function() { | |
| let div = $(this); | |
| hosts.push(div.text().replace('ip-', '').replace(/-/g, '.').replace('\n', '')) | |
| }, []) | |
| let hostsFile = '[' + hosts.map(function(host) { return "'" + host + "'" }).join(', ') + ']' | |
| fs.writeFileSync(__dirname + '/vuln', hostsFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment