-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
63 lines (49 loc) · 1.42 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import rwpm
from pgrep import pgrep
import struct
endian = sys.byteorder
is_64bits = sys.maxsize > 2**32
size_ptr = is_64bits*4+4
size_int = is_64bits*4+4
def read_b(p,a,s=4,bo=sys.byteorder,ro=False):
r = rwpm.process_vm_readv(p,a,s)
if ro:
r = bytearray(r)
return memoryview(r)
def read_int(p,a,s=8,bo=sys.byteorder):
r = rwpm.process_vm_readv(p,a,s)
return int.from_bytes(r,byteorder=bo,signed=False)
def write_int(p,a,i,s=8,bo=sys.byteorder):
if not isinstance(i, (bytes, bytearray)):
i = i.to_bytes(s, bo)
r = rwpm.process_vm_writev(p,a,i)
return r
def write_double(p,a,i,s=8,bo=sys.byteorder):
if not isinstance(i, (bytes, bytearray)):
i = struct.pack('d', i)
r = rwpm.process_vm_writev(p,a,i)
return r
def read_double(p,a,s=8,bo=sys.byteorder):
r = rwpm.process_vm_readv(p,a,s)
return struct.unpack('d', r)[0]
def read_float(p,a,s=4,bo=sys.byteorder):
r = rwpm.process_vm_readv(p,a,s)
return struct.unpack('f', r)[0]
def write_float(p,a,i,s=4,bo=sys.byteorder):
if not isinstance(i, (bytes, bytearray)):
i = struct.pack('f', i)
r = rwpm.process_vm_writev(p,a,i)
return r
addr = 0x55e64d92c010
a_dd = 0x55e64d92c018
size = 4
PID = pgrep('loopy')[0]
#print(read_int(PID,addr))
#print(write_int(PID,addr,101))
#m = read_b(PID,addr,8)
#print(read_double(PID,a_dd))
#f = 4244.54
#print(write_double(PID,a_dd,f))
#print(read_float(PID,0x56550bac0014))
#print(write_float(PID,0x56550bac0014,10.333))