ambevar-dotfiles/.local/bin/netmap

26 lines
509 B
Bash
Executable File

#!/bin/sh
usage () {
cat <<EOF>&2
Usage: ${0##*/} IP
Print the map of the network associated to the provided IP.
EOF
}
[ $# -ne 1 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
## Network operations
if ! command -v nmap >/dev/null 2>&1; then
echo >&2 "'nmap' not found"
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