ambevar-dotfiles/.scripts/netmap

23 lines
470 B
Bash
Executable File

#!/bin/sh
if [ $# -ne 1 ] || [ "$1" = "-h" ] ; then
cat<<EOF
Usage: ${1##*/} IP
Print the map of the network associated to the provided IP.
EOF
exit
fi
## Network operations
if ! command -v nmap >/dev/null 2>&1; then
echo >&2 "'nmap' not found in PATH. Exiting."
exit 1
fi
echo "$1"
for SCANIP in $( nmap -sL "$1" | grep -i "\([[:digit:]]\+\.\)\{3,\}[[:digit:]]\+" | awk '{print $5}' ); do
sudo nmap -oX - -n -sT -T Normal -O -sR -I -F -P0 "$SCANIP"
echo
done