netmap 509 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. usage () {
  3. cat <<EOF>&2
  4. Usage: ${0##*/} IP
  5. Print the map of the network associated to the provided IP.
  6. EOF
  7. }
  8. [ $# -ne 1 ] && usage && exit 1
  9. [ "$1" = "-h" ] && usage && exit
  10. [ "$1" = "--" ] && shift
  11. ## Network operations
  12. if ! command -v nmap >/dev/null 2>&1; then
  13. echo >&2 "'nmap' not found"
  14. exit 1
  15. fi
  16. echo "$1"
  17. for SCANIP in $( nmap -sL "$1" | grep -i "\([[:digit:]]\+\.\)\{3,\}[[:digit:]]\+" | awk '{print $5}' ); do
  18. sudo nmap -oX - -n -sT -T Normal -O -sR -I -F -P0 "$SCANIP"
  19. echo
  20. done