Search code examples
xamarin.android

Get a list of passwords Wi-Fi


I want a way to view the previously saved WiFi ssid and passwords on the android phone ?

for example

good boy 221548dshvshg

This code is for fetching WiFi data without a password. I want to get the password with the network name

 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

List myListrow = new List();

        var wifiMgr = (WifiManager)GetSystemService(WifiService);
        var wifiList = wifiMgr.ScanResults;

        foreach (var item in wifiList)
        {
            var wifiLevel = WifiManager.CalculateSignalLevel(item.Level, 100);
             myListrow.Add(($"Wifi Name: {item.Ssid} - Single: {wifiLevel}"));

        }

Solution

  • Without rooting - due to security reasons, you cannot do that. You can only check the security type of the network through each network's capabilities.

    With rooting - You can do it by simply reading the contents of /data/misc/wifi/wpa_supplicant.conf file. Unfortunately, this is not universal for all phones and you will find out that this configuration file is sometimes located somewhere else, depending of the phone's manufacturer.