如何对整个JAR文件进行反复编译?

发布于 2025-02-13 21:04:47 字数 1835 浏览 0 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

温柔一刀 2025-02-20 21:04:47

2023: splashout 建议在 vineflower/vineflower demompiler(),从Quiltflower重命名为Vineflower。

java -jar vineflower.jar -dgs=1 c:\Temp\binary\library.jar c:\Temp\souce

2022更新: quiltmc/quiltmc/quiltflower 是最新的

href =“ https://www.reddit.com/r/java/comments/ue8u59/new_open_source_java_java_decompiler/” rel =“ noreferrer”>“ noreferrer”>最先进的Java demompiler 代码质量,速度和可用性。
QuiltFlower是 fernflower 和forgeflower和forgeflower。

更改包括:

  • 新的语言功能(尝试使用资源,开关表达式,模式匹配等)
  • 更好的控制流量产生(循环,try-catch和switch等)
  • 更多可配置性
  • 更好的错误消息
  • Javadoc应用程序
  • 多线程
  • 优化
  • 许多其他其他特征和修复

最初旨在与Minecraft的QuiltMC工具链一起使用,Quiltflower迅速扩展为通用Java分解器,旨在创建尽可能准确和清洁的代码。

如果这个名字听起来很熟悉,那是因为Quiltflower是 fernflower ,由Stiver开发的(由Jetbrains维护)的(In)著名的译者,成为Intellij Idea中的默认分解器。
Fernflower也很快找到了许多其他工具。

在过去的一年中,Quiltflower增加了对现代字符串串联,代码格式,密封类,图案匹配,开关表达式,try-with-with-with-with-resources等功能的支持。 Quiltflower还专注于分解输出的代码质量,并非常重视可读性。

参见“ noreferrer”>输出示例

jbang

  https://github.com/quiltmc/quiltflower/releases/download/1.8.1/quiltflower-1.8.1.jar
 

  java -jar quiltflower.jar -dgs = 1 c:\ temp \ biary \ library \ library.jar c:\ temp \ biniary \ biond \ boot.class c:\ temp \ source \ source \ source \ source \ source \
 

2009: javadecompiler 可以用jar做出一个很好的工作文件显示。

” href =“ https://stackoverflow.com/questions/272535/272535/how-do-i-i-decompile-java-complile-java-class-files/272595#272595”>问题“我如何“分解” Java类文件? a>。

自2009年底以来,JD-Eclipse似乎没有改变(请参阅更改)。
因此,它与最新的日食(3.8,4.2+)的集成可能是有问题的。

JD核心被积极维护。

两者都是(SO) emmanuel dupuy 的出色工作的结果。


2018年:更现代的选择,提到 David Kennedy Araujo

jetbrains/intellij-community/插件/java-decompiler/Engine

fernflower是Java的第一个实际工作分析分解器,通常用于高级编程语言。

  java -jar fernflower.jar [ - < option> =< value>]* [< source>]+<

java -jar fernflower.jar -hes = 0 -hdc = 0 c:\ temp \ binary \ -e = c:\ java \ rt.jar c:\ temp \ source \ source \ source \ source \ source \
 

另请参阅命令使用最近的Intellij Idea。


2022更新: florian wendelborn 建议在评论

这个效果很好: jdec.app 来自 leonardo santos

2023: splashout suggests in the comments the Vineflower/vineflower decompiler (releases), renaming from Quiltflower to Vineflower.

java -jar vineflower.jar -dgs=1 c:\Temp\binary\library.jar c:\Temp\souce

2022 update: QuiltMC/quiltflower is the latest most advanced Java decompiler:

Quiltflower is a modern, general purpose decompiler focused on improving code quality, speed, and usability.
Quiltflower is a fork of Fernflower and Forgeflower.

Changes include:

  • New language features (Try with resources, switch expressions, pattern matching, and more)
  • Better control flow generation (loops, try-catch, and switch, etc.)
  • More configurability
  • Better error messages
  • Javadoc application
  • Multithreading
  • Optimization
  • Many other miscellaneous features and fixes

Originally intended just for use with the QuiltMC toolchain with Minecraft, Quiltflower quickly expanded to be a general purpose java decompiler aiming to create code that is as accurate and clean as possible.

If the name sounds familiar it's because Quiltflower is a fork of Fernflower, the (in)famous decompiler that was developed by Stiver, maintained by Jetbrains, and became the default decompiler in Intellij IDEA.
Fernflower also quickly found its way into many other tools.

Over the past year, Quiltflower has added support for features such as modern string concatenation, a code formatter, sealed classes, pattern matching, switch expressions, try-with-resources, and more. Quiltflower also focuses on the code quality of the decompiled output, and takes readability very seriously.

See output examples.

Runs nice with jbang

https://github.com/QuiltMC/quiltflower/releases/download/1.8.1/quiltflower-1.8.1.jar

Or:

java -jar quiltflower.jar -dgs=1 c:\Temp\binary\library.jar c:\Temp\binary\Boot.class c:\Temp\source\

2009: JavaDecompiler can do a good job with a jar: since 0.2.5, All files, in JAR files, are displayed.

http://java.decompiler.free.fr/sites/default/screenshots/screenshot1.png

See also the question "How do I “decompile” Java class files?".

The JD-Eclipse doesn't seem to have changed since late 2009 though (see Changes).
So its integration with latest Eclipse (3.8, 4.2+) might be problematic.

JD-Core is actively maintained.

Both are the result of the fantastic work of (SO user) Emmanuel Dupuy.


2018: A more modern option, mentioned in the comments by David Kennedy Araujo:

JetBrains/intellij-community/plugins/java-decompiler/engine

Fernflower is the first actually working analytical decompiler for Java and probably for a high-level programming language in general.

java -jar fernflower.jar [-<option>=<value>]* [<source>]+ <destination>

java -jar fernflower.jar -hes=0 -hdc=0 c:\Temp\binary\ -e=c:\Java\rt.jar c:\Temp\source\

See also How to decompile to java files intellij idea for a command working with recent IntelliJ IDEA.


2022 update: Florian Wendelborn suggests in the comments

this one works well: jdec.app from Leonardo Santos.

爱的那么颓废 2025-02-20 21:04:47

首先,值得记住的是,所有Java存档文件( .jar / .war /etct ...)都是基本上只是幻想。 zip 文件,带有一些添加的清单和元数据。

其次,要解决这个问题,我个人使用了几种在所有级别上处理此问题的工具:

  • jad < /a> + jadclipse 在IDE工作时进行分解 .class 文件
  • winrar ,我最喜欢的压缩工具本身支持Java档案 段落)。
  • 超越比较 ,当正确配置时,我最喜欢的diff工具可以在the-the-the-上进行在任何存档文件之间进行比较,包括 jar s。值得一试。

所有上述所有的优点是,我不需要拥有任何其他外部工具来影响我的工作环境。这些文件之一可以从我的IDE内部处理我所需要的一切,也可以与其他文件一起散布。

First of all, it's worth remembering that all Java archive files (.jar/.war/etc...) are all basically just fancy.zip files, with a few added manifests and metadata.

Second, to tackle this problem I personally use several tools which handle this problem on all levels:

  • Jad + Jadclipse while working in IDE for decompiling .class files
  • WinRAR, my favorite compression tool natively supports Java archives (again, see first paragraph).
  • Beyond Compare, my favorite diff tool, when configured correctly can do on-the-fly comparisons between any archive file, including jars. Well worth a try.

The advantage of all the aforementioned, is that I do not need to hold any other external tool which clutters my work environment. Everything I will ever need from one of those files can be handled inside my IDE or diffed with other files natively.

丢了幸福的猪 2025-02-20 21:04:47

如果您碰巧有一个bash壳和Jad:

JAR=(your jar file name)
unzip -d $JAR.tmp $JAR
pushd $JAR.tmp
for f in `find . -name '*.class'`; do
    jad -d $(dirname $f) -s java -lnc $f
done
popd

我可能对此很小,但它应该或多或少地按照广告宣传起作用。您应该最终得到 $ jar.tmp 包含分解文件的文件。

If you happen to have both a bash shell and jad:

JAR=(your jar file name)
unzip -d $JAR.tmp $JAR
pushd $JAR.tmp
for f in `find . -name '*.class'`; do
    jad -d $(dirname $f) -s java -lnc $f
done
popd

I might be a tiny, tiny bit off with that, but it should work more or less as advertised. You should end up with $JAR.tmp containing your decompiled files.

寂寞清仓 2025-02-20 21:04:47

我的工具(沮丧地)“ jd:java demompiler ”。

我发现在处理Java 5及更高> 的类时,我发现它比大多数反编译器更好。不幸的是,它仍然可以在贾德(Jad)通常会成功的一些打ic上。

I have had reasonable success with a tool named (frustratingly) "JD: Java Decompiler".

I have found it better than most decompilers when dealing with classes compiled for Java 5 and higher. Unfortunately, it can still have some hiccups where JAD would normally succeed.

没有心的人 2025-02-20 21:04:47

类似:

jar -xf foo.jar && find . -iname "*.class" | xargs /opt/local/bin/jad -r

也许?

Something like:

jar -xf foo.jar && find . -iname "*.class" | xargs /opt/local/bin/jad -r

maybe?

我偏爱纯白色 2025-02-20 21:04:47

将以下内容插入empompile.jar.sh

# Usage: decompile.jar.sh some.jar [-d]

# clean target folders
function clean_target {
  rm -rf $unjar $src $jad_log
}

# clean all debug stuff
function clean_stuff {
  rm -rf $unjar $jad_log
}

# the main function
function work {
  jar=$1
  unjar=`basename $jar.unjar`
  src=`basename $jar.src`
  jad_log=jad.log

  clean_target

  unzip -q $jar -d $unjar
  jad -d $src -ff -r -lnc -o -s java $unjar/**/*.class > $jad_log 2>&1

  if [ ! $debug ]; then
    clean_stuff
  fi

  if [ -d $src ] 
    then
      echo "$jar has been decompiled to $src"
    else
      echo "Got some problems check output or run in debug mode"
  fi
}

function usage {
  echo "This script extract and decompile JAR file"
  echo "Usage: $0 some.jar [-d]"
  echo "    where: some.jar is the target to decompile"
  echo "    use -d for debug mode"
}

# check params
if [ -n "$1" ]
  then
    if [ "$2" == "-d" ]; then
      debug=true
      set -x
    fi
    work $1
  else
    usage
fi
  • chmod +x decompon.sh.sh //可执行
  • ln -s ./decompolie.jar.s/usr/usr/bin/dj

准备使用,只需键入 dj your.jar your.jar << dj your.jar << /code>,您将获得带有来源的文件夹您的.jar.src 。使用 -d 调试模式的选项。

Insert the following into decompile.jar.sh

# Usage: decompile.jar.sh some.jar [-d]

# clean target folders
function clean_target {
  rm -rf $unjar $src $jad_log
}

# clean all debug stuff
function clean_stuff {
  rm -rf $unjar $jad_log
}

# the main function
function work {
  jar=$1
  unjar=`basename $jar.unjar`
  src=`basename $jar.src`
  jad_log=jad.log

  clean_target

  unzip -q $jar -d $unjar
  jad -d $src -ff -r -lnc -o -s java $unjar/**/*.class > $jad_log 2>&1

  if [ ! $debug ]; then
    clean_stuff
  fi

  if [ -d $src ] 
    then
      echo "$jar has been decompiled to $src"
    else
      echo "Got some problems check output or run in debug mode"
  fi
}

function usage {
  echo "This script extract and decompile JAR file"
  echo "Usage: $0 some.jar [-d]"
  echo "    where: some.jar is the target to decompile"
  echo "    use -d for debug mode"
}

# check params
if [ -n "$1" ]
  then
    if [ "$2" == "-d" ]; then
      debug=true
      set -x
    fi
    work $1
  else
    usage
fi
  • chmod +x decomplie.jar.sh //executable
  • ln -s ./decomplie.jar.s /usr/bin/dj

Ready to use, just type dj your.jar and you will get your.jar.src folder with sources. Use -d option for debug mode.

黑色毁心梦 2025-02-20 21:04:47

您提取它,然后将Jad用在DIR上。

You extract it and then use jad against the dir.

原谅我要高飞 2025-02-20 21:04:47

注意:此解决方案仅适用于Mac和 *Nix用户。

我还试图找到没有运气的Jad。我的快速解决方案是下载 macjad 包含JAD。下载后,您可以在[where-downloaded-macjad]/macjad/cottents/cormest/resources/jad中找到JAD。

Note: This solution only works for Mac and *nix users.

I also tried to find Jad with no luck. My quick solution was to download MacJad that contains jad. Once you downloaded it you can find jad in [where-you-downloaded-macjad]/MacJAD/Contents/Resources/jad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文