Skip to content

Instantly share code, notes, and snippets.

@guim1111
Last active December 10, 2019 13:24
Show Gist options
  • Save guim1111/2b83006909720a09962bb7f9453d1046 to your computer and use it in GitHub Desktop.
Save guim1111/2b83006909720a09962bb7f9453d1046 to your computer and use it in GitHub Desktop.
Extract up hosts in /24 networks to csv for OpenVas using nmap -sp (so nmap needed)
#!/bin/bash
#script extract the IPs of a network that answer to a ping request
#create a csv for others automated vuln scanners
#use fo this: ./checkUpIps.sh 192.168.1.0 (only networks /24 ended with 0 without writing /24)
ip=$1
ipname=$(echo $1 | tr . -)
nameResult='ips'$ipname'.txt'
namecsv='onlyIps'$ipname'.csv'
nmap -sP $1/24 > $nameResult
cat $nameResult | grep -P 'Nmap scan report for' | sed -e 's/Nmap scan report for \(.*\)/\1/' | sed 's/$/,/' > $namecsv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment