1

I'm considering to compile a python code in order to ensure the source-code without losing script functionality

By reading the following post from stackoverflow: "Is it possible to decompile a compiled .pyc file into a .py file?", I took into account that there is still a chance to get the source code by decompiling the .pyc file.

So, the question is:

Is there anyway to lock and protect the code to get a compiled program in order to protect the code of the script(.py)?

Community
  • 1
  • 1
PeCaDe
  • 277
  • 1
  • 8
  • 33
  • Please @Aaron add, further aspects and limitations in order substantiate your answer. Because, as far as I know im not wondering nothing impossible... Thx – PeCaDe Apr 05 '17 at 13:19
  • 1
    @Aaron could you specify/explain why is ther not any possibility? – NuValue Apr 05 '17 at 13:20
  • you already provided an answer to your own question... the python interpreter only interprets regular python bytecode, which as you have shown can be decompiled – Aaron Apr 05 '17 at 13:21
  • 1
    depending on how technical you want to get, everything can be decompiled with enough work, but things like reading raw x86 binary is a lot harder than python bytecode – Aaron Apr 05 '17 at 13:22
  • 2
    a workaround could be to compile your sensitive functions that you don't want others to easily reverse engineer in something like c++ or c# and add them as extension modules. this would make it much harder to reverse, but not impossible. This also limits portability which is one of python's main benefits – Aaron Apr 05 '17 at 13:24
  • So, there was a misunderstanding, with the concept of lock the compilation I meant encryption. my apologies – PeCaDe Apr 05 '17 at 13:25
  • 2
    Perhaps this could help: https://github.com/Falldog/pyconcrete – Adonis Apr 05 '17 at 13:27
  • 1
    whoever must execute the code must be able to decrypt it to run it.... – Aaron Apr 05 '17 at 13:27
  • 1
    @PeCaDe I poked around `pyconcrete` for a bit, and tried installing it.. (it won't install on my computer rn because I don't have mingw or the admin to install it). From an initial look it should be secure enough to prevent decompilation from anyone with less than a few years of solid experience. – Aaron Apr 05 '17 at 13:59

0 Answers0