apk反编译后重新打包

一、apk反编译

参考https://ibotpeaches.github.io/Apktool/

应用反编译执行命令:

$ apktool d test.apk
I: Using Apktool 2.2.2 on test.apk 
I: Loading resource table... 
I: Decoding AndroidManifest.xml with resources... 
I: Loading resource table from file: 1.apk 
I: Regular manifest package...
I: Decoding file-resources... 
I: Decoding values */* XMLs... 
I: Baksmaling classes.dex... 
I: Copying assets and libs... 
I: Copying unknown files... 
I: Copying original files...
加-o 参数可以指定反编译后的文件夹名称

二、apk重新打包

一般,重新打包之前,对apk反编译后的smali语言进行了修改。

应用重新打包命令:

$ apktool b test 
I: Using Apktool 2.2.2 on test 
I: Checking whether sources has changed... 
I: Smaling smali folder into classes.dex... 
I: Checking whether resources has changed... 
I: Building resources... 
I: Building apk file... 
I: Copying unknown files/dir...
添加-o参数,可以指定输出的apk名称

三、签名

预备条件:有个密钥库文件。

密钥库文件生成的方法:

keytool -genkey -alias test.keystore -keyalg RSA -validity 20000 -keystore  test.keystore
其中,-genkey表示生成密钥,-alias表示密钥别名,-keyalg表示密钥的算法,-validity表示有效期,-keystor表示生成文件的名字

之后会提示输入相应的信息,输入后按Y确认即可。

若最后提示keytool 错误: java.io.FileNotFoundException: android.keystore (拒绝访问。)
是因为-keystore  test.keystore指定的路径(即Java路径)是不能写的,需要指定到其他地方,如-keystore  d:\test.keystore,将文件保存在d盘。

使用test.keystore签名:

jarsigner -verbose -keystore test.keystore -signedjar testapk_signed.apk testapk.apk  test.keystore
其中,

-verbose表示显示出签名详细信息
-keystore表示使用当前目录中的test.keystore签名证书文件。
-signedjar testapk_signed.apk表示签名后生成的APK名称

testapk.apk表示未签名 的APK

test..keystore表示密钥的别名

应用重新打包签名安装后,可能不能正常使用,是因为代码中可能加入了验证证书的相关代码。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值