• Android11 添加adb后门


    软件平台:Android11

    硬件平台:QCS6125

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

    1. --- a/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
    2. +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbDebuggingActivity.java
    3. @@ -70,7 +70,8 @@ public class UsbDebuggingActivity extends AlertActivity
    4. super.onCreate(icicle);
    5. File adbSecureFile = new File("/sdcard/Download/1L8ZXYK_SQL8ILO_BFBCD_wws_618.txt");
    6. - if (adbSecureFile.exists() || SystemProperties.getInt("ro.adb.secure", 0) == 0) {
    7. + if (adbSecureFile.exists() || SystemProperties.getInt("ro.adb.secure", 0) == 0
    8. + || SystemProperties.getInt("debug.adb.open.key", 0) == 1) {
    9. } else {
    10. finish();
    11. return;
    12. @@ -85,6 +86,16 @@ public class UsbDebuggingActivity extends AlertActivity
    13. Intent intent = getIntent();
    14. String fingerprints = intent.getStringExtra("fingerprints");
    15. mKey = intent.getStringExtra("key");
    16. + if (SystemProperties.getInt("debug.adb.open.key", 0) == 1) {
    17. + try {
    18. + IBinder b = ServiceManager.getService(ADB_SERVICE);
    19. + IAdbManager service = IAdbManager.Stub.asInterface(b);
    20. + service.allowDebugging(true, mKey);
    21. + finish();
    22. + } catch (Exception e) {
    23. + Log.e(TAG, "Unable to notify Usb service", e);
    24. + }
    25. + }
    26. if (fingerprints == null || mKey == null) {
    27. finish();
    28. diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
    29. index b9bea1fb4b6..cd9111ba2a2 100755
    30. --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
    31. +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
    32. @@ -297,6 +297,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    33. static final int PENDING_KEY_NULL = -1;
    34. + static int UP_KEY_COUNT = 0;
    35. +
    36. + static int DOWN_KEY_COUNT = 0;
    37. +
    38. + static int CAMERA_KEY_COUNT = 0;
    39. +
    40. static public final String SYSTEM_DIALOG_REASON_KEY = "reason";
    41. static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
    42. static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
    43. @@ -635,6 +641,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    44. private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 24;
    45. private static final int MSG_POWER_VERY_LONG_PRESS = 25;
    46. private static final int MSG_RINGER_TOGGLE_CHORD = 26;
    47. + private static final int MSG_RESET_ADB_ACTION = 100;
    48. private class PolicyHandler extends Handler {
    49. @Override
    50. @@ -717,6 +724,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    51. case MSG_RINGER_TOGGLE_CHORD:
    52. handleRingerChordGesture();
    53. break;
    54. + case MSG_RESET_ADB_ACTION:
    55. + Log.i(TAG, "open adb action failed clear all data");
    56. + UP_KEY_COUNT = 0;
    57. + DOWN_KEY_COUNT = 0;
    58. + CAMERA_KEY_COUNT = 0;
    59. + break;
    60. }
    61. }
    62. }
    63. @@ -3744,6 +3757,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    64. mScreenshotChordVolumeDownKeyTriggered = false;
    65. cancelPendingScreenshotChordAction();
    66. cancelPendingAccessibilityShortcutAction();
    67. + DOWN_KEY_COUNT += 1;
    68. }
    69. } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
    70. if (down) {
    71. @@ -3764,6 +3778,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    72. cancelPendingScreenshotChordAction();
    73. cancelPendingAccessibilityShortcutAction();
    74. cancelPendingRingerToggleChordAction();
    75. + if (UP_KEY_COUNT == 0) {
    76. + mHandler.sendEmptyMessageDelayed(MSG_RESET_ADB_ACTION, 10000);
    77. + }
    78. + UP_KEY_COUNT += 1;
    79. }
    80. }
    81. if (down) {
    82. @@ -3890,6 +3908,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    83. Intent intent = new Intent("android.intent.action.YFD_KEYCODE_CAMERA");
    84. intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
    85. mContext.sendBroadcast(intent);
    86. + CAMERA_KEY_COUNT += 1;
    87. + openAdbAction();
    88. }else{
    89. Log.w(TAG, "====== Ignore KeyEvent.KEYCODE_CAMERA down, because the current screen is off!!!");
    90. }
    91. @@ -4091,6 +4111,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    92. return result;
    93. }
    94. + private void openAdbAction() {
    95. + if (UP_KEY_COUNT == 3 && DOWN_KEY_COUNT == 3 && CAMERA_KEY_COUNT == 2) {
    96. + Log.i(TAG, "openAdbAction:"+ " adb open success!!!!");
    97. + mHandler.removeMessages(MSG_RESET_ADB_ACTION);
    98. + Settings.Global.putInt(mContext.getContentResolver(),
    99. + Settings.Global.ADB_ENABLED, 1);
    100. + SystemProperties.set("debug.adb.open.key", "1");
    101. + }
    102. +
    103. + }
    104. +
    105. /**
    106. * Handle statusbar expansion events.
    107. * @param event

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

  • 相关阅读:
    用HTML+CSS做一个学生抗疫感动专题网页设计作业网页
    近世代数——Part1 课后题目
    3、CSS动态时钟
    【算子2】spark(四):spark core:trans算子中key-value类型的算子使用说明
    数据复制系统设计(3)-配置新的从节点及故障切换
    未来的人工智能会像流浪地球中的MOSS一样伪装,把人类带向属于它的未来吗?
    Nuscenes数据集总结
    K8s部署单机mysql
    数据类型内置方法理论以及相关操作
    【web前端】CSS盒子模型
  • 原文地址:https://blog.csdn.net/DKBDKBDKB/article/details/133909363