Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何自己针对特定版本贴吧客户端apk制作javaproto目录下的文件 #3

Open
n0099 opened this issue Jan 28, 2023 · 2 comments

Comments

@n0099
Copy link
Owner

n0099 commented Jan 28, 2023

  1. 下载某个历史版本贴吧客户端 apk(豌豆荚 apkpure 欢迎补充)并置于path/to/apk

  2. 下载最新版本dex-tools然后解压并cd进解压路径

  3. 修改文件d2j_invoke.bat(win)/d2j-dex2jar.sh(*nix)中的-Xms512m -Xmx2048m-Xmx3g -Xmx4g(如果您有至少 4G 空闲内存,也可以使用2g, 3g但会更频繁触发 GC 导致使用更多 cpu)

    • *nix:
      sed -i -e 's/-Xms512m -Xmx2048m/-Xms3g -Xmx4g/' d2j{-dex2jar.sh,_invoke.bat}

    以避免途中发生java.lang.OutOfMemoryError: Java heap space OutOfMemoryError ThexXTURBOXx/dex2jar#13
    image
    至少需要设置 2G 左右的-Xmx,cpu 使用稳定单核,就像是在开大型 mcmod 整合包服务端
    还建议通过更改文件中使用的java路径以切换至graalvm

  4. 执行并等待数十分钟

    • win:
      .\d2j-dex2jar.bat "path\to\apk" -o "path\to\jar"
    • *nix:
      ./d2j-dex2jar.sh "path/to/apk" -o "path/to/jar"

    其中path/to/jar为您期望的输出 jar 文件路径

  5. 下载jd-cli https://search.maven.org/artifact/com.github.kwart.jd/jd-cli Missing binary release? intoolswetrust/jd-cli#62 (comment)

  6. 执行

    java -jar jd-cli-1.2.1.jar -p tbclient -ods classes "path/to/jar"

    路径classes/jar文件名/tbclient下便是 repo 的java目录下的所有.class文件

  7. 使用本 repo 提供的squareWireProtoBufJavaGeneratedClassesDecompiler.php将这些.class java 源码转换为.proto文件

    php squareWireProtoBufJavaGeneratedClassesDecompiler.php --in="classes/jar文件名/tbclient" --out=proto
@n0099
Copy link
Owner Author

n0099 commented Feb 3, 2023

ls -1 | shuf | sed 's/\.apk$//' | parallel -j 63 --eta --progress '../jadx/bin/jadx -ds {}/src -dr {}/res -j 1 --show-bad-code --fs-case-sensitive --comments-level debug --log-level error {}.apk 2>&1 > {}.log'

image
瓶颈是石头盘
建议直接/dev/shm内存盘
image

@n0099
Copy link
Owner Author

n0099 commented Feb 3, 2023

根据starry神 @Starry-OvO 此前于 HuanCheng65/TiebaLite#150 (comment) 的最高指示精神
建议使用jadx而不是缝合dex2jar+jd-cli来进行反编译流程:

  1. jadx一个程序内就能完成dex(dalvik executable)jar(jvm bytecode,dex和jar同为给运行时eval的二进制格式)(也就是dex2jar),然后jar反编译回java代码(也就是jd)的流程
  2. jadx目前还有多人维护,这也使得他能更正确地还原kotlin等较新的jvm语言所编译的bytecode
  3. jadxdex2jar快得多并有一定的并行度,我只需要8分钟就能跑完一个庞大的12.x版本apk,反观dex2jarUsing param --optmize-synchronized and --reuse-reg of dex2jar will consume more cpu/memory usage and time ThexXTURBOXx/dex2jar#30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant