scan.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. function initial {
  3. if [ -f nmap/initial.nmap ]; then
  4. echo "[-] initial scan files are already present on system"
  5. exit 1
  6. fi
  7. echo "[-] Initial scan for $1"
  8. nmap -T4 -oA nmap/initial "$1" 2> /dev/null
  9. }
  10. function allports {
  11. if [ -f nmap/all-ports.nmap ]; then
  12. echo "[-] initial scan files are already present on system"
  13. exit 1
  14. fi
  15. echo "[-] Full scna for $1"
  16. nmap -T4 -p- -sV -oA nmap/all-ports "$1" 2> /dev/null
  17. }
  18. function udp {
  19. if [ -f nmap/udp.nmap ]; then
  20. echo "[-] initial scan files are already present on system"
  21. exit 1
  22. fi
  23. echo "[-] UDP scan for $1 (root is needed for that scan-mode)"
  24. sudo nmap -T4 --top-ports 1000 -sU -oA nmap/udp "$1" 2> /dev/null
  25. }
  26. if [ $# -ne 2 ]; then
  27. echo '[-] scan <range> <type> (initial, all, udp)'
  28. exit 1
  29. fi
  30. if [ ! -d nmap/ ]; then
  31. echo "[*] creating nmap folder"
  32. mkdir nmap
  33. fi
  34. if [ "$2" = "initial" ]; then
  35. initial "$1"
  36. elif [ "$2" = "full" ] || [ "$2" = "all" ]; then
  37. allports "$1"
  38. elif [ "$2" = "udp" ]; then
  39. udp "$1"
  40. fi