Advertisement
kjacobsen

Automating Nmap analysis with PowerShell

Apr 2nd, 2012
9,720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Code Snippet from aperturescience.su
  2.  
  3. $subnets = "10.0.0.0/16", "192.168.1.0/24"
  4. #run nmap scan for each subnet
  5. foreach ($subnet in $subnets)
  6. {
  7.     $filename = ($subnet.substring(0,$subnet.length - 6))
  8.     $nmapfile = ".\temp\" + $filename  + ".xml"
  9.     cmd.exe /c "nmap -PS20,21,22,23,25,3389,80,443,8080 -PE -R  <your dns servers here> -p 20,21,22,23,25,3389,80,443,8080 -oX $nmapfile --no-stylesheet -A -v $subnet"
  10.  
  11.     $csvfilename = ".\results\" + $filename  + ".csv"
  12.     .\parse-nmap.ps1 $nmapfile | select ipv4, status, hostname, fqdn | Export-Csv $csvfilename
  13. }
  14.  
  15. # Code Snippet from aperturescience.su
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement