Plugin Cleanup

This commit is contained in:
Konloch 2021-07-06 13:47:34 -07:00
parent 5509a659fb
commit b2d37f6adb
4 changed files with 60 additions and 35 deletions

View file

@ -37,25 +37,34 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
* @author Konloch
*/
public class ShowAllStrings extends Plugin {
public class ShowAllStrings extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
public void execute(ArrayList<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Show All Strings");
StringBuilder sb = new StringBuilder();
for (ClassNode classNode : classNodeList) {
for (Object o : classNode.fields.toArray()) {
for (ClassNode classNode : classNodeList)
{
for (Object o : classNode.fields.toArray())
{
FieldNode f = (FieldNode) o;
Object v = f.value;
if (v instanceof String) {
if (v instanceof String)
{
String s = (String) v;
if (!s.isEmpty())
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append(" -> \"")
.append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r"))
.append("\"").append(nl);
}
if (v instanceof String[]) {
for (int i = 0; i < ((String[]) v).length; i++) {
if (v instanceof String[])
{
for (int i = 0; i < ((String[]) v).length; i++)
{
String s = ((String[]) v)[i];
if (!s.isEmpty())
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append("[").append(i)
@ -65,13 +74,17 @@ public class ShowAllStrings extends Plugin {
}
}
for (Object o : classNode.methods.toArray()) {
for (Object o : classNode.methods.toArray())
{
MethodNode m = (MethodNode) o;
InsnList iList = m.instructions;
for (AbstractInsnNode a : iList.toArray()) {
if (a instanceof LdcInsnNode) {
if (((LdcInsnNode) a).cst instanceof String) {
for (AbstractInsnNode a : iList.toArray())
{
if (a instanceof LdcInsnNode)
{
if (((LdcInsnNode) a).cst instanceof String)
{
final String s = (String) ((LdcInsnNode) a).cst;
if (!s.isEmpty())
sb.append(classNode.name).append(".").append(m.name).append(m.desc).append(" -> \"")
@ -86,4 +99,4 @@ public class ShowAllStrings extends Plugin {
frame.appendText(sb.toString());
frame.setVisible(true);
}
}
}

View file

@ -32,19 +32,26 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
* @author Sh1ftchg
*/
public class ShowMainMethods extends Plugin {
public class ShowMainMethods extends Plugin
{
private static final int PUBLIC_STATIC = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC;
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
public void execute(ArrayList<ClassNode> classNodeList)
{
PluginConsole frame = new PluginConsole("Show Main Methods");
StringBuilder sb = new StringBuilder();
for (ClassNode classNode : classNodeList) {
for (Object o : classNode.methods.toArray()) {
for (ClassNode classNode : classNodeList)
{
for (Object o : classNode.methods.toArray())
{
MethodNode m = (MethodNode) o;
if ((m.access & (PUBLIC_STATIC)) == PUBLIC_STATIC) {
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V")) {
if ((m.access & (PUBLIC_STATIC)) == PUBLIC_STATIC)
{
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V"))
{
sb.append(classNode.name);
sb.append(".");
sb.append(m.name);
@ -55,11 +62,10 @@ public class ShowMainMethods extends Plugin {
}
}
if (sb.length() == 0) {
if (sb.length() == 0)
frame.appendText("No main methods found.");
} else {
else
frame.appendText(sb.toString());
}
frame.setVisible(true);
}

View file

@ -9,16 +9,21 @@ import org.objectweb.asm.tree.MethodNode;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
public class StackFramesRemover extends Plugin {
public class StackFramesRemover extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
public void execute(ArrayList<ClassNode> classNodeList)
{
AtomicInteger counter = new AtomicInteger();
PluginConsole frame = new PluginConsole("StackFrames Remover");
for (ClassNode cn : classNodeList) {
for (MethodNode mn : cn.methods) {
for (AbstractInsnNode insn : mn.instructions.toArray()) {
if (insn instanceof FrameNode) {
for (ClassNode cn : classNodeList)
{
for (MethodNode mn : cn.methods)
{
for (AbstractInsnNode insn : mn.instructions.toArray())
{
if (insn instanceof FrameNode)
{
mn.instructions.remove(insn);
counter.incrementAndGet();
}
@ -29,4 +34,4 @@ public class StackFramesRemover extends Plugin {
frame.appendText(String.format("Removed %s stackframes.", counter));
frame.setVisible(true);
}
}
}

View file

@ -29,10 +29,11 @@ import the.bytecode.club.bytecodeviewer.api.Plugin;
* @author Konloch
*/
public class ZKMStringDecrypter extends Plugin {
public class ZKMStringDecrypter extends Plugin
{
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
public void execute(ArrayList<ClassNode> classNodeList)
{
BytecodeViewer.showMessage("This is a planned feature.");
}
}
}