kjacobsen icon

Automating Nmap analysis with PowerShell

kjacobsen | PRO | 04/02/12 09:55:37 AM UTC | 0 ⭐ | 9906 👁️ | Never ⏰ | []
PowerShell |

610 B

|

None

|

0 👍

/

0 👎

# Code Snippet from aperturescience.su
 
$subnets = "10.0.0.0/16", "192.168.1.0/24"
#run nmap scan for each subnet
foreach ($subnet in $subnets)
{
    $filename = ($subnet.substring(0,$subnet.length - 6))
    $nmapfile = ".\temp\" + $filename  + ".xml"
    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"
 
    $csvfilename = ".\results\" + $filename  + ".csv"
    .\parse-nmap.ps1 $nmapfile | select ipv4, status, hostname, fqdn | Export-Csv $csvfilename
}
 
# Code Snippet from aperturescience.su

Comments