This commit is contained in:
Konloch 2021-06-22 07:25:34 -07:00
commit d28e9c1407
6 changed files with 136 additions and 81 deletions

32
pom.xml
View file

@ -23,7 +23,7 @@
<dependency> <dependency>
<groupId>org.jetbrains</groupId> <groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId> <artifactId>annotations</artifactId>
<version>20.1.0</version> <version>21.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apktool</groupId> <groupId>org.apktool</groupId>
@ -90,7 +90,7 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.8.0</version> <version>2.10.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
@ -105,7 +105,7 @@
<dependency> <dependency>
<groupId>org.jboss.windup.decompiler</groupId> <groupId>org.jboss.windup.decompiler</groupId>
<artifactId>decompiler-fernflower</artifactId> <artifactId>decompiler-fernflower</artifactId>
<version>5.1.3.Final</version> <version>5.1.4.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
@ -115,7 +115,7 @@
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.6</version> <version>2.8.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.imgscalr</groupId> <groupId>org.imgscalr</groupId>
@ -132,7 +132,7 @@
<artifactId>jd-gui</artifactId> <artifactId>jd-gui</artifactId>
<version>1.6.6</version> <version>1.6.6</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/libs/jd-gui-1.6.6-no-asm.jar</systemPath> <systemPath>${project.basedir}/libs/jd-gui-1.6.6-no-asm-rsta.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>eu.bibl.banalysis</groupId> <groupId>eu.bibl.banalysis</groupId>
@ -174,7 +174,7 @@
<dependency> <dependency>
<groupId>com.fifesoft</groupId> <groupId>com.fifesoft</groupId>
<artifactId>rsyntaxtextarea</artifactId> <artifactId>rsyntaxtextarea</artifactId>
<version>3.1.2</version> <version>3.1.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@ -228,6 +228,26 @@
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>unpack</id>
<!-- In process resource phase such that it doesn't
override other dependencies or BCV's own files -->
<phase>process-resources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeScope>system</includeScope>
<outputDirectory>${basedir}/target/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>

View file

@ -6,6 +6,8 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.Arrays;
import java.util.stream.Collectors;
import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskReader;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
@ -45,8 +47,19 @@ public class KrakatauDecompiler extends Decompiler {
public String quick() { public String quick() {
if (Configuration.library.isEmpty()) if (Configuration.library.isEmpty())
return ""; return "";
else
File dir = new File(Configuration.library);
if (!dir.exists())
return "";
if (!dir.isDirectory())
return ";" + Configuration.library; 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) { public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) {

View file

@ -1,6 +1,5 @@
package the.bytecode.club.bytecodeviewer.gui; package the.bytecode.club.bytecodeviewer.gui;
import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -22,12 +21,13 @@ import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter; import javax.swing.text.Highlighter;
import javax.swing.text.JTextComponent; import javax.swing.text.JTextComponent;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.RTextScrollPane;
import org.imgscalr.Scalr; import org.imgscalr.Scalr;
import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources; 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.FileContainer;
import the.bytecode.club.bytecodeviewer.util.Language;
/*************************************************************************** /***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
@ -127,71 +127,8 @@ public class FileViewer extends Viewer {
} }
} }
if (name.endsWith(".xml") || contentsS.startsWith("<?xml") || contentsS.startsWith(("<xml"))) { panelArea.setSyntaxEditingStyle(Language.detectLanguage(name, contentsS).getSyntaxConstant());
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
panelArea.setText(contentsS); panelArea.setText(contentsS);
} else if (name.endsWith(".py") || name.endsWith(".python")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
panelArea.setText(contentsS);
} else if (name.endsWith(".rb") || name.endsWith(".ruby")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_RUBY);
panelArea.setText(contentsS);
} else if (name.endsWith(".java")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setText(contentsS);
} else if (name.endsWith(".html")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
panelArea.setText(contentsS);
} else if (name.endsWith(".css")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CSS);
panelArea.setText(contentsS);
} else if (name.endsWith(".properties") || name.endsWith(".mf") || name.endsWith(".sf")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);
panelArea.setText(contentsS);
} else if (name.endsWith(".php") || contentsS.startsWith("<?php")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PHP);
panelArea.setText(contentsS);
} else if (name.endsWith(".js")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
panelArea.setText(contentsS);
} else if (name.endsWith(".bat")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_WINDOWS_BATCH);
panelArea.setText(contentsS);
} else if (name.endsWith(".sh")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL);
panelArea.setText(contentsS);
} else if (name.endsWith(".c")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_C);
panelArea.setText(contentsS);
} else if (name.endsWith(".cpp")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
panelArea.setText(contentsS);
} else if (name.endsWith(".scala")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SCALA);
panelArea.setText(contentsS);
} else if (name.endsWith(".clojure")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CLOJURE);
panelArea.setText(contentsS);
} else if (name.endsWith(".groovy")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
panelArea.setText(contentsS);
} else if (name.endsWith(".lua")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_LUA);
panelArea.setText(contentsS);
} else if (name.endsWith(".sql")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
panelArea.setText(contentsS);
} else if (name.endsWith(".json")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
panelArea.setText(contentsS);
} else if (name.endsWith(".jsp")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSP);
panelArea.setText(contentsS);
} else {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
panelArea.setText(contentsS);
}
panelArea.setCaretPosition(0); panelArea.setCaretPosition(0);
scrollPane.setColumnHeaderView(panel); scrollPane.setColumnHeaderView(panel);
panel2.add(scrollPane); panel2.add(scrollPane);

View file

@ -89,6 +89,18 @@ public class TabbedPane extends JPanel {
} }
}; };
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON2) {
final int i = pane.indexOfTabComponent(TabbedPane.this);
if (i != -1) {
pane.remove(i);
}
}
}
});
this.add(label); this.add(label);
// add more space between the label and the button // add more space between the label and the button
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));

View file

@ -0,0 +1,73 @@
package the.bytecode.club.bytecodeviewer.util;
import java.util.function.BiFunction;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
public enum Language {
XML(SyntaxConstants.SYNTAX_STYLE_XML, (n, c) -> n.endsWith(".xml")
|| c.startsWith("<?xml") || c.startsWith("<xml")),
PYTHON(SyntaxConstants.SYNTAX_STYLE_PYTHON, (n, c) -> 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("<?php")),
JS(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, (n, c) -> 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<String, String, Boolean> criteria;
private final String syntaxConstant;
Language(String syntaxConstant, BiFunction<String, String, Boolean> 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;
}
}