From 902b1b519f8ae89910f6f0d9f077738711349324 Mon Sep 17 00:00:00 2001 From: Cuchaz Date: Mon, 23 Mar 2015 16:26:44 -0400 Subject: add protectifier! Muwahahaha!!! --- src/cuchaz/enigma/Deobfuscator.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/cuchaz/enigma/Deobfuscator.java') diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index b63f163..82ce6a2 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java @@ -45,6 +45,7 @@ import cuchaz.enigma.analysis.JarIndex; import cuchaz.enigma.analysis.SourceIndex; import cuchaz.enigma.analysis.SourceIndexVisitor; import cuchaz.enigma.analysis.Token; +import cuchaz.enigma.bytecode.ClassProtectifier; import cuchaz.enigma.mapping.ArgumentEntry; import cuchaz.enigma.mapping.BehaviorEntry; import cuchaz.enigma.mapping.ClassEntry; @@ -357,6 +358,37 @@ public class Deobfuscator { } } + public void protectifyJar(File out, ProgressListener progress) { + try (JarOutputStream outJar = new JarOutputStream(new FileOutputStream(out))) { + if (progress != null) { + progress.init(JarClassIterator.getClassEntries(m_jar).size(), "Protectifying classes..."); + } + + int i = 0; + for (CtClass c : JarClassIterator.classes(m_jar)) { + if (progress != null) { + progress.onProgress(i++, c.getName()); + } + + try { + c = ClassProtectifier.protectify(c); + outJar.putNextEntry(new JarEntry(c.getName().replace('.', '/') + ".class")); + outJar.write(c.toBytecode()); + outJar.closeEntry(); + } catch (Throwable t) { + throw new Error("Unable to protectify class " + c.getName(), t); + } + } + if (progress != null) { + progress.onProgress(i, "Done!"); + } + + outJar.close(); + } catch (IOException ex) { + throw new Error("Unable to write to Jar file!"); + } + } + public T obfuscateEntry(T deobfEntry) { if (deobfEntry == null) { return null; -- cgit v1.2.3