Skip to content

[Bug] 鸿蒙系统使用"破解签名校验"修补过的apk无法安装/HarmonyOS: APK Patched with "Signature Bypass" Can't be Installed #122

Description

@sanstale6

Steps to reproduce/复现步骤

在鸿蒙4.2系统(尚未测试非鸿蒙系统下是否能够复现)以默认配置修补任意apk并启用"破解签名校验"(测试时使用的apk为甲壳虫adb助手1.3.1和via7.2.1,以下内容出现的apk均使用甲壳虫adb助手1.3.1)

Expected behaviour/预期行为

修补后的apk应当可以正常安装

Actual behaviour/实际行为

尝试使用adb安装修补过后的apk时报错
INSTALL_FAILED_INVALID_APK: Scanning Failed.: Package /data/app/~~sOVoM7eE-59XaUneanLuQw==/com.didjdk.adbhelper-Xjpv9j7gWJ6MHTf-BtgDGA==/base.apk code is missing
查看修补后的甲壳虫adb1.3.1 apk后发现以下问题:

  • 修补后的apk没有classes.dex,取而代之的是原apk中没有的classes2.dex
  • 尝试使用mt管理器编辑修补后apk中的classes2.dex发生以下报错(使用dex编辑器++不会报错):
VER: 2.26.7(26070756)  
PERMISSION: SHELL  
ABI: arm64-v8a  
MODEL: BTKR-W00  
SDK: 31  
RELEASE: 12  
TARGET_SDK: 30  
---StackTrace---  
java.lang.RuntimeException: bad magic value: 64 65 78 0a 30 33 39 00  
	at l.۟ܳܺ.<init>(159U:483)  
	at l.۫ᩴ֡.ۖ(X66Y:191)  
	at l.۟᩵᩸.run(74W2:115)  
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  
	at java.lang.Thread.run(Thread.java:933)  

若在修补时将"破解签名校验"一项选为None,则修补后的apk可以被正常安装

Xposed Module List/Xposed 模块列表

未使用模块

NPatch version/NPatch 版本

1.0.6

Android version/Android 版本

Harmony OS 4.2.0 (或许是Android12?)

Shizuku version/Shizuku 版本

13.6.0.r1086.2650830c

Version requirement/版本要求

  • I am using latest debug CI version of NPatch and enable verbose log/我正在使用最新 CI 调试版本且启用详细日志

Apk file/Apk 文件

甲壳虫adb助手.zip

Logs/日志

Details

20260727-manager.log

--------- beginning of main
07-27 21:02:37.761 21414 21414 E top.nkbe.npatc: Not starting debugger since process cannot load the jdwp agent.
07-27 21:02:37.814 21414 32456 E BehaviorCollectManager: Fail to acquire dataAnalyzerService...
07-27 21:02:37.816 21414 21414 W top.nkbe.npatc: gtm: Initialize: failed to open hwgtm_client, sepolicy=untrusted_app
07-27 21:02:37.816 21414 21414 W top.nkbe.npatc: gtm: Disable global task manager
07-27 21:02:37.827 21414 32462 E AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@ae9336
07-27 21:02:37.833 21414 21414 W top.nkbe.npatc: Unsupported class loader
07-27 21:02:37.854 21414 21414 W top.nkbe.npatc: OpenDexFilesFromOat: open oat file failed and fallback to load dex file from apk, package_name = top.nkbe.npatch version_code = 698 context = 0x0 class_loader = org.lsposed.hiddenapibypass.CoreOjClassLoader/0x0 class_loader_status = 1 dex_location = /apex/com.android.art/javalib/core-oj.jar dex_location_writable = 0 oat_file_exists = 0 is_compressed_dex = 0 is_jank_perceptible = 0 is_process_on_top = 1 is_main_thread = 1 fallback_time = 21118750
07-27 21:02:37.854 21414 21414 W top.nkbe.npatc: Unsupported class loader
07-27 21:02:37.854 21414 21414 W top.nkbe.npatc: Unsupported class loader
07-27 21:02:37.863 21414 32467 E NeoPackageManager: Shizuku failed to fetch package list, falling back to standard PM
07-27 21:02:37.863 21414 32467 E NeoPackageManager: java.lang.NoSuchMethodError: No interface method getInstalledPackages(JI)Landroid/content/pm/ParceledListSlice; in class Landroid/content/pm/IPackageManager; or its super classes (declaration of 'android.content.pm.IPackageManager' appears in /system/framework/framework.jar)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at 喵猫喵喵猫喵喵喵.貓貓.喵喵猫(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:126)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at 猫喵貓喵喵喵喵喵.喵喵.猫喵貓(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:6)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at 猫喵喵喵喵喵喵貓.喵喵喵貓.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:109)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at com.google.common.util.concurrent.貓猫.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:64)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at 喵貓喵猫喵喵喵喵.猫猫.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:3)
07-27 21:02:37.863 21414 32467 E NeoPackageManager: 	at 喵貓喵猫喵喵喵喵.喵喵.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:82)
07-27 21:02:37.946 21414 21414 W ViewGroup: ViewUI is dispatching child view at this moment, child:喵貓喵喵貓.貓喵猫{8a7a000 VFED..... ......I. 0,0-0,0 aid=1073741824}, index:0
07-27 21:02:38.007 21414 32472 E OpenGLRenderer: Unable to match the desired swap behavior.
07-27 21:02:38.011 21414 32497 W Gralloc3: mapper 3.x is not supported
07-27 21:02:38.014 21414 32497 W Gralloc4: allocator 4.x is not supported
07-27 21:02:38.016 21414 32497 W Gralloc3: allocator 3.x is not supported
07-27 21:02:38.058 21414 21414 W HwRemoteInputMethodManager: isCasting false because IHwDistributedWindowManager is invalid.
07-27 21:02:38.176 21414 32482 E filemap : invalid offset value:2641231548,2641227776
07-27 21:02:39.079 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:39.079 21414 21414 W Settings: Setting device_provisioned has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
--------- beginning of system
07-27 21:02:39.082 21414 21414 W HwApsManager: HwApsManagerService, registerCallback, start !
07-27 21:02:40.242 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:40.251 21414 21414 W Choreographer: Frame time is 18.966944 ms in the future!  Check that graphics HAL is generating vsync timestamps using the correct timebase.
07-27 21:02:40.894 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:40.989 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:46.433 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:46.450 21414 32472 E OpenGLRenderer: Unable to match the desired swap behavior.
07-27 21:02:46.487 21414 21414 W HwRemoteInputMethodManager: isCasting false because IHwDistributedWindowManager is invalid.
07-27 21:02:47.271 21414 21414 W HwDamageRectFpsManager: submitFps mFpsDecisionHandler == null
07-27 21:02:47.277 21414 21414 W Choreographer: Frame time is 10.037483 ms in the future!  Check that graphics HAL is generating vsync timestamps using the correct timebase.
07-27 21:02:47.286 21414 21414 W Choreographer: Frame time is 17.606672 ms in the future!  Check that graphics HAL is generating vsync timestamps using the correct timebase.
07-27 21:02:47.487 21414 32452 W top.nkbe.npatc: ApkAssets: Deleting an ApkAssets object '<empty> and /data/user/0/top.nkbe.npatch/cache/apk/甲壳虫ADB助手_1.3.1.apk' with 1 weak references
07-27 21:02:47.759 21414 32452 W System  : A resource failed to call end. 
07-27 21:02:47.759 21414 32452 W System  : A resource failed to call end. 
07-27 21:02:47.783 21414 32468 W System.err: 喵貓貓喵喵喵喵.喵猫: 喵猫喵貓喵喵喵.貓喵 is not annotated with 喵貓貓喵喵喵喵.喵貓
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵貓貓喵喵喵喵.猫喵.貓猫(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:199)
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵貓貓喵喵喵喵.猫喵.貓貓(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:13)
07-27 21:02:47.783 21414 32468 W System.err: 	at 猫喵喵喵喵猫喵.貓貓喵.喵猫(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:46)
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵貓貓.貓喵.喵喵猫(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:22)
07-27 21:02:47.783 21414 32468 W System.err: 	at 貓喵喵喵喵猫喵.猫猫喵.猫貓喵(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:412)
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵喵喵喵貓喵喵.喵貓喵.喵貓(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:185)
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵貓喵喵喵猫喵.猫喵貓.喵猫猫喵(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:29)
07-27 21:02:47.783 21414 32468 W System.err: 	at 喵貓喵喵喵猫喵.猫喵貓.猫喵喵喵喵(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:1162)
07-27 21:02:47.784 21414 32468 W System.err: 	at 喵貓喵喵喵猫喵.猫喵貓.close(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:5)
07-27 21:02:47.784 21414 32468 W System.err: 	at top.nkbe.npatch.patch.NPatch.patch(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:1425)
07-27 21:02:47.784 21414 32468 W System.err: 	at top.nkbe.npatch.patch.NPatch.doCommandLine(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:266)
07-27 21:02:47.784 21414 32468 W System.err: 	at androidx.lifecycle.貓猫喵.喵喵猫(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:232)
07-27 21:02:47.784 21414 32468 W System.err: 	at 猫喵貓喵喵喵喵喵.喵喵.猫喵貓(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:6)
07-27 21:02:47.784 21414 32468 W System.err: 	at 猫喵喵喵喵喵喵貓.喵喵喵貓.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:109)
07-27 21:02:47.784 21414 32468 W System.err: 	at com.google.common.util.concurrent.貓猫.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:64)
07-27 21:02:47.784 21414 32468 W System.err: 	at 喵貓喵猫喵喵喵喵.猫猫.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:3)
07-27 21:02:47.784 21414 32468 W System.err: 	at 喵貓喵猫喵喵喵喵.喵喵.run(r8-map-id-08b343e684ba0f024b30f6b31fb74c4b3077023cb2c80150e7a799b7ea2b57b0:82)
07-27 21:02:48.797 21414 32452 W System  : A resource failed to call end. 



Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions