Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

parse-nmap.ps1

By: a guest on Nov 19th, 2012  |  syntax: Power Shell  |  size: 1.25 KB  |  views: 53  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. [cmdletbinding()]
  2. param (
  3.     [string[]]$targets
  4. )
  5. cls
  6.  
  7. foreach ($targetHost in $targets){
  8.     [xml]$nmapResults = nmap -Pn -oX - $targetHost;
  9.     $portResults = @();
  10.         foreach ($port in $nmapresults.nmaprun.host.ports.port){
  11.             $portinfo = New-Object System.Object;
  12.             $portinfo|add-member -membertype noteproperty -name hostname -value $targetHost;
  13.             $portinfo|add-member -membertype noteproperty -name protocol -value $($port.protocol);
  14.             $portinfo|add-member -membertype noteproperty -name portid -value $($port.portid);
  15.             $portinfo|add-member -membertype noteproperty -name state -value $($port.state.state);
  16.             $portinfo|add-member -membertype noteproperty -name reason -value $($port.state.reason);
  17.             $portinfo|add-member -membertype noteproperty -name reason_ttl -value $( $port.state.reason_ttl);
  18.             $portinfo|add-member -membertype noteproperty -name servicename -value $($port.service.name);
  19.             $portinfo|add-member -membertype noteproperty -name method -value $($port.service.method);
  20.             $portinfo|add-member -membertype noteproperty -name conf -value $($port.service.conf);
  21.             $portResults += $portinfo;
  22.     }
  23. }
  24. $portresults |ft -auto;
clone this paste RAW Paste Data