Advertisement
xosski

Network scanner/vulnerability testing

Dec 13th, 2024
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import os
  2. import subprocess
  3.  
  4. def main():
  5. print("Tools Scanner\n")
  6. n = input("1 - nmap\n2 - detection\n3 - exploit\nEnter number: ")
  7.  
  8. if n == '1':
  9. nmap()
  10. elif n == '2':
  11. vuln()
  12. elif n == '3':
  13. os.system('msfconsole')
  14. else:
  15. print("Invalid choice. Please enter a number between 1 and 3.")
  16.  
  17. def nmap():
  18. print("Running nmap scan...\n")
  19. ip = input("Enter target IP: ")
  20. port_range = input("Enter port range (e.g., 1-1024): ")
  21.  
  22. try:
  23. # Use subprocess to call nmap for better control over the command
  24. result = subprocess.run(['nmap', '-p', port_range, ip], capture_output=True, text=True)
  25. print(result.stdout)
  26. except Exception as e:
  27. print(f"Error running nmap: {e}")
  28.  
  29. def vuln():
  30. print("Running vulnerability scan...\n")
  31. ip = input("Enter target IP: ")
  32.  
  33. try:
  34. # Correct the vulnerability scan command formatting
  35. result = subprocess.run(['nmap', '-sV', '--script=vulscan.nse', ip], capture_output=True, text=True)
  36. print(result.stdout)
  37. except Exception as e:
  38. print(f"Error running vulnerability scan: {e}")
  39.  
  40. if __name__ == "__main__":
  41. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement