CMeRo is a Python-to-C/C++ compiler based on Cython. It is designed to compile standard Python (.py) and Cython (.pyx) files into standalone C/C++ code. It also provides tools to build executable binaries (EXE) and shared libraries (DLL, SO, PYD), alongside a built-in code obfuscation feature.
- Standard Python Compilation: Compiles regular
.pyscripts and.pyxfiles directly to C or C++ extensions. - Code Obfuscation (
--obf): Built-in obfuscation pipeline that includes:- String literal encoding (replaces strings with byte arrays evaluated at runtime).
- Local variable renaming.
- Opaque predicate injection (dead code blocks).
- Binary Generation: Direct build targets for standalone executables (
--target exe), dynamic link libraries (--target dll), and shared objects (--target so). - External Dependencies: Supports compiling projects that utilize external Python libraries (e.g.,
requests,openai).
You can install CMeRo directly via pip:
pip install CMeRoOr install from the source repository:
git clone https://github.com/6x-u/CMeRo
cd CMeRo
pip install .CMeRo operates primarily as a command-line tool. Below are the common use cases.
Compiles a Python file to C source code (script.c):
CMeRo script.pyCompiles the file while applying the obfuscation pipeline:
CMeRo --obf script.pyCompiles a Python script to C++ and builds a shared library or standalone binary:
CMeRo --obf --cplus --target dll script.pyNote: Use --target so for Linux shared objects, or --target elf for Linux/Android executable binaries.
Compiles a Python script into a standalone executable (Windows exe or Android/Linux elf):
# For Windows (EXE)
CMeRo --obf --target exe script.py
# For Linux / Android (ELF)
CMeRo --obf --embed --target elf script.pyCMeRo can be integrated into standard Python build processes using setuptools.
Example setup.py:
from setuptools import setup
from CMeRo.Build import CMeRoize
setup(
name="MyApplication",
version="1.0.0",
ext_modules=CMeRoize(
["my_app/*.py"],
compiler_directives={'language_level': "3"}
),
)Build command:
python setup.py build_ext --inplace| Option | Description |
|---|---|
-V or --version |
Print the current CMeRo version and developer credits. |
-o FILE |
Specify the output C/C++ file name. |
-3 |
Force compilation using Python 3 language semantics (default). |
--cplus |
Output C++ code instead of C. |
--arch x64|x86 |
Specify the target build architecture. |
--icon FILE |
Embed an .ico icon file into the generated EXE (Windows only). |
-D or --no-docstrings |
Strip all docstrings from the compiled output. |
Developed by MERO:TG@QP4RM.
Released under the Apache License 2.0.