Memory-unsafe operations in pure CPython via LOAD_CONST OOB exploit, wrapped in safe context managers
Project description
unsafe-python
Memory-unsafe operations in pure CPython, gated behind safe context managers. No ctypes, no C extensions.
CPython 3.8 - 3.11 only.
Installation
pip install -U unsafelib
Usage
from unsafelib import Unsafe
# All unsafe ops require a context block
with Unsafe() as u:
# Get heap address of any Python object
obj = [1, 2, 3]
print(hex(u.addrof(obj))) # 0x7f2a1c3d4e80
# Read/write raw process memory
mem = u.getmem()
print(bytes(mem[u.addrof(obj):u.addrof(obj) + 32]))
# Forge a fake object from an address
clone = u.fakeobj(u.addrof(obj))
assert clone is obj
# Jump to arbitrary address (segfaults)
u.setrip(0xDEADBEEF)
# Outside the block - raises UnsafeContextError
u.getmem() # UnsafeContextError: Cannot call 'getmem' outside of an unsafe context.
License
MIT
Project details
Release history Release notifications | RSS feed
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 unsafelib-0.1.0.tar.gz.
File metadata
- Download URL: unsafelib-0.1.0.tar.gz
- Upload date:
- Size: 21.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db78534ca1a8c05efa816f2665c6785259ed4a53647c7d64a4d7adc0c6289d07
|
|
| MD5 |
8866003c44463f77d1acb1bdc6a52e2c
|
|
| BLAKE2b-256 |
875c2f24933767050f7aeba84c0fb9f15c352a08a643250202ff6307bed4a4d1
|
Provenance
The following attestation bundles were made for unsafelib-0.1.0.tar.gz:
Publisher:
publish.yml on freQuensy23-coder/unsafelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unsafelib-0.1.0.tar.gz -
Subject digest:
db78534ca1a8c05efa816f2665c6785259ed4a53647c7d64a4d7adc0c6289d07 - Sigstore transparency entry: 1051760701
- Sigstore integration time:
-
Permalink:
freQuensy23-coder/unsafelib@1d09a8baeffa7fa9f9fa3c48264c35dec7656c76 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/freQuensy23-coder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1d09a8baeffa7fa9f9fa3c48264c35dec7656c76 -
Trigger Event:
push
-
Statement type:
File details
Details for the file unsafelib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unsafelib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb5691c0c724f55dd4fa975c15384b14bab16bd7a27b1654773b077d23c27410
|
|
| MD5 |
f080cccdf5568a0c823f0bf55e1f717f
|
|
| BLAKE2b-256 |
28ff9da962bd5a7f37d7af884785013593d42d501fe263696281f4f20ecabcce
|
Provenance
The following attestation bundles were made for unsafelib-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on freQuensy23-coder/unsafelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unsafelib-0.1.0-py3-none-any.whl -
Subject digest:
eb5691c0c724f55dd4fa975c15384b14bab16bd7a27b1654773b077d23c27410 - Sigstore transparency entry: 1051760703
- Sigstore integration time:
-
Permalink:
freQuensy23-coder/unsafelib@1d09a8baeffa7fa9f9fa3c48264c35dec7656c76 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/freQuensy23-coder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1d09a8baeffa7fa9f9fa3c48264c35dec7656c76 -
Trigger Event:
push
-
Statement type: