从Android中的请求方配置文件中提取SSID密码 [英] Extracting SSID password from supplicant config file in Android

查看:208
本文介绍了从Android中的请求方配置文件中提取SSID密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个Android SYSTEM应用,该应用从请求方配置文件(/data/misc/wifi/wpa_supplicant.conf)中提取Wifi密码.

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).

使用具有root权限的adb,我可以毫无问题地读取文件,并以纯文本格式查看密码.

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

但是,当我尝试以编程方式打开文件时,出现EACCES(权限被拒绝)错误.即使我的应用程序以系统"用户身份运行(我在清单中定义了android:sharedUserId ="android.uid.system"),这种情况也会发生,该应用程序已使用系统私钥签名并被推送到/system/app中.

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.

我知道可以使用系统权限来完成此操作,因为在Android的源代码中,在frameworks/base/wifi/java/android/net/wifi/WifiConfigStore.java中有一个读取此文件的代码.这段代码在"system_server"进程下运行,该进程使用"system"用户,就像我的应用程序一样.

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));

如果两个应用程序都以系统"用户身份运行并具有系统权限,那么system_server怎么能读取此文件而我的应用程序却失败了?我想念什么?

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?

请不要建议依赖于根访问的解决方案,因为这与我的情况无关.我需要一个仅基于系统权限而不是root用户的解决方案.

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.

推荐答案

您需要平台签名,在清单部分中添加android:sharedUserId ="android.uid.system"属性,并在其中添加android:process ="system"属性应用部分.

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

这篇关于从Android中的请求方配置文件中提取SSID密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆