Browse by type
Pyarmor is a popular tool to protect Python source code. It turns Python scripts into binary data, which can be regarded as an encrypted variant of pyc files. They can be decrypted by a shared library (pyarmor_runtime) and then executed by Python interpreter.
This project aims to convert armored data back to bytecode assembly and (experimentally) source code. We forked the awesome Decompyle++ (aka pycdc), and added some processes on it like modifying abstract syntax tree.
[!IMPORTANT]
This tool should only be used on scripts you own or have permission to analyze. Please respect software licenses and terms of service. The author is not responsible for any misuse or damage caused by this tool.
[!NOTE]
Like other decompilers, this tool is intended for professional users. You should have a basic understanding of Python bytecode. If not, you may need to ask for help from someone who does.
[!WARNING]
Disassembly results are accurate, but decompiled code can be incomplete and incorrect. See issue #3
You don't need to execute the encrypted script. We decrypt them using the same algorithm as pyarmor_runtime. This is useful when the scripts cannot be trusted.
Currently we are trying to support Pyarmor 8.0 to 9.2.x (latest), Python 3.7 - 3.13, on all operating systems, with obfuscating options as many as possible. (However, we only have limited tests.)
You can run this tool in any environment, no need to be the same with obfuscated scripts or runtime.
[!NOTE]
If the data starts with
PYfollowed by six digits, it is supported. Otherwise, if it starts withPYARMOR, it is generated by Pyarmor 7 or earlier, and is not supported.
The only thing you need to do is specifying where your obfuscated scripts are. The tool does everything like detecting armored data, parsing, disassembling, and decompiling. See "Usage" section below.
mkdir build
cd build
cmake ../pycdc
cmake --build .
cmake --install .
You can also download prebuilt binary files on releases page.
python /path/to/oneshot/shot.py /path/to/scripts
Before running shot.py, make sure the executable pyarmor-1shot (pyarmor-1shot.exe on Windows) exists in oneshot directory.
You only need to specify the directory that contains all armored data and pyarmor_runtime. The tool finds and handles them recursively as much as possible.
When necessary, specify a pyarmor_runtime executable with -r path/to/pyarmor_runtime[.pyd|.so|.dylib].
All files generated from this tool have a .1shot. in file names. If you want to save them in another directory instead of in-place, use -o another/path/. Folder structure will remain unchanged.
Note:
__pycache__ or site-packages or it directly contains a file named .no1shot, and symbolic links will not be followed, to avoid repeat or forever loop and save time. If you really need them, run the script later in these directories and specify the runtime.Feel free to open an issue if you have any questions, suggestions, or problems. Don't forget to attach the armored data and the pyarmor_runtime executable if possible.
Bug fixes and minor improvements.
The author is trying to design and implement a new pyc decompiler. After that, we can rewrite this tool with the new decompiler.
We will discard the current codebase based on pycdc, and after the new code becomes stable, expected in 2027, we will reach version 1.0.0.
The project is already functioning well, no need to wait for v1.0.0. The public API is still subject to change.
These are the features we are planning to implement before v1.0.0:
Maybe there are not many things to do after v1.0.0. We will maintain the project and fix bugs if necessary.
There are not many code protection tools for Python that are publicly available, and Pyarmor is one of the most popular ones. However, when I (Lil-Ran) was analyzing some specific Pyarmor-protected scripts, I found it not so difficult as I had imagined.
Just encrypting the code objects is not as irreversible as the project claims. To be honest, Python bytecode based protection is much less secure than native code based protection.
We definitely do not make profits by cracking. We ourselves had no other uses for this tool, so we published it, hoping to let people know that Pyarmor with default configuration is not as secure as they think.
The Pyarmor algorithm has not been changed, even a year after this unpacking tool is released. Perhaps it is due to considerations of backward compatibility.
We guarantee that once Pyarmor project changes the algorithm, we will not update this tool to support the new algorithm. Currently existing code generated by supported versions of Pyarmor can always be decrypted by this tool.
Please, don't make CTF (Capture The Flag) REVERSE challenges that are about finding and using existing TOOLS. It is not fun for anyone. It is more like a game of hide-and-seek, rather than a test of skill and ingenuity.
It is more meaningful to understand how Pyarmor or this tool works, and then try to improve them.
$ claude mcp add Pyarmor-Static-Unpack-1shot \
-- python -m otcore.mcp_server <graph>