-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmini_test.cpp
62 lines (49 loc) · 1.16 KB
/
mini_test.cpp
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
#include "stdint.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
extern "C" {
void __attribute__((noinline)) __libdft_set_taint(void *p, unsigned int v) {
printf("set: %p, %d\n", p, v);
}
void __attribute__((noinline)) __libdft_get_taint(void *p) {
printf("get: %p\n", p);
}
void __attribute__((noinline)) __libdft_getval_taint(uint64_t v) {
printf("getval: %lu\n", v);
}
}
void __attribute__((noinline)) foo(uint64_t v) { __libdft_get_taint(&v); }
int main(int argc, char **argv) {
if (argc < 2)
return 0;
FILE *fp;
char buf[255];
size_t ret;
fp = fopen(argv[1], "rb");
if (!fp) {
printf("st err\n");
return 0;
}
int len = 20;
// dfsan_read_label(&(len), sizeof *buf);
ret = fread(buf, sizeof *buf, len, fp);
fclose(fp);
// printf("len is :%d\n", len);
if (ret < len) {
// printf("input fail \n");
return 0;
}
uint64_t m = 0;
__libdft_set_taint(&m, 8);
__libdft_get_taint(&m);
__libdft_getval_taint(m);
uint16_t x = 0;
__libdft_get_taint(&x);
memcpy(&x, buf + 5, 2); // x 1 - 2
__libdft_get_taint(&x);
__libdft_getval_taint(x);
uint64_t y = x + 2;
__libdft_getval_taint(y);
return 0;
}