decompile cython extension back to python
Asked Answered
S

1

1

I have used cythonize to compile my python modules. This way speed of code is increased and also the code can not be read by developers. However I have doubts if some python developer can crack that cython module to hack the code.

Question is, can someone decompile them back to python or other readable format to crack the code?

Sublimity answered 25/2, 2022 at 16:56 Comment(0)
M
2

There are C decompilers which will get the Cython extension back to (somewhat readable) C. It won't be the same C code that Cython generated, but it will likely be possible to work out the details of your algorithm. You wouldn't be able to get it back to the original Python/Cython code very easily (but given that Cython generates code in a fairly predictable way it might be possible...)

In particular, things like string constants will be fairly easy to extract from the C file (or even directly from the so file). Since a lot of Python code is based around attribute lookups from string constants (e.g. np.ones(...) looks up a global with the string constant "np", then looks up an attribute with the string constant "ones", then some variation of PyObject_Call), then that code will be fairly easy to decompile. Because of this, a typical Cython extension module is probably a little easier to decompile than a typical C program.

In short you should assume:

  • if you've messed up and deleted your .py/.pyx file then you should assume it's lost for good, and you can't get it back.
  • If someone else has a sufficient interest in working out what your code does, then you should assume they will be able to do it.
Meiny answered 25/2, 2022 at 18:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.