From ea5e834abe78d4fb6dc7a5fe160b10c18b88219f Mon Sep 17 00:00:00 2001 From: hoenicke Date: Mon, 13 Aug 2001 11:59:21 +0000 Subject: [PATCH] * configure.in: Set version number to 1.1.1. * jode/obfuscator/Identifier.java.in (writeTable): New boolean parameter specifying if reversed or not. * jode/obfuscator/ClassBundle.java.in: Renamed the table file variables, added outTableFile. (setOption): Support outtable, intable and outrevtable. Support verbose. (writeTable): Writes table unreversed. (writeRevTable): New method, Writes table reversed. * jode/obfuscator/Main.java.in: (rand): New variable. * jode/obfuscator/PackageIdentifier.java.in: Use Main.rand instead of definining its own random. * jode/obfuscator/ClassIdentifier.java.in: likewise. git-svn-id: https://svn.code.sf.net/p/jode/code/branches/branch_1_1@1344 379699f6-c40d-0410-875b-85095c16579e --- jode/ChangeLog | 17 +++++ jode/NEWS | 3 + jode/configure.in | 10 +-- jode/jode/obfuscator/ClassBundle.java.in | 63 +++++++++++++++---- jode/jode/obfuscator/ClassIdentifier.java.in | 6 +- jode/jode/obfuscator/Identifier.java.in | 9 ++- jode/jode/obfuscator/Main.java.in | 9 +++ .../jode/obfuscator/PackageIdentifier.java.in | 4 +- 8 files changed, 90 insertions(+), 31 deletions(-) diff --git a/jode/ChangeLog b/jode/ChangeLog index 0121658..00a7b17 100644 --- a/jode/ChangeLog +++ b/jode/ChangeLog @@ -1,5 +1,22 @@ 2001-08-12 Jochen Hoenicke + * configure.in: Set version number to 1.1.1. + +2001-08-12 Jochen Hoenicke + + * jode/obfuscator/Identifier.java.in (writeTable): New boolean + parameter specifying if reversed or not. + * jode/obfuscator/ClassBundle.java.in: Renamed the table file + variables, added outTableFile. + (setOption): Support outtable, intable and outrevtable. + Support verbose. + (writeTable): Writes table unreversed. + (writeRevTable): New method, Writes table reversed. + * jode/obfuscator/Main.java.in: (rand): New variable. + * jode/obfuscator/PackageIdentifier.java.in: Use Main.rand instead + of definining its own random. + * jode/obfuscator/ClassIdentifier.java.in: likewise. + * jode/flow/FlowBlock.java.in: (checkConsistent): Allow lastModified in a finally block. diff --git a/jode/NEWS b/jode/NEWS index 6c64557..d6be9f8 100644 --- a/jode/NEWS +++ b/jode/NEWS @@ -1,3 +1,6 @@ +New in 1.1.1 +* Only bug fixes + New in 1.1 * break long lines * handle most of javac v8 constructs (jdk 1.3) diff --git a/jode/configure.in b/jode/configure.in index a6fb551..967bba9 100644 --- a/jode/configure.in +++ b/jode/configure.in @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT() -AM_INIT_AUTOMAKE(jode, 1.1) +AM_INIT_AUTOMAKE(jode, 1.1.1) dnl Checks for programs. AC_PROG_MAKE_SET @@ -241,10 +241,4 @@ bin/jode.bat doc/Makefile test/Makefile, [chmod 755 javaDependencies.pl bin/jode], -[for i in \$CONFIG_FILES; do -changequote(, )dnl - if echo \$i | grep '.java\$'; then -changequote([, ])dnl - $PERL $srcdir/jcpp $JCPPFLAGS \$i - fi -done]) +[$PERL $srcdir/jcpp $JCPPFLAGS \`ls \$CONFIG_FILES | grep '.java\$'\`]) diff --git a/jode/jode/obfuscator/ClassBundle.java.in b/jode/jode/obfuscator/ClassBundle.java.in index b2ced86..0875455 100644 --- a/jode/jode/obfuscator/ClassBundle.java.in +++ b/jode/jode/obfuscator/ClassBundle.java.in @@ -52,8 +52,9 @@ public class ClassBundle implements OptionHandler { String classPath; String destDir; - String tableFile; - String toTableFile; + String inTableFile; + String outTableFile; + String outRevTableFile; IdentifierMatcher loading; IdentifierMatcher preserving; @@ -103,21 +104,39 @@ public class ClassBundle implements OptionHandler { return; } - if (option.equals("table")) { + if (option.equals("verbose")) { + if (values.size() != 1) + throw new IllegalArgumentException + ("Verbose takes one int parameter"); + GlobalOptions.verboseLevel + = ((Integer) values.iterator().next()).intValue(); + return; + } + + if (option.equals("intable") || option.equals("table")) { if (values.size() != 1) throw new IllegalArgumentException ("Only one destination path allowed"); - tableFile = (String) values.iterator().next(); + inTableFile = (String) values.iterator().next(); return; } - if (option.equals("revtable")) { + if (option.equals("outtable")) { if (values.size() != 1) throw new IllegalArgumentException ("Only one destination path allowed"); - toTableFile = (String) values.iterator().next(); + outTableFile = (String) values.iterator().next(); return; } + + if (option.equals("outrevtable") || option.equals("revtable")) { + if (values.size() != 1) + throw new IllegalArgumentException + ("Only one destination path allowed"); + outRevTableFile = (String) values.iterator().next(); + return; + } + if (option.equals("strip")) { next_token: for (Iterator iter = values.iterator(); iter.hasNext(); ) { @@ -359,25 +378,41 @@ public class ClassBundle implements OptionHandler { public void readTable() { try { TranslationTable table = new TranslationTable(); - InputStream input = new FileInputStream(tableFile); + InputStream input = new FileInputStream(inTableFile); table.load(input); input.close(); basePackage.readTable(table); } catch (java.io.IOException ex) { - GlobalOptions.err.println("Can't read rename table " + tableFile); + GlobalOptions.err.println("Can't read rename table " + + inTableFile); ex.printStackTrace(GlobalOptions.err); } } public void writeTable() { TranslationTable table = new TranslationTable(); - basePackage.writeTable(table); + basePackage.writeTable(table, false); try { - OutputStream out = new FileOutputStream(toTableFile); + OutputStream out = new FileOutputStream(outTableFile); table.store(out); out.close(); } catch (java.io.IOException ex) { - GlobalOptions.err.println("Can't write rename table "+toTableFile); + GlobalOptions.err.println("Can't write rename table " + + outTableFile); + ex.printStackTrace(GlobalOptions.err); + } + } + + public void writeRevTable() { + TranslationTable revtable = new TranslationTable(); + basePackage.writeTable(revtable, true); + try { + OutputStream out = new FileOutputStream(outRevTableFile); + revtable.store(out); + out.close(); + } catch (java.io.IOException ex) { + GlobalOptions.err.println("Can't write rename table " + + outRevTableFile); ex.printStackTrace(GlobalOptions.err); } } @@ -477,11 +512,13 @@ public class ClassBundle implements OptionHandler { GlobalOptions.err.println("Renaming methods"); time = System.currentTimeMillis(); - if (tableFile != null) + if (inTableFile != null) readTable(); buildTable(renamer); - if (toTableFile != null) + if (outTableFile != null) writeTable(); + if (outRevTableFile != null) + writeRevTable(); System.err.println("Time used: "+(System.currentTimeMillis() - time)); GlobalOptions.err.println("Transforming the classes"); diff --git a/jode/jode/obfuscator/ClassIdentifier.java.in b/jode/jode/obfuscator/ClassIdentifier.java.in index 563862d..f25115d 100644 --- a/jode/jode/obfuscator/ClassIdentifier.java.in +++ b/jode/jode/obfuscator/ClassIdentifier.java.in @@ -30,7 +30,6 @@ import @COLLECTIONS@.Iterator; import @COLLECTIONS@.List; import @COLLECTIONS@.LinkedList; import @COLLECTIONS@.Map; -import @COLLECTIONS@.Random; import @COLLECTIONEXTRA@.UnsupportedOperationException; import java.lang.reflect.Modifier; @@ -374,9 +373,8 @@ public class ClassIdentifier extends Identifier { FieldInfo[] finfos = info.getFields(); MethodInfo[] minfos = info.getMethods(); if (Main.swapOrder) { - Random rand = new Random(); - Collections.shuffle(Arrays.asList(finfos), rand); - Collections.shuffle(Arrays.asList(minfos), rand); + Collections.shuffle(Arrays.asList(finfos), Main.rand); + Collections.shuffle(Arrays.asList(minfos), Main.rand); } fieldIdents = new ArrayList(finfos.length); methodIdents = new ArrayList(minfos.length); diff --git a/jode/jode/obfuscator/Identifier.java.in b/jode/jode/obfuscator/Identifier.java.in index 2260f95..01e9786 100644 --- a/jode/jode/obfuscator/Identifier.java.in +++ b/jode/jode/obfuscator/Identifier.java.in @@ -199,7 +199,7 @@ public abstract class Identifier { ((Identifier)i.next()).buildTable(renameRule); } - public void writeTable(Map table) { + public void writeTable(Map table, boolean reversed) { if (!isReachable() && (Main.stripping & Main.STRIP_UNREACH) != 0) return; @@ -212,11 +212,14 @@ public abstract class Identifier { name = outer.getName() + "." + name; outer = outer.getParent(); } - table.put(getFullAlias(), name); + if (reversed) + table.put(getFullAlias(), name); + else + table.put(getFullName(), getAlias()); } for (Iterator i = getChilds(); i.hasNext(); ) - ((Identifier)i.next()).writeTable(table); + ((Identifier)i.next()).writeTable(table, reversed); } public void readTable(Map table) { diff --git a/jode/jode/obfuscator/Main.java.in b/jode/jode/obfuscator/Main.java.in index 9cc5c67..796ec84 100644 --- a/jode/jode/obfuscator/Main.java.in +++ b/jode/jode/obfuscator/Main.java.in @@ -31,6 +31,7 @@ import java.io.FileReader; import java.io.InputStreamReader; import java.io.IOException; import @COLLECTIONS@.Collections; +import @COLLECTIONS@.Random; public class Main { public static boolean swapOrder = false; @@ -58,6 +59,14 @@ public class Main { public static final int STRIP_LNT = 0x0008; public static final int STRIP_SOURCE = 0x0010; public static int stripping = 0; + /** + * A random pool used to destroy order of method identifiers and + * classes in packages.
+ * + * A pseudo random is enough, no need to generate the seed + * securely. This makes obfuscating errors reproducable. + */ + public static Random rand = new Random(123456); private static ClassBundle bundle; diff --git a/jode/jode/obfuscator/PackageIdentifier.java.in b/jode/jode/obfuscator/PackageIdentifier.java.in index a8b3ee5..07b43a7 100644 --- a/jode/jode/obfuscator/PackageIdentifier.java.in +++ b/jode/jode/obfuscator/PackageIdentifier.java.in @@ -34,7 +34,6 @@ import @COLLECTIONS@.HashMap; import @COLLECTIONS@.Iterator; import @COLLECTIONS@.List; import @COLLECTIONS@.ArrayList; -import @COLLECTIONS@.Random; import @COLLECTIONS@.Arrays; import @COLLECTIONS@.Collections; @@ -47,7 +46,6 @@ public class PackageIdentifier extends Identifier { boolean loadOnDemand; Map loadedClasses; List swappedClasses; - Random rand = new Random(); public PackageIdentifier(ClassBundle bundle, PackageIdentifier parent, @@ -355,7 +353,7 @@ public class PackageIdentifier extends Identifier { */ if (swappedClasses == null) { swappedClasses = Arrays.asList(loadedClasses.values().toArray()); - Collections.shuffle(swappedClasses, rand); + Collections.shuffle(swappedClasses, Main.rand); } return swappedClasses.iterator(); }