[Q] how to protect python program from decompilation

Skip Montanaro skip at mojam.com
Sun Feb 18 13:18:50 EST 2001


    Leonid> Right now we are considering the following scheme: build a
    Leonid> Python with opcodes in Include/opcode.h reshuffled, and without
    Leonid> the dis module in it; use this interpreter to byte compile our
    Leonid> code; use its Tools/freeze to package our program into
    Leonid> executable and ship it to customers.

Well, a determined person could simply locate the real dis, and start (using
trial and error, perhaps), to decipher your byte code, adjusting dis.py as
they go along.  For example, you can't simply shuffle all your byte codes,
there are two cut points, HAVE_ARGUMENT and EXTENDED_ARG.  Below
HAVE_ARGUMENT, none of the opcodes take arguments, so only opcodes <
HAVE_ARGUMENT could be shuffled amongst each other.  Another clue, all
functions are compiled with RETURN None at the end.  Without modifying the
compiler or running an optimizer of some sort, those will always be there.
Those are just starter clues that came off the top of my head.  I'm sure
there are other clues in the bytecode.  In addition, a determined person
could step through eval_code2 to see what it does.  Even at the assembler
level if necessary.

-- 
Skip Montanaro (skip at mojam.com)
Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml
(847)971-7098




More information about the Python-list mailing list