Question: We see there is an unsafe ( ) function which has some checks for different local variables. The positioning of these variables is important because

We see there is an unsafe() function which has some checks for different local variables. The positioning of these variables is important because they are declared before the input buffer which means that a buffer overflow will cause data to be overwritten.
This program is a Buffer Overflow, however you will not be changing the control flow to a specific binary address, rather you will need to enter in the right values to trick the pointer arithmetic logic and get to the call_me() function.
(psst, the math is easy, dont overthink it, its just addition)
This is the C File:
#include
#include
#include
#include "../../shared/kernels_lib.c"
typedef struct node_t {
int x;
char y;
float z;
} weird_node;
void unsafe(){
int characters_read;
int some_other_value =0xFFFF;
int* protector =(int *)malloc(sizeof(weird_node)*33);
char buffer[24];
printf("Give me some strings (Mind your values!):
");
read(0, buffer, 1000);
characters_read = strlen(buffer);
if (*(&protector + some_other_value)==0xbadf00d){
if (characters_read >24){
printf("
\ttoo many characters read!
");
exit(-1);
} else {
call_me();
}
}
}
int main(int argc, char* argv[]){
unsafe();
return 0;
}
How will the exploit python look like?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!