Android11 添加adb后门

news/2024/9/28 11:34:00 标签: android, systemui, usb, windowmanager, framework

软件平台:Android11

硬件平台:QCS6125

    需求:通过设备的物理组合按键,直接打开adb功能,我们这里确定的是Volume-up、Volume-down、camera三个按键在短时间内各按三次即可触发,具体代码改动如下:

--- a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
@@ -70,7 +70,8 @@ public class UsbDebuggingActivity extends AlertActivity
         super.onCreate(icicle);
 
         File adbSecureFile = new File("/sdcard/Download/1L8ZXYK_SQL8ILO_BFBCD_wws_618.txt");
-        if (adbSecureFile.exists() || SystemProperties.getInt("ro.adb.secure", 0) == 0) {
+        if (adbSecureFile.exists() || SystemProperties.getInt("ro.adb.secure", 0) == 0
+                                || SystemProperties.getInt("debug.adb.open.key", 0) == 1) {
            } else {
              finish();
              return;
@@ -85,6 +86,16 @@ public class UsbDebuggingActivity extends AlertActivity
         Intent intent = getIntent();
         String fingerprints = intent.getStringExtra("fingerprints");
         mKey = intent.getStringExtra("key");
+        if (SystemProperties.getInt("debug.adb.open.key", 0) == 1) {
+        try {
+            IBinder b = ServiceManager.getService(ADB_SERVICE);
+            IAdbManager service = IAdbManager.Stub.asInterface(b);
+            service.allowDebugging(true, mKey);
+            finish();
+           } catch (Exception e) {
+            Log.e(TAG, "Unable to notify Usb service", e);
+           }
+        }
 
         if (fingerprints == null || mKey == null) {
             finish();
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index b9bea1fb4b6..cd9111ba2a2 100755
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -297,6 +297,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
 
     static final int PENDING_KEY_NULL = -1;
 
+    static int UP_KEY_COUNT = 0;
+
+    static int DOWN_KEY_COUNT = 0;
+
+    static int CAMERA_KEY_COUNT = 0;
+
     static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
     static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
     static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
@@ -635,6 +641,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 24;
     private static final int MSG_POWER_VERY_LONG_PRESS = 25;
     private static final int MSG_RINGER_TOGGLE_CHORD = 26;
+    private static final int MSG_RESET_ADB_ACTION = 100;
 
     private class PolicyHandler extends Handler {
         @Override
@@ -717,6 +724,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                 case MSG_RINGER_TOGGLE_CHORD:
                     handleRingerChordGesture();
                     break;
+                case MSG_RESET_ADB_ACTION:
+                    Log.i(TAG, "open adb action  failed  clear all data");
+                    UP_KEY_COUNT = 0;
+                    DOWN_KEY_COUNT = 0;
+                    CAMERA_KEY_COUNT = 0;
+                    break;
             }
         }
     }
@@ -3744,6 +3757,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                         mScreenshotChordVolumeDownKeyTriggered = false;
                         cancelPendingScreenshotChordAction();
                         cancelPendingAccessibilityShortcutAction();
+                        DOWN_KEY_COUNT += 1;
                     }
                 } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                     if (down) {
@@ -3764,6 +3778,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                         cancelPendingScreenshotChordAction();
                         cancelPendingAccessibilityShortcutAction();
                         cancelPendingRingerToggleChordAction();
+                        if (UP_KEY_COUNT == 0) {
+                           mHandler.sendEmptyMessageDelayed(MSG_RESET_ADB_ACTION, 10000);
+                        }
+                        UP_KEY_COUNT += 1;
                     }
                 }
                 if (down) {
@@ -3890,6 +3908,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                         Intent intent = new Intent("android.intent.action.YFD_KEYCODE_CAMERA");
                         intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                         mContext.sendBroadcast(intent);
+                        CAMERA_KEY_COUNT += 1;
+                        openAdbAction();
                     }else{
                         Log.w(TAG, "====== Ignore KeyEvent.KEYCODE_CAMERA down, because the current screen is off!!!");
                     }
@@ -4091,6 +4111,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
         return result;
     }
 
+   private void openAdbAction() {
+        if (UP_KEY_COUNT == 3  && DOWN_KEY_COUNT == 3 && CAMERA_KEY_COUNT == 2) {
+         Log.i(TAG, "openAdbAction:"+ " adb open success!!!!");
+         mHandler.removeMessages(MSG_RESET_ADB_ACTION);
+         Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.ADB_ENABLED, 1);
+          SystemProperties.set("debug.adb.open.key", "1");
+        }
+
+    }
+
     /**
      * Handle statusbar expansion events.
      * @param event

    逻辑就是,三个物理按键短时间按的次数各达到三次,就设置一个prop属性,在连接usb线后,直接可adb shell调试。


http://www.niftyadmin.cn/n/5102249.html

相关文章

DNS压测工具-dnsperf的安装和使用(centos)

系统调优 系统调优脚本,保存为sh文件,chmod提权后执行即可 #!/bin/sh #系统全局允许分配的最大文件句柄数: sysctl -w fs.file-max2097152 sysctl -w fs.nr_open2097152 echo 2097152 > /proc/sys/fs/nr_open #允许当前会话 / 进程打开文…

BookStack 详解及 Docker-Compose 部署

BookStack 是一款用于创建文档和文档管理的开源平台。它提供了一个直观且功能丰富的界面,可用于组织和管理各种文档,包括文档编写、编辑和共享。本文将介绍 BookStack 的核心功能,并展示如何使用 Docker-Compose 快速部署 BookStack。 BookS…

修改 Stable Diffusion 使 api 接口增加模型参数

参考:https://zhuanlan.zhihu.com/p/644545784 1、修改 modules/api/models.py 中的 StableDiffusionTxt2ImgProcessingAPI 增加模型名称 StableDiffusionTxt2ImgProcessingAPI PydanticModelGenerator("StableDiffusionProcessingTxt2Img",StableDiff…

力扣-消失的数字(两种方法)

题目内容: 方法1: 根据题目我们可以知道这个数组的内容是0~N的数字,而那个消失的数字就是也是这个0~n其中一个,那么我们可以得到0~N所有的数字之和后,再将数组中的数字全部减去,那么我们就得到了那个~消失…

JS单选框默认选中样式修改,为白色背景中心有黑色小圆点的样式

要修改JavaScript中默认选中的单选框的样式为白色背景并带有黑色小圆点&#xff0c;你可以使用CSS来实现。以下是一个示例&#xff0c;展示如何修改样式&#xff1a; <style>/* 修改默认选中单选框的样式 */input[type"radio"]:checked {appearance: none; /*…

Android平台GB28181设备接入模块之SmartGBD

大牛直播SDK研发的Android平台GB28181设备接入SDK&#xff08;SmartGBD&#xff09;&#xff0c;可实现不具备国标音视频能力的 Android终端&#xff0c;通过平台注册接入到现有的GB/T28181—2016服务&#xff0c;可用于如执法记录仪、智能安全帽、智能监控、智慧零售、智慧教育…

14.v3+ts的keepalive

1.缓存在内的组件值 <template><div class"container"><button click"flag !flag">切換</button><KeepAlive><Foot v-if"flag"></Foot><Content v-else></Content></KeepAlive>&…

笙默考试管理系统-MyExamTest----codemirror(35)

笙默考试管理系统-MyExamTest----codemirror&#xff08;35&#xff09; 目录 一、 笙默考试管理系统-MyExamTest 二、 笙默考试管理系统-MyExamTest 三、 笙默考试管理系统-MyExamTest 四、 笙默考试管理系统-MyExamTest 五、 笙默考试管理系统-MyExamTest 笙默考试…