Meh*_*ran 1 reverse android smali
这是TestClass和MainActivity。
为了始终显示Toast,我使用 smali 修补将TestClass 构造函数 更改为以下内容:
但编译签名后,新的补丁apk无法安装。
哪里有问题??
这是修补代码:
iput-boolean p1, p0, Lcom/example/test1/TestClass;->testB:Z
if-nez p1, :cond_0
const/4 p1, 0x1
iput-boolean p1, p0, Lcom/example/test1/TestClass;->testB:Z
:cond_0
Run Code Online (Sandbox Code Playgroud)
这是安装过程中的LOGCAT:
1772 1772 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
1772 1772 D AndroidRuntime: CheckJNI is OFF
1772 1772 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
1772 1772 E memtrack: Couldn't load memtrack module (No such file or directory)
1772 1772 E android.os.Debug: failed to load memtrack module: -2
1772 1772 I Radio-JNI: register_android_hardware_Radio DONE
1772 1772 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
1594 1606 D DefContainer: Copying /data/local/tmp/app-release_SIGNED_UNALIGNED.apk to base.apk
637 662 D NativeLibraryHelper: Library 'libtoolChecker.so' is not page-aligned - will not be able to open it directly from apk.
637 662 W NativeHelper: Failure copying native libraries [errorCode=-2]
637 662 I art : Starting a blocking GC Explicit
637 662 I art : Explicit concurrent mark sweep GC freed 34438(1881KB) AllocSpace objects, 2(40KB) LOS objects, 33% free, 6MB/9MB, paused 267us total 14.270ms
1772 1772 I art : System.exit called, status: 1
1772 1772 I AndroidRuntime: VM exiting with result code 1.
Run Code Online (Sandbox Code Playgroud)
zipalign使用和(如果还没有)对齐 APK 文件,使用apksigner处理 v2 签名,这是一项附加要求。
您的 logcat 中有两次提到对齐,这强烈表明您的 APK 文件未对齐。从Android 11开始,要求APK文件包含未压缩的resources.asrc文件,该文件与文件中的4字节对齐。
通过 ADB 复制问题,我使用了以下命令:
# 1) Install the original APK file
adb install original.apk
# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk
# 3) Apply the logic patch
patch -p1 < switch.patch
# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original
# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0
# 6) Attempt installation of the rebuilt APK file
adb install -r rebuilt.apk
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
adb: 无法安装 rebuilt.apk: 失败 [-124: installPackageLI 期间解析失败:以 R+(版本 30 及更高版本)为目标,要求已安装 APK 的 resources.arsc 未压缩存储并在 4 字节边界上对齐]
我的第一个想法是简单地使用zipalignafter usingjarsigner来签署 APK,如下所示:
# 1) Install the original APK file
adb install original.apk
# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk
# 3) Apply the logic patch
patch -p1 < switch.patch
# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original
# 5) Sign the rebuilt APK file
jarsigner -keystore keystore -storepass password rebuilt.apk key0
# 6) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk
# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
Run Code Online (Sandbox Code Playgroud)
但是,这导致了以下错误:
adb:无法安装 rebuilt-aligned.apk:失败 [INSTALL_PARSE_FAILED_NO_CERTIFICATES:扫描失败。:在 au.com.msbit.a68855123 版本 2 或更高版本的包中找不到签名]
这表明Android 11还有另一个要求;APK 文件使用 v2 签名方案进行签名,这需要apksigner. 将两者放在一起,类似于以下内容:
# 1) Install the original APK file
adb install original.apk
# 2) Decode the original APK file, decompiling into Smali
apktool decode --output original original.apk
# 3) Apply the logic patch
patch -p1 < switch.patch
# 4) Rebuild an APK file with the patch
apktool build --output rebuilt.apk original
# 5) Create an aligned APK file
zipalign 4 rebuilt.apk rebuilt-aligned.apk
# 6) Sign the rebuilt APK file
apksigner sign --ks keystore --ks-pass pass:password rebuilt-aligned.apk
# 7) Attempt installation of the rebuilt APK file
adb install -r rebuilt-aligned.apk
Run Code Online (Sandbox Code Playgroud)
正如 的 文档中所述apksigner,它必须在对 APK 文件进行任何修改之后运行,因此,与使用 时的顺序相反jarsigner,它必须在 之前zipalign运行。 apksigner
| 归档时间: |
|
| 查看次数: |
2892 次 |
| 最近记录: |