RCE Blocking Rename

This commit is contained in:
Konloch 2021-07-06 20:42:48 -07:00
parent 4af4764a71
commit 02115c4820
10 changed files with 49 additions and 39 deletions

View File

@ -249,7 +249,7 @@ public class BytecodeViewer
*/
public static synchronized String getJavaCommand()
{
sm.stopBlocking();
sm.pauseBlocking();
try
{
ProcessBuilder pb = new ProcessBuilder("java", "-version");
@ -258,7 +258,7 @@ public class BytecodeViewer
}
catch (Exception e) //ignore
{
sm.setBlocking();
sm.resumeBlocking();
boolean empty = Configuration.java.isEmpty();
while (empty)
{
@ -270,7 +270,7 @@ public class BytecodeViewer
}
finally
{
sm.setBlocking();
sm.resumeBlocking();
}
return Configuration.java;

View File

@ -1,16 +1,6 @@
package the.bytecode.club.bytecodeviewer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import me.konloch.kontainer.io.DiskReader;
import me.konloch.kontainer.io.DiskWriter;
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* General program constants, to use this class include everything as a wildcard static import:
@ -78,13 +68,13 @@ public class Constants
*/
private static void hideFile(File f)
{
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
// Hide file by running attrib system command (on Windows)
Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath());
} catch (Exception e) {
BytecodeViewer.handleException(e);
}
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
}

View File

@ -30,13 +30,33 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
***************************************************************************/
/**
* Used to rename/replace methods/classes/fields loaded as a BCV resource
* Used to interact with classnodes loaded inside of BCV as resources
*
* @author Konloch
*/
public final class ASMRenameUtil
public final class ASMResourceUtil
{
/**
* Attempts to a method main inside of the loaded resources and returns the fully qualified name
*/
public static String findMainMethod(String defaultFQN)
{
for (ClassNode cn : BytecodeViewer.getLoadedClasses())
{
for (Object o : cn.methods.toArray())
{
MethodNode m = (MethodNode) o;
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V"))
{
return cn.name + "." + m.name;
}
}
}
return defaultFQN;
}
public static void renameFieldNode(String originalParentName,
String originalFieldName, String originalFieldDesc,

View File

@ -67,7 +67,7 @@ public class JavaCompiler extends InternalCompiler
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), cp.getAbsolutePath());
boolean cont = true;
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
StringBuilder log = new StringBuilder();
ProcessBuilder pb;
@ -142,7 +142,7 @@ public class JavaCompiler extends InternalCompiler
cont = false;
e.printStackTrace();
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
cp.delete();

View File

@ -72,7 +72,7 @@ public class KrakatauAssembler extends InternalCompiler
StringBuilder log = new StringBuilder();
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try
{
ProcessBuilder pb = new ProcessBuilder(
@ -120,7 +120,7 @@ public class KrakatauAssembler extends InternalCompiler
e.printStackTrace();
//BytecodeViewer.handleException(log.toString());
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
return null;

View File

@ -91,14 +91,14 @@ public class FernFlowerDecompiler extends InternalDecompiler
generateMainMethod(tempClass.getAbsolutePath(),
new File(tempDirectory).getAbsolutePath())
));
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
Process p = pb.start();
BytecodeViewer.createdProcesses.add(p);
p.waitFor();
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
} else {
try {

View File

@ -91,7 +91,7 @@ public class KrakatauDecompiler extends InternalDecompiler
String s = "Bytecode Viewer Version: " + VERSION + nl + nl +
"Please send this to konloch@gmail.com. " + nl + nl;
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
@ -141,7 +141,7 @@ public class KrakatauDecompiler extends InternalDecompiler
e.printStackTrace();
s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw;
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
return s;
@ -178,7 +178,7 @@ public class KrakatauDecompiler extends InternalDecompiler
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
@ -232,7 +232,7 @@ public class KrakatauDecompiler extends InternalDecompiler
e.printStackTrace();
s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw;
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
return s;
@ -259,7 +259,7 @@ public class KrakatauDecompiler extends InternalDecompiler
final File tempJar = new File(sourceJar);
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
@ -284,7 +284,7 @@ public class KrakatauDecompiler extends InternalDecompiler
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
}
}

View File

@ -59,7 +59,7 @@ public class KrakatauDisassembler extends InternalDecompiler
String s = "Bytecode Viewer Version: " + VERSION + nl + nl +
"Please send this to konloch@gmail.com. " + nl + nl;
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
@ -108,7 +108,7 @@ public class KrakatauDisassembler extends InternalDecompiler
e.printStackTrace();
s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw;
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
return s;
}
@ -133,7 +133,7 @@ public class KrakatauDisassembler extends InternalDecompiler
final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
@ -181,7 +181,7 @@ public class KrakatauDisassembler extends InternalDecompiler
e.printStackTrace();
s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw;
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
return s;
}
@ -199,7 +199,7 @@ public class KrakatauDisassembler extends InternalDecompiler
final File tempJar = new File(sourceJar);
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python,
@ -220,7 +220,7 @@ public class KrakatauDisassembler extends InternalDecompiler
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
}
}

View File

@ -68,10 +68,10 @@ public class APKTool {
//save entire jar as smali files
System.out.println("Building!");
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
brut.apktool.Main.main(new String[]{"b", container.APKToolContents.getAbsolutePath(), "--frame-path",
tempAPKPath.getAbsolutePath(), "-o", output.getAbsolutePath()});
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
tempAPKPath.delete();
} catch (Exception e) {
BytecodeViewer.handleException(e);

View File

@ -49,7 +49,7 @@ public class Enjarify {
return;
}
BytecodeViewer.sm.stopBlocking();
BytecodeViewer.sm.pauseBlocking();
try {
ProcessBuilder pb = new ProcessBuilder(
Configuration.python3,
@ -71,7 +71,7 @@ public class Enjarify {
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.setBlocking();
BytecodeViewer.sm.resumeBlocking();
}
}
}