mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Fixed a bug with obfuscated names
This commit is contained in:
1 parent
123ad89c0d
commit
d6b7aeec73
3 files changed
+42
-39
No files matched your search
@@ -27,6 +27,7 @@ import org.objectweb.asm.tree.MethodNode;
|
|||||||
|
|
||||||
import me.ByteEdit.boxes.GlobalSearchOpenBox.Info;
|
import me.ByteEdit.boxes.GlobalSearchOpenBox.Info;
|
||||||
import me.ByteEdit.main.Main;
|
import me.ByteEdit.main.Main;
|
||||||
|
import me.ByteEdit.utils.UnicodeUtils;
|
||||||
|
|
||||||
public class GlobalSearchBox extends JFrame {
|
public class GlobalSearchBox extends JFrame {
|
||||||
|
|
||||||
@@ -160,9 +161,9 @@ public class GlobalSearchBox extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String owner = txtOwner.getText();
|
String owner = UnicodeUtils.unescape(txtOwner.getText());
|
||||||
String name = txtName.getText();
|
String name = UnicodeUtils.unescape(txtName.getText());
|
||||||
String desc = txtDesc.getText();
|
String desc = UnicodeUtils.unescape(txtDesc.getText());
|
||||||
for (ClassNode cn : Main.classNodes.values()) {
|
for (ClassNode cn : Main.classNodes.values()) {
|
||||||
for (MethodNode mn : cn.methods) {
|
for (MethodNode mn : cn.methods) {
|
||||||
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
for (AbstractInsnNode insn : mn.instructions.toArray()) {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package me.ByteEdit.main;
|
||||||
|
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
|
public class ByteEditTreeNode extends DefaultMutableTreeNode {
|
||||||
|
|
||||||
|
public String path;
|
||||||
|
|
||||||
|
public ByteEditTreeNode(String name) {
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteEditTreeNode(String name, String path) {
|
||||||
|
this(name);
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,7 +49,6 @@ import javax.swing.event.TreeSelectionEvent;
|
|||||||
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.event.TreeSelectionListener;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
|
||||||
@@ -257,19 +256,7 @@ public class Main extends JFrame {
|
|||||||
} else if (e.getKeyCode() == 127) { // del
|
} else if (e.getKeyCode() == 127) { // del
|
||||||
if (tree.getSelectionPath() == null)
|
if (tree.getSelectionPath() == null)
|
||||||
return;
|
return;
|
||||||
String s = "";
|
String s = ((ByteEditTreeNode) tree.getSelectionPath().getLastPathComponent()).path;
|
||||||
boolean b = false;
|
|
||||||
for (Object o : tree.getSelectionPath().getPath()) {
|
|
||||||
DefaultMutableTreeNode path = (DefaultMutableTreeNode) o;
|
|
||||||
if (!b) {
|
|
||||||
b = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
s += (s.isEmpty() || s.replace("/", "").isEmpty() ? "" : "/")
|
|
||||||
+ (path.toString().isEmpty() ? "/" : path.toString());
|
|
||||||
}
|
|
||||||
if (s.isEmpty() || s.endsWith("/"))
|
|
||||||
return;
|
|
||||||
if (JOptionPane.showConfirmDialog(INSTANCE, "Do you want to delete\n\"" + s + "\"?", "Delete",
|
if (JOptionPane.showConfirmDialog(INSTANCE, "Do you want to delete\n\"" + s + "\"?", "Delete",
|
||||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
String substr = s.substring(0, s.length() - 6);
|
String substr = s.substring(0, s.length() - 6);
|
||||||
@@ -308,18 +295,7 @@ public class Main extends JFrame {
|
|||||||
|
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
if (!isChangingFile) {
|
if (!isChangingFile) {
|
||||||
String s = "";
|
selectFile(((ByteEditTreeNode) e.getPath().getLastPathComponent()).path);
|
||||||
boolean b = false;
|
|
||||||
for (Object o : e.getPath().getPath()) {
|
|
||||||
DefaultMutableTreeNode path = (DefaultMutableTreeNode) o;
|
|
||||||
if (!b) {
|
|
||||||
b = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
s += (s.isEmpty() || s.replace("/", "").isEmpty() ? "" : "/")
|
|
||||||
+ (path.toString().isEmpty() ? "/" : path.toString());
|
|
||||||
}
|
|
||||||
selectFile(s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -555,6 +531,10 @@ public class Main extends JFrame {
|
|||||||
String[] nameSplit = className.split("/");
|
String[] nameSplit = className.split("/");
|
||||||
String methodName = nameSplit[nameSplit.length - 1];
|
String methodName = nameSplit[nameSplit.length - 1];
|
||||||
className = className.substring(0, className.length() - methodName.length() - 1);
|
className = className.substring(0, className.length() - methodName.length() - 1);
|
||||||
|
while (className.endsWith("/")) {
|
||||||
|
methodName = "/" + methodName;
|
||||||
|
className = className.substring(0, className.length() - 1);
|
||||||
|
}
|
||||||
ClassNode classNode = classNodes.get(className + ".class");
|
ClassNode classNode = classNodes.get(className + ".class");
|
||||||
if (classNode == null) {
|
if (classNode == null) {
|
||||||
return;
|
return;
|
||||||
@@ -587,6 +567,10 @@ public class Main extends JFrame {
|
|||||||
String[] nameSplit = className.split("/");
|
String[] nameSplit = className.split("/");
|
||||||
String fieldName = nameSplit[nameSplit.length - 1];
|
String fieldName = nameSplit[nameSplit.length - 1];
|
||||||
className = className.substring(0, className.length() - fieldName.length() - 1);
|
className = className.substring(0, className.length() - fieldName.length() - 1);
|
||||||
|
while (className.endsWith("/")) {
|
||||||
|
fieldName = "/" + fieldName;
|
||||||
|
className = className.substring(0, className.length() - 1);
|
||||||
|
}
|
||||||
ClassNode classNode = classNodes.get(className + ".class");
|
ClassNode classNode = classNodes.get(className + ".class");
|
||||||
if (classNode == null) {
|
if (classNode == null) {
|
||||||
return;
|
return;
|
||||||
@@ -652,8 +636,8 @@ public class Main extends JFrame {
|
|||||||
String[] split = s.split(" ");
|
String[] split = s.split(" ");
|
||||||
String className = UnicodeUtils.unescape(split[split.length - 1]);
|
String className = UnicodeUtils.unescape(split[split.length - 1]);
|
||||||
renameBox.className = className;
|
renameBox.className = className;
|
||||||
String name = m.pattern() == renameableFieldPattern ? m.group(2) : m.group(1);
|
String name = UnicodeUtils.unescape(m.pattern() == renameableFieldPattern ? m.group(2) : m.group(1));
|
||||||
String desc = m.pattern() == renameableFieldPattern ? m.group(1) : m.group(2);
|
String desc = UnicodeUtils.unescape(m.pattern() == renameableFieldPattern ? m.group(1) : m.group(2));
|
||||||
renameBox.name = name;
|
renameBox.name = name;
|
||||||
renameBox.desc = desc;
|
renameBox.desc = desc;
|
||||||
renameBox.txtName.setText(name);
|
renameBox.txtName.setText(name);
|
||||||
@@ -833,12 +817,12 @@ public class Main extends JFrame {
|
|||||||
public boolean newCreated = false;
|
public boolean newCreated = false;
|
||||||
|
|
||||||
public ArchiveTreeModel() {
|
public ArchiveTreeModel() {
|
||||||
super(new DefaultMutableTreeNode("New"));
|
super(new ByteEditTreeNode("New"));
|
||||||
newCreated = true;
|
newCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArchiveTreeModel(JarFile jar) {
|
public ArchiveTreeModel(JarFile jar) {
|
||||||
super(new DefaultMutableTreeNode(jar.getName().split(File.separator.equals("\\") ? "\\\\"
|
super(new ByteEditTreeNode(jar.getName().split(File.separator.equals("\\") ? "\\\\"
|
||||||
: File.separator)[jar.getName().split(File.separator.equals("\\") ? "\\\\" : File.separator).length
|
: File.separator)[jar.getName().split(File.separator.equals("\\") ? "\\\\" : File.separator).length
|
||||||
- 1]));
|
- 1]));
|
||||||
try {
|
try {
|
||||||
@@ -882,16 +866,16 @@ public class Main extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
setRoot(new DefaultMutableTreeNode(((DefaultMutableTreeNode) getRoot()).toString()));
|
setRoot(new ByteEditTreeNode(((ByteEditTreeNode) getRoot()).toString()));
|
||||||
Collections.sort(paths);
|
Collections.sort(paths);
|
||||||
for (String s : paths) {
|
for (String s : paths) {
|
||||||
String[] elements = s.split("/");
|
String[] elements = s.split("/");
|
||||||
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) getRoot();
|
ByteEditTreeNode currentNode = (ByteEditTreeNode) getRoot();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
String token = elements[i];
|
String token = elements[i];
|
||||||
DefaultMutableTreeNode nextNode = findNode(currentNode, token);
|
ByteEditTreeNode nextNode = findNode(currentNode, token);
|
||||||
if (nextNode == null) {
|
if (nextNode == null) {
|
||||||
nextNode = new DefaultMutableTreeNode(token);
|
nextNode = new ByteEditTreeNode(token, s);
|
||||||
currentNode.add(nextNode);
|
currentNode.add(nextNode);
|
||||||
}
|
}
|
||||||
currentNode = nextNode;
|
currentNode = nextNode;
|
||||||
@@ -899,10 +883,10 @@ public class Main extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DefaultMutableTreeNode findNode(DefaultMutableTreeNode parent, String name) {
|
private ByteEditTreeNode findNode(ByteEditTreeNode parent, String name) {
|
||||||
Enumeration<?> e = parent.children();
|
Enumeration<?> e = parent.children();
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
DefaultMutableTreeNode element = (DefaultMutableTreeNode) e.nextElement();
|
ByteEditTreeNode element = (ByteEditTreeNode) e.nextElement();
|
||||||
if (element.getUserObject().equals(name)) {
|
if (element.getUserObject().equals(name)) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user