1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*
* Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
* these intellectual property rights may include one or more of the U.S.
* patents listed at http://www.sun.com/patents and one or more additional
* patents or pending patent applications in the U.S. and in other countries.
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements. Use is subject to license terms.
* Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
* product is covered and controlled by U.S. Export Control laws and may be
* subject to the export or import laws in other countries. Nuclear, missile,
* chemical biological weapons or nuclear maritime end uses or end users,
* whether direct or indirect, are strictly prohibited. Export or reexport
* to countries subject to U.S. embargo or to entities identified on U.S.
* export exclusion lists, including, but not limited to, the denied persons
* and specially designated nationals lists is strictly prohibited.
*/
This directory contains an obfuscation program. This program takes
the following inputs:
. An input directory which contains the original Java programs. This
must be the CLASSPATH directory. All Java files within this
directory except those under SCCS directories are considered for
obfuscation.
. An output directory into which the obfuscated files are generated.
It should be possible to build the obfuscated version by setting the
CLASSPATH to this directory.
. A file of mappings of the form:
( originalId "->" obfuscatedId ";" )*
This specifies mappings from original identifiers to corresponding
obfuscated ones. This file is optional, and even when it is
present, it does not have to specify all identifiers in the input
file.
. A file containing identifiers that must not be obfuscated. This is
typically used to prevent references to the standard API's from
being changed. This file is optional.
. A file containing identifiers to be used for obfuscation. If an
identifier is encountered in the original file that does not have a
specified mapping and is not an identifier that must not be
obfuscated, then identifiers from this file are used for
obfuscation. Once identifiers from this file are exhausted, then
identifiers starting with "O0" the letter 'O' followed by the digit
'0' are generated automatically. This file is optional.
The output of the program is:
. An obfuscated version for each input Java file. Since package and
class names are also obfuscated, the directory and file names will
be different also.
. A main program for each of the original main programs in their
original forms (with the same package and class names) that calls
the corresponding obfuscated main program. This is useful to retain
access to the system as before.
. A file containing all the mappings used during the obfuscation
process. This file is in the same syntax as the input mapping file,
and therefore it can be used as input for future obfuscations. This
is useful when related systems are obfuscated in different runs of
this program.
To build the obfuscator, do the following:
javacc Java1.1.jj
javacc IdsFile.jj
javacc MapFile.jj
javac *.java
Now the obfuscator is ready for use. Try it out as follows on the
example provided:
java Main input output maps nochangeids useids
And take a look at the input and output directories.
This example illustrates the use of multiple grammar files, some of
which are used more than once while the system is running. Take a
look at the usage of ReInit's and also the actions in the grammar.
Note how easy it was to include actions into the Java grammar to
determine whether or not it had a main program. Also note how easy it
is to modify this program.
Some comments are present in each of the files that comprise this
example.
|