Last active
July 26, 2017 15:23
-
-
Save jamesfed/6a5c6634abc12c180f125e25c2764d1f to your computer and use it in GitHub Desktop.
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
#Needed for the full example | |
$Source = "C:\Program Files (x86)\OpenVAS-OMP" | |
#Use this section for the Creating a Target Section | |
#Create a target from a Subnet | |
$Subnet = "10.128.16.0/21" | |
$Name = "VLAN4 - Wired Clients" | |
& $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$Subnet</hosts></create_target>" | |
#Create a target from a range of IP Addresses | |
$IpRange = "10.128.16.20-10.128.16.44" | |
$Name = "High Risk Machines" | |
& $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$IpRange</hosts></create_target>" | |
#Create a target from a single IP Address | |
$SingleIpAddress = "10.128.16.23" | |
$Name = "James' Computer" | |
& $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$SingleIpAddress</hosts></create_target>" | |
#Use this section with Creating and kicking off a Task | |
#Get the GUIDs of the Targets, parse the result into something useable by PowerShell store the result in $OutputTargets | |
$Targets = & $Source\omp.exe -T | |
$OutputTargets = New-Object System.Collections.ArrayList | |
foreach($line in $Targets){ | |
$item = New-Object -TypeName System.Object | |
$item | Add-Member -MemberType NoteProperty -Name "GUID" -Value $line.Substring(0,36) | |
$item | Add-Member -MemberType NoteProperty -Name "Name" -Value $line.Remove(0,38) | |
$OutputTargets.Add($item) | Out-Null | |
} | |
#Create a Full and fast task against target with name $Target | |
$Target = "James' Computer" | |
$TargetHost = $OutputTargets | Where-Object -Property Name -EQ $Target | |
& $Source\omp.exe -C -c daba56c8-73ec-11df-a475-002264764cea --name "Scan $($TargetHost.Name)" -t $($TargetHost.GUID) | |
#Get the GUIDs of the Tasks, parse the result into something useable by PowerShell store the result in $OutputTasks | |
$Tasks = & $Source\omp.exe --get-tasks | |
$OutputTasks = New-Object System.Collections.ArrayList | |
foreach($line in $Tasks){ | |
$item = New-Object -TypeName System.Object | |
$item | Add-Member -MemberType NoteProperty -Name "GUID" -Value $line.Substring(0,36) | |
$item | Add-Member -MemberType NoteProperty -Name "Status" -Value $($line.Substring(38,13)).TrimEnd() | |
$item | Add-Member -MemberType NoteProperty -Name "Name" -Value $line.Remove(0,51) | |
$OutputTasks.Add($item) | Out-Null | |
} | |
#Kick off the task with name $Task | |
$Task = "Scan James' Computer" | |
$TargetTask = $OutputTasks | Where-Object -Property Name -EQ $Task | |
$ReportGUID = & $Source\omp.exe -S $TargetTask.GUID | |
#Check on the progress of the task | |
& $Source\omp.exe --get-tasks $TargetTask.GUID | |
#Use this section with Exporting the Report | |
#Get the results report in CSV format | |
& $Source\omp.exe --get-report $ReportGUID --format c1645568-627a-11e3-a660-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Results-Report.csv | |
#Get the hosts report in CSV format | |
& $Source\omp.exe --get-report $ReportGUID --format 9087b18c-626c-11e3-8892-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Hosts-Report.csv | |
#Report in HTML format | |
& $Source\omp.exe --get-report $ReportGUID --format 6c248850-1f62-11e1-b082-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Results-Report.htm | |
#Use this section with Reading the Report | |
Import-Csv C:\OpenVAS-Reports\Results-Report.csv | Out-GridView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment