14

I am trying to get the WiFi passwords programmatically from a non-rooted Android device.

All I need is to be able to read the passwords, I do not need to be able to edit them.

Can I get permission in the manifest file?

1
  • This question has answers that claim to work for earlier versions of Android, but don't work for more recent versions: stackoverflow.com/questions/4374862/… Commented Apr 13, 2015 at 10:10

4 Answers 4

9

If your application is a privileged app (that is - installed in /system/priv-app for example using SuperUser) then you can use the new WifiManager#getPrivilegedConfiguredNetworks() API in Lollipop and newer.

See: https://android.googlesource.com/platform/frameworks/base/+/758bdf4a915c313f1c3bef0b95b494c91f363f03%5E%21/#F1

Sign up to request clarification or add additional context in comments.

1 Comment

I wonder if this is how the Google Home app does it when onboarding chromecast/home devices. It really does make the onboarding slicker.
7

This is not possible as this would be a major security risk.

You may be able to if the phone is rooted but I do not know, I would imagine, and hope, even if you could get to where it is stored on the phone, it would be encrypted.

4 Comments

can i get the password of the connected wifi network ?
No, again this would be a security risk, and why would you need to, if you are connected, you probably know the password
Google Chromecast (now Home) can read current wifi password and provide it to Chromecast...
Well, Home has the necessary privileges to do so, it's unfair, but it's Google ;)
7

Most of the time, the Wi-Fi credentials are managed by the wpa_supplicant daemon which store this in a configuration file like /data/misc/wifi/wpa_supplicant.conf.

In this file you will find network structures which store the remembered networks like this:

network={
    ssid="example"
    key_mgmt=WPA-PSK
    psk="passphrase"
}

This file is usually own by a system user like wifi or root. So you have to be root if you want to read it directly.

Nevertheless, you can get the ssid or other network variables of the remember networks by using the wpa_cli command:

$ wpa_cli get_network <id> ssid
"example"

But if you try with the psk you will get a * as this is a security risk:

$ wpa_cli get_network <id> psk
*

1 Comment

This file doesn't have such information in latest android (kitkat). How to do it in kitkat?
3

There is no API support for reading/writing WiFi passwords for APKs not signed with the system key. So you won't be able to retrieve it.

2 Comments

can i get the password of the connected wifi network ?
Passwords of connected WiFi networks are stored in your phone. But you need Root Access to read this file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.