diff options
| author | 2014-08-10 18:12:20 -0400 | |
|---|---|---|
| committer | 2014-08-10 18:12:20 -0400 | |
| commit | 1ea27e61b915e944f6015d1711b89b9809ddff9f (patch) | |
| tree | a177116fc66d8c3147b39ce778758a670e097551 /src/cuchaz | |
| parent | improved keyboard shortcuts (diff) | |
| download | enigma-1ea27e61b915e944f6015d1711b89b9809ddff9f.tar.gz enigma-1ea27e61b915e944f6015d1711b89b9809ddff9f.tar.xz enigma-1ea27e61b915e944f6015d1711b89b9809ddff9f.zip | |
filter out tokens that are not obfuscated
Diffstat (limited to 'src/cuchaz')
| -rw-r--r-- | src/cuchaz/enigma/Deobfuscator.java | 77 |
1 files changed, 16 insertions, 61 deletions
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index 8eda889f..16c11d3f 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java | |||
| @@ -22,22 +22,15 @@ import java.util.jar.JarEntry; | |||
| 22 | import java.util.jar.JarFile; | 22 | import java.util.jar.JarFile; |
| 23 | 23 | ||
| 24 | import com.google.common.collect.Lists; | 24 | import com.google.common.collect.Lists; |
| 25 | import com.strobel.assembler.metadata.MemberReference; | ||
| 26 | import com.strobel.assembler.metadata.MetadataSystem; | 25 | import com.strobel.assembler.metadata.MetadataSystem; |
| 27 | import com.strobel.assembler.metadata.TypeDefinition; | 26 | import com.strobel.assembler.metadata.TypeDefinition; |
| 28 | import com.strobel.componentmodel.Key; | ||
| 29 | import com.strobel.decompiler.DecompilerContext; | 27 | import com.strobel.decompiler.DecompilerContext; |
| 30 | import com.strobel.decompiler.DecompilerSettings; | 28 | import com.strobel.decompiler.DecompilerSettings; |
| 31 | import com.strobel.decompiler.PlainTextOutput; | 29 | import com.strobel.decompiler.PlainTextOutput; |
| 32 | import com.strobel.decompiler.languages.java.JavaOutputVisitor; | 30 | import com.strobel.decompiler.languages.java.JavaOutputVisitor; |
| 33 | import com.strobel.decompiler.languages.java.ast.AstBuilder; | 31 | import com.strobel.decompiler.languages.java.ast.AstBuilder; |
| 34 | import com.strobel.decompiler.languages.java.ast.AstNode; | ||
| 35 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; | 32 | import com.strobel.decompiler.languages.java.ast.CompilationUnit; |
| 36 | import com.strobel.decompiler.languages.java.ast.Identifier; | ||
| 37 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; | 33 | import com.strobel.decompiler.languages.java.ast.InsertParenthesesVisitor; |
| 38 | import com.strobel.decompiler.languages.java.ast.InvocationExpression; | ||
| 39 | import com.strobel.decompiler.languages.java.ast.Keys; | ||
| 40 | import com.strobel.decompiler.languages.java.ast.MemberReferenceExpression; | ||
| 41 | 34 | ||
| 42 | import cuchaz.enigma.analysis.SourceIndex; | 35 | import cuchaz.enigma.analysis.SourceIndex; |
| 43 | import cuchaz.enigma.analysis.SourceIndexVisitor; | 36 | import cuchaz.enigma.analysis.SourceIndexVisitor; |
| @@ -203,58 +196,6 @@ public class Deobfuscator | |||
| 203 | return index; | 196 | return index; |
| 204 | } | 197 | } |
| 205 | 198 | ||
| 206 | private void dump( AstNode node, int depth ) | ||
| 207 | { | ||
| 208 | StringBuilder buf = new StringBuilder(); | ||
| 209 | for( int i=0; i<depth; i++ ) | ||
| 210 | { | ||
| 211 | buf.append( "\t" ); | ||
| 212 | } | ||
| 213 | buf.append( node.getClass().getSimpleName() ); | ||
| 214 | |||
| 215 | MemberReference memberRef = node.getUserData( Keys.MEMBER_REFERENCE ); | ||
| 216 | if( memberRef != null ) | ||
| 217 | { | ||
| 218 | buf.append( String.format( " (MemberReference: %s.%s -> %s)", memberRef.getDeclaringType(), memberRef.getName(), memberRef.getSignature() ) ); | ||
| 219 | } | ||
| 220 | |||
| 221 | for( Key<?> key : Keys.ALL_KEYS ) | ||
| 222 | { | ||
| 223 | if( key == Keys.MEMBER_REFERENCE ) | ||
| 224 | { | ||
| 225 | continue; | ||
| 226 | } | ||
| 227 | Object val = node.getUserData( key ); | ||
| 228 | if( val != null ) | ||
| 229 | { | ||
| 230 | buf.append( String.format( " (%s=%s)", key, val ) ); | ||
| 231 | } | ||
| 232 | } | ||
| 233 | |||
| 234 | |||
| 235 | if( node instanceof Identifier ) | ||
| 236 | { | ||
| 237 | Identifier n = (Identifier)node; | ||
| 238 | buf.append( ": " + n.getName() ); | ||
| 239 | } | ||
| 240 | else if( node instanceof MemberReferenceExpression ) | ||
| 241 | { | ||
| 242 | MemberReferenceExpression n = (MemberReferenceExpression)node; | ||
| 243 | buf.append( ": " + n.getTarget() + "." + n.getMemberName() ); | ||
| 244 | } | ||
| 245 | else if( node instanceof InvocationExpression ) | ||
| 246 | { | ||
| 247 | |||
| 248 | } | ||
| 249 | |||
| 250 | System.out.println( buf ); | ||
| 251 | |||
| 252 | for( AstNode child : node.getChildren() ) | ||
| 253 | { | ||
| 254 | dump( child, depth + 1 ); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | // NOTE: these methods are a bit messy... oh well | 199 | // NOTE: these methods are a bit messy... oh well |
| 259 | 200 | ||
| 260 | public void rename( Entry obfEntry, String newName ) | 201 | public void rename( Entry obfEntry, String newName ) |
| @@ -366,8 +307,22 @@ public class Deobfuscator | |||
| 366 | // obf classes must be in the list | 307 | // obf classes must be in the list |
| 367 | return m_obfClassNames.contains( obfEntry.getName() ); | 308 | return m_obfClassNames.contains( obfEntry.getName() ); |
| 368 | } | 309 | } |
| 310 | else if( obfEntry instanceof FieldEntry ) | ||
| 311 | { | ||
| 312 | return m_obfClassNames.contains( ((FieldEntry)obfEntry).getClassName() ); | ||
| 313 | } | ||
| 314 | else if( obfEntry instanceof MethodEntry ) | ||
| 315 | { | ||
| 316 | return m_obfClassNames.contains( ((MethodEntry)obfEntry).getClassName() ); | ||
| 317 | } | ||
| 318 | else if( obfEntry instanceof ArgumentEntry ) | ||
| 319 | { | ||
| 320 | // arguments only appear in method delcarations | ||
| 321 | // since we only show declrations for obf classes, these are always obfuscated | ||
| 322 | return true; | ||
| 323 | } | ||
| 369 | 324 | ||
| 370 | // assume everything else is an identifier | 325 | // assume everything else is not obfuscated |
| 371 | return true; | 326 | return false; |
| 372 | } | 327 | } |
| 373 | } | 328 | } |