Print the re-mapping of classes/methods/fields

This commit is contained in:
im-frizzy 2015-02-28 22:10:45 -06:00
parent f01a11e8bb
commit d4611106cb

AI 샘플 코드 생성 중입니다

Loading...
5 changed files with 40 additions and 5 deletions

View File

@ -340,6 +340,8 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
private final JSeparator separator_6 = new JSeparator();
public final JCheckBoxMenuItem refreshOnChange = new JCheckBoxMenuItem("Refresh On View Change");
public FileNavigationPane cn = new FileNavigationPane(this);
public boolean isMaximized = false;
public void removed(boolean busy) {
@ -1434,6 +1436,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
}
new RenameFields().start();
workPane.refreshClass.doClick();
cn.tree.updateUI();
}
});
@ -1455,6 +1458,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
}
new RenameMethods().start();
workPane.refreshClass.doClick();
cn.tree.updateUI();
}
});
@ -1467,6 +1471,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
}
new RenameClasses().start();
workPane.refreshClass.doClick();
cn.tree.updateUI();
}
});
@ -1575,7 +1580,6 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
// scrollPane.setViewportView(tree);
FileNavigationPane cn = new FileNavigationPane(this);
cn.setMinimumSize(new Dimension(200, 50));
// panel.add(cn);
SearchingPane s = new SearchingPane(this);

View File

@ -43,6 +43,9 @@ public abstract class JavaObfuscator extends Thread {
String name = "";
while (!found) {
String nameTry = MiscUtils.randomString(1) + MiscUtils.randomStringNum(length - 1);
if (!Character.isJavaIdentifierStart(nameTry.toCharArray()[0]))
continue;
if (!names.contains(nameTry)) {
names.add(nameTry);
name = nameTry;

View File

@ -1,6 +1,8 @@
package the.bytecode.club.bytecodeviewer.obfuscators.mapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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, MethodMappingData> sortedMethods;
protected final Map<String, FieldMappingData> sortedFields;
protected final List<String> mappingList;
private StringBuilder builder;
public RefactorMapper(HookMap hookMap) {
sortedClasses = new HashMap<>();
sortedMethods = new HashMap<>();
sortedFields = new HashMap<>();
mappingList = new ArrayList<>();
builder = new StringBuilder();
for(MappingData hook : hookMap.getClasses()){
if(hook.getObfuscatedName().contains("$"))
continue;
@ -46,24 +53,44 @@ public class RefactorMapper extends Remapper {
@Override
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 type;
}
@Override
public String mapFieldName(String owner, String name, String 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();
}
return name;
}
@Override
public String mapMethodName(String owner, String name, String 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();
}
return name;
}
public void printMap() {
for (String map : mappingList) {
builder.append(map);
}
System.out.println(builder.toString());
}
}

View File

@ -45,6 +45,7 @@ public class Refactorer {
for (Map.Entry<String, ClassNode> factor : refactored.entrySet()) {
BytecodeViewer.relocate(factor.getKey(), factor.getValue());
}
mapper.printMap();
}
private byte[] getClassNodeBytes(ClassNode cn) {

View File

@ -22,7 +22,7 @@ public class RenameClasses extends JavaObfuscator {
@Override
public void obfuscate() {
int stringLength = getStringLength();
int stringLength = 5;//getStringLength();
System.out.println("Obfuscating class names...");
classLoop: for (ClassNode c : BytecodeViewer.getLoadedClasses()) {