apk修改及签名

apk安装测试环境:Android 8.1.0(aosp)

一、apk反编译

工具:apktool V2.6.0

下载地址:https://ibotpeaches.github.io/Apktool/install/ (含环境配置说明)

Install Instructions

Quick Check

  1. Is at least Java 1.8 installed?
  2. Does executing java -version on command line / command prompt return 1.8 or greater?
  3. If not, please install Java 8+ and make it the default. (Java 7 will also work at this time)

Installation for Apktool

  • Windows:
    1. Download Windows wrapper script (Right click, Save Link As apktool.bat)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool.bat) to your Windows directory (Usually C://Windows)
    5. If you do not have access to C://Windows, you may place the two files anywhere then add that directory to your Environment Variables System PATH variable.
    6. Try running apktool via command prompt
  • Linux:
    1. Download Linux wrapper script (Right click, Save Link As apktool)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
    5. Make sure both files are executable (chmod +x)
    6. Try running apktool via cli
  • macOS:
    1. Download Mac wrapper script (Right click, Save Link As apktool)
    2. Download apktool-2 (find newest here)
    3. Rename downloaded jar to apktool.jar
    4. Move both files (apktool.jar & apktool) to /usr/local/bin (root needed)
    5. Make sure both files are executable (chmod +x)
    6. Try running apktool via cli

    Or you can install apktool via Homebrew:

    1. Install Homebrew as described in this page
    2. Execute command brew install apktool in terminal (no root needed). The latest version will be installed in /usr/local/Cellar/apktool/[version]/ and linked to /usr/local/bin/apktool.
    3. Try running apktool via cli

Note - Wrapper scripts are not needed, but helpful so you don’t have to type java -jar apktool.jar over and over.

文档说明:https://ibotpeaches.github.io/Apktool/documentation/ (使用说明文档)

反编译(Decode)试例:

$ apktool d foo.jar
// decodes foo.jar to foo.jar.out folder

$ apktool decode foo.jar
// decodes foo.jar to foo.jar.out folder

$ apktool d bar.apk
// decodes bar.apk to bar folder

$ apktool decode bar.apk
// decodes bar.apk to bar folder

$ apktool d bar.apk -o baz
// decodes bar.apk to baz folder

二、检索需要修改的内容

工具:jadx-gui-1.1.0-no-jre

下载地址:https://pan.baidu.com/s/158rrUszReXzRpeYa-rkWJQ?pwd=ixqg 提取码: ixqg

打开apk文件,点搜索图标,支持类名、方法名、变量名、代码等内容搜索。确定内容所在位置,到反编译好的目录下找到对应文件,并通过notepad工具打开、修改、保存

其他工具:http://java-decompiler.github.io/

三、重建apk(build)

工具:apktool V2.6.0

Build试例:

$ apktool b foo.jar.out
// builds foo.jar.out folder into foo.jar.out/dist/foo.jar file

$ apktool build foo.jar.out
// builds foo.jar.out folder into foo.jar.out/dist/foo.jar file

$ apktool b bar
// builds bar folder into bar/dist/bar.apk file

$ apktool b .
// builds current directory into ./dist

$ apktool b bar -o new_bar.apk
// builds bar folder into new_bar.apk

$ apktool b bar.apk
// WRONG: brut.androlib.AndrolibException: brut.directory.PathNotExist: apktool.yml
// Must use folder, not apk/jar file

四、APK签名

后面百度云盘更新的signapk文件夹内的压缩包,下载即用,完美Sign~~~

 

第一版未实现的错误方向---jdk版本不对,更改成jdk-8u91,下面方法即可正常签名。

{签名所需文件:

signapk.jar:可自行搜索并编译signapk.java以获得(对于本小白来说有点难没深究)。本人下载该文件地址:安卓工具箱 http://www.top139.com/AndroidTools.html

platform.pk8、platform.x509.pem:使用浏览器打开 https://github.com/aosp-mirror/platform_build/blob/master/target/product/security/platform.x509.pem,在文件内容右上角 找到类似显示器图标(alt=Open this file in Github desktop),按提示安装 GitHub Desktop应用并注册登录,完成后打开360极速浏览器重新开始操作,按提示使用gitHub Desktop打开,即可clone该项目所有文件到你的计算机上。everything一下。

使用说明:(大部分教程都告诉了怎么用命令,但是没说明环境。再说一遍:jdk-8u91)

把上面3个文件以及Built好的文件放到同一个文件夹下,运行命令行:

java -jar signapk.jar platform.pk8 platform.x509.pem old.apk signok.apk}

 2021.12.29更新第三版

再次验证原有方法在改变jdk-8u91后也能成功签名,更新说明。

2021.12.28更新第二版

看到大神提醒,更改jdk-8u91,未测试原有方法,仅发现能通过gui工具签名,自以为是工具问题;

2021.12.28第一版

附涉及文件地址链接:https://pan.baidu.com/s/1G-mu7Xa5hX6LgcMfqXG8pQ?pwd=etqy 提取码: etqy

每天都在摸着石头过河,寻互关伴读~

 
posted @ 2021-12-28 11:40  FormID  阅读(818)  评论(0)    收藏  举报