Print the re-mapping of classes/methods/fields
This commit is contained in:
parent
f01a11e8bb
commit
d4611106cb
5 changed files with 40 additions and 5 deletions
|
@ -340,6 +340,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
private final JSeparator separator_6 = new JSeparator();
|
private final JSeparator separator_6 = new JSeparator();
|
||||||
public final JCheckBoxMenuItem refreshOnChange = new JCheckBoxMenuItem("Refresh On View Change");
|
public final JCheckBoxMenuItem refreshOnChange = new JCheckBoxMenuItem("Refresh On View Change");
|
||||||
|
|
||||||
|
public FileNavigationPane cn = new FileNavigationPane(this);
|
||||||
|
|
||||||
public boolean isMaximized = false;
|
public boolean isMaximized = false;
|
||||||
|
|
||||||
public void removed(boolean busy) {
|
public void removed(boolean busy) {
|
||||||
|
@ -1434,6 +1436,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
}
|
}
|
||||||
new RenameFields().start();
|
new RenameFields().start();
|
||||||
workPane.refreshClass.doClick();
|
workPane.refreshClass.doClick();
|
||||||
|
cn.tree.updateUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1455,6 +1458,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
}
|
}
|
||||||
new RenameMethods().start();
|
new RenameMethods().start();
|
||||||
workPane.refreshClass.doClick();
|
workPane.refreshClass.doClick();
|
||||||
|
cn.tree.updateUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1467,6 +1471,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
}
|
}
|
||||||
new RenameClasses().start();
|
new RenameClasses().start();
|
||||||
workPane.refreshClass.doClick();
|
workPane.refreshClass.doClick();
|
||||||
|
cn.tree.updateUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1575,7 +1580,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
|
new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
|
||||||
|
|
||||||
// scrollPane.setViewportView(tree);
|
// scrollPane.setViewportView(tree);
|
||||||
FileNavigationPane cn = new FileNavigationPane(this);
|
|
||||||
cn.setMinimumSize(new Dimension(200, 50));
|
cn.setMinimumSize(new Dimension(200, 50));
|
||||||
// panel.add(cn);
|
// panel.add(cn);
|
||||||
SearchingPane s = new SearchingPane(this);
|
SearchingPane s = new SearchingPane(this);
|
||||||
|
|
|
@ -43,6 +43,9 @@ public abstract class JavaObfuscator extends Thread {
|
||||||
String name = "";
|
String name = "";
|
||||||
while (!found) {
|
while (!found) {
|
||||||
String nameTry = MiscUtils.randomString(1) + MiscUtils.randomStringNum(length - 1);
|
String nameTry = MiscUtils.randomString(1) + MiscUtils.randomStringNum(length - 1);
|
||||||
|
if (!Character.isJavaIdentifierStart(nameTry.toCharArray()[0]))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!names.contains(nameTry)) {
|
if (!names.contains(nameTry)) {
|
||||||
names.add(nameTry);
|
names.add(nameTry);
|
||||||
name = nameTry;
|
name = nameTry;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package the.bytecode.club.bytecodeviewer.obfuscators.mapping;
|
package the.bytecode.club.bytecodeviewer.obfuscators.mapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.objectweb.asm.commons.Remapper;
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
@ -17,11 +19,16 @@ public class RefactorMapper extends Remapper {
|
||||||
protected final Map<String, MappingData> sortedClasses;
|
protected final Map<String, MappingData> sortedClasses;
|
||||||
protected final Map<String, MethodMappingData> sortedMethods;
|
protected final Map<String, MethodMappingData> sortedMethods;
|
||||||
protected final Map<String, FieldMappingData> sortedFields;
|
protected final Map<String, FieldMappingData> sortedFields;
|
||||||
|
protected final List<String> mappingList;
|
||||||
|
|
||||||
|
private StringBuilder builder;
|
||||||
|
|
||||||
public RefactorMapper(HookMap hookMap) {
|
public RefactorMapper(HookMap hookMap) {
|
||||||
sortedClasses = new HashMap<>();
|
sortedClasses = new HashMap<>();
|
||||||
sortedMethods = new HashMap<>();
|
sortedMethods = new HashMap<>();
|
||||||
sortedFields = new HashMap<>();
|
sortedFields = new HashMap<>();
|
||||||
|
mappingList = new ArrayList<>();
|
||||||
|
builder = new StringBuilder();
|
||||||
for(MappingData hook : hookMap.getClasses()){
|
for(MappingData hook : hookMap.getClasses()){
|
||||||
if(hook.getObfuscatedName().contains("$"))
|
if(hook.getObfuscatedName().contains("$"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -46,24 +53,44 @@ public class RefactorMapper extends Remapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String map(String type) {
|
public String map(String type) {
|
||||||
if (sortedClasses.containsKey(type))
|
if (sortedClasses.containsKey(type)) {
|
||||||
|
String map = new String(type + " --> " + sortedClasses.get(type).getRefactoredName() + "\n");
|
||||||
|
if (!mappingList.contains(map))
|
||||||
|
mappingList.add(map);
|
||||||
|
|
||||||
return sortedClasses.get(type).getRefactoredName();
|
return sortedClasses.get(type).getRefactoredName();
|
||||||
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String mapFieldName(String owner, String name, String desc) {
|
public String mapFieldName(String owner, String name, String desc) {
|
||||||
String obfKey = owner + "$$$$" + name + "$$$$" + desc;
|
String obfKey = owner + "$$$$" + name + "$$$$" + desc;
|
||||||
if (sortedFields.containsKey(obfKey))
|
if (sortedFields.containsKey(obfKey)) {
|
||||||
|
String map = new String(owner + "." + name + " --> " + owner + sortedFields.get(obfKey).getName().getRefactoredName() + "\n");
|
||||||
|
if (!mappingList.contains(map))
|
||||||
|
mappingList.add(map);
|
||||||
name = sortedFields.get(obfKey).getName().getRefactoredName();
|
name = sortedFields.get(obfKey).getName().getRefactoredName();
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String mapMethodName(String owner, String name, String desc) {
|
public String mapMethodName(String owner, String name, String desc) {
|
||||||
String obfKey = owner + "$$$$" + name + "$$$$" + desc;
|
String obfKey = owner + "$$$$" + name + "$$$$" + desc;
|
||||||
if (sortedMethods.containsKey(obfKey))
|
if (sortedMethods.containsKey(obfKey)) {
|
||||||
|
String map = new String(owner + "." + name + " --> " + owner + sortedMethods.get(obfKey).getMethodName().getRefactoredName() + "\n");
|
||||||
|
if (!mappingList.contains(map))
|
||||||
|
mappingList.add(map);
|
||||||
name = sortedMethods.get(obfKey).getMethodName().getRefactoredName();
|
name = sortedMethods.get(obfKey).getMethodName().getRefactoredName();
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printMap() {
|
||||||
|
for (String map : mappingList) {
|
||||||
|
builder.append(map);
|
||||||
|
}
|
||||||
|
System.out.println(builder.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public class Refactorer {
|
||||||
for (Map.Entry<String, ClassNode> factor : refactored.entrySet()) {
|
for (Map.Entry<String, ClassNode> factor : refactored.entrySet()) {
|
||||||
BytecodeViewer.relocate(factor.getKey(), factor.getValue());
|
BytecodeViewer.relocate(factor.getKey(), factor.getValue());
|
||||||
}
|
}
|
||||||
|
mapper.printMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getClassNodeBytes(ClassNode cn) {
|
private byte[] getClassNodeBytes(ClassNode cn) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class RenameClasses extends JavaObfuscator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void obfuscate() {
|
public void obfuscate() {
|
||||||
int stringLength = getStringLength();
|
int stringLength = 5;//getStringLength();
|
||||||
|
|
||||||
System.out.println("Obfuscating class names...");
|
System.out.println("Obfuscating class names...");
|
||||||
classLoop: for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
classLoop: for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue