Extracting SSID password from supplicant config file in Android

社会主义新天地 提交于 2019-12-21 05:32:25

问题


I'm trying to write an Android SYSTEM app that extracts the Wifi password from the supplicant configuration file (/data/misc/wifi/wpa_supplicant.conf).

Using adb with root permissions, I can read the file without any problem and see the password in plain text.

However, when I try to open the file programatically I get EACCES (Permission denied) error. That happens even though my app is running as 'system' user (I define android:sharedUserId="android.uid.system" in the manifest), the app is signed with the system private key and pushed into /system/app.

I know for a fact that it can be done using system permissions, because in Android's source code, in frameworks/base/wifi/java/android/net/wifi/WifiConfigStore.java there's a code that reads this file. This code runs under the 'system_server' process, which is using the 'system' user, just like my app.

My code to open the file that fails:

reader = new BufferedReader(new FileReader(SUPPLICANT_CONFIG_FILE));

If both apps run with the 'system' user and have system permissions, how come system_server can read this file and my app fails? What am I missing?

Please do not suggest solutions that rely on root access, since it's irrelevant in my case. I need a solution that is based on system permissions only, not root.


回答1:


You need platform signature, add android:sharedUserId="android.uid.system" property in manifest section, and add android:process="system" property in application section.



来源:https://stackoverflow.com/questions/22758650/extracting-ssid-password-from-supplicant-config-file-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!