-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaslr_examp.cpp
35 lines (31 loc) · 927 Bytes
/
aslr_examp.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
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
printf("Press:\n0 - to quit\n1 - for ASLR off\n2 - for ASLR on: ");
int choice;
int i;
scanf("%d", &choice);
while (choice != 0) {
printf("choice = %d\n", choice);
if (choice == 1) {
system(
"echo \"1\" | sudo -S sh -c 'echo \"0\" > "
"/proc/sys/kernel/randomize_va_space'");
printf("\nASLR is OFF\n");
} else if (choice == 2) {
printf(
"echo \"1\" | sudo -S sh -c 'echo \"2\" > "
"/proc/sys/kernel/randomize_va_space'");
system(
"echo \"1\" | sudo -S sh -c 'echo \"2\" > "
"/proc/sys/kernel/randomize_va_space'");
printf("\nASLR is ON\n");
}
for (i = 0; i < 10; i++) {
system("./print_mem");
}
printf("Press:\n0 - to quit\n1 - for ASLR off\n2 - for ASLR on: ");
scanf("%d", &choice);
}
return 0;
}