APK反编译分析的时候,不免须要对APK进行重打包来辅助反编译的分析。好比经过重打包给APK添加可调试功能或者添加可抓https包的功能,都须要应用到重打包的技术。android
// 清除framwork,避免framwork过时,拉取最新的framwork资源 apktool empty-framework-dir --force // 开始反编译 apktool d -f org.fedorahosted.freeotp.apk 复制代码
以反编译的包支持debug和支持charles https抓包为例git
(1)修改manifestgithub
<application // 支持debug android:debuggable="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" // 支持https抓包 android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:theme="@style/AppTheme"> 复制代码
(2)在res目录下新建xml文件夹,新建network_security_config.xmlbash
<?xml version="1.0" encoding="utf-8"?> <network-security-config> <debug-overrides cleartextTrafficPermitted="true"> <trust-anchors> <certificates src="system" /> <certificates src="user" /> </trust-anchors> </debug-overrides> </network-security-config> 复制代码
(1)apktool编译:编译修改后的代码生成新的apkmarkdown
apktool b org.fedorahosted.freeotp -o new.apk
复制代码
(3)zipalign对齐:将新生成的apk对齐app
zipalign -f -v -p 4 new.apk new_zip_align.apk 复制代码
(4)apksigner签名:只有签名后的apk才能够安装ide
apksigner sign --ks /Users/weishenhong/Desktop/wsh/code/android/android_learning/app/keystore --ks-key-alias key0 --ks-pass pass:112112 --out rebuild_signed.apk new_zip_align.apk
复制代码
(5)安装apkoop
adb install -r -t rebuild_signed.apk
复制代码
至此,你重打包的apk就成功安装了。post