Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with drawing the stack at 3 different points in the execution of a segment of code. Specifically, I need to draw

I need some help with drawing the stack at 3 different points in the execution of a segment of code. Specifically, I need to draw the stack and detail what is located on the stack and where at the following points:

.

1) Before the code starts executing the function Gets (so the instance after the call is executed, but before any code from "gets" executed,) and should show where any information from the functions "test" and "getbuf" is located on the stack

2) Just before the ret in your exploit string gets executed.

3) Just before "hexmatch" has executed its ret.

It is also important that the diagrams include what address "rsp" and "rbp" are referencing.

.

The segment of code referred to is the following:

unsigned getbuf() { char buf[BUFFER_SIZE]; Gets(buf); return 1; } void test() { int val; val = getbuf(); printf("No exploit. Getbuf returned 0x%x ", val); } /*Compare string to hex represention of unsigned value*/ int hexmatch(unsigned val, char *sval) { char cbuf[110]; /*Make position of check string unpredictable*/ char *s = cbuf + random() % 100; sprintf(s, "%.8x", val); return strncmp(sval, s, 9) == 0; } void touch3(char *sval){ vlevel = 3; /*Part of validation protocol*/ if (hexmatch(cookie, sval)) { printf("Touch3!: You called touch3(\"%s\") ", sval); validate(3); } else { printf("Misfire: You called touch3(\"%s\") ", sval); fail(3); } exit(0); }

For further reference, this segment of code comes from the Attack Lab assignment, though the drawing of the stack is not part of the Lab itself.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago