-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrcpy_test.c
28 lines (24 loc) · 892 Bytes
/
strcpy_test.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
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>
const char password[] = "passwordpasswordpasswordpassword";
int main()
{
char *userInput = (char *)mmap((void *)0x1337000, 32, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
char *taintBuffer = (char *)mmap((void *)0x2337000, 32, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
scanf("%32s", userInput);
strcpy(taintBuffer, userInput);
printf("STRCPY TEST\n");
printf("Original Input Buffer (source of taint):\n");
printf("%p - %p\n", userInput, userInput + 32);
printf("Taint Buffer (tainted via strcpy(taintBuffer, userInput)):\n");
printf("%p - %p\n", taintBuffer, taintBuffer + 32);
if (strcmp(password, taintBuffer))
{
puts("Incorrect!");
return -1;
}
puts("Correct!");
return 0;
}