Actually, Dropbox made it very well, they were able to secure their desktop application made in python; I researched this a lot, but no good solution better than obfuscation, which is not very secure way to go, and you will end up seeing your code uploaded somewhere.
I listened to a session made by Giovanni Bajo (the PyInstaller founder), he said Dropbox does this:
- Bytecode-scrambling by recompiling your CPython's interpreter, and by this, standard CPython interpreter will not be able to run it, only the recompiled cpython interpreter.
- All what you need to do is to shuffle the numbers below the
define loadup 8
.
I've never gone through Python's source code, so, I will not claim that I fully understand the above words.
I need to hear the voice of experts: How to do such a thing? And if after recompilation I will be able to package my application using the available tools like PyInstaller?
Update:
I made some research regarding how Dropbox does this type of obfuscation/mutation, and I found this:
According to Hagen Fritsch, they do it in two stages:
They use TEA cipher along with an RNG seeded by some values in the code object of each python module. They adjusted the interpreter accordingly so that it
a) Decrypts the modules and
b) Prevents access to the decrypted code-objects.
This would have been the straightforward path just letting dropbox decrypt everything and dump the modules using the builtin marshaller.
Another trick used is the manual scrambling of the opcodes. Unfortunately this could only be fixed semiautomatically thus their monoalphabetic substitution cipher proved quite effective in terms of winning some time.
I still want more insights on how this could be done, more over, I don't know how the decryption happens in this process... I want all the experts' voice here ... common guys where are you.