Skip to content

Commit

Permalink
v2.9.18 fixes + JADX decompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Apr 25, 2019
1 parent fb4f2a1 commit 7f227ca
Show file tree
Hide file tree
Showing 26 changed files with 594 additions and 78 deletions.
Binary file added libs/android-5.1.jar
Binary file not shown.
Binary file added libs/annotations-17.0.0.jar
Binary file not shown.
Binary file added libs/cloning-1.9.12.jar
Binary file not shown.
Binary file added libs/dx-1.16.jar
Binary file not shown.
Binary file added libs/gson-2.8.5.jar
Binary file not shown.
Binary file added libs/jadx-core.jar
Binary file not shown.
Binary file added libs/objenesis-3.0.1.jar
Binary file not shown.
Binary file added libs/slf4j-api-1.7.26.jar
Binary file not shown.
13 changes: 12 additions & 1 deletion src/the/bytecode/club/bootloader/InitialBootScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.io.IOException;

import javax.swing.JEditorPane;
Expand All @@ -13,6 +16,7 @@
import javax.swing.JScrollPane;
import javax.swing.text.html.HTMLEditorKit;

import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Resources;

/***************************************************************************
Expand Down Expand Up @@ -44,7 +48,14 @@ public class InitialBootScreen extends JFrame {
private JProgressBar progressBar = new JProgressBar();

public InitialBootScreen() throws IOException {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
BytecodeViewer.canExit = true;
System.exit(0);
}
});
this.setIconImages(Resources.iconList);

int i = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
Expand Down
59 changes: 45 additions & 14 deletions src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;

import javax.swing.JDialog;
import javax.swing.JFileChooser;
Expand All @@ -26,12 +30,14 @@
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;

import com.google.gson.reflect.TypeToken;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import me.konloch.kontainer.io.HTTPRequest;

import org.apache.commons.io.FileUtils;
import org.objectweb.asm.tree.ClassNode;
import com.google.gson.*;

import the.bytecode.club.bootloader.Boot;
import the.bytecode.club.bootloader.ILoader;
Expand Down Expand Up @@ -68,6 +74,10 @@
***************************************************************************/

/**
* TODO:
* open as folder doesn't actually work
* smali compile
*
* A lightweight Java Reverse Engineering suite, developed by Konloch - http://konloch.me
*
* All you have to do is add a jar or class file into the workspace,
Expand Down Expand Up @@ -109,7 +119,7 @@
public class BytecodeViewer
{
/*per version*/
public static final String VERSION = "2.9.17";
public static final String VERSION = "2.9.18";
public static String krakatauVersion = "12";
public static String enjarifyVersion = "4";
public static final boolean BLOCK_TAB_MENU = true;
Expand Down Expand Up @@ -142,22 +152,46 @@ public class BytecodeViewer
public static String nl = System.getProperty("line.separator");
private static File BCVDir = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
public static File RJ_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
private static String filesName = getBCVDirectory() + fs + "recentfiles.bcv";
private static String pluginsName = getBCVDirectory() + fs + "recentplugins.bcv";
private static String filesName = getBCVDirectory() + fs + "recentfiles.json";
private static String pluginsName = getBCVDirectory() + fs + "recentplugins.json";
public static String settingsName = getBCVDirectory() + fs + "settings.bcv";
public static String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs;
public static String libsDirectory = getBCVDirectory() + fs + "libs" + fs;
public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion;
public static String enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + enjarifyVersion;
private static ArrayList<String> recentFiles = DiskReader.loadArrayList(filesName, false);
private static ArrayList<String> recentPlugins = DiskReader.loadArrayList(pluginsName, false);
public static boolean runningObfuscation = false;
private static long start = System.currentTimeMillis();
public static String lastDirectory = "";
public static String lastDirectory = ".";
public static ArrayList<Process> createdProcesses = new ArrayList<Process>();
public static Refactorer refactorer = new Refactorer();
public static boolean pingback = false;
public static boolean deleteForeignLibraries = true;
public static boolean canExit = false;
public static Gson gson;

private static ArrayList<String> recentPlugins;
private static ArrayList<String> recentFiles;

static
{
try
{
gson = new GsonBuilder().setPrettyPrinting().create();
if(new File(filesName).exists())
recentFiles = gson.fromJson(DiskReader.loadAsString(filesName), new TypeToken<ArrayList<String>>() {}.getType());
else
recentFiles = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentfiles.bcv", false);

if(new File(pluginsName).exists())
recentPlugins = gson.fromJson(DiskReader.loadAsString(pluginsName), new TypeToken<ArrayList<String>>() {}.getType());
else
recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentplugins.bcv", false);
}
catch (Exception e)
{
e.printStackTrace();
}
}

/**
* The version checker thread
Expand Down Expand Up @@ -812,7 +846,7 @@ public void run() {
} else {
if (f.isDirectory()) {
FileContainer container = new FileContainer(f);
HashMap<String, byte[]> files = new HashMap<String, byte[]>();
HashMap<String, byte[]> files = new HashMap<>();
boolean finished = false;
ArrayList<File> totalFiles = new ArrayList<File>();
totalFiles.add(f);
Expand Down Expand Up @@ -844,10 +878,10 @@ public void run() {
container.files = files;
BytecodeViewer.files.add(container);
} else {
if (fn.endsWith(".jar") || fn.endsWith(".zip")) {
if (fn.endsWith(".jar") || fn.endsWith(".zip") || fn.endsWith(".war")) {
try {
JarUtils.put(f);
} catch (final java.util.zip.ZipException z) {
} catch (java.io.IOException z) {
try {
JarUtils.put2(f);
} catch (final Exception e) {
Expand Down Expand Up @@ -938,7 +972,7 @@ else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.view
}
return;
} else {
HashMap<String, byte[]> files = new HashMap<String, byte[]>();
HashMap<String, byte[]> files = new HashMap<>();
byte[] bytes = JarUtils.getBytes(new FileInputStream(f));
files.put(f.getName(), bytes);

Expand Down Expand Up @@ -1201,10 +1235,7 @@ private static void hideFile(File f) {
* @return string with newline per array object
*/
private static String quickConvert(ArrayList<String> a) {
String s = "";
for (String r : a)
s += r + nl;
return s;
return gson.toJson(a);
}

private static long last = System.currentTimeMillis();
Expand Down
1 change: 1 addition & 0 deletions src/the/bytecode/club/bytecodeviewer/CommandLineInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public static void executeCommandLine(String[] args) {

System.out.println("Finished.");
System.out.println("Bytecode Viewer CLI v" + BytecodeViewer.VERSION + " by @Konloch - http://bytecodeviewer.com");
BytecodeViewer.canExit = true;
System.exit(0);
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
Expand Down
4 changes: 4 additions & 0 deletions src/the/bytecode/club/bytecodeviewer/SecurityMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public void checkDelete(String file) {

@Override
public void checkExit(int status) {
if(!BytecodeViewer.canExit)
{
throw new SecurityException("BCV is awesome, blocking System.exit("+status+");");
}
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/the/bytecode/club/bytecodeviewer/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ else if (decompiler == 8)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1KrakatauBytecode.getModel(), true);
else if (decompiler == 9)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.panel1JDGUI.getModel(), true);
else if (decompiler == 10)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ1.getModel(), true);

decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 82, false));
if (decompiler == 0)
Expand All @@ -351,6 +353,8 @@ else if (decompiler == 8)
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2KrakatauBytecode.getModel(), true);
else if (decompiler == 9)
BytecodeViewer.viewer.panelGroup2.setSelected(BytecodeViewer.viewer.panel2JDGUI.getModel(), true);
else if (decompiler == 10)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ2.getModel(), true);

decompiler = Integer.parseInt(DiskReader.loadString(BytecodeViewer.settingsName, 83, false));
if (decompiler == 0)
Expand All @@ -373,6 +377,8 @@ else if (decompiler == 8)
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3KrakatauBytecode.getModel(), true);
else if (decompiler == 9)
BytecodeViewer.viewer.panelGroup3.setSelected(BytecodeViewer.viewer.panel3JDGUI.getModel(), true);
else if (decompiler == 10)
BytecodeViewer.viewer.panelGroup1.setSelected(BytecodeViewer.viewer.jadxJ3.getModel(), true);

BytecodeViewer.viewer.refreshOnChange.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 84, false)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public byte[] compile(String contents, String name) {
}

try {
com.googlecode.d2j.smali.SmaliCmd.main(new String[]{tempSmaliFolder.getAbsolutePath(), "-o", tempDex.getAbsolutePath()});
com.googlecode.d2j.smali.SmaliCmd.main(new String[]{tempSmaliFolder.getAbsolutePath()});//, "-o", tempDex.getAbsolutePath()});
} catch (Exception e) {
e.printStackTrace();
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,51 @@

public class CFRDecompiler extends Decompiler {

private static final String[] WINDOWS_IS_GREAT = new String[]
{
"CON",
"PRN",
"AUX",
"NUL",
"COM1",
"COM2",
"COM3",
"COM4",
"COM5",
"COM6",
"COM7",
"COM8",
"COM9",
"LPT1",
"LPT2",
"LPT3",
"LPT4",
"LPT5",
"LPT6",
"LPT7",
"LPT8",
"LPT9"
};

public static String windowsFun(String base)
{
for(String s : WINDOWS_IS_GREAT)
{
if(base.contains(s.toLowerCase()))
{
base = base.replace(s.toLowerCase(), "BCV");
}
}

return base;
}

@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs;
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs.toLowerCase();

String exception = "";
//final File tempClass = new File(windowsFun(MiscUtils.getUniqueName(fileStart, ".class") + ".class"));
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");

try {
Expand All @@ -66,6 +106,7 @@ public String decompileClassNode(ClassNode cn, byte[] b) {
}

String fuckery = fuckery(fileStart);

/*if (!BytecodeViewer.fatJar) {
try {
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
Expand All @@ -84,6 +125,7 @@ public String decompileClassNode(ClassNode cn, byte[] b) {
} else {
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery));
}*/

try
{
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery));
Expand All @@ -104,8 +146,6 @@ public String decompileClassNode(ClassNode cn, byte[] b) {
return findFile(file.listFiles());

return "CFR error! Send the stacktrace to Konloch at http://the.bytecode.club or konloch@gmail.com" + BytecodeViewer.nl + BytecodeViewer.nl + "Suggested Fix: Click refresh class, if it fails again try another decompiler." + BytecodeViewer.nl + BytecodeViewer.nl + exception;


}

Random r = new Random();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public abstract class Decompiler {
public final static Decompiler cfr = new CFRDecompiler();
public final static KrakatauDecompiler krakatau = new KrakatauDecompiler();
public final static KrakatauDisassembler krakatauDA = new KrakatauDisassembler();
public final static Decompiler smali = new SmaliDisassembler();
public final static SmaliDisassembler smali = new SmaliDisassembler();
public final static Decompiler jdgui = new JDGUIDecompiler();
public final static Decompiler jadx = new JADXDecompiler();

public abstract String decompileClassNode(ClassNode cn, byte[] b);

Expand Down

0 comments on commit 7f227ca

Please sign in to comment.