Showing posts tagged powershell

Automating Nmap analysis with PowerShell

# 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