-
Notifications
You must be signed in to change notification settings - Fork 3
/
program.c
88 lines (80 loc) · 1.88 KB
/
program.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
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#define MAX_NUM_IMPL 256
//From "include/ifunc-impl-list.h"
struct libc_ifunc_impl
{
/* The name of function to be tested. */
const char *name;
/* The address of function to be tested. */
void (*fn) (void);
/* True if this implementation is usable on this machine. */
bool usable;
};
extern size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max);
const char* function_names[] = {
"__memcpy_chk",
"__memmove_chk",
"__mempcpy_chk",
"__memset_chk",
"__wmemset_chk",
"memchr",
"memcmp",
"memcpy",
"memmove",
"mempcpy",
"memrchr",
"memset",
"rawmemchr",
"stpcpy",
"stpncpy",
"strcasecmp",
"strcasecmp_l",
"strcat",
"strchr",
"strchrnul",
"strcmp",
"strcpy",
"strcspn",
"strlen",
"strncasecmp",
"strncasecmp_l",
"strncat",
"strncmp",
"strncpy",
"strnlen",
"strpbrk",
"strrchr",
"strspn",
"strstr",
"wcschr",
"wcscmp",
"wcscpy",
"wcslen",
"wcsncmp",
"wcsnlen",
"wcsrchr",
"wmemchr",
"wmemcmp",
"wmemset",
NULL
};
uintptr_t find_libc_base() {
uintptr_t libc_pointer;
for(libc_pointer = (uintptr_t)printf & (~0xFFF); *(uint32_t*)libc_pointer != 0x464c457f; libc_pointer-=0x1000);
return libc_pointer;
}
int main() {
struct libc_ifunc_impl entries[MAX_NUM_IMPL];
uintptr_t libc_base = find_libc_base();
for(const char** function_name = function_names; *function_name; function_name++) {
size_t num_entries = __libc_ifunc_impl_list(*function_name, entries, MAX_NUM_IMPL);
for(size_t i = 0; i < num_entries; i++) {
printf("%p %s\n", (void*)((uintptr_t)entries[i].fn - (uintptr_t)libc_base), entries[i].name);
}
}
return 0;
}