forked from R00tkitSMM/CVE-2024-27804
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflip.c
47 lines (38 loc) · 1.33 KB
/
flip.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
#include <IOKit/IOKitLib.h>
#include <dlfcn.h>
#include <execinfo.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysctl.h>
#include <time.h>
void flip_bit(void *buf, size_t len) {
if (!len)
return;
size_t offset = rand() % len;
((int *)buf)[offset] = 0x41414141;
}
kern_return_t fake_IOConnectCallMethod(mach_port_t connection,
uint32_t selector, uint64_t *input,
uint32_t inputCnt, void *inputStruct,
size_t inputStructCnt, uint64_t *output,
uint32_t *outputCnt, void *outputStruct,
size_t *outputStructCntP) {
flip_bit(inputStruct, inputStructCnt);
return IOConnectCallMethod(connection, selector, input, inputCnt, inputStruct,
inputStructCnt, output, outputCnt, outputStruct,
outputStructCntP);
}
typedef struct interposer {
void *replacement;
void *original;
} interpose_t;
__attribute__((used)) static const interpose_t interposers[]
__attribute__((section("__DATA, __interpose"))) =
{
{
.replacement = (void *)fake_IOConnectCallMethod,
.original = (void *)IOConnectCallMethod
}
};