Metadata-Version: 2.4
Name: unsafelib
Version: 0.1.0
Summary: Memory-unsafe operations in pure CPython via LOAD_CONST OOB exploit, wrapped in safe context managers
Project-URL: Homepage, https://github.com/freQuensy23-coder/unsafelib
Project-URL: Repository, https://github.com/freQuensy23-coder/unsafelib
Project-URL: Issues, https://github.com/freQuensy23-coder/unsafelib/issues
Author: unsafe-python contributors
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# 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

```bash
pip install -U unsafelib
```

## Usage

```python
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
