Skip to content

Instantly share code, notes, and snippets.

@blluv
Created January 23, 2022 06:23
Show Gist options
  • Save blluv/043b2635cc8c6066492f626fb3b6c736 to your computer and use it in GitHub Desktop.
Save blluv/043b2635cc8c6066492f626fb3b6c736 to your computer and use it in GitHub Desktop.
read another python process int list
from mem import MemoryOSX
import struct
proc = MemoryOSX(int(input("pid: ")))
idval = int(input("address: "))
idval += 8
m = struct.unpack("L", proc.read_bytes(idval, 8))[0]
idval += 8
length = struct.unpack("L", proc.read_bytes(idval, 8))[0]
idval += 8
arr = struct.unpack("L", proc.read_bytes(idval, 8))[0]
for i in range(length):
item_addr = struct.unpack("L", proc.read_bytes(arr+(8*i), 8))[0]
ob_size = struct.unpack("L", proc.read_bytes(item_addr + (8*2), 8))[0]
num = 0
for i in range(ob_size):
n = struct.unpack("I", proc.read_bytes(item_addr + (8*3) + (4*i), 4))[0]
num += n * (2 ** (30 * i))
print("val", num)
@blluv
Copy link
Author

blluv commented Jan 23, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment