Well you learnt something

So I copied the script in windows and transferred it to the laptop. So thats how it ended up .txt
import subprocess try: # Get a list of active Wi-Fi connections wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'NAME', 'connection', 'show', '--active']).decode('utf-8') wifi_profiles = wifi_profiles_info.strip().split('\n') if wifi_profiles: print("Available Wi-Fi networks:") for index, profile in enumerate(wifi_profiles, start=1): print(f"{index}. {profile}") selection = int(input("Select a Wi-Fi network (enter the number): ")) - 1 selected_profile = wifi_profiles[selection] wifi_password_info = subprocess.check_output(['nmcli', '-s', '-g', '802-11-wireless-security.psk', 'connection', 'show', selected_profile]).decode('utf-8') wifi_password = wifi_password_info.strip() print(f"Wi-Fi network: {selected_profile}") print(f"Password: {wifi_password}") else: print("No Wi-Fi networks found.") except (ValueError, IndexError): print("Invalid selection or no Wi-Fi network selected.")
$wifiProfiles = netsh wlan show profiles | Select-String "All User Profile" | ForEach-Object { $_ -replace "All User Profile\s+:\s+" } $selectedProfile = $wifiProfiles | Out-GridView -Title "Select a Wi-Fi network" -OutputMode Single if ($selectedProfile) { $wifiPassword = (netsh wlan show profile name="$selectedProfile" key=clear | Select-String "Key Content").ToString() -replace "Key Content\s+:\s+" Write-Host "Wi-Fi network: $selectedProfile" Write-Host "Password: $wifiPassword" } else { Write-Host "No Wi-Fi network selected." }
skynet@ubuntu:~/Desktop$ python3 script.txt Error: invalid field 'SSID'; allowed fields: NAME,UUID,TYPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,AUTOCONNECT-PRIORITY,READONLY,DBUS-PATH,ACTIVE,DEVICE,STATE,ACTIVE-PATH,SLAVE. Traceback (most recent call last): File "script.txt", line 4, in <module> wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']).decode('utf-8') File "/usr/lib/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']' returned non-zero exit status 2.
import subprocess wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'NAME', 'connection', 'show', '--active']).decode('utf-8') wifi_profiles = [line.strip() for line in wifi_profiles_info.split('\n')] print("Available Wi-Fi networks:") for index, profile in enumerate(wifi_profiles): print(f"{index + 1}. {profile}") selection = input("Select a Wi-Fi network (enter the number): ") try: selected_profile = wifi_profiles[int(selection) - 1] except (ValueError, IndexError): selected_profile = None if selected_profile: wifi_password_info = subprocess.check_output(['nmcli', '-s', '-g', '802-11-wireless-security.psk', 'connection', 'show', selected_profile]).decode('utf-8') wifi_password = wifi_password_info.strip() print(f"Wi-Fi network: {selected_profile}") print(f"Password: {wifi_password}") else: print("No Wi-Fi network selected.")
skynet@ubuntu:~/Desktop$ python3 script.txt Error: invalid field 'SSID'; allowed fields: NAME,UUID,TYPE,TIMESTAMP,TIMESTAMP-REAL,AUTOCONNECT,AUTOCONNECT-PRIORITY,READONLY,DBUS-PATH,ACTIVE,DEVICE,STATE,ACTIVE-PATH,SLAVE. Traceback (most recent call last): File "script.txt", line 4, in <module> wifi_profiles_info = subprocess.check_output(['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']).decode('utf-8') File "/usr/lib/python3.6/subprocess.py", line 356, in check_output **kwargs).stdout File "/usr/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['nmcli', '-t', '-f', 'SSID', 'connection', 'show', '--active']' returned non-zero exit status 2.
Leave a comment: