Advertisement
Python253

win_netsh_all

Mar 1st, 2024 (edited)
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 24.18 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # Filename: win_netsh_all.py
  3. # Author: Jeoi Reqi
  4. # This script is a command-line tool for Windows network management using netsh commands, featuring a menu-driven interface for tasks like firewall settings and Wi-Fi management, providing a user-friendly solution for network operations on Windows systems.
  5.  
  6. import sys
  7. import subprocess
  8.  
  9.  
  10.  
  11. '''                ::UTILITY FUNCTIONS::'''
  12.  
  13.  
  14.  
  15. # Utility function to run netsh commands
  16. def run_netsh_command(command, trace_file_path=None, max_size=None):
  17.     try:
  18.         args = command + (['tracefile=' + trace_file_path, 'persistent=yes', f'maxsize={max_size}'] if trace_file_path and max_size else [])
  19.         result = subprocess.run(args, capture_output=True, text=True, check=True)
  20.  
  21.         output = result.stdout.strip()
  22.         if output:
  23.             print(output)
  24.             save_option_data(command[-1] if trace_file_path else ' '.join(command), output)
  25.  
  26.         else:
  27.             print(f"No data found for '{command[-1]}'. Not saved to file (Value: None).\n")
  28.  
  29.     except subprocess.CalledProcessError as e:
  30.         print("Error:", e.stderr)
  31.  
  32.  
  33. # Utility function to save data to a file
  34. def save_option_data(option_name, data):
  35.     if data is not None:
  36.         print("\nData:")
  37.         print(data)
  38.  
  39.         valid_choices = {'yes', 'y', 'no', 'n', '1', '2'}
  40.         save_choice = input(
  41.             f"Do you want to save the data from '{option_name}'?\n1. Yes (y)\n2. No (n)\nEnter your choice: ").lower()
  42.  
  43.         if save_choice in valid_choices:
  44.             if save_choice in {'yes', 'y', '1'}:
  45.                 sanitized_option_name = ''.join(c for c in option_name if c.isalnum() or c in ('_', ' '))
  46.                 filename = f"{sanitized_option_name}.txt"
  47.                 with open(filename, 'w', encoding='utf-8') as file:
  48.                     file.write(data)
  49.                 print(f"Data saved to '{filename}'\n")
  50.             else:
  51.                 print("Data not saved.\n")
  52.         else:
  53.             print("Invalid choice. Data not saved.\n")
  54.  
  55.         # Wait for user input before proceeding
  56.         input("Press Enter to continue...")
  57.     else:
  58.         print(f"No data found for '{option_name}'. Not saved to file (Value: None).\n")
  59.  
  60.  
  61.  
  62. '''                ::OPTION MENU FUNCTIONS::'''
  63.  
  64.  
  65.  
  66. # OPTION 0
  67. def display_firewall_settings():
  68.     run_netsh_command(['netsh', 'advfirewall', 'show', 'allprofiles'])
  69.  
  70. # OPTION 1
  71. def check_firewall_rules():
  72.     run_netsh_command(['netsh', 'advfirewall', 'firewall', 'show', 'rule', 'name=all'])
  73.  
  74.  
  75. # OPTION 2
  76. def check_network_interface_status():
  77.     try:
  78.         result = subprocess.check_output(['netsh', 'interface', 'show', 'interface'], text=True)
  79.         return result
  80.     except subprocess.CalledProcessError as e:
  81.         print(f"Error checking network interface status: {e}")
  82.         return None
  83.  
  84.  
  85. # OPTION 3
  86. def get_wifi_profiles_and_passwords():    # Show Known Wi-Fi Network/Profiles Passwords
  87.     # Get the Wi-Fi profiles
  88.     command = 'netsh wlan show profiles'
  89.     result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, text=True)
  90.  
  91.     # Extract profile names from the result
  92.     profile_names = [line.split(":")[1].strip() for line in result.stdout.splitlines() if "All User Profile" in line]
  93.  
  94.     # Collect data to be displayed and saved
  95.     output_data = ""
  96.  
  97.     # Iterate through profile names and display their names and passwords
  98.     for profile_name in profile_names:
  99.         profile_command = f'netsh wlan show profile name="{profile_name}" key=clear'
  100.         profile_result = subprocess.run(profile_command, shell=True, stdout=subprocess.PIPE, text=True)
  101.  
  102.         # Extract and collect only relevant information
  103.         password_line = [line.strip() for line in profile_result.stdout.splitlines() if "Key Content" in line]
  104.         if password_line:
  105.             output_data += f"\nProfile: {profile_name}, Password: {password_line[0].split(':')[1].strip()}\n"
  106.         else:
  107.             output_data += f"Profile: {profile_name}, Password not found.\n"
  108.  
  109.     return output_data
  110.  
  111. # Display the list to the user
  112. def show_wifi_profiles():
  113.     profiles_output = get_wifi_profiles_and_passwords()
  114.  
  115.     # Print the collected data
  116.     print(profiles_output)
  117.  
  118.     # Prompt the user to save the file
  119.     save_option_data("Wi-Fi Profiles", profiles_output)
  120.  
  121.  
  122. # OPTION 4
  123. def get_current_wifi_info():
  124.     try:
  125.         result = subprocess.check_output(["netsh", "wlan", "show", "interfaces"], text=True)
  126.         return result
  127.     except subprocess.CalledProcessError as e:
  128.         print(f"Error getting current Wi-Fi information: {e}")
  129.         return None
  130.    
  131. # OPTION 5
  132. def check_available_wireless_connections():
  133.     try:
  134.         result = subprocess.check_output(['netsh', 'wlan', 'show', 'network'], text=True)
  135.         return result
  136.     except subprocess.CalledProcessError as e:
  137.         print(f"Error checking available wireless connections: {e}")
  138.         return None
  139.    
  140. # Function to extract available networks
  141. def extract_available_wireless_networks(output):
  142.     networks = []
  143.     lines = output.splitlines()
  144.     for line in lines:
  145.         if "SSID" in line:
  146.             ssid = line.split(":")[1].strip()
  147.             networks.append(ssid)
  148.     return networks
  149.  
  150. # Function to display available wireless networks
  151. def display_available_wireless_networks(networks):
  152.     print("\nAvailable Wireless Networks:\n")
  153.     for i, ssid in enumerate(networks, start=1):
  154.         print(f"{i}. {ssid}")
  155.  
  156.  
  157. # OPTION 6            
  158. def check_wireless_interface_details():
  159.     try:
  160.         result = subprocess.check_output(['netsh', 'wlan', 'show', 'interfaces'], text=True)
  161.         return result
  162.     except subprocess.CalledProcessError as e:
  163.         print(f"Error checking wireless interface details: {e}")
  164.         return None
  165.    
  166.    
  167. # OPTION 7
  168. def disconnect_wireless_device():
  169.     run_netsh_command(['netsh', 'wlan', 'disconnect'])
  170.  
  171. # OPTION 8
  172. def connect_to_wireless_device(selected_network):
  173.     try:
  174.         # Use the selected_network variable to connect to the chosen Wi-Fi network
  175.         result = subprocess.run(['netsh', 'wlan', 'connect', f'name="{selected_network}"'], capture_output=True, text=True, check=True)
  176.         print(result.stdout)
  177.  
  178.         # Ask the user if they want to save the data
  179.         save_choice = input("\nDo you want to save the output of the connection attempt?\n1. Yes (y)\n2. No (n)\nEnter your choice: ").lower()
  180.  
  181.         if save_choice in {'yes', 'y', '1'}:
  182.             # Generate a filename based on the function name
  183.             filename = f"connect_to_wireless_device_output.txt"
  184.             with open(filename, 'w', encoding='utf-8') as file:
  185.                 file.write(result.stdout)
  186.             print(f"Data saved to '{filename}'\n")
  187.         else:
  188.             print("Data not saved.\n")
  189.  
  190.         return result.stdout  # Return the result
  191.  
  192.     except subprocess.CalledProcessError as e:
  193.         print("Error connecting to the wireless network:", e.stderr)
  194.  
  195.     # Wait for user input before proceeding to the menu
  196.     input("Press Enter to continue...")
  197.     return None  # Return None in case of an error
  198.  
  199.  
  200. # Display List Of Available Networks
  201. def select_wifi_network(networks):
  202.     print("\nAvailable Wireless Networks:")
  203.     print("{:<5} {:<}".format("Num", "SSID"))
  204.     for i, network in enumerate(networks, start=1):
  205.         print("{:<5} {:<}".format(i, network))
  206.  
  207.     while True:
  208.         try:
  209.             choice = input("\nEnter the number of the network to connect to (or press Enter to cancel): ").strip()
  210.             if not choice:
  211.                 return None  # User pressed Enter to cancel
  212.             else:
  213.                 choice = int(choice)
  214.                 if 1 <= choice <= len(networks):
  215.                     return networks[choice - 1]  # Return the selected network
  216.                 else:
  217.                     print("Invalid choice. Please enter a valid number.")
  218.         except ValueError:
  219.             print("Invalid input. Please enter a valid number.")
  220.    
  221. # OPTION 9  
  222. def show_all_wireless_interfaces():
  223.     run_netsh_command(['netsh', 'wlan', 'show', 'interfaces'])
  224.  
  225. # OPTION 10
  226. def show_wireless_drivers():
  227.     run_netsh_command(['netsh', 'wlan', 'show', 'drivers'])
  228.  
  229. # OPTION 11
  230. def show_proxy_settings():
  231.     run_netsh_command(['netsh', 'winhttp', 'show', 'proxy'])
  232.  
  233. # OPTION 12
  234. def show_tcp_global_parameters():
  235.     run_netsh_command(['netsh', 'interface', 'tcp', 'show', 'global'])
  236.  
  237. # OPTION 13
  238. def show_udp_global_parameters():
  239.     run_netsh_command(['netsh', 'interface', 'udp', 'show', 'global'])
  240.  
  241. # OPTION 14
  242. def disable_tcp_rss():
  243.     run_netsh_command(['netsh', 'interface', 'tcp', 'set', 'global', 'rss=disabled'])
  244.  
  245. # OPTION 15
  246. def enable_tcp_rss():
  247.     run_netsh_command(['netsh', 'interface', 'tcp', 'set', 'global', 'rss=enabled'])
  248.  
  249. # OPTION 16
  250. def list_defined_aliases():
  251.     run_netsh_command(['netsh', 'show', 'alias'])
  252.  
  253. # OPTION 17
  254. def reset_winsock_entries():
  255.     run_netsh_command(['netsh', 'winsock', 'reset', 'catalog'])
  256.  
  257. # OPTION 18
  258. def reset_tcp_ip_stack():
  259.     run_netsh_command(['netsh', 'int', 'ip', 'reset', 'reset.log'])
  260.  
  261. # OPTION 19
  262. def set_proxy():
  263.     proxy_address = input("Enter the proxy address (e.g., myproxy.proxyaddress.com:8484): ")
  264.     exceptions = input("Enter proxy exceptions (e.g., <local>;*.proxyaddress.com): ")
  265.     run_netsh_command(['netsh', 'winhttp', 'set', 'proxy', f'"{proxy_address}"', f'"{exceptions}"'])
  266.  
  267. # OPTION 20
  268. def show_multicast_joins():
  269.     run_netsh_command(['netsh', 'interface', 'ip', 'show', 'joins'])
  270.  
  271. # OPTION 21
  272. def allow_port_firewall():
  273.     rule_name = input("Enter the name of the firewall rule: ")
  274.     protocol = input("Enter the protocol (TCP/UDP): ")
  275.     direction = input("Enter the direction (in/out): ")
  276.     local_port = input("Enter the local port: ")
  277.     run_netsh_command(['netsh', 'advfirewall', 'firewall', 'add', 'rule', f'name="{rule_name}"', f'protocol={protocol}', f'dir={direction}', f'localport={local_port}', 'action=allow'])
  278.  
  279. # OPTION 22
  280. def add_primary_dns_server():
  281.     interface_name_dns = input("Enter the name of the network interface: ")
  282.     dns_server_address = input("Enter the Primary DNS Server address: ")
  283.     run_netsh_command(['netsh', 'interface', 'ip', 'add', 'dns', f'name="{interface_name_dns}"', f'addr={dns_server_address}'])
  284.  
  285. # OPTION 23
  286. def allow_ping_requests():
  287.     run_netsh_command(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name="All ICMP V4"', 'dir=in', 'action=allow', 'protocol=icmpv4'])
  288.  
  289. # OPTION 24
  290. def block_ping_requests():
  291.     run_netsh_command(['netsh', 'advfirewall', 'firewall', 'add', 'rule', 'name="All ICMP V4"', 'dir=in', 'action=block', 'protocol=icmpv4'])
  292.  
  293. # OPTION 25
  294. def disable_windows_firewall():
  295.     run_netsh_command(['netsh', 'advfirewall', 'set', 'allprofiles', 'state', 'off'])
  296.  
  297. # OPTION 26
  298. def reset_firewall_settings():
  299.     run_netsh_command(['netsh', 'advfirewall', 'reset'])
  300.  
  301. # OPTION 27
  302. def stop_network_trace():
  303.     run_netsh_command(['netsh', 'trace', 'stop'])
  304.  
  305. # OPTION 28
  306. def capture_packets():
  307.     try:
  308.         # Ask the user to choose the duration for the ping test
  309.         print("Choose the duration for the ping test:")
  310.         print("1. Quick Ping Test (15 sec.)")
  311.         print("2. Standard Ping Test (30 sec.)")
  312.         print("3. Long Ping Test (60 sec.)")
  313.  
  314.         choice = input("Enter the option number: ")
  315.  
  316.         if choice == '1':
  317.             duration_seconds = 15
  318.         elif choice == '2':
  319.             duration_seconds = 30
  320.         elif choice == '3':
  321.             duration_seconds = 60
  322.         else:
  323.             print("Invalid choice. Defaulting to Standard Ping Test (30 sec.)")
  324.             duration_seconds = 30
  325.  
  326.         # Inform the user about the test
  327.         print(f"Capturing packets for {duration_seconds} seconds. Please wait...")
  328.  
  329.         # Run ping test (change 'example.com' to the desired target)
  330.         result = subprocess.run(['ping', '-n', str(duration_seconds), 'example.com'], capture_output=True, text=True, check=True)
  331.  
  332.         # Display completion message
  333.         print("Packet capture completed.")
  334.  
  335.         # Save data
  336.         save_option_data('Capture Packets', result.stdout)
  337.  
  338.     except subprocess.CalledProcessError as e:
  339.         # Handle error if the command fails
  340.         print("Error:", e.stderr)
  341.  
  342. # OPTION 29
  343. def change_interface_ip_address():
  344.     interface_name = input("Enter the name of the network interface: ")
  345.     ip_address = input("Enter the new IP address: ")
  346.     subnet_mask = input("Enter the subnet mask: ")
  347.     gateway = input("Enter the gateway address: ")
  348.     run_netsh_command(['netsh', 'int', 'ip', 'set', 'address', interface_name, 'static', ip_address, subnet_mask, gateway])
  349.  
  350.  
  351.  
  352. # OPTION 30
  353. # PLACEHOLDER SCRIPT FOR NOW
  354. def placeholder():
  355.     print("\nPLACEHOLDER\n")
  356.    
  357.    
  358.  
  359. '''                ::IPV4::'''
  360.  
  361.  
  362.  
  363.  
  364. # OPTION 31
  365. def view_current_ipv4_configuration():
  366.     print("\n\t\t\t\t::IPV4::\n")
  367.     try:
  368.         command = ['netsh', 'interface', 'ipv4', 'show', 'config']
  369.         result = subprocess.run(command, capture_output=True, text=True, check=True)
  370.  
  371.         output = result.stdout.strip()
  372.         if output:
  373.             print("\nCurrent IPv4 Configuration:")
  374.             print(output)
  375.             save_option_data('View_Current_IPV4_Configuration', output)
  376.         else:
  377.             print("No data found for IPv4 configuration.")
  378.  
  379.     except subprocess.CalledProcessError as e:
  380.         print("Error:", e.stderr)
  381.  
  382.  
  383.  
  384.  
  385. '''                ::IPV6::  [BROKEN]'''
  386.  
  387.  
  388.  
  389. # OPTION 32
  390. def view_current_ipv6_configuration(interfaces):
  391.     print("\n\t\t\t\t::IPV6::\n")
  392.    
  393.     if not interfaces:
  394.         print("No network interfaces available.")
  395.         input("\nPress Enter to continue...")
  396.         return
  397.  
  398.     selected_interface = get_interface_number(interfaces)
  399.     if selected_interface is not None:
  400.         try:
  401.             # Display IPv6 information using the provided netsh commands
  402.             run_netsh_command(['netsh', 'interface', 'ipv6', 'show', 'interfaces'], trace_file_path=None, max_size=None)
  403.             run_netsh_command(['netsh', 'interface', 'ipv6', 'show', 'addresses'], trace_file_path=None, max_size=None)
  404.  
  405.         except subprocess.CalledProcessError as e:
  406.             print("Error displaying IPv6 configuration:", e.stderr)
  407.  
  408.  
  409.  
  410.  
  411.        
  412. # OPTION 33 (EXIT)
  413.  
  414.  
  415.  
  416.  
  417. '''                ::OPTIONS MENU::'''
  418.  
  419.  
  420.  
  421. def display_menu():
  422.     options = [
  423.         "Display Firewall Settings",
  424.         "Check Firewall Rules",
  425.         "Check Network Interface Status",
  426.         "Show Wi-Fi Network/Profiles & Passwords",
  427.         "Get Current Wi-Fi Information",
  428.         "Check all the Available Wireless Connections",
  429.         "Check the State & Strength of all the Available Wireless Connections",
  430.         "Disconnect from Currently Connected Wireless Device",
  431.         "Connect to an Available Wireless Device",
  432.         "Show all the Wireless Interfaces",
  433.         "Show Drivers of Wireless Interfaces",
  434.         "Check Current Proxy Setting in Windows",
  435.         "Check TCP Global Parameters Status",
  436.         "Check UDP Global Parameters Status",
  437.         "Disable TCP RSS Global Parameter",
  438.         "Enable TCP RSS Global Parameter",
  439.         "List all the defined Aliases",
  440.         "Reset Winsock entries to default",
  441.         "Reset TCP/IP Stack to Installation Default",
  442.         "Set Proxy in Windows using netsh command",
  443.         "Show Multicast Joins for all Network Interfaces",
  444.         "Allow a Port from Windows Firewall using netsh command",
  445.         "Add a Primary DNS Server to an Interface",
  446.         "Allow Ping requests through Windows Firewall",
  447.         "Block Ping requests through Windows Firewall",
  448.         "Disable Windows Firewall in all Profiles",
  449.         "Reset Windows Firewall Settings to Default",
  450.         "Stop Trace using netsh command",
  451.         "[PING] Capture Packets using netsh command",
  452.         "Change Interface IP Address",
  453.         "--[PLACEHOLDER OPTION]--",
  454.         "View Current IPV4 Configuration",
  455.         "View Current IPV6 Configuration --[BROKEN]--",
  456.         "Exit the program"
  457.     ]
  458.  
  459.     for i, option in enumerate(options):
  460.         print(f"{i}. {option}")
  461.        
  462.        
  463.        
  464.        
  465. '''                ::MAIN PROGRAM::'''
  466.  
  467.  
  468.        
  469. def main():
  470.     interfaces = []  # Initialize an empty list of interfaces
  471.    
  472.     while True:
  473.         display_menu()
  474.  
  475.         # Get user choice
  476.         choice = input("Enter the option number: ")
  477.  
  478.         if choice.isdigit() and 0 <= int(choice) <= 33:
  479.             if choice == '0':
  480.                 last_command_output = display_firewall_settings()
  481.                 save_option_data('Display_firewall_settings', last_command_output)
  482.             elif choice == '1':
  483.                 try:
  484.                     result = subprocess.run(['netsh', 'advfirewall', 'firewall', 'show', 'rule', 'name=all'],
  485.                                            capture_output=True, text=True, check=True)
  486.                     last_command_output = result.stdout
  487.                     if last_command_output:
  488.                         print("\nCurrent Firewall Rules for the Profile:")
  489.                         print(last_command_output)
  490.                         save_option_data('Show_all_Firewall_rules_for_Current_Profile', last_command_output)
  491.                     else:
  492.                         print("No firewall rules found.")
  493.                 except subprocess.CalledProcessError as e:
  494.                     print("Error:", e.stderr)
  495.             elif choice == '2':
  496.                 last_command_output = check_network_interface_status()
  497.                 save_option_data('Check Network Interface Status', last_command_output)
  498.             elif choice == '3':
  499.                 last_command_output = view_current_ipv4_configuration()
  500.                 save_option_data('View_Current_IPV4_Configuration', last_command_output)
  501.             elif choice == '4':
  502.                 last_command_output = get_current_wifi_info()
  503.                 save_option_data('Get Current Wi-Fi Information', last_command_output)
  504.             elif choice == '5':
  505.                 last_command_output = check_available_wireless_connections()
  506.                 save_option_data('Check_Available_Wireless_Connections', last_command_output)
  507.             elif choice == '6':
  508.                 last_command_output = check_wireless_interface_details()
  509.                 save_option_data('Check_Wireless_Interface_Details', last_command_output)
  510.             elif choice == '7':    #Disconnect From Current Wi-Fi
  511.                 last_command_output = disconnect_wireless_device()
  512.                 save_option_data('Disconnect_from_Currently_Connected_Wireless_Device', last_command_output)
  513.             elif choice == '8':    #Reconnect To Stored Wi-Fi Network
  514.                 wireless_networks_output = check_available_wireless_connections()
  515.                 networks = extract_available_wireless_networks(wireless_networks_output)
  516.                 selected_network = select_wifi_network(networks)
  517.                 if selected_network:
  518.                     last_command_output = connect_to_wireless_device(selected_network)
  519.             elif choice == '9':
  520.                 last_command_output = show_all_wireless_interfaces()
  521.                 save_option_data('Show_all_Wireless_Interfaces', last_command_output)
  522.             elif choice == '10':
  523.                 last_command_output = show_wireless_drivers()
  524.                 save_option_data('Show_Wireless_Drivers', last_command_output)
  525.             elif choice == '11':
  526.                 last_command_output = show_proxy_settings()
  527.                 save_option_data('Show_Current_Proxy_Setting_in_Windows', last_command_output)
  528.             elif choice == '12':
  529.                 last_command_output = show_tcp_global_parameters()
  530.                 save_option_data('Check_TCP_Global_Parameters_Status', last_command_output)
  531.             elif choice == '13':
  532.                 last_command_output = show_udp_global_parameters()
  533.                 save_option_data('Check_UDP_Global_Parameters_Status', last_command_output)
  534.             elif choice == '14':
  535.                 last_command_output = disable_tcp_rss()
  536.                 save_option_data('Disable_TCP_RSS_Global_Parameter', last_command_output)
  537.             elif choice == '15':
  538.                 last_command_output = enable_tcp_rss()
  539.                 save_option_data('Enable_TCP_RSS_Global_Parameter', last_command_output)
  540.             elif choice == '16':
  541.                 last_command_output = list_defined_aliases()
  542.                 save_option_data('List_All_Defined_Aliases', last_command_output)
  543.             elif choice == '17':
  544.                 last_command_output = reset_winsock_entries()
  545.                 save_option_data('Reset_Winsock_Entries_to_Default', last_command_output)
  546.             elif choice == '18':
  547.                 last_command_output = reset_tcp_ip_stack()
  548.                 save_option_data('Reset_TCP_IP_Stack_to_Installation_Default', last_command_output)
  549.             elif choice == '19':
  550.                 last_command_output = set_proxy()
  551.                 save_option_data('Set_Proxy_in_Windows_using_netsh_command', last_command_output)
  552.             elif choice == '20':
  553.                 last_command_output = show_multicast_joins()
  554.                 save_option_data('Show_Multicast_Joins_for_All_Network_Interfaces', last_command_output)
  555.             elif choice == '21':
  556.                 last_command_output = allow_port_firewall()
  557.                 save_option_data('Allow_a_Port_from_Windows_Firewall_using_netsh_command', last_command_output)
  558.             elif choice == '22':
  559.                 last_command_output = add_primary_dns_server()
  560.                 save_option_data('Add_Primary_DNS_Server_to_an_Interface', last_command_output)
  561.             elif choice == '23':
  562.                 last_command_output = allow_ping_requests()
  563.                 save_option_data('Allow_Ping_Requests_through_Windows_Firewall', last_command_output)
  564.             elif choice == '24':
  565.                 last_command_output = block_ping_requests()
  566.                 save_option_data('Block_Ping_Requests_through_Windows_Firewall', last_command_output)
  567.             elif choice == '25':
  568.                 last_command_output = disable_windows_firewall()
  569.                 save_option_data('Disable_Windows_Firewall_in_All_Profiles', last_command_output)
  570.             elif choice == '26':
  571.                 last_command_output = reset_firewall_settings()
  572.                 save_option_data('Reset_Windows_Firewall_Settings_to_Default', last_command_output)
  573.             elif choice == '27':
  574.                 last_command_output = stop_network_trace()
  575.                 save_option_data('Stop_Trace_using_netsh_command', last_command_output)
  576.             elif choice == '28':
  577.                 last_command_output = capture_packets()
  578.                 save_option_data('[PING]Capture_Packets_using_netsh_command', last_command_output)
  579.             elif choice == '29':
  580.                 last_command_output = change_interface_ip_address()
  581.                 save_option_data('Change_Interface_IP_Address', last_command_output)
  582.             elif choice == '30':
  583.                 last_command_output = placeholder()
  584.                 save_option_data('PLACEHOLDER FOR OPTION', last_command_output)
  585.             elif choice == '31':
  586.                 last_command_output = view_current_ipv4_configuration()
  587.                 save_option_data('View_Current_IPV4_Configuration', last_command_output)
  588.             elif choice == '32':
  589.                 interfaces = display_network_interfaces()
  590.                 last_command_output = view_current_ipv6_configuration_wrapper(interfaces, display_list=False)
  591.                 save_option_data('View_Current_IPV6_Configuration', last_command_output)
  592.             elif choice == '33': # [BROKEN]
  593.                 print("Exiting the program. Goodbye!")
  594.                 sys.exit(0)
  595.             else:
  596.                 print("\nInput Invalid!\n\tPlease enter a valid option number between 0 and 33.\n\t\tOr... type '34' to exit the program.\n")
  597.                 input("\nPress Enter to continue...\n")
  598.         else:
  599.             print("\nInput Invalid!\n\tPlease enter a valid option number between 0 and 33.\n\t\tOr... type '34' to exit the program\n")
  600.             input("\nPress Enter to continue...\n")
  601.  
  602. if __name__ == "__main__":
  603.     main()
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement