scan.sh 1.5 KB

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