On 01/-10/-28163 02:59 PM, Octavian Rasnita wrote:
From: "geremy condra"<debat...@gmail.com>
On Wed, Jan 19, 2011 at 2:31 AM, Octavian Rasnita<orasn...@gmail.com>  wrote:
<snip>

Would it be hard to introduce the possibility of adding encryption of the
bytecode similar to what the Zend encoder does for PHP or Filter::Crypto for
Perl?

Octavian

The iron law of cryptography: there is no cryptographic solution to a
problem in which the attacker and intended recipient are the same
person.

Schemes like this are at most an annoyance to people willing to
reverse engineer your code.

Geremy Condra


I don't know how the Python bytecode works... how it is executed.

I thought that Python parses the .py file and generates the bytecode that 
doesn't contain all the necessary information for re-creating the source code.
(But that I agree, that might mean real compilation which is not the case...)

Octavian

It's not hard to experiment with. I've written disassemblers for other byte-code formats, but not for Python's. The following is pasted together, so it may not be completely correct. But it's close.


Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def test(arg1, arg2):
...     if arg1 < 65:
...         print arg2
...
>>> import dis
>>> dis.dis(test)
  2           0 LOAD_FAST                0 (arg1)
              3 LOAD_CONST               1 (65)
              6 COMPARE_OP               0 (<)
              9 JUMP_IF_FALSE            9 (to 21)
             12 POP_TOP

  3          13 LOAD_FAST                1 (arg2)
             16 PRINT_ITEM
             17 PRINT_NEWLINE
             18 JUMP_FORWARD             1 (to 22)
        >>   21 POP_TOP
        >>   22 LOAD_CONST               0 (None)
             25 RETURN_VALUE
>>>

Now, there are tools which reverse that into something pretty similar to python source. But you can see even from the built-in features that lots of information is there. I'd assume that something very similar is in the byte code files themselves.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to