Need advice for obfuscating Python code

Gerson Kurz gerson.kurz at t-online.de
Tue Feb 26 23:32:53 EST 2002


On Tue, 26 Feb 2002 22:08:41 GMT, "Sandeep Gupta"
<sandeep182 at hotmail.com> wrote:

>I've written a product in Python and I wanted to find out how best to
>obfuscate the code.  I want the distributed files to be moderately hard to
>reverse engineer.

Well, "Python Obfuscation" is my middle name ;) For starters, there is

- the "How to write unmaintainable code" FAQ

http://mindprod.com/unmain.html

- and my very own "Obfuscated Code HOWTO"

http://www.p-nand-q.com/obtech.htm

which, alas, is a bit C/C++ specific.

Seriously though, I've been toying around with this idea: Recompile
python22.dll to use redirected file functions in the import module;
redirect the files to a database, so new versions can be managed
remotely. Rather than doing so, you could redirect them to encrypted
files.

I've not looked into this really seriously; maybe the "python import
hook" does the job already. See
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59867 for an
example that changes imported files on-the-fly. 



More information about the Python-list mailing list