Question: Having the program below called exploit.c : #include #include #include #include #include /* * a toy program for learning stack buffer * overflow exploiting *

Having the program below called exploit.c:

#include

#include

#include

#include

#include

/*

* a toy program for learning stack buffer

* overflow exploiting

* It reads a list of hex data from the

* specified file, and performs bubble sorting

*/

uint32_t n = 0, c = 0, d = 0, v = 0, swap = 0;

FILE *fp = NULL;

void Sort()

{

uint32_t array[5];

printf(".txt file contains: ");

char line[sizeof(uint32_t) * 2 + 1] = {0};

while(fgets(line, sizeof(line), fp))

{

if (strlen((char *)line) > 1)

{

sscanf(line, "%x", &(array[n]));

printf("%x ", array[n]);

++n;

}

}

fclose(fp);

#if 1 //Change this 1 to a 0 and recompile if you do not want the function to sort your values.

for (c = 0; c < (n - 1); c++)

{

v = c;

for (d = ( c + 1 ); d < n; d++)

{

if (array[d] < array[v])

{

// Swap the found minimum element with the first element

swap = array[d];

array[d] = array[v];

array[v] = swap;

}

}

}

#endif

// output sorting result

printf(" Sorted list in ascending order: ");

for ( c = 0 ; c < n ; c++ )

printf("%x ", array[c]);

}

int main(int argc, char **argv)

{

if(argc!=2)

{

printf("Usage: ./exploit file_name ");

return -1;

}

fp = fopen(argv[1], "rb");

Sort();

return 0;

}

I need to figure out the required amount of padding to construct an attack to exploit the program above. But I'm not sure how to find the padding and what it is. Could you please give some help?

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 Databases Questions!