Skip to content

Commit

Permalink
v2.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Konloch committed Jun 1, 2019
1 parent 9f3302f commit f76b31d
Show file tree
Hide file tree
Showing 12 changed files with 398 additions and 55 deletions.
56 changes: 38 additions & 18 deletions src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
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 Down Expand Up @@ -118,7 +114,7 @@
public class BytecodeViewer
{
/*per version*/
public static final String VERSION = "2.9.19";
public static final String VERSION = "2.9.20";
public static String krakatauVersion = "12";
public static String enjarifyVersion = "4";
public static final boolean BLOCK_TAB_MENU = true;
Expand All @@ -145,12 +141,13 @@ public class BytecodeViewer
public static boolean currentlyDumping = false;
public static boolean needsReDump = true;
public static boolean warnForEditing = false;
public static ArrayList<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
public static List<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
private static int maxRecentFiles = 25;
public static String fs = System.getProperty("file.separator");
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");
public static File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
public static File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar");
private static String filesName = getBCVDirectory() + fs + "recentfiles.json";
private static String pluginsName = getBCVDirectory() + fs + "recentplugins.json";
public static String settingsName = getBCVDirectory() + fs + "settings.bcv";
Expand All @@ -161,15 +158,15 @@ public class BytecodeViewer
public static boolean runningObfuscation = false;
private static long start = System.currentTimeMillis();
public static String lastDirectory = ".";
public static ArrayList<Process> createdProcesses = new ArrayList<Process>();
public static List<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;
private static List<String> recentPlugins;
private static List<String> recentFiles;

static
{
Expand Down Expand Up @@ -669,6 +666,10 @@ public static FileContainer getFileContainer(String name) {
return null;
}

public static List<FileContainer> getFiles() {
return files;
}

public static ClassNode getClassNode(FileContainer container, String name) {
for (ClassNode c : container.classes)
if (c.name.equals(name))
Expand Down Expand Up @@ -943,7 +944,7 @@ public void run() {

if (viewer.decodeAPKResources.isSelected()) {
File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
APKTool.decodeResources(tempCopy, decodedResources);
APKTool.decodeResources(tempCopy, decodedResources, container);
container.files = JarUtils.loadResources(decodedResources);
}

Expand Down Expand Up @@ -1080,7 +1081,7 @@ public static void resetWorkSpace(boolean ask)
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
}

private static ArrayList<String> killList = new ArrayList<String>();
private static List<String> killList = new ArrayList<String>();

/**
* Add the recent file
Expand Down Expand Up @@ -1109,7 +1110,7 @@ public static void addRecentFile(File f) {
resetRecentFilesMenu();
}

private static ArrayList<String> killList2 = new ArrayList<String>();
private static List<String> killList2 = new ArrayList<String>();

/**
* Add to the recent plugin list
Expand Down Expand Up @@ -1187,7 +1188,7 @@ public static void cleanup() {
tempF.mkdir();
}

public static ArrayList<String> createdRandomizedNames = new ArrayList<String>();
public static List<String> createdRandomizedNames = new ArrayList<String>();

/**
* Ensures it will only return a uniquely generated names, contains a dupe checker to be sure
Expand Down Expand Up @@ -1254,7 +1255,7 @@ private static void hideFile(File f) {
* @param a array
* @return string with newline per array object
*/
private static String quickConvert(ArrayList<String> a) {
private static String quickConvert(List<String> a) {
return gson.toJson(a);
}

Expand Down Expand Up @@ -1471,11 +1472,30 @@ else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.pane
return files;
}

public static void rtCheck()
public synchronized static void rtCheck()
{
if(rt.equals("") && RJ_JAR.exists())
if(rt.equals(""))
{
rt = RJ_JAR.getAbsolutePath();
if(RT_JAR.exists())
{
rt = RT_JAR.getAbsolutePath();
}
else if(RT_JAR_DUMPED.exists())
{
rt = RT_JAR_DUMPED.getAbsolutePath();
}
else
{
try
{
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
rt = RT_JAR_DUMPED.getAbsolutePath();
}
catch (Throwable t)
{
t.printStackTrace();
}
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/the/bytecode/club/bytecodeviewer/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
Expand Down Expand Up @@ -37,7 +38,7 @@

public class Resources {

public static ArrayList<BufferedImage> iconList;
public static List<BufferedImage> iconList;
public static BufferedImage icon;
public static ImageIcon nextIcon;
public static ImageIcon prevIcon;
Expand Down
6 changes: 4 additions & 2 deletions src/the/bytecode/club/bytecodeviewer/SecurityMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void stopBlocking() { //slightly safer security system than just a public
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.JDGUIDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.KrakatauAssembler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.Enjarify") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.JavaCompiler")) {
blocking = false;
Expand All @@ -60,7 +61,8 @@ public void checkExec(String cmd) {
"attrib",
"python",
"pypy",
"java"
"java",
"brut_util",
};
boolean allow = false;

Expand All @@ -71,7 +73,7 @@ public void checkExec(String cmd) {

if (allow && !blocking) {
System.out.println("Allowing exec:" + cmd);
} else throw new SecurityException("BCV is awesome, blocking " + cmd);
} else throw new SecurityException("BCV is awesome, blocking("+blocking+") exec " + cmd);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public byte[] compile(String contents, String name) {
tempSmaliFolder.mkdir();

File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + BytecodeViewer.fs + fileNumber + ".smali");
File tempDex = new File(fileStart + fileNumber + ".dex");
File tempDex = new File("./out.dex");
File tempJar = new File(fileStart + fileNumber + ".jar");
File tempJarFolder = new File(fileStart + fileNumber + "-jar" + BytecodeViewer.fs);

Expand All @@ -68,6 +68,7 @@ else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.view
Enjarify.apk2Jar(tempDex, tempJar);

try {
System.out.println("Unzipping to " + tempJarFolder.getAbsolutePath());
ZipUtils.unzipFilesToPath(tempJar.getAbsolutePath(), tempJarFolder.getAbsolutePath());

File outputClass = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public class SmaliDisassembler extends Decompiler {

public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b) {
String exception = "";
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
+ "temp";
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";

String start = MiscUtils.getUniqueName(fileStart, ".class");

Expand All @@ -62,9 +61,7 @@ public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b

//ZipUtils.zipFile(tempClass, tempZip);

Dex2Jar.saveAsDex(container.file, tempDex, false);

System.out.println("FOR SHOW: " + tempDex.getName().replaceFirst("\\.dex", "-out")); //tempSmali.getAbsolutePath()
Dex2Jar.saveAsDex(tempClass, tempDex, true);

try
{
Expand Down Expand Up @@ -94,9 +91,6 @@ public String decompileClassNode(FileContainer container, ClassNode cn, byte[] b
exception += "Bytecode Viewer Version: " + BytecodeViewer.VERSION + BytecodeViewer.nl + BytecodeViewer.nl + sw.toString();
}

System.out.println("FOR SHOW1: " + rename.getAbsolutePath());
System.out.println("FOR SHOW2: " + tempSmali.getAbsolutePath());

File outputSmali = null;

boolean found = false;
Expand Down

0 comments on commit f76b31d

Please sign in to comment.