Universal speedhack library for Python (Linux)
Project description
xspeedhack-linux
xspeedhack-linux is the Linux edition of xspeedhack.
It provides:
- a preloadable native library (
libxspeedhack.so) that scales process time/sleep APIs - a Python client (
import xspeedhack_linux as xsh) to control speed at runtime
Safety note: this project hooks runtime APIs. Use only on processes you own and are allowed to modify.
Highlights
LD_PRELOADinjection for new processes- optional
gdbattach injection for already-running processes - runtime speed control over Unix socket (
float32protocol)
Requirements
- Linux x86_64
- Python
>=3.8 - build tools: C compiler (
gcc/clang),cmake - optional for attach:
gdb
Install
pip install xspeedhack-linux
Quick start
1) Launch a process with preload
import xspeedhack_linux as xsh
client = xsh.SpeedHackClient.launch(["/path/to/app", "--flag"])
client.set_speed(2.0)
2) Attach to existing process
import xspeedhack_linux as xsh
client = xsh.attach(12345)
client.set_speed(0.5)
3) Legacy-compatible constructor
import xspeedhack_linux as xsh
client = xsh.Client(process_id=12345)
client.set_speed(1.25)
4) CLI
xspeedhack-launch --speed 2.0 /path/to/app --flag
xspeedhack-attach --speed 0.5 12345
Runtime behavior
- default scaled clocks:
CLOCK_MONOTONIC* - default unscaled clocks:
time(),gettimeofday(),CLOCK_REALTIME* - default socket path:
/tmp/xspeedhack_<pid>.sock
Environment variables
XSH_SOCKET_PATH: custom Unix socket pathXSH_SCALE_REALTIME=1: also scale realtime clocks (time,gettimeofday,CLOCK_REALTIME*)
Build from source
python -m pip install -U build
python -m build
Run tests
python -m pip install -e .[dev]
pytest -q tests
Troubleshooting
- attach fails with ptrace restrictions:
sudo sysctl -w kernel.yama.ptrace_scope=0
gdbnot found: installgdbor useSpeedHackClient.launch()- socket timeout: verify preload/attach succeeded and target process is still running
License
MIT (see LICENSE).
Acknowledgement
See xspeedhack. Thanks for their excellent project!
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 xspeedhack_linux-1.0.0.tar.gz.
File metadata
- Download URL: xspeedhack_linux-1.0.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38a291c780a1605d8ad0ec7b5914e17d72b1c539512105df0f00fbf5a8992ed6
|
|
| MD5 |
c9dd35462f3d36a674d8c10aed8529fd
|
|
| BLAKE2b-256 |
bdc3ba2c3280d47dd63d54d19e3540dab62d46ed865a9a8b38eca48635ca4ea6
|
File details
Details for the file xspeedhack_linux-1.0.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: xspeedhack_linux-1.0.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 12.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63f8a796ab7656e86bb9172fd3ab1c21229ba7169faa1c5b181cdf52f48bd9d7
|
|
| MD5 |
970b2d4f676bd3a612e9e870339a3b9a
|
|
| BLAKE2b-256 |
9c23660dad594bba5a60b27cf52fcc7c83bd8e7034a42184844b061304699529
|