All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javacc-7.0.4.examples.Obfuscator.README Maven / Gradle / Ivy

/* Copyright (c) 2006, Sun Microsystems, Inc.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 *     * Redistributions of source code must retain the above copyright notice,
 *       this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the Sun Microsystems, Inc. nor the names of its
 *       contributors may be used to endorse or promote products derived from
 *       this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

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.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy