-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.c
53 lines (41 loc) · 1.08 KB
/
test.c
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
#include <stdio.h>
#include <stdint.h>
#include "melkor.c"
int pid;
int offset = 0x14;
int baseOffset = 0x7ffb30;
int region = 16;
int main() {
if (isRoot()) {
printf("[+] pid: ");
scanf("%d", &pid);
mach_port_t process = getProcess(pid);
if (isNoError() && isProcessValid(process)) {
uintptr_t baseAddress = getBaseAddressByRegion(process, 16);
if (baseAddress) {
uintptr_t pointerAddress = (uintptr_t)readAddress(
process,
baseAddress + baseOffset,
sizeof(uintptr_t)
);
if (isNoError()) {
uintptr_t targetAddress = pointerAddress - offset;
int target = (int)readAddress(
process,
targetAddress,
sizeof(int)
);
if (isNoError()) {
printf("[x] old result: %d\n", target);
int hack = 12345;
writeAddress(process, targetAddress, sizeof(hack), &hack);
if (isNoError()) {
printf("[x] write success : )\n");
}
}
}
}
}
}
return 0;
}