Actually, Dropbox did it very well, they were able to protect their desktop application made in python; I researched this a lot, but not a better solution than obfuscation, which is not a very safe way to go, and you will eventually see that your code is loaded somewhere.
I listened to a session made by Giovanni Bajo (founder of PyInstaller), he said Dropbox does this:
- Bytecode-scrambling by recompiling your CPython interpreter and the standard CPython interpreter will not be able to run it, only the recompiled cpython interpreter.
- All you have to do is shuffle the numbers below
define loadup 8 .
I have never read the Python source code, so I will not claim to fully understand the words above.
I need to hear the voice of experts: how to do this? And if after recompilation I can pack my application using available tools like PyInstaller?
Update:
I did some research on how Dropbox performs this type of obfuscation / mutation, and I found this:
According to Hagen Fritch , they do this in two stages:
They use the TEA cipher along with RNG, seeded with some values ββin the code object of each python module. They adjusted the translator accordingly so that he
a) Decrypts the modules and
b) Prevents access to decrypted code objects.
This would be a simple way for Dropbox to decrypt everything and reset modules using the built-in marshaller.
Another trick is to manually scramble the operation codes. Unfortunately, this could be fixed semi-automatically, so their mono-alphabetic substitution cipher turned out to be very effective in terms of gaining some time.
I still need to learn more about how this can be done, moreover, I do not know how decryption takes place in this process ... I want the whole voice of experts here ... ordinary guys, where are you.
compiler-construction python cpython packaging ctypes
securecurve
source share