pip install pyTelegramBotAPI tabulate
import subprocess
import re
import ctypes
import time
import sys
from tabulate import tabulate
# Emojis for user notifications
SUCCESS_EMOJI = "✅"
ERROR_EMOJI = "❌"
INFO_EMOJI = "ℹ️"
LOADING_EMOJI = "⏳"
WARNING_EMOJI = "⚠️"
# Check if the script is running with admin privileges
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except Exception:
return False
# Display a sliding loading bar
def loading_bar(duration=3):
print(f"{LOADING_EMOJI} Fetching WiFi profiles, please wait...")
bar_length = 20
for i in range(101):
percent = i
filled = int(bar_length * i // 100)
bar = "█" * filled + " " * (bar_length - filled)
sys.stdout.write(f"\rProgress: [{bar}] {percent}%")
sys.stdout.flush()
time.sleep(duration / 100)
print("\n")
# Fetch WiFi profiles using netsh
def get_wifi_profiles():
try:
command = ["netsh", "wlan", "show", "profiles"]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
print(f"{ERROR_EMOJI} Failed to fetch WiFi profiles: {result.stderr}")
return []
output = result.stdout
profiles = re.findall(r"All User Profile : (.*)", output)
if not profiles:
print(f"{WARNING_EMOJI} No WiFi profiles found in command output.")
return profiles
except Exception as e:
print(f"{ERROR_EMOJI} Unexpected error fetching profiles: {e}")
return []
# Fetch password for a specific WiFi profile
def get_password(profile):
try:
command = ["netsh", "wlan", "show", "profile", f"name={profile}", "key=clear"]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode != 0:
print(f"{ERROR_EMOJI} Error fetching password for '{profile}': {result.stderr}")
return "Error"
output = result.stdout
match = re.search(r"Key Content : (.*)", output)
return match.group(1) if match else "No password"
except Exception as e:
print(f"{ERROR_EMOJI} Unexpected error fetching password for '{profile}': {e}")
return "Error"
# Main function
def main():
# Check for admin privileges
if not is_admin():
print(f"{ERROR_EMOJI} This script requires administrative privileges.")
print(f"{INFO_EMOJI} Please right-click the script or Command Prompt and select 'Run as administrator'.")
sys.exit(1)
else:
print(f"{SUCCESS_EMOJI} Administrative privileges confirmed.")
# Show loading bar
loading_bar()
# Get WiFi profiles
profiles = get_wifi_profiles()
if not profiles:
print(f"{ERROR_EMOJI} No WiFi profiles found on this desktop.")
print(f"{INFO_EMOJI} Connect to a WiFi network first or ensure profiles are saved.")
sys.exit(1)
# Fetch passwords and store data
wifi_data = []
for profile in profiles:
password = get_password(profile)
wifi_data.append([profile, password])
# Display results in a table
print(f"{SUCCESS_EMOJI} WiFi details retrieved successfully:")
print(tabulate(wifi_data, headers=["WiFi Name", "Password"], tablefmt="pretty"))
if __name__ == "__main__":
main()
Comments
Post a Comment