-
-
Save 0xhexmex/0b4d43ae17d44ae31361c1f157c114ab to your computer and use it in GitHub Desktop.
This script can be used to extract a list of HTTP servers from .nessus files.
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
# This script can be used to extract a list of HTTP servers from .nessus files. | |
# Original Author: Scott Sutherland, NetSPI 2017 | |
# Modified by KM 11/2018 to extract a list of all HTTP servers, not just IIS6 | |
# Instructions: Run the script in a directory containing only .nessus files. Super dirty/slow, but functional. | |
# Create an output table | |
$outputtbl =New-Object System.Data.DataTable | |
$outputtbl.Columns.Add("IpAddress") | Out-Null | |
$outputtbl.Columns.Add("WebServerVersion") | Out-Null | |
# Iterate through each host | |
Get-ChildItem *.nessus | select fullname -ExpandProperty fullname| % { | |
Write-Output "Processing $_"; | |
[xml]$myfile = gc "$_" | |
$myfile.NessusClientData_v2.Report.ReportHost | | |
foreach{ | |
# Grab the IP address and host items | |
$IpAddress = $_.name | |
$ReportItems = $_.reportitem | |
# Filter for the HTTP server list | |
$ReportItems | | |
Foreach{ | |
$MyPlugin = $_.pluginname | |
if($MyPlugin -like "HTTP Server Type and Version"){ | |
# Parse out version | |
$pluginoutput = $_.plugin_output | |
$httpver = (($pluginoutput -replace ("The remote web server type is :","")) -replace '\s+\r\n+', "`r`n").trim() | |
# Write to data table | |
Write-Output "Found one! - $IpAddress ($httpver)" | |
$outputtbl.rows.Add($IpAddress,$httpver) | Out-Null | |
} | |
} | |
} | |
} | |
# Write results to a file | |
$outputtbl | Export-Csv webservers.csv -notypeinformation | |
# Return output to the pipeline | |
$outputtbl | Sort-Object IpAddress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment