Cleaning up the main BytecodeViewer class file
This commit is contained in:
parent
21f8bf8382
commit
cb1c27f46c
7 changed files with 45 additions and 46 deletions
|
@ -115,6 +115,8 @@ public class BytecodeViewer
|
|||
public static boolean deleteForeignLibraries = true;
|
||||
public static boolean canExit = false;
|
||||
|
||||
private static long last = System.currentTimeMillis();
|
||||
|
||||
|
||||
public static boolean verify = false; //eventually may be a setting
|
||||
public static String[] args;
|
||||
|
@ -605,7 +607,7 @@ public class BytecodeViewer
|
|||
recentFiles.remove(maxRecentFiles - 1); // zero indexing
|
||||
|
||||
recentFiles.add(0, f.getAbsolutePath());
|
||||
DiskWriter.replaceFile(filesName, quickConvert(recentFiles), false);
|
||||
DiskWriter.replaceFile(filesName, MiscUtils.listToString(recentFiles), false);
|
||||
resetRecentFilesMenu();
|
||||
}
|
||||
|
||||
|
@ -634,7 +636,7 @@ public class BytecodeViewer
|
|||
recentPlugins.remove(maxRecentFiles - 1); // zero indexing
|
||||
|
||||
recentPlugins.add(0, f.getAbsolutePath());
|
||||
DiskWriter.replaceFile(pluginsName, quickConvert(recentPlugins), false);
|
||||
DiskWriter.replaceFile(pluginsName, MiscUtils.listToString(recentPlugins), false);
|
||||
resetRecentFilesMenu();
|
||||
}
|
||||
|
||||
|
@ -679,39 +681,6 @@ public class BytecodeViewer
|
|||
tempF.mkdir();
|
||||
}
|
||||
|
||||
public static List<String> createdRandomizedNames = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Ensures it will only return a uniquely generated names, contains a dupe checker to be sure
|
||||
*
|
||||
* @return the unique randomized name of 25 characters.
|
||||
*/
|
||||
public static String getRandomizedName() {
|
||||
boolean generated = false;
|
||||
String name = "";
|
||||
while (!generated) {
|
||||
String randomizedName = MiscUtils.randomString(25);
|
||||
if (!createdRandomizedNames.contains(randomizedName)) {
|
||||
createdRandomizedNames.add(randomizedName);
|
||||
name = randomizedName;
|
||||
generated = true;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array list to a string
|
||||
*
|
||||
* @param a array
|
||||
* @return string with newline per array object
|
||||
*/
|
||||
private static String quickConvert(List<String> a) {
|
||||
return gson.toJson(a);
|
||||
}
|
||||
|
||||
private static long last = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* Checks the hotkeys
|
||||
*
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.objectweb.asm.ClassWriter;
|
|||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.decompilers.Decompilers;
|
||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||
|
||||
|
@ -186,7 +187,7 @@ public class CommandLineInput {
|
|||
//if its just class allow any
|
||||
|
||||
File tempZip =
|
||||
new File(tempDirectory + fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar");
|
||||
new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
||||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
|
|
|
@ -770,7 +770,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
Thread t16 = new Thread(() -> {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String input = tempDirectory + fs + BytecodeViewer.getRandomizedName() + ".jar";
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
Thread t15 = new Thread(() -> {
|
||||
|
@ -880,7 +880,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
Thread t14 = new Thread(() -> {
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
final String input = tempDirectory + fs + BytecodeViewer.getRandomizedName() + ".jar";
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
Thread t13 = new Thread(() -> {
|
||||
|
@ -969,7 +969,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
|||
|
||||
BytecodeViewer.viewer.setIcon(true);
|
||||
|
||||
File tempZip = new File(tempDirectory + fs + "temp_" + BytecodeViewer.getRandomizedName() + ".jar");
|
||||
File tempZip = new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
||||
if (tempZip.exists())
|
||||
tempZip.delete();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class APKTool {
|
|||
|
||||
public static synchronized void buildAPK(File input, File output, FileContainer container) {
|
||||
String temp = tempDirectory + fs;
|
||||
File tempDir = new File(temp + fs + BytecodeViewer.getRandomizedName() + fs);
|
||||
File tempDir = new File(temp + fs + MiscUtils.getRandomizedName() + fs);
|
||||
tempDir.mkdirs();
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import java.io.File;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.gson;
|
||||
|
||||
/***************************************************************************
|
||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||
|
@ -36,6 +37,7 @@ public class MiscUtils {
|
|||
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private static final Random rnd = new Random();
|
||||
private static HashSet<String> createdRandomizedNames = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Returns a random string without numbers
|
||||
|
@ -50,6 +52,25 @@ public class MiscUtils {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures it will only return a uniquely generated names, contains a dupe checker to be sure
|
||||
*
|
||||
* @return the unique randomized name of 25 characters.
|
||||
*/
|
||||
public static String getRandomizedName() {
|
||||
boolean generated = false;
|
||||
String name = "";
|
||||
while (!generated) {
|
||||
String randomizedName = MiscUtils.randomString(25);
|
||||
if (!createdRandomizedNames.contains(randomizedName)) {
|
||||
createdRandomizedNames.add(randomizedName);
|
||||
name = randomizedName;
|
||||
generated = true;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static void printProcess(Process process) throws Exception {
|
||||
//Read out dir output
|
||||
InputStream is = process.getInputStream();
|
||||
|
@ -137,6 +158,15 @@ public class MiscUtils {
|
|||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array list to a string
|
||||
*
|
||||
* @param a array
|
||||
* @return string with newline per array object
|
||||
*/
|
||||
public static String listToString(List<String> a) {
|
||||
return gson.toJson(a);
|
||||
}
|
||||
/**
|
||||
* @author JoshTheWolfe
|
||||
*/
|
||||
|
|
|
@ -149,7 +149,7 @@ public class OpenFile implements Runnable
|
|||
Objects.requireNonNull(container.files).putAll(JarUtils.loadResources(tempCopy)); //copy and rename
|
||||
// to prevent unicode filenames
|
||||
|
||||
String name = BytecodeViewer.getRandomizedName() + ".jar";
|
||||
String name = MiscUtils.getRandomizedName() + ".jar";
|
||||
File output = new File(tempDirectory + fs + name);
|
||||
|
||||
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||
|
@ -176,7 +176,7 @@ public class OpenFile implements Runnable
|
|||
|
||||
FileContainer container = new FileContainer(tempCopy, f.getName());
|
||||
|
||||
String name = BytecodeViewer.getRandomizedName() + ".jar";
|
||||
String name = MiscUtils.getRandomizedName() + ".jar";
|
||||
File output = new File(tempDirectory + fs + name);
|
||||
|
||||
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||
|
|
|
@ -50,7 +50,6 @@ public class VersionChecker implements Runnable
|
|||
try {
|
||||
int simplemaths = Integer.parseInt(version.replace(".", ""));
|
||||
int simplemaths2 = Integer.parseInt(localVersion.replace(".", ""));
|
||||
System.out.println("DEBUG: " + simplemaths + " vs " + simplemaths2);
|
||||
if (simplemaths2 > simplemaths)
|
||||
return; //developer version
|
||||
} catch (Exception ignored) {
|
||||
|
|
Loading…
Reference in a new issue