Need advice for obfuscating Python code
cimarron+google at taylors.org
Wed Feb 27 03:14:33 EST 2002
I have used the following tricks before with Java code, some of them
should be useable with python.
1. Use a source-to-source translator to convert all your class, method
and variable names into gibberish.
2. Introduce special "dispatch" classes to obscure the communications
paths. E.g instead of calling foo.bar(), call dispatcher.bar(foo)
where dispatcher is a dynamically instanciated object. Have lots
of dispatchers and periodically switch them around in meaningless ways.
3. Add lots of decoy code. Put bar() methods in lots of classes which
are never used. Include the gibberish versions of a few previous
versions of your code with logic deliberately reversed. Intermix
meaningless logic with the code which does the actual work. Bulk up
your product with a few dozen distributions of other redistributable
4. Hide some initialization logic outside your program. Have your
program step reload classes. If your program manages external files
(e.g. userids or passwords), have it hide some critical initialization
logic there. Encode some of your program state in records in a database
which requires a separate initialization and/or installation step.
5. Distribute your program in separate pieces. Have your program partially
depend on external libraries.
6. Partition your program's operation into separate phases and/or processes.
Have one process generate code on the fly to be executed by the other.
Hide important information in otherwise meaningless status messages
exchanged between the two.
Most of these things will make your program more difficult to reverse engineer.
Heaven help you if you ever need to fix a bug in it!
More information about the Python-list