Git Product home page Git Product logo

pyprotect's Introduction

pyprotect

pyprotect is a lightweight python code protector, makes your python project harder to reverse engineer.

Features

  • Cross platform
  • No need to install any extra dependents
  • Very easy to use

Only python3.x is supported by current version

How it works?

how-it-works

Build pyprotect

  1. Create a directory "deps" in pyprotect root directory.
  2. Download pybind11 project into the newly created deps directory.
  3. Unzip pybind11 zip file, and change the extracted directory's name from something like "pybind11-x.x.x" to "pybind11"
  • Run these commands in pyprotect root directory:
mkdir build
cd build && cmake .. && make

And you can find libpyprotect.cpython-PYVERSION-PLATFORM.so in the objs directory.

Encrypt your python project

Command:

python encrypt.py -s SCRIPTS_DIR -e ENTRY_POINT_LIST -o OUTPUT_DIR [--exclude EXCLUDED_SCRIPT_LIST]
  • SCRIPTS_DIR is your python project root directory.
  • ENTRY_POINT_LIST is a comma separated list of file function pair which is directly ran as the entry point of your programme. For example "app.py:main,test_app.py:run_test".
  • OUTPUT_DIR is the destination directory to store the encrypted python scripts.
  • EXCLUDED_SCRIPT_LIST is a comma separated list of python scripts which you don't wan to encrypt.

You need to put libpyprotect.cpython-PYVERSION-PLATFORM.so into the OUTPUT_DIR as part of your programme.

Configuration [IMPORTANT]

For security reason you should change the AES key and IV, which is used to encrypt/decrypt the python scripts, to a stronger value. And you may want to change the file extension of encrypted python scripts (which is ".pye" by default).

You can find these macros or variables in config.h and encrypt.py:

  • PYPROTECT_KEY
  • PYPROTECT_IV
  • PYPROTECT_EXT_NAME

You need to change the two files both. Please change the PYPROTECT_KEY and PYPROTECT_IV to a safer value.

Roadmap

  • Support python3 scripts
  • Support python2.7 scripts
  • Anti debugging
  • Software license control

License

pyprotect is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

pyprotect's People

Contributors

ga0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyprotect's Issues

Error al compilar en Windows x64 - Error hypot

Esta seria la solución:
1.- Instalar Mingw
2.- Instalar cmake
3.- Tener Pybind dentro de carpeta deps
4.- Tener listo el programa Codelite, con el compilador c++ configurado (mingw).
5.- Editar archivo cmath, dentro de Mingw; cambiar linea "::hypot" a "::_hypot"
6.- Abrir cmake, ingresar source, y directorio build
7.- en Cmake, configurar con los pasos hechos, y dar click en generar; Escoger compilador que se encuentra dentro de Bin en Mingw.
8.- Compilar archivo wordspace de codelite, generado en cmake, dentro de codelite.

Resultado final:
libpyprotect.cp36-win_amd64.pyd (windows)

Installation Error on Debian (Kali linux)

OS: Debian (last version)
Python: 3.8.x and 3.9.x - 64bits

root@milani:~/Desktop/pybind11-2.6.0# cd build && cmake .. && make
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- pybind11 v2.6.0 
-- CMake 3.18.2
-- Found PythonInterp: /usr/bin/python3.9 (found version "3.9") 
-- Found PythonLibs: python3.9
-- PYTHON 3.9.0
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- pybind11::lto enabled
-- pybind11::thin_lto enabled
-- Setting tests build type to MinSizeRel as none was specified
-- Building tests WITHOUT Eigen, use -DDOWNLOAD_EIGEN on CMake 3.11+ to download
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.56")  
-- Found pytest 4.6.11
-- Catch not detected. Interpreter tests will be skipped. Install Catch headers manually or use `cmake -DDOWNLOAD_CATCH=ON` to fetch them automatically.
-- Configuring done
-- Generating done
-- Build files have been written to: /root/Desktop/pybind11-2.6.0/build
Scanning dependencies of target cross_module_gil_utils
[  2%] Building CXX object tests/CMakeFiles/cross_module_gil_utils.dir/cross_module_gil_utils.cpp.o
In file included from /root/Desktop/pybind11-2.6.0/include/pybind11/pytypes.h:12,
                 from /root/Desktop/pybind11-2.6.0/include/pybind11/cast.h:13,
                 from /root/Desktop/pybind11-2.6.0/include/pybind11/attr.h:13,
                 from /root/Desktop/pybind11-2.6.0/include/pybind11/pybind11.h:45,
                 from /root/Desktop/pybind11-2.6.0/tests/cross_module_gil_utils.cpp:9:
/root/Desktop/pybind11-2.6.0/include/pybind11/detail/common.h:122:10: fatal error: Python.h: No such file or directory
  122 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [tests/CMakeFiles/cross_module_gil_utils.dir/build.make:82: tests/CMakeFiles/cross_module_gil_utils.dir/cross_module_gil_utils.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:252: tests/CMakeFiles/cross_module_gil_utils.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

Failed to run MSBuild command

cd build && cmake .. && make
CMake Error at CMakeLists.txt:8 (project):
Failed to run MSBuild command:

C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe

to get the value of VCTargetsPath:

Microsoft(R) 生成引擎版本 4.7.2556.0
[Microsoft .NET Framework 版本 4.0.30319.42000]
版权所有 (C) Microsoft Corporation。保留所有权利。

生成启动时间为 2018/8/20 15:58:15。
节点 1 上的项目“C:\pyencrypt\build\CMakeFiles\3.11.1\VCTargetsPath.vcxproj”(默认目标)。
C:\pyencrypt\build\CMakeFiles\3.11.1\VCTargetsPath.vcxproj(14,2): error MSB4019: 未找到导入的项目“C:\Microsoft.Cpp.Default.props”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。
已完成生成项目“C:\pyencrypt\build\CMakeFiles\3.11.1\VCTargetsPath.vcxproj”(默认目标)的操作 - 失败。

生成失败。

“C:\pyencrypt\build\CMakeFiles\3.11.1\VCTargetsPath.vcxproj”(默认目标) (1) ->
  C:\pyencrypt\build\CMakeFiles\3.11.1\VCTargetsPath.vcxproj(14,2): error MSB4019: 未找到导入的项目“C:\Microsoft.Cpp.Default.props”。请确认 <Import> 声明中的路径正确,且磁盘上存在该文件。

    0 个警告
    1 个错误

已用时间 00:00:00.21

Exit code: 1

-- Configuring incomplete, errors occurred!
See also "C:/pyencrypt/build/CMakeFiles/CMakeOutput.log".

请问这是啥错误,.net版本问题?

Python 2

When this project will support python 2? If it will be. :)

Windows - error padding

I run in windows, and have error with padding.

[error] padding=210

struct ModLoader {

    #ifdef DEBUG
            printf("[error] padding=%d\n", padding);
    #endif
}

libpyprotect.so: undefined symbol: PyThread_tss_get

  1. After make, i get the file "libpyprotect.cpython-37m-x86_64-linux-gnu.so", then from the same directory i do "import libpyprotect" i get ModuleNotFound error,
  2. Then I rename it to "libpyprotect.so". Now when in python I do "import libpyprotect" from the same directory where the ".so" file is kept, i get this error:
    ImportError: /home/Rishi/pyprotect/libpyprotect.so: undefined symbol: PyThread_tss_get

Exclude virtual environment

Nearly everyone nowadays use virtual environment for project development. How to exclude the whole venv directory from encryption?

Windows support

Dear ga0

Could you make a new make file which can build the libpyprotect.cpython-37m-x86_64-windows-gnu.dll for windows 10?

AttributeError: ModLoader.is_package() method is missing but is required by Flask of PEP 302 import hooks. If you do not use import hooks and you encounter this error please file a bug against Flask.

您好,感谢您提供了这个好用的工具,我用它加密了一些软件,确实没问题,但是当我在代码中使用了flask模块后,报错如下:
AttributeError: ModLoader.is_package() method is missing but is required by Flask of PEP 302 import hooks. If you do not use import hooks and you encounter this error please file a bug against Flask.
系统:ubuntu16.4.04
python3.5 in virtualenv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.