Scanner.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!env/bin/python
  2. import nmap
  3. from time import sleep
  4. import readline
  5. def print_logo(logo: str):
  6. for line in logo.split("\n"):
  7. print(line)
  8. sleep(.1)
  9. logo = """
  10. ╔═══╗ ╔════╗
  11. ║╔═╗║ ║╔╗╔╗║
  12. ║╚═╝║╔══╗ ╔╗╔╗╚╝║║╚╝╔══╗╔═╗
  13. ║╔══╝╚ ╗║ ║╚╝║ ║║ ║╔╗║║╔╗╗
  14. ║║ ║╚╝╚╗║║║║ ╔╝╚╗ ║╚╝║║║║║
  15. ╚╝ ╚═══╝╚╩╩╝ ╚══╝ ╚══╝╚╝╚╝
  16. """
  17. scanner = nmap.PortScanner()
  18. print("Wellcome, this is a simple nmap automation tool")
  19. print("<--------------------------------------------------->")
  20. print_logo(logo)
  21. ip_addr = input("Please enter th IP address you want to scan: ")
  22. print("The IP you entered is: ", ip_addr)
  23. type(ip_addr)
  24. resp = input("""\nPlease enter the type of scan you want to run
  25. 1) SYN ACK Scan
  26. 2) UDP Scan
  27. 3) Comprehansive Scan
  28. : """)
  29. print("You have selected option: ", resp)
  30. if resp == '1':
  31. print("Nmap Version:", scanner,nmap.__version__)
  32. scanner.scan(ip_addr, '1-1024', '-v -sS')
  33. print("Scan info:", scanner.scaninfo())
  34. print("IP status:", scanner[ip_addr].state())
  35. print("Protocols:", list(scanner[ip_addr].all_protocols()))
  36. try:
  37. print("Open ports:", list(scanner[ip_addr]['tcp'].keys()))
  38. except KeyError:
  39. print(f"It seems like host witn IP address {ip_addr} is down")
  40. elif resp == '2':
  41. print("Nmap Version:", scanner,nmap.__version__)
  42. scanner.scan(ip_addr, '1-1024', '-v -sU')
  43. print("Scan info:", scanner.scaninfo())
  44. print("IP status:", scanner[ip_addr].state())
  45. print("Protocols:", list(scanner[ip_addr].all_protocols()))
  46. try:
  47. print("Open ports:", list(scanner[ip_addr]['udp'].keys()))
  48. except KeyError:
  49. print(f"It seems like host witn IP address {ip_addr} is down")
  50. elif resp == '3':
  51. print("Nmap Version:", scanner,nmap.__version__)
  52. scanner.scan(ip_addr, '1-9000', '-v -sS -sV -A -O')
  53. print("Scan info:", scanner.scaninfo())
  54. print("IP status:", scanner[ip_addr].state())
  55. print("Protocols:", list(scanner[ip_addr].all_protocols()))
  56. try:
  57. print("Open ports:", list(scanner[ip_addr]['tcp'].keys()))
  58. except KeyError:
  59. print(f"It seems like host witn IP address {ip_addr} is down")
  60. else:
  61. print("Please enter a valide option")
  62. exit()