Skip to main content

A Python library for getting access to raw memory and internals

Project description

Memhax

A python library for accessing raw python objects and other regions in memory.

Installation

$ pip install memhax

Usage

Read/Write raw memory

from memhax.constants import memory

# Read 4 bytes from address 0x12345678
with memory(0x12345678) as mem:
    data = mem.read(4)

Dump an object's struct

from memhax.cpython.primitives import PyLongObject

num_obj = PyLongObject(id(1234))
print(num_obj.struct_str())

# struct PyLongObject {
#     Py_ssize_t      ob_refcnt;
#     PyTypeObject*   ob_type;
#     Py_ssize_t      ob_size;
#     unsigned int[1] ob_digit;
# }

Read/modify python objects

from memhax.cpython.collections import PyTupleObject

my_tuple = (1, "abc", 3.5)
tuple_obj = PyTupleObject(id(my_tuple))

# Get the tuple's length
print(tuple_obj.ob_size())  # => 3

# Replace an item in the tuple
new_item = [my_tuple, b"123"]
tuple_obj.ob_item[0] = id(new_item)
print(my_tuple)  # => ([(...), b'123'], 'abc', 3.5)

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

memhax-0.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

memhax-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file memhax-0.0.1.tar.gz.

File metadata

  • Download URL: memhax-0.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for memhax-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ca55d451a4087945822a9d60e874a919f3067a763b56b95e2164c9db103e69b4
MD5 57008212bc4f0cf0549c866c1c9ea9d2
BLAKE2b-256 03651637edbb56b5c3c9cb09ed6da64406fdf73b9b02c4d45d600541ee4f2bd5

See more details on using hashes here.

File details

Details for the file memhax-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: memhax-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for memhax-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b87e88c856f9a87d0e1534864a7fe9edccbddf9bfd0b617341e9eb1cd2e7544e
MD5 a80fc0b341f216a318ed12baa58f441f
BLAKE2b-256 6f8424187af6fe44e33787e577e9548888828d6f3e6a7021c0e4f521a2cf7953

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page