Protecting a Python Codebase - Part 3

This is the third part of the Protecting a Python codebase series. This time we will be playing with Python interpreter in order to protect the original code of a Python based project. The Python Interpreter Going to the basics, the Python Interpreter is a machine that: Consumes Python code (.py files, from the command line, from a REPL shell) Compiles the code to bytecode Executes the bytecode (here and here) Of course that’s a very rough description. But that’s enough to get started on modifying it to make your own version that will run your own code, and your code won’t run on others interpreters (even the standard one). ...

April 9, 2015 · 4 min · 836 words · Me

Protecting a Python Codebase - Part 2

This is the second part of the Protecting a Python codebase series. This time we will be playing with Python Abstract Syntax Trees in order to protect the original code of a Python based project. Python Abstract Syntax Trees As the Python Documentation says: The ast module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like. ...

March 25, 2015 · 5 min · 925 words · Me

Protecting a Python Codebase

The very nature of Python makes the task of protecting the source code complicated. As an interpreted language, the source code must be available in some form in order to execute it. During this article, I’ll write down the steps I’ve followed while trying to find a fit solution to the problem of protecting a Python based codebase. The explored techniques are implemented in the companion repository with a few more attempts that will be discussed in a second article. The objective in that project was to protect a simple Flask application with NumPy as a dependency. ...

March 11, 2015 · 9 min · 1763 words · Me