Advertisement
Darkonis

Untitled

Nov 8th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.99 KB | Source Code | 0 0
  1. #!/usr/bin/env python3
  2. import os
  3. import subprocess
  4. import time
  5. import sys
  6.  
  7. def run_command(command):
  8.     try:
  9.         return subprocess.check_output(command, shell=True, text=True).strip()
  10.     except subprocess.CalledProcessError:
  11.         return None
  12.  
  13. def slow_print(text, color="\033[31m"):  # Red color for emphasis
  14.     for char in text:
  15.         sys.stdout.write(f"{color}{char}\033[0m")
  16.         sys.stdout.flush()
  17.         time.sleep(0.05)
  18.     print()
  19.  
  20. def list_wifi_networks():
  21.     print("\nScanning for available WiFi networks...\n")
  22.     networks = run_command("nmcli -t -f SSID dev wifi list")
  23.     if networks:
  24.         for idx, network in enumerate(networks.splitlines()):
  25.             print(f"{idx + 1}: {network}")
  26.     else:
  27.         print("No networks found.")
  28.  
  29. def connect_to_wifi():
  30.     ssid = input("Enter the SSID of the network you want to connect to: ")
  31.     password = input("Enter the password: ")
  32.     command = f"nmcli dev wifi connect '{ssid}' password '{password}'"
  33.     result = run_command(command)
  34.     print("Connected successfully." if result else "Failed to connect.")
  35.  
  36. def disconnect_wifi():
  37.     print("\nDisconnecting WiFi...\n")
  38.     result = run_command("nmcli con down id $(nmcli -t -f NAME con show --active)")
  39.     print("Disconnected successfully." if result else "No active connection to disconnect.")
  40.  
  41. def network_status():
  42.     print("\nCurrent Network Status:\n")
  43.     status = run_command("nmcli -t -f ACTIVE,SSID,MODE,CHAN,RATE,SIGNAL,BARS,SECURITY dev wifi list | grep '^yes'")
  44.     if status:
  45.         fields = status.split(':')
  46.         print(f"SSID: {fields[1]}\nMode: {fields[2]}\nChannel: {fields[3]}\nRate: {fields[4]} Mbps\nSignal Strength: {fields[5]}%\nSignal Bars: {fields[6]}\nSecurity: {fields[7]}")
  47.     else:
  48.         print("No active WiFi connection.")
  49.  
  50.     local_ip = run_command("hostname -I | awk '{print $1}'")
  51.     gateway_ip = run_command("ip route | grep default | awk '{print $3}'")
  52.     external_ip = run_command("curl -s https://ipinfo.io/ip")
  53.  
  54.     print(f"Local IP: {local_ip}\nGateway IP: {gateway_ip}\nExternal IP: {external_ip}")
  55.  
  56. def port_scan():
  57.     target = input("Enter the IP address to scan: ")
  58.     print(f"\nScanning ports on {target}...\n")
  59.     result = run_command(f"nmap -Pn {target}")
  60.     print(result if result else "Port scan failed or returned no results.")
  61.  
  62. def bruteforce_wifi():
  63.     ssid = input("Enter the SSID of the network to brute-force: ")
  64.     wordlist = input("Enter the path to the wordlist file: ")
  65.     print(f"\nStarting brute-force attack on {ssid}...\n")
  66.     result = run_command(f"aircrack-ng -w {wordlist} -e {ssid} /tmp/*.cap")
  67.     print(result if result else "Brute-force attack failed or returned no results.")
  68.  
  69. def show_route_table():
  70.     print("\nRoute Table and Local Network Information:\n")
  71.     route_table = run_command("ip route")
  72.     interfaces = run_command("ip addr")
  73.     print(f"Route Table:\n{route_table}\n\nNetwork Interfaces:\n{interfaces}")
  74.  
  75. def list_file_shares():
  76.     print("\nScanning local network for file shares...\n")
  77.     result = run_command("smbclient -L //localhost -N")
  78.     print(result if result else "No file shares found or failed to retrieve shares.")
  79.  
  80. def traceroute_test():
  81.     target = input("Enter the IP address or URL for traceroute: ")
  82.     print(f"\nTraceroute to {target}...\n")
  83.     result = run_command(f"traceroute {target}")
  84.     print(result if result else "Traceroute failed or returned no results.")
  85.  
  86. def ping_test():
  87.     target = input("Enter the IP address or URL to ping: ")
  88.     print(f"\nPinging {target}...\n")
  89.     result = run_command(f"ping -c 4 {target}")
  90.     print(result if result else "Ping test failed or returned no results.")
  91.  
  92. def main():
  93.     slow_print("Network Configuration Menu", "\033[34m")
  94.     while True:
  95.         print("\nOptions:")
  96.         print("1: List WiFi Networks")
  97.         print("2: Connect to WiFi")
  98.         print("3: Disconnect from WiFi")
  99.         print("4: Show Network Status")
  100.         print("5: Port Scan")
  101.         print("6: WiFi Bruteforce Attack")
  102.         print("7: Show Route Table and Network Info")
  103.         print("8: List Active File Shares")
  104.         print("9: Traceroute Test")
  105.         print("10: Ping Test")
  106.         print("11: Exit")
  107.  
  108.         choice = input("\nEnter your choice: ")
  109.         if choice == '1':
  110.             list_wifi_networks()
  111.         elif choice == '2':
  112.             connect_to_wifi()
  113.         elif choice == '3':
  114.             disconnect_wifi()
  115.         elif choice == '4':
  116.             network_status()
  117.         elif choice == '5':
  118.             port_scan()
  119.         elif choice == '6':
  120.             bruteforce_wifi()
  121.         elif choice == '7':
  122.             show_route_table()
  123.         elif choice == '8':
  124.             list_file_shares()
  125.         elif choice == '9':
  126.             traceroute_test()
  127.         elif choice == '10':
  128.             ping_test()
  129.         elif choice == '11':
  130.             break
  131.         else:
  132.             print("You picked wrong dumb ass")
  133.  
  134. if __name__ == "__main__":
  135.     main()
  136.  
Tags: pnet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement