diff --git a/libs/jd-gui-1.6.6-no-asm.jar b/libs/jd-gui-1.6.6-no-asm-rsta.jar similarity index 61% rename from libs/jd-gui-1.6.6-no-asm.jar rename to libs/jd-gui-1.6.6-no-asm-rsta.jar index 405115f3..36d238ba 100644 Binary files a/libs/jd-gui-1.6.6-no-asm.jar and b/libs/jd-gui-1.6.6-no-asm-rsta.jar differ diff --git a/pom.xml b/pom.xml index 050bc7de..aa63d4c7 100644 --- a/pom.xml +++ b/pom.xml @@ -23,14 +23,14 @@ org.jetbrains annotations - 20.1.0 + 21.0.1 org.apktool apktool 2.3.0 - system - ${project.basedir}/libs/apktool_2.3.0.jar + system + ${project.basedir}/libs/apktool_2.3.0.jar org.ow2.asm @@ -90,7 +90,7 @@ commons-io commons-io - 2.8.0 + 2.10.0 org.apache.commons @@ -105,7 +105,7 @@ org.jboss.windup.decompiler decompiler-fernflower - 5.1.3.Final + 5.1.4.Final com.google.guava @@ -115,7 +115,7 @@ com.google.code.gson gson - 2.8.6 + 2.8.7 org.imgscalr @@ -131,15 +131,15 @@ com.jd jd-gui 1.6.6 - system - ${project.basedir}/libs/jd-gui-1.6.6-no-asm.jar + system + ${project.basedir}/libs/jd-gui-1.6.6-no-asm-rsta.jar eu.bibl.banalysis byteanalysis 1.0 - system - ${project.basedir}/libs/byteanalysis-1.0.jar + system + ${project.basedir}/libs/byteanalysis-1.0.jar org.tinyjee.jgraphx @@ -174,7 +174,7 @@ com.fifesoft rsyntaxtextarea - 3.1.2 + 3.1.3 org.slf4j @@ -228,6 +228,26 @@ + + org.apache.maven.plugins + maven-dependency-plugin + 3.2.0 + + + unpack + + process-resources + + unpack-dependencies + + + system + ${basedir}/target/classes + + + + org.apache.maven.plugins maven-jar-plugin diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java index 38a6df80..c08523fb 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/KrakatauDecompiler.java @@ -6,6 +6,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; +import java.util.Arrays; +import java.util.stream.Collectors; import me.konloch.kontainer.io.DiskReader; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; @@ -45,8 +47,19 @@ public class KrakatauDecompiler extends Decompiler { public String quick() { if (Configuration.library.isEmpty()) return ""; - else + + File dir = new File(Configuration.library); + if (!dir.exists()) + return ""; + if (!dir.isDirectory()) return ";" + Configuration.library; + + File[] files = dir.listFiles(); + if (files == null || files.length == 0) + return ""; + + return ";" + Arrays.stream(files).filter(File::isFile) + .map(File::getAbsolutePath).collect(Collectors.joining(";")); } public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) { @@ -159,9 +172,9 @@ public class KrakatauDecompiler extends Decompiler { final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempDirectory.mkdir(); final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); - + JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - + BytecodeViewer.sm.stopBlocking(); try { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java index cc94aafe..b8226e74 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/FileViewer.java @@ -1,6 +1,5 @@ package the.bytecode.club.bytecodeviewer.gui; -import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor; import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.KeyEvent; @@ -22,12 +21,13 @@ import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; import javax.swing.text.JTextComponent; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; -import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rtextarea.RTextScrollPane; import org.imgscalr.Scalr; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Resources; +import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor; import the.bytecode.club.bytecodeviewer.util.FileContainer; +import the.bytecode.club.bytecodeviewer.util.Language; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -127,71 +127,8 @@ public class FileViewer extends Viewer { } } - if (name.endsWith(".xml") || contentsS.startsWith(" n.endsWith(".xml") + || c.startsWith(" n.endsWith(".py") || n.endsWith(".python")), + RUBY(SyntaxConstants.SYNTAX_STYLE_RUBY, (n, c) -> n.endsWith(".rb") || n.endsWith(".ruby")), + JAVA(SyntaxConstants.SYNTAX_STYLE_JAVA, (n, c) -> n.endsWith(".java")), + HTML(SyntaxConstants.SYNTAX_STYLE_HTML, (n, c) -> n.endsWith(".html")), + CSS(SyntaxConstants.SYNTAX_STYLE_CSS, (n, c) -> n.endsWith(".css")), + PROPERTIES(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE, (n, c) -> n.endsWith(".properties") + || n.endsWith(".mf") || n.endsWith(".sf")), + PHP(SyntaxConstants.SYNTAX_STYLE_PHP, (n, c) -> n.endsWith(".php") || c.startsWith(" n.endsWith(".js")), + BATCH(SyntaxConstants.SYNTAX_STYLE_WINDOWS_BATCH, (n, c) -> n.endsWith(".bat")), + SHELL(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL, (n, c) -> n.endsWith(".sh")), + C(SyntaxConstants.SYNTAX_STYLE_C, (n, c) -> n.endsWith(".c") || n.endsWith(".h")), + CPP(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS, (n, c) -> n.endsWith(".cpp") || n.endsWith(".hpp")), + SCALA(SyntaxConstants.SYNTAX_STYLE_SCALA, (n, c) -> n.endsWith(".scala")), + CLOJURE(SyntaxConstants.SYNTAX_STYLE_CLOJURE, (n, c) -> n.endsWith(".clojure")), + GROOVY(SyntaxConstants.SYNTAX_STYLE_GROOVY, (n, c) -> n.endsWith(".groovy") || n.endsWith(".gradle")), + LUA(SyntaxConstants.SYNTAX_STYLE_LUA, (n, c) -> n.endsWith(".lua")), + SQL(SyntaxConstants.SYNTAX_STYLE_SQL, (n, c) -> n.endsWith(".sql")), + JSON(SyntaxConstants.SYNTAX_STYLE_JSON, (n, c) -> n.endsWith(".json")), + JSP(SyntaxConstants.SYNTAX_STYLE_JSP, (n, c) -> n.endsWith(".jsp")), + YAML(SyntaxConstants.SYNTAX_STYLE_YAML, (n, c) -> n.endsWith(".yml") || n.endsWith(".yaml")), + CS(SyntaxConstants.SYNTAX_STYLE_CSHARP, (n, c) -> n.endsWith(".cs")), + CSV(SyntaxConstants.SYNTAX_STYLE_CSV, (n, c) -> n.endsWith(".csv")), + DOCKER(SyntaxConstants.SYNTAX_STYLE_DOCKERFILE, (n, c) -> n.endsWith(".dockerfile")), + DART(SyntaxConstants.SYNTAX_STYLE_DART, (n, c) -> n.endsWith(".dart")), + GO(SyntaxConstants.SYNTAX_STYLE_GO, (n, c) -> n.endsWith(".go")), + HTACCESS(SyntaxConstants.SYNTAX_STYLE_HTACCESS, (n, c) -> n.endsWith(".htaccess")), + INI(SyntaxConstants.SYNTAX_STYLE_INI, (n, c) -> n.endsWith(".ini")), + KOTLIN(SyntaxConstants.SYNTAX_STYLE_KOTLIN, (n, c) -> n.endsWith(".kt") || n.endsWith(".kts")), + LATEX(SyntaxConstants.SYNTAX_STYLE_LATEX, (n, c) -> n.endsWith(".tex")), + MARKDOWN(SyntaxConstants.SYNTAX_STYLE_MARKDOWN, (n, c) -> n.endsWith(".md")), + PERL(SyntaxConstants.SYNTAX_STYLE_PERL, (n, c) -> n.endsWith(".pl")), + TYPESCRIPT(SyntaxConstants.SYNTAX_STYLE_TYPESCRIPT, (n, c) -> n.endsWith(".ts")), + NONE(SyntaxConstants.SYNTAX_STYLE_NONE, (n, c) -> false); + + public static final Language[] VALUES = values(); + + private final BiFunction criteria; + + private final String syntaxConstant; + + Language(String syntaxConstant, BiFunction criteria) { + this.criteria = criteria; + this.syntaxConstant = syntaxConstant; + } + + public boolean isLanguage(String fileName, String content) { + return criteria.apply(fileName, content); + } + + public String getSyntaxConstant() { + return syntaxConstant; + } + + public static Language detectLanguage(String fileName, String content) { + for (Language lang : VALUES) { + if (lang.isLanguage(fileName, content)) { + return lang; + } + } + return NONE; + } + +}