Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. #Needed for the full example
  2. $Source = "C:\Program Files (x86)\OpenVAS-OMP"
  3.  
  4. #Use this section for the Creating a Target Section
  5.  
  6. #Create a target from a Subnet
  7. $Subnet = "10.128.16.0/21"
  8. $Name = "VLAN4 - Wired Clients"
  9. & $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$Subnet</hosts></create_target>"
  10.  
  11. #Create a target from a range of IP Addresses
  12. $IpRange = "10.128.16.20-10.128.16.44"
  13. $Name = "High Risk Machines"
  14. & $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$IpRange</hosts></create_target>"
  15.  
  16. #Create a target from a single IP Address
  17. $SingleIpAddress = "10.128.16.23"
  18. $Name = "James' Computer"
  19. & $Source\omp.exe -X "<create_target><name>$Name</name><hosts>$SingleIpAddress</hosts></create_target>"
  20.  
  21. #Use this section with Creating and kicking off a Task
  22.  
  23. #Get the GUIDs of the Targets, parse the result into something useable by PowerShell store the result in $OutputTargets
  24. $Targets = & $Source\omp.exe -T
  25.  
  26. $OutputTargets = New-Object System.Collections.ArrayList
  27.  
  28. foreach($line in $Targets){
  29. $item = New-Object -TypeName System.Object
  30. $item | Add-Member -MemberType NoteProperty -Name "GUID" -Value $line.Substring(0,36)
  31. $item | Add-Member -MemberType NoteProperty -Name "Name" -Value $line.Remove(0,38)
  32. $OutputTargets.Add($item) | Out-Null
  33. }
  34.  
  35. #Create a Full and fast task against target with name $Target
  36. $Target = "James' Computer"
  37. $TargetHost = $OutputTargets | Where-Object -Property Name -EQ $Target
  38. & $Source\omp.exe -C -c daba56c8-73ec-11df-a475-002264764cea --name "Scan $($TargetHost.Name)" -t $($TargetHost.GUID)
  39.  
  40. #Get the GUIDs of the Tasks, parse the result into something useable by PowerShell store the result in $OutputTasks
  41. $Tasks = & $Source\omp.exe --get-tasks
  42.  
  43. $OutputTasks = New-Object System.Collections.ArrayList
  44.  
  45. foreach($line in $Tasks){
  46. $item = New-Object -TypeName System.Object
  47. $item | Add-Member -MemberType NoteProperty -Name "GUID" -Value $line.Substring(0,36)
  48. $item | Add-Member -MemberType NoteProperty -Name "Status" -Value $($line.Substring(38,13)).TrimEnd()
  49. $item | Add-Member -MemberType NoteProperty -Name "Name" -Value $line.Remove(0,51)
  50. $OutputTasks.Add($item) | Out-Null
  51. }
  52.  
  53. #Kick off the task with name $Task
  54. $Task = "Scan James' Computer"
  55. $TargetTask = $OutputTasks | Where-Object -Property Name -EQ $Task
  56. $ReportGUID = & $Source\omp.exe -S $TargetTask.GUID
  57.  
  58. #Check on the progress of the task
  59. & $Source\omp.exe --get-tasks $TargetTask.GUID
  60.  
  61. #Use this section with Exporting the Report
  62.  
  63. #Get the results report in CSV format
  64. & $Source\omp.exe --get-report $ReportGUID --format c1645568-627a-11e3-a660-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Results-Report.csv
  65.  
  66. #Get the hosts report in CSV format
  67. & $Source\omp.exe --get-report $ReportGUID --format 9087b18c-626c-11e3-8892-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Hosts-Report.csv
  68.  
  69. #Report in HTML format
  70. & $Source\omp.exe --get-report $ReportGUID --format 6c248850-1f62-11e1-b082-406186ea4fc5 | Out-File C:\OpenVAS-Reports\Results-Report.htm
  71.  
  72. #Use this section with Reading the Report
  73. Import-Csv C:\OpenVAS-Reports\Results-Report.csv | Out-GridView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement