Advertisement
Python253

loading_screen_with_wifi_data

Jun 20th, 2024 (edited)
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.23 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: loading_screen.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. Description:
  9.    - This script gathers various system information essential for network management and troubleshooting.
  10.      It retrieves the following details:
  11.        - Public IP address:
  12.            Obtained from an external API endpoint.
  13.        - User details:
  14.            Includes the username currently logged into the system.
  15.        - Computer name:
  16.            Retrieves the local computer's name.
  17.        - Operating system:
  18.            Fetches information about the current operating system.
  19.        - Wi-Fi network information:
  20.            Retrieves SSIDs (Service Set Identifiers) and passwords of previously saved Wi-Fi networks on the machine.
  21.    
  22.    - It presents this information using a simulated loading effect, enhancing user experience with a progress bar visual representation.
  23.    
  24. Requirements:
  25.    - Python 3.x
  26.    - The Following Modules:
  27.        - json
  28.        - urllib
  29.        - subprocess
  30.        - colorama
  31.  
  32. Functions:
  33.    - get_wifi_passwords():
  34.        Retrieves SSIDs and passwords of saved Wi-Fi networks on the machine.
  35.  
  36.    - loading():
  37.        Displays system information with a loading bar effect, including IP,
  38.        username, PC name, OS, and Wi-Fi information.
  39.  
  40. Usage:
  41.    - Ensure Python 3.x is installed.
  42.    - Install required modules using pip (if not already installed):
  43.      
  44.      EXAMPLE:
  45.                'pip install colorama'
  46.  
  47.    - Run the script.
  48.  
  49. Additional Notes:
  50.    - The loading function clears the screen and displays information in a loop,
  51.      simulating a loading process with a progress bar.
  52.    - This script requires administrative privileges on Windows to retrieve Wi-Fi passwords.
  53.  
  54. """
  55.  
  56. import os
  57. import time
  58. import random
  59. from json import load
  60. from urllib.request import urlopen
  61. import subprocess
  62. from colorama import init, Fore, Style
  63.  
  64. # Initialize colorama
  65. init(autoreset=True)
  66.  
  67. def get_wifi_passwords():
  68.     """
  69.    Retrieves the SSIDs and passwords of saved Wi-Fi networks on the machine.
  70.  
  71.    Returns:
  72.        wifi_data (str): A formatted string containing SSIDs and passwords.
  73.    """
  74.     wifi_data = ""
  75.     try:
  76.         # Get the list of Wi-Fi profiles
  77.         wifi_profiles = subprocess.check_output("netsh wlan show profiles", shell=True, text=True).split('\n')
  78.         profiles = [line.split(":")[1].strip() for line in wifi_profiles if "All User Profile" in line]
  79.  
  80.         for profile in profiles:
  81.             # Get the Wi-Fi password for each profile
  82.             wifi_details = subprocess.check_output(f"netsh wlan show profile name=\"{profile}\" key=clear", shell=True, text=True).split('\n')
  83.             password = None
  84.             for line in wifi_details:
  85.                 if "Key Content" in line:
  86.                     password = line.split(":")[1].strip()
  87.                     break
  88.  
  89.             wifi_data += f"SSID: {profile}, Password: {password if password else 'None'}\n"
  90.  
  91.     except Exception as e:
  92.         wifi_data += f"Error retrieving Wi-Fi passwords: {e}\n"
  93.  
  94.     return wifi_data
  95.    
  96. def loading():
  97.     """
  98.    Displays system information with a loading bar effect.
  99.  
  100.    Retrieves the public IP, username, computer name, operating system, and Wi-Fi information,
  101.    then displays this information while simulating a loading process with a progress bar.
  102.    """
  103.     # Gather system information
  104.     ip_info = load(urlopen('https://api.myip.com/'))
  105.     wifi_info = get_wifi_passwords()
  106.     img = f"""
  107. IP: {ip_info['ip']}
  108. Username: {os.getlogin()}
  109. PC Name: {os.getenv('COMPUTERNAME')}
  110. Operating System: {os.getenv('OS')}
  111.  
  112. Known Wi-Fi Networks + Passwords:
  113.  
  114. {wifi_info}
  115.    """
  116.  
  117.     # Display system information with a loading bar
  118.     for i in range(40):
  119.         os.system('cls' if os.name == 'nt' else 'clear')  # Clear the screen
  120.         print(img)
  121.         progress = (Fore.GREEN + "#" * (i + 1) + Style.RESET_ALL).ljust(40, '-')
  122.         print(f"[{progress}]")
  123.         time.sleep(random.uniform(0.025, 0.075))  # Random delay between 0.025 and 0.075 seconds
  124.  
  125. if __name__ == '__main__':
  126.     loading()
  127.     print("\n\n\tAll processes completed.\n\n\tExiting Program...   GoodBye!\n")
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement