Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. from sys import version_info
  2. import subprocess
  3. import time
  4. import re
  5. import os
  6. os.system("cls")
  7. os.system("color a")
  8. proc = str(subprocess.Popen(["ipconfig","/all"], stdout=subprocess.PIPE, shell=True).communicate())
  9. ipv4 = (str(re.findall("(?<=IPv4 Address. . . . . . . . . . . : )(\d+\.\d+\.\d+\.\d+)",proc)))
  10. dhcp = (str(re.findall("(?<=DHCP Server . . . . . . . . . . . : )(\d+\.\d+\.\d+\.\d+)",proc)))
  11. submask = (str(re.findall("(?<=Subnet Mask . . . . . . . . . . . : )(\d+\.\d+\.\d+\.\d+)",proc)))
  12.  
  13. def menu():
  14. print("\n\n\n************************************************************\n\n")
  15. print(" 1 - Custom command ")
  16. print(" 2 - Display IP configuration ")
  17. print(" 3 - Trace route to any website/IP")
  18. print(" 4 - Ping an IP/website with customization")
  19. print(" 5 - Display all important network information")
  20. print(" 6 - Find all IPV4 addresses connected to your LAN ")
  21. print("\n e - Exit Program")
  22. print("\n")
  23. print("************************************************************")
  24. def takeInput(message):
  25. try:
  26. reply = raw_input(message)
  27. except:
  28. reply = input(message)
  29. return reply
  30. def main():
  31. menu()
  32. opt = takeInput("> ")
  33. if opt == "e":
  34. print("\n\nProgram closing")
  35. os.system("color 7")
  36. os.system("cls")
  37. elif opt == "1":
  38. opt = input("Command> ")
  39. os.system(opt)
  40. main()
  41. elif opt == "2":
  42. os.system("ipconfig /all")
  43. main()
  44. elif opt == "3":
  45. opt2 = input("Address or exit (e)> ")
  46. if opt2 == "e" or opt2 == "exit":
  47. main()
  48. else:
  49. full = "tracert "+opt2
  50. os.system(full)
  51. main()
  52. elif opt == "4":
  53. opt2 = input("Address or exit (e)> ")
  54. if opt2 == "e" or opt2 == "exit":
  55. main()
  56. else:
  57. print("\nInput how much time in ms until the ping times out")
  58. print("Tip for average ping times in ms - Good ping:<5 | Medium ping:30 | Bad ping:>100")
  59. opt3 = input("Time? (0-255 ms) or exit (e)> ")
  60. if opt3 == "e" or opt3 == "exit":
  61. main()
  62. else:
  63. print("\nInput how many times the address will be pinged")
  64. print("Tip for average tries - If tries have to go above 4, there is usually a network issue. ")
  65. opt4 = input("Tries? (0-1000) or exit (e)> ")
  66. if opt4 == "e" or opt4 == "exit":
  67. main()
  68. else:
  69. full = "ping "+opt2+" -i "+opt3+" -n "+opt4
  70. os.system(full)
  71. main()
  72. elif opt == "5":
  73. print("Networking Information:\n\n")
  74. print("Default Gateway: ",dhcp)
  75. print("Network DHCP server: ",dhcp)
  76. print("Current subnet mask: ",submask)
  77. print("Current IPV4 Address: ",ipv4)
  78. main()
  79. elif opt == "6":
  80. os.system("arp -a")
  81. main()
  82. else:
  83. print("Invalid option...")
  84. main()
  85.  
  86.  
  87. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement