最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】用Procyon命令行去从jar包导出java源代码

Java crifan 1165浏览 0评论
在:
【已解决】用基于Procyon的Luyten反编译安卓jar包得到java源码
之后,折腾:
【未解决】小花生中如何得到getToken的计算逻辑以便得到正确的md5值可以正常请求接口
期间,想要导出jar包的全部代码,结果最后98%的时候,卡死了:
不过又等了半天,好像没有卡死:
有进展和变化了:
但是还是导致电脑太卡了。
-》所以:
去尝试换用命令行Procyon去导出代码试试
mstrobel / Procyon — Bitbucket
mstrobel / Procyon / Downloads — Bitbucket
去下载
procyon-decompiler-0.5.34.jar
-》
再去看看如何使用
procyon usage
Decompile .class File to .java File using Proycon – Stack Overflow
procyon(1) — procyon-decompiler — Debian stretch — Debian Manpages
参考:
mstrobel / Procyon / wiki / Java Decompiler — Bitbucket
Decompile a single class to the console.
$ java -jar decompiler.jar java.lang.String
$ java -DAnsi=true -jar decompiler.jar java.util.Collections
Decompile a whole jar to a directory.
$ java -jar decompiler.jar -jar myJar.jar -o out
去试试
➜  v3.4.8 java -jar  /Users/crifan/dev/dev_tool/android/reverse_engineering/Procyon/procyon-decompiler-0.5.34.jar -jar com.huili.readingclub8825612-dex2jar.jar -o com.huili.readingclub8825612
Decompiling android/support/annotation/AnimRes...
Decompiling android/support/annotation/AnimatorRes...
...
然后发现,也挺耗CPU的。。。
只能继续等待了。
不过速度很快,没一会,几分钟就搞定了
对比之下,Luyten要几十分钟,还没完成。
去看看生成的代码:
找到了我们希望的源码:
【总结】
此处用Procyon作为命令行工具去导出一个jar包文件为java源代码的过程是:
1.下载Procyon的jar包
procyon-decompiler-0.5.34.jar
2.用procyon的jar包从你的jar包转换出java代码
java -jar /path/to/procyon-decompiler-0.5.34.jar -jar your_to_decompile.jar -o outputFolderName
举例:
java -jar  /Users/crifan/dev/dev_tool/android/reverse_engineering/Procyon/procyon-decompiler-0.5.34.jar -jar com.huili.readingclub8825612-dex2jar.jar -o com.huili.readingclub8825612
即可。
后记:
【无法解决】用Procyon导出某个jar包中指定的包名的代码
不过期间输出了语法帮助:
procyon-decompiler -?
Usage: <main class> [options] <type names or class/jar files>
  Options:
    -b, --bytecode-ast
       Output Bytecode AST instead of Java.
       Default: false
    -ci, --collapse-imports
       Collapse multiple imports from the same package into a single wildcard
       import.
       Default: false
    -cp, --constant-pool
       Includes the constant pool when displaying raw bytecode (unnecessary with
       -v).
       Default: false
    -dl, --debug-line-numbers
       For debugging, show Java line numbers as inline comments (implies -ln;
       requires -o).
       Default: false
        --disable-foreach
       Disable 'for each' loop transforms.
       Default: false
    -eml, --eager-method-loading
       Enable eager loading of method bodies (may speed up decompilation of
       larger archives).
       Default: false
    -ent, --exclude-nested
       Exclude nested types when decompiling their enclosing types.
       Default: false
    -ei, --explicit-imports
       [DEPRECATED] Explicit imports are now enabled by default.  This option
       will be removed in a future release.
       Default: false
    -eta, --explicit-type-arguments
       Always print type arguments to generic methods.
       Default: false
    -fsb, --flatten-switch-blocks
       Drop the braces statements around switch sections when possible.
       Default: false
    -fq, --force-qualified-references
       Force fully qualified type and member references in Java output.
       Default: false
    -?, --help
       Display this usage information and exit.
       Default: false
    -jar, --jar-file
       [DEPRECATED] Decompile all classes in the specified jar file (disables
       -ent and -s).
    -lc, --light
       Use a color scheme designed for consoles with light background colors.
       Default: false
    -lv, --local-variables
       Includes the local variable tables when displaying raw bytecode
       (unnecessary with -v).
       Default: false
    -ll, --log-level
       Set the level of log verbosity (0-3).  Level 0 disables logging.
       Default: 0
    -mv, --merge-variables
       Attempt to merge as many variables as possible.  This may lead to fewer
       declarations, but at the expense of inlining and useful naming.  This feature is
       experimental and may be removed or become the standard behavior in future releases.
       Default: false
    -o, --output-directory
       Write decompiled results to specified directory instead of the console.
    -r, --raw-bytecode
       Output Raw Bytecode instead of Java (to control the level of detail, see:
       -cp, -lv, -ta, -v).
       Default: false
    -ec, --retain-explicit-casts
       Do not remove redundant explicit casts.
       Default: false
    -ps, --retain-pointless-switches
       Do not lift the contents of switches having only a default label.
       Default: false
    -ss, --show-synthetic
       Show synthetic (compiler-generated) members.
       Default: false
    -sm, --simplify-member-references
       Simplify type-qualified member references in Java output [EXPERIMENTAL].
       Default: false
    -sl, --stretch-lines
       Stretch Java lines to match original line numbers (only in combination
       with -o) [EXPERIMENTAL].
       Default: false
    -ta, --type-attributes
       Includes type attributes when displaying raw bytecode (unnecessary with
       -v).
       Default: false
        --unicode
       Enable Unicode output (printable non-ASCII characters will not be
       escaped).
       Default: false
    -u, --unoptimized
       Show unoptimized code (only in combination with -b).
       Default: false
    -v, --verbose
       Includes more detailed output depending on the output language (currently
       only supported for raw bytecode).
       Default: false
        --version
       Display the decompiler version and exit.
       Default: false
    -ln, --with-line-numbers
       Include line numbers in raw bytecode mode; supports Java mode with -o
       only.
       Default: false
以及:
从这些支持的参数中,可以推断:
基于Procyon的Luyten中的菜单中的选项
都是对应着这些参数的
去看了看,果然是的,比如:
对应着此处参数:
    -fsb, --flatten-switch-blocks
       Drop the braces statements around switch sections when possible.
       Default: false
其他以此类推,都是一样的逻辑:把命令行工具的参数,用菜单选项的形式展示和支持出来了。

转载请注明:在路上 » 【已解决】用Procyon命令行去从jar包导出java源代码

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.162 seconds, using 22.17MB memory