Code Cleanup
This commit is contained in:
parent
fb825589c3
commit
5dab52bfd3
|
@ -42,7 +42,11 @@ public class Configuration
|
||||||
public static boolean python3Extra = false;
|
public static boolean python3Extra = false;
|
||||||
public static String rt = "";
|
public static String rt = "";
|
||||||
public static String library = "";
|
public static String library = "";
|
||||||
public static String java = Constants.JAVA_BINARY.exists() ? Constants.JAVA_BINARY.getAbsolutePath() : Constants.JAVA_BINARY_NIX.exists() ? Constants.JAVA_BINARY_NIX.getAbsolutePath() : "";
|
public static String java = Constants.JAVA_BINARY.exists()
|
||||||
|
? Constants.JAVA_BINARY.getAbsolutePath()
|
||||||
|
: Constants.JAVA_BINARY_NIX.exists()
|
||||||
|
? Constants.JAVA_BINARY_NIX.getAbsolutePath()
|
||||||
|
: "";
|
||||||
public static String javac = "";
|
public static String javac = "";
|
||||||
public static String javaTools = "";
|
public static String javaTools = "";
|
||||||
public static File krakatauTempDir;
|
public static File krakatauTempDir;
|
||||||
|
|
|
@ -60,8 +60,11 @@ public class Constants
|
||||||
|
|
||||||
//version is set via maven
|
//version is set via maven
|
||||||
public static final String VERSION = getVersion(BytecodeViewer.class.getPackage().getImplementationVersion());
|
public static final String VERSION = getVersion(BytecodeViewer.class.getPackage().getImplementationVersion());
|
||||||
|
|
||||||
|
//CHECKSTYLE:OFF
|
||||||
//dev mode is just a check for running via IDE
|
//dev mode is just a check for running via IDE
|
||||||
public static boolean DEV_MODE;
|
public static boolean DEV_MODE;
|
||||||
|
//CHECKSTYLE:ON
|
||||||
|
|
||||||
//if true the version checker will prompt and ask how you would like to proceed
|
//if true the version checker will prompt and ask how you would like to proceed
|
||||||
public static final boolean FORCE_VERSION_CHECKER_PROMPT = false;
|
public static final boolean FORCE_VERSION_CHECKER_PROMPT = false;
|
||||||
|
@ -71,7 +74,7 @@ public class Constants
|
||||||
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.SUPPORTED_BCV_EXTENSION_MAP.keySet().toArray(new String[0]);
|
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.SUPPORTED_BCV_EXTENSION_MAP.keySet().toArray(new String[0]);
|
||||||
public static final int ASM_VERSION = Opcodes.ASM9;
|
public static final int ASM_VERSION = Opcodes.ASM9;
|
||||||
|
|
||||||
public static final File BCVDir = resolveBCVRoot();
|
public static final File BCV_DIR = resolveBCVRoot();
|
||||||
public static final File RT_JAR = new File(System.getProperty("java.home") + FS + "lib" + FS + "rt.jar");
|
public static final File RT_JAR = new File(System.getProperty("java.home") + FS + "lib" + FS + "rt.jar");
|
||||||
public static final File JAVA_BINARY = new File(System.getProperty("java.home") + FS + "bin" + FS + "java.exe");
|
public static final File JAVA_BINARY = new File(System.getProperty("java.home") + FS + "bin" + FS + "java.exe");
|
||||||
public static final File JAVA_BINARY_NIX = new File(System.getProperty("java.home") + FS + "bin" + FS + "java");
|
public static final File JAVA_BINARY_NIX = new File(System.getProperty("java.home") + FS + "bin" + FS + "java");
|
||||||
|
@ -119,18 +122,18 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static String getBCVDirectory()
|
public static String getBCVDirectory()
|
||||||
{
|
{
|
||||||
while (!BCVDir.exists())
|
while (!BCV_DIR.exists())
|
||||||
BCVDir.mkdirs();
|
BCV_DIR.mkdirs();
|
||||||
|
|
||||||
//hides the BCV directory
|
//hides the BCV directory
|
||||||
if (isWindows() && !BCVDir.isHidden())
|
if (isWindows() && !BCV_DIR.isHidden())
|
||||||
{
|
{
|
||||||
new Thread(() ->
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Hide file by running attrib system command (on Windows)
|
// Hide file by running attrib system command (on Windows)
|
||||||
Process p = new ProcessBuilder("attrib", "+H", BCVDir.getAbsolutePath()).start();
|
Process p = new ProcessBuilder("attrib", "+H", BCV_DIR.getAbsolutePath()).start();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +142,7 @@ public class Constants
|
||||||
}, "Hide BCV Dir").start();
|
}, "Hide BCV Dir").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return BCVDir.getAbsolutePath();
|
return BCV_DIR.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -141,7 +141,9 @@ public class ExceptionUI extends JFrameConsole
|
||||||
|
|
||||||
return TranslatedStrings.PLEASE_SEND_THIS_ERROR_LOG_TO + " " + author + "\n"
|
return TranslatedStrings.PLEASE_SEND_THIS_ERROR_LOG_TO + " " + author + "\n"
|
||||||
+ TranslatedStrings.PLEASE_SEND_RESOURCES
|
+ TranslatedStrings.PLEASE_SEND_RESOURCES
|
||||||
+ "\nBytecode Viewer Version: " + VERSION + fatJar + ", OS: " + System.getProperty("os.name") + ", Java: " + System.getProperty("java.version");
|
+ "\nBytecode Viewer Version: " + VERSION + fatJar
|
||||||
|
+ ", OS: " + System.getProperty("os.name")
|
||||||
|
+ ", Java: " + System.getProperty("java.version");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = -5230501978224926296L;
|
private static final long serialVersionUID = -5230501978224926296L;
|
||||||
|
|
|
@ -331,7 +331,8 @@ public class Boot
|
||||||
while (temp.exists())
|
while (temp.exists())
|
||||||
temp.delete();
|
temp.delete();
|
||||||
|
|
||||||
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + krakatauVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp))
|
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + krakatauVersion + ".zip");
|
||||||
|
FileOutputStream baos = new FileOutputStream(temp))
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
@ -368,7 +369,8 @@ public class Boot
|
||||||
while (temp.exists())
|
while (temp.exists())
|
||||||
temp.delete();
|
temp.delete();
|
||||||
|
|
||||||
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + Constants.enjarifyVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp))
|
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + Constants.enjarifyVersion + ".zip");
|
||||||
|
FileOutputStream baos = new FileOutputStream(temp))
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
@ -405,7 +407,8 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
||||||
System.out.println("Downloading " + fileName);
|
System.out.println("Downloading " + fileName);
|
||||||
|
|
||||||
try (InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/raw/master/libs/" + fileName).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(file))
|
try (InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/raw/master/libs/" + fileName).openConnection().getInputStream();
|
||||||
|
FileOutputStream fos = new FileOutputStream(file))
|
||||||
{
|
{
|
||||||
System.out.println("Downloading from " + s);
|
System.out.println("Downloading from " + s);
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
|
|
@ -118,7 +118,8 @@ public class UpdateCheck implements Runnable
|
||||||
if (Desktop.isDesktopSupported())
|
if (Desktop.isDesktopSupported())
|
||||||
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
||||||
else
|
else
|
||||||
BytecodeViewer.showMessage("Cannot open the page, please manually type it." + NL + "https://github.com/Konloch/bytecode-viewer/releases");
|
BytecodeViewer.showMessage("Cannot open the page, please manually type it."
|
||||||
|
+ NL + "https://github.com/Konloch/bytecode-viewer/releases");
|
||||||
}
|
}
|
||||||
else if (result == 1)
|
else if (result == 1)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +235,8 @@ public class UpdateCheck implements Runnable
|
||||||
private static void download(String url, File saveTo, Runnable onFinish) throws Exception
|
private static void download(String url, File saveTo, Runnable onFinish) throws Exception
|
||||||
{
|
{
|
||||||
BCV.log("Downloading from: " + url);
|
BCV.log("Downloading from: " + url);
|
||||||
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished you will be alerted with another message box." + NL + NL + "Expect this to take several minutes.");
|
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished you will be alerted with another message box."
|
||||||
|
+ NL + NL + "Expect this to take several minutes.");
|
||||||
|
|
||||||
try (InputStream is = new URL(url).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(saveTo))
|
try (InputStream is = new URL(url).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(saveTo))
|
||||||
{
|
{
|
||||||
|
|
|
@ -178,7 +178,15 @@ public class CommandLineInput
|
||||||
//if its zip/jar/apk/dex attempt unzip as whole zip
|
//if its zip/jar/apk/dex attempt unzip as whole zip
|
||||||
//if its just class allow any
|
//if its just class allow any
|
||||||
|
|
||||||
if (decompiler != null && !decompiler.equalsIgnoreCase("procyon") && !decompiler.equalsIgnoreCase("cfr") && !decompiler.equalsIgnoreCase("fernflower") && !decompiler.equalsIgnoreCase("krakatau") && !decompiler.equalsIgnoreCase("krakatau-bytecode") && !decompiler.equalsIgnoreCase("jd-gui") && !decompiler.equalsIgnoreCase("smali") && !decompiler.equalsIgnoreCase("asmifier"))
|
if (decompiler != null
|
||||||
|
&& !decompiler.equalsIgnoreCase("procyon")
|
||||||
|
&& !decompiler.equalsIgnoreCase("cfr")
|
||||||
|
&& !decompiler.equalsIgnoreCase("fernflower")
|
||||||
|
&& !decompiler.equalsIgnoreCase("krakatau")
|
||||||
|
&& !decompiler.equalsIgnoreCase("krakatau-bytecode")
|
||||||
|
&& !decompiler.equalsIgnoreCase("jd-gui")
|
||||||
|
&& !decompiler.equalsIgnoreCase("smali")
|
||||||
|
&& !decompiler.equalsIgnoreCase("asmifier"))
|
||||||
{
|
{
|
||||||
System.out.println("Error, no decompiler called '" + decompiler + "' found. Type -list" + " for the list");
|
System.out.println("Error, no decompiler called '" + decompiler + "' found. Type -list" + " for the list");
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ public class InstructionPrinter implements Opcodes
|
||||||
this(m, args);
|
this(m, args);
|
||||||
InstructionSearcher searcher = new InstructionSearcher(m.instructions, pattern);
|
InstructionSearcher searcher = new InstructionSearcher(m.instructions, pattern);
|
||||||
match = searcher.search();
|
match = searcher.search();
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
for (AbstractInsnNode[] ains : searcher.getMatches())
|
for (AbstractInsnNode[] ains : searcher.getMatches())
|
||||||
|
@ -102,6 +103,7 @@ public class InstructionPrinter implements Opcodes
|
||||||
{
|
{
|
||||||
firstLabel = false;
|
firstLabel = false;
|
||||||
info.clear();
|
info.clear();
|
||||||
|
|
||||||
for (AbstractInsnNode ain : mNode.instructions)
|
for (AbstractInsnNode ain : mNode.instructions)
|
||||||
{
|
{
|
||||||
String line = printInstruction(ain);
|
String line = printInstruction(ain);
|
||||||
|
@ -114,8 +116,10 @@ public class InstructionPrinter implements Opcodes
|
||||||
info.add(line);
|
info.add(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (firstLabel && BytecodeViewer.viewer.appendBracketsToLabels.isSelected())
|
if (firstLabel && BytecodeViewer.viewer.appendBracketsToLabels.isSelected())
|
||||||
info.add("}");
|
info.add("}");
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,18 +173,14 @@ public class InstructionPrinter implements Opcodes
|
||||||
if (BytecodeViewer.viewer.debugHelpers.isSelected())
|
if (BytecodeViewer.viewer.debugHelpers.isSelected())
|
||||||
{
|
{
|
||||||
if (vin.var == 0 && !Modifier.isStatic(mNode.access))
|
if (vin.var == 0 && !Modifier.isStatic(mNode.access))
|
||||||
{
|
|
||||||
sb.append(" // reference to self");
|
sb.append(" // reference to self");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int refIndex = vin.var - (Modifier.isStatic(mNode.access) ? 0 : 1);
|
final int refIndex = vin.var - (Modifier.isStatic(mNode.access) ? 0 : 1);
|
||||||
if (refIndex >= 0 && refIndex < args.length - 1)
|
if (refIndex >= 0 && refIndex < args.length - 1)
|
||||||
{
|
|
||||||
sb.append(" // reference to ").append(args[refIndex].name);
|
sb.append(" // reference to ").append(args[refIndex].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -229,9 +229,11 @@ public class InstructionPrinter implements Opcodes
|
||||||
protected String printLdcInsnNode(LdcInsnNode ldc)
|
protected String printLdcInsnNode(LdcInsnNode ldc)
|
||||||
{
|
{
|
||||||
if (ldc.cst instanceof String)
|
if (ldc.cst instanceof String)
|
||||||
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
|
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString())
|
||||||
|
+ "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||||
|
|
||||||
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString()) + " (" + ldc.cst.getClass().getCanonicalName() + ")";
|
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString())
|
||||||
|
+ " (" + ldc.cst.getClass().getCanonicalName() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String printInsnNode(InsnNode in)
|
protected String printInsnNode(InsnNode in)
|
||||||
|
@ -270,6 +272,7 @@ public class InstructionPrinter implements Opcodes
|
||||||
String starting = tcbs.stream().filter(tcb -> tcb.start == label).map(tcb -> "start TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
String starting = tcbs.stream().filter(tcb -> tcb.start == label).map(tcb -> "start TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
||||||
String ending = tcbs.stream().filter(tcb -> tcb.end == label).map(tcb -> "end TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
String ending = tcbs.stream().filter(tcb -> tcb.end == label).map(tcb -> "end TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
||||||
String handlers = tcbs.stream().filter(tcb -> tcb.handler == label).map(tcb -> "handle TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
String handlers = tcbs.stream().filter(tcb -> tcb.handler == label).map(tcb -> "handle TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
|
||||||
|
|
||||||
if (!ending.isEmpty())
|
if (!ending.isEmpty())
|
||||||
info.add("// " + ending);
|
info.add("// " + ending);
|
||||||
if (!starting.isEmpty())
|
if (!starting.isEmpty())
|
||||||
|
@ -325,10 +328,12 @@ public class InstructionPrinter implements Opcodes
|
||||||
StringBuilder line = new StringBuilder(nameOpcode(tin.getOpcode()) + " \n");
|
StringBuilder line = new StringBuilder(nameOpcode(tin.getOpcode()) + " \n");
|
||||||
List<?> labels = tin.labels;
|
List<?> labels = tin.labels;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (int i = tin.min; i < tin.max + 1; i++)
|
for (int i = tin.min; i < tin.max + 1; i++)
|
||||||
{
|
{
|
||||||
line.append(" val: ").append(i).append(" -> ").append("L").append(resolveLabel((LabelNode) labels.get(count++))).append("\n");
|
line.append(" val: ").append(i).append(" -> ").append("L").append(resolveLabel((LabelNode) labels.get(count++))).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
line.append(" default" + " -> L").append(resolveLabel(tin.dflt));
|
line.append(" default" + " -> L").append(resolveLabel(tin.dflt));
|
||||||
return line.toString();
|
return line.toString();
|
||||||
}
|
}
|
||||||
|
@ -408,6 +413,7 @@ public class InstructionPrinter implements Opcodes
|
||||||
{
|
{
|
||||||
if (obj instanceof LabelNode)
|
if (obj instanceof LabelNode)
|
||||||
return "label [L" + resolveLabel((LabelNode) obj) + "]";
|
return "label [L" + resolveLabel((LabelNode) obj) + "]";
|
||||||
|
|
||||||
if (obj instanceof Integer)
|
if (obj instanceof Integer)
|
||||||
{
|
{
|
||||||
switch ((int) obj)
|
switch ((int) obj)
|
||||||
|
@ -430,8 +436,10 @@ public class InstructionPrinter implements Opcodes
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj instanceof String)
|
if (obj instanceof String)
|
||||||
return obj.toString();
|
return obj.toString();
|
||||||
|
|
||||||
return "unknown [" + obj.toString() + "]";
|
return "unknown [" + obj.toString() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,5 @@ public class ASMTextifierDisassembler extends InternalDecompiler
|
||||||
@Override
|
@Override
|
||||||
public void decompileToZip(String sourceJar, String zipName)
|
public void decompileToZip(String sourceJar, String zipName)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class HTMLPane extends JEditorPane
|
||||||
text = text.replace("{fatJar}", String.valueOf(FAT_JAR));
|
text = text.replace("{fatJar}", String.valueOf(FAT_JAR));
|
||||||
text = text.replace("{java}", Configuration.java);
|
text = text.replace("{java}", Configuration.java);
|
||||||
text = text.replace("{javac}", Configuration.javac);
|
text = text.replace("{javac}", Configuration.javac);
|
||||||
text = text.replace("{bcvDir}", BCVDir.getAbsolutePath());
|
text = text.replace("{bcvDir}", BCV_DIR.getAbsolutePath());
|
||||||
text = text.replace("{python}", Configuration.python2 + " " + (Configuration.python2Extra ? "-2" : ""));
|
text = text.replace("{python}", Configuration.python2 + " " + (Configuration.python2Extra ? "-2" : ""));
|
||||||
text = text.replace("{python3}", Configuration.python3 + " " + (Configuration.python3Extra ? "-3" : ""));
|
text = text.replace("{python3}", Configuration.python3 + " " + (Configuration.python3Extra ? "-3" : ""));
|
||||||
text = text.replace("{rt}", Configuration.rt);
|
text = text.replace("{rt}", Configuration.rt);
|
||||||
|
|
|
@ -49,8 +49,7 @@ public enum LAFTheme
|
||||||
SOLARIZED_DARK("Solarized Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_DARK_THEME),
|
SOLARIZED_DARK("Solarized Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_DARK_THEME),
|
||||||
SOLARIZED_LIGHT("Solarized Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_LIGHT_THEME),
|
SOLARIZED_LIGHT("Solarized Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_LIGHT_THEME),
|
||||||
HIGH_CONTRAST_DARK("High Contrast Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_DARK_THEME),
|
HIGH_CONTRAST_DARK("High Contrast Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_DARK_THEME),
|
||||||
HIGH_CONTRAST_LIGHT("High Contrast Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_LIGHT_THEME),
|
HIGH_CONTRAST_LIGHT("High Contrast Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_LIGHT_THEME);
|
||||||
;
|
|
||||||
|
|
||||||
private final String readableName;
|
private final String readableName;
|
||||||
private final RSTATheme rstaTheme;
|
private final RSTATheme rstaTheme;
|
||||||
|
|
|
@ -38,7 +38,12 @@ public enum RSTATheme
|
||||||
THEME_MATCH("Theme Match (Recommended)", null, TranslatedComponents.THEME_MATCH), //uses the default theme from RSyntaxTextArea
|
THEME_MATCH("Theme Match (Recommended)", null, TranslatedComponents.THEME_MATCH), //uses the default theme from RSyntaxTextArea
|
||||||
DEFAULT("Default (Recommended Light)", "/org/fife/ui/rsyntaxtextarea/themes/default.xml", TranslatedComponents.DEFAULT_RECOMMENDED_LIGHT), //uses the default dark theme from RSyntaxTextArea
|
DEFAULT("Default (Recommended Light)", "/org/fife/ui/rsyntaxtextarea/themes/default.xml", TranslatedComponents.DEFAULT_RECOMMENDED_LIGHT), //uses the default dark theme from RSyntaxTextArea
|
||||||
DARK("Dark (Recommended Dark)", "/org/fife/ui/rsyntaxtextarea/themes/dark.xml", TranslatedComponents.DARK),
|
DARK("Dark (Recommended Dark)", "/org/fife/ui/rsyntaxtextarea/themes/dark.xml", TranslatedComponents.DARK),
|
||||||
DEFAULT_ALT("Default-Alt", "/org/fife/ui/rsyntaxtextarea/themes/default-alt.xml", TranslatedComponents.DEFAULT_ALT), ECLIPSE("Eclipse", "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml", TranslatedComponents.ECLIPSE), IDEA("IntelliJ", "/org/fife/ui/rsyntaxtextarea/themes/idea.xml", TranslatedComponents.INTELLIJ), VS("Visual Studio", "/org/fife/ui/rsyntaxtextarea/themes/vs.xml", TranslatedComponents.VISUAL_STUDIO), DRUID("Druid (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/druid.xml", TranslatedComponents.DRUID_DARK), MONOKAI("Monokai (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/monokai.xml", TranslatedComponents.MONOKAI_DARK);
|
DEFAULT_ALT("Default-Alt", "/org/fife/ui/rsyntaxtextarea/themes/default-alt.xml", TranslatedComponents.DEFAULT_ALT),
|
||||||
|
ECLIPSE("Eclipse", "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml", TranslatedComponents.ECLIPSE),
|
||||||
|
IDEA("IntelliJ", "/org/fife/ui/rsyntaxtextarea/themes/idea.xml", TranslatedComponents.INTELLIJ),
|
||||||
|
VS("Visual Studio", "/org/fife/ui/rsyntaxtextarea/themes/vs.xml", TranslatedComponents.VISUAL_STUDIO),
|
||||||
|
DRUID("Druid (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/druid.xml", TranslatedComponents.DRUID_DARK),
|
||||||
|
MONOKAI("Monokai (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/monokai.xml", TranslatedComponents.MONOKAI_DARK);
|
||||||
|
|
||||||
private final String readableName;
|
private final String readableName;
|
||||||
private final String file;
|
private final String file;
|
||||||
|
|
|
@ -45,7 +45,8 @@ public class RenameFields extends JavaObfuscator
|
||||||
{
|
{
|
||||||
FieldNode f = (FieldNode) o;
|
FieldNode f = (FieldNode) o;
|
||||||
String newName = generateUniqueName(stringLength);
|
String newName = generateUniqueName(stringLength);
|
||||||
ASMResourceUtil.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
|
ASMResourceUtil.renameFieldNode(c.name, f.name, f.desc,
|
||||||
|
null, newName, null);
|
||||||
f.name = newName;
|
f.name = newName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ public class RenameMethods extends JavaObfuscator
|
||||||
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
|
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
|
||||||
{
|
{
|
||||||
String newName = generateUniqueName(stringLength);
|
String newName = generateUniqueName(stringLength);
|
||||||
ASMResourceUtil.renameMethodNode(c.name, m.name, m.desc, null, newName, null);
|
ASMResourceUtil.renameMethodNode(c.name, m.name, m.desc,
|
||||||
|
null, newName, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,11 @@ public abstract class Remapper extends org.objectweb.asm.commons.Remapper
|
||||||
if (value instanceof Handle)
|
if (value instanceof Handle)
|
||||||
{
|
{
|
||||||
Handle h = (Handle) value;
|
Handle h = (Handle) value;
|
||||||
return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(h.getOwner(), h.getName(), h.getDesc()), mapMethodDesc(h.getDesc()), h.getTag() == Opcodes.H_INVOKEINTERFACE);
|
return new Handle(h.getTag(),
|
||||||
|
mapType(h.getOwner()),
|
||||||
|
mapMethodName(h.getOwner(), h.getName(), h.getDesc()),
|
||||||
|
mapMethodDesc(h.getDesc()),
|
||||||
|
h.getTag() == Opcodes.H_INVOKEINTERFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class RenameClasses extends JavaObfuscator
|
||||||
{
|
{
|
||||||
if (Configuration.runningObfuscation)
|
if (Configuration.runningObfuscation)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" + ".");
|
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +75,6 @@ public class RenameClasses extends JavaObfuscator
|
||||||
String newName = generateUniqueName(stringLength);
|
String newName = generateUniqueName(stringLength);
|
||||||
|
|
||||||
BytecodeViewer.refactorer.getHooks().addClass(new MappingData(c.name, newName));
|
BytecodeViewer.refactorer.getHooks().addClass(new MappingData(c.name, newName));
|
||||||
|
|
||||||
/*ASMUtil_OLD.renameClassNode(c.name, newName);
|
|
||||||
c.name = newName;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Obfuscated class names.");
|
System.out.println("Obfuscated class names.");
|
||||||
|
|
|
@ -64,9 +64,6 @@ public class RenameFields extends JavaObfuscator
|
||||||
String newName = generateUniqueName(stringLength);
|
String newName = generateUniqueName(stringLength);
|
||||||
|
|
||||||
BytecodeViewer.refactorer.getHooks().addField(new FieldMappingData(c.name, new MappingData(f.name, newName), f.desc));
|
BytecodeViewer.refactorer.getHooks().addField(new FieldMappingData(c.name, new MappingData(f.name, newName), f.desc));
|
||||||
|
|
||||||
/*ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
|
|
||||||
f.name = newName;*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class RenameMethods extends JavaObfuscator
|
||||||
{
|
{
|
||||||
if (Configuration.runningObfuscation)
|
if (Configuration.runningObfuscation)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" + ".");
|
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +66,20 @@ public class RenameMethods extends JavaObfuscator
|
||||||
if ((m.access & Opcodes.ACC_NATIVE) != 0)
|
if ((m.access & Opcodes.ACC_NATIVE) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (m.access != Opcodes.ACC_ABSTRACT && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED)
|
if (m.access != Opcodes.ACC_ABSTRACT
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE
|
||||||
|
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED)
|
||||||
{
|
{
|
||||||
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
|
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
|
||||||
{
|
{
|
||||||
String newName = generateUniqueName(stringLength);
|
String newName = generateUniqueName(stringLength);
|
||||||
|
|
||||||
BytecodeViewer.refactorer.getHooks().addMethod(new MethodMappingData(c.name, new MappingData(m.name, newName), m.desc));
|
BytecodeViewer.refactorer.getHooks().addMethod(new MethodMappingData(c.name, new MappingData(m.name, newName), m.desc));
|
||||||
|
|
||||||
/*ASMUtil_OLD.renameMethodNode(c.name, m.name, m.desc,
|
|
||||||
null, newName, null);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ import java.util.*;
|
||||||
|
|
||||||
public final class PluginManager
|
public final class PluginManager
|
||||||
{
|
{
|
||||||
private static final Map<String, PluginLaunchStrategy> launchStrategies = new HashMap<>();
|
private static final Map<String, PluginLaunchStrategy> LAUNCH_STRATEGIES = new HashMap<>();
|
||||||
private static final PluginFileFilter filter = new PluginFileFilter();
|
private static final PluginFileFilter FILTER = new PluginFileFilter();
|
||||||
private static final List<Plugin> pluginInstances = new ArrayList<>();
|
private static final List<Plugin> PLUGIN_INSTANCES = new ArrayList<>();
|
||||||
|
|
||||||
//TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time
|
//TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time
|
||||||
// the solution is to tie the plugin object into the plugin console,
|
// the solution is to tie the plugin object into the plugin console,
|
||||||
|
@ -63,21 +63,21 @@ public final class PluginManager
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
launchStrategies.put("jar", new CompiledJavaPluginLaunchStrategy());
|
LAUNCH_STRATEGIES.put("jar", new CompiledJavaPluginLaunchStrategy());
|
||||||
launchStrategies.put("java", new JavaPluginLaunchStrategy());
|
LAUNCH_STRATEGIES.put("java", new JavaPluginLaunchStrategy());
|
||||||
launchStrategies.put("js", new JavascriptPluginLaunchStrategy());
|
LAUNCH_STRATEGIES.put("js", new JavascriptPluginLaunchStrategy());
|
||||||
|
|
||||||
GroovyPluginLaunchStrategy groovy = new GroovyPluginLaunchStrategy();
|
GroovyPluginLaunchStrategy groovy = new GroovyPluginLaunchStrategy();
|
||||||
launchStrategies.put("gy", groovy);
|
LAUNCH_STRATEGIES.put("gy", groovy);
|
||||||
launchStrategies.put("groovy", groovy);
|
LAUNCH_STRATEGIES.put("groovy", groovy);
|
||||||
|
|
||||||
PythonPluginLaunchStrategy python = new PythonPluginLaunchStrategy();
|
PythonPluginLaunchStrategy python = new PythonPluginLaunchStrategy();
|
||||||
launchStrategies.put("py", python);
|
LAUNCH_STRATEGIES.put("py", python);
|
||||||
launchStrategies.put("python", python);
|
LAUNCH_STRATEGIES.put("python", python);
|
||||||
|
|
||||||
RubyPluginLaunchStrategy ruby = new RubyPluginLaunchStrategy();
|
RubyPluginLaunchStrategy ruby = new RubyPluginLaunchStrategy();
|
||||||
launchStrategies.put("rb", ruby);
|
LAUNCH_STRATEGIES.put("rb", ruby);
|
||||||
launchStrategies.put("ruby", ruby);
|
LAUNCH_STRATEGIES.put("ruby", ruby);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,10 +106,10 @@ public final class PluginManager
|
||||||
activePlugin = newPluginInstance;
|
activePlugin = newPluginInstance;
|
||||||
|
|
||||||
//clean the plugin list from dead threads
|
//clean the plugin list from dead threads
|
||||||
pluginInstances.removeIf(Plugin::isFinished);
|
PLUGIN_INSTANCES.removeIf(Plugin::isFinished);
|
||||||
|
|
||||||
//add to the list of running instances
|
//add to the list of running instances
|
||||||
pluginInstances.add(newPluginInstance);
|
PLUGIN_INSTANCES.add(newPluginInstance);
|
||||||
|
|
||||||
//start the plugin thread
|
//start the plugin thread
|
||||||
newPluginInstance.start();
|
newPluginInstance.start();
|
||||||
|
@ -124,10 +124,11 @@ public final class PluginManager
|
||||||
public static void runPlugin(File f) throws Throwable
|
public static void runPlugin(File f) throws Throwable
|
||||||
{
|
{
|
||||||
String ext = f.getName().substring(f.getName().lastIndexOf('.') + 1);
|
String ext = f.getName().substring(f.getName().lastIndexOf('.') + 1);
|
||||||
PluginLaunchStrategy strategy = launchStrategies.get(ext);
|
PluginLaunchStrategy strategy = LAUNCH_STRATEGIES.get(ext);
|
||||||
|
|
||||||
if (strategy == null)
|
if (strategy == null)
|
||||||
throw new RuntimeException(String.format("No launch strategy for extension %s (%s)", ext, f.getAbsolutePath()));
|
throw new RuntimeException(String.format("No launch strategy for extension %s (%s)",
|
||||||
|
ext, f.getAbsolutePath()));
|
||||||
|
|
||||||
Plugin p = strategy.run(f);
|
Plugin p = strategy.run(f);
|
||||||
|
|
||||||
|
@ -147,7 +148,9 @@ public final class PluginManager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name = activePlugin.activeContainer == null ? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1) : activePlugin.activeContainer.name;
|
final String name = activePlugin.activeContainer == null
|
||||||
|
? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1)
|
||||||
|
: activePlugin.activeContainer.name;
|
||||||
|
|
||||||
ExceptionUI existingUI = exceptionTabs.get(name);
|
ExceptionUI existingUI = exceptionTabs.get(name);
|
||||||
|
|
||||||
|
@ -198,22 +201,22 @@ public final class PluginManager
|
||||||
|
|
||||||
public static void register(String name, PluginLaunchStrategy strat)
|
public static void register(String name, PluginLaunchStrategy strat)
|
||||||
{
|
{
|
||||||
launchStrategies.put(name, strat);
|
LAUNCH_STRATEGIES.put(name, strat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> pluginExtensions()
|
public static Set<String> pluginExtensions()
|
||||||
{
|
{
|
||||||
return launchStrategies.keySet();
|
return LAUNCH_STRATEGIES.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, PluginLaunchStrategy> getLaunchStrategies()
|
public static Map<String, PluginLaunchStrategy> getLaunchStrategies()
|
||||||
{
|
{
|
||||||
return launchStrategies;
|
return LAUNCH_STRATEGIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileFilter fileFilter()
|
public static FileFilter fileFilter()
|
||||||
{
|
{
|
||||||
return filter;
|
return FILTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PluginFileFilter extends FileFilter
|
public static class PluginFileFilter extends FileFilter
|
||||||
|
|
|
@ -13,6 +13,17 @@ public class TokenUtil
|
||||||
public static Token getToken(final RSyntaxTextArea textArea, final @NotNull Token token)
|
public static Token getToken(final RSyntaxTextArea textArea, final @NotNull Token token)
|
||||||
{
|
{
|
||||||
String lexeme = token.getLexeme();
|
String lexeme = token.getLexeme();
|
||||||
return lexeme.isEmpty() || lexeme.equals(".") || lexeme.equals("(") || lexeme.equals(")") || lexeme.equals("[") || lexeme.equals("~") || lexeme.equals("-") || lexeme.equals("+") || lexeme.equals(" ") || lexeme.equals(";") || lexeme.equals(",") || lexeme.equals(">") ? textArea.modelToToken(textArea.getCaretPosition() - 1) : token;
|
return lexeme.isEmpty()
|
||||||
|
|| lexeme.equals(".")
|
||||||
|
|| lexeme.equals("(")
|
||||||
|
|| lexeme.equals(")")
|
||||||
|
|| lexeme.equals("[")
|
||||||
|
|| lexeme.equals("~")
|
||||||
|
|| lexeme.equals("-")
|
||||||
|
|| lexeme.equals("+")
|
||||||
|
|| lexeme.equals(" ")
|
||||||
|
|| lexeme.equals(";")
|
||||||
|
|| lexeme.equals(",")
|
||||||
|
|| lexeme.equals(">") ? textArea.modelToToken(textArea.getCaretPosition() - 1) : token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ public class APKExport implements Exporter
|
||||||
//if theres only one file in the container don't bother asking
|
//if theres only one file in the container don't bother asking
|
||||||
if (validContainers.size() >= 2)
|
if (validContainers.size() >= 2)
|
||||||
{
|
{
|
||||||
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Select APK", "Which file would you like to export as an APK?", validContainersNames.toArray(new String[0]));
|
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Select APK",
|
||||||
|
"Which file would you like to export as an APK?", validContainersNames.toArray(new String[0]));
|
||||||
|
|
||||||
//TODO may be off by one
|
//TODO may be off by one
|
||||||
container = (ResourceContainer) containers.stream().skip(dialog.promptChoice());
|
container = (ResourceContainer) containers.stream().skip(dialog.promptChoice());
|
||||||
|
@ -80,7 +81,8 @@ public class APKExport implements Exporter
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on." + "\n\nTip: Try exporting as DEX, it doesn't rely on decoded APK resources");
|
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on."
|
||||||
|
+ "\n\nTip: Try exporting as DEX, it doesn't rely on decoded APK resources");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +116,14 @@ public class APKExport implements Exporter
|
||||||
APKTool.buildAPK(new File(input), file, finalContainer);
|
APKTool.buildAPK(new File(input), file, finalContainer);
|
||||||
BytecodeViewer.updateBusyStatus(false);
|
BytecodeViewer.updateBusyStatus(false);
|
||||||
}, "Process APK");
|
}, "Process APK");
|
||||||
|
|
||||||
buildAPKThread.start();
|
buildAPKThread.start();
|
||||||
}, "Jar Export");
|
}, "Jar Export");
|
||||||
|
|
||||||
saveThread.start();
|
saveThread.start();
|
||||||
}
|
}
|
||||||
}, "Resource Export");
|
}, "Resource Export");
|
||||||
|
|
||||||
exportThread.start();
|
exportThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,11 +81,14 @@ public class DexExport implements Exporter
|
||||||
|
|
||||||
BytecodeViewer.updateBusyStatus(false);
|
BytecodeViewer.updateBusyStatus(false);
|
||||||
}, "Process DEX");
|
}, "Process DEX");
|
||||||
|
|
||||||
saveAsDex.start();
|
saveAsDex.start();
|
||||||
}, "Jar Export");
|
}, "Jar Export");
|
||||||
|
|
||||||
saveAsJar.start();
|
saveAsJar.start();
|
||||||
}
|
}
|
||||||
}, "Resource Export");
|
}, "Resource Export");
|
||||||
|
|
||||||
exportThread.start();
|
exportThread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class SecurityMan extends SecurityManager
|
||||||
//can only write into BCV dir, so anything executing from here has probably been dropped
|
//can only write into BCV dir, so anything executing from here has probably been dropped
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (normalizedPath.startsWith(Constants.BCVDir.getCanonicalPath().toLowerCase()))
|
if (normalizedPath.startsWith(Constants.BCV_DIR.getCanonicalPath().toLowerCase()))
|
||||||
blocked = true;
|
blocked = true;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -373,7 +373,7 @@ public class SecurityMan extends SecurityManager
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//can only write into BCV dir
|
//can only write into BCV dir
|
||||||
if (file.startsWith(Constants.BCVDir.getCanonicalPath()))
|
if (file.startsWith(Constants.BCV_DIR.getCanonicalPath()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//can only write into system temp
|
//can only write into system temp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user