Consider the following code shellcode2.c. Modify the code so that it can successfully execute the shellcode when the main module is returned. Note that you cannot remove any variable declaration. char shellcode[] = "\xeb\x2a\x5e\x89\x76\x08\xc6\x46\x07\x00\xc7\x46\x0c\x00\x00\x00" "\x00\xb8\x0b\x00\x00\x00\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80" "\xb8\x01\x00\x00\x00\xbb\x00\x00\x00\x00\xcd\x80\xe8\xd1\xff\xff" "\xff\x2f\x62\x69\x6e\x2f\x73\x68\x00\x89\xec\x5d\xc3"; int main() { int x, y, z; int *ret; ret = (int *)&ret + 2; (*ret) = (int)shellcode; return 0; }
Added by Jose Francisco T.
Close
Step 1
The code is attempting to execute shellcode, but there are multiple problems preventing it from working properly: - The shellcode is stored in read-only memory (as a string literal) - The pointer arithmetic in `ret = (int *)&ret + z;` is incorrect - The shellcode Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 70 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Supreeta N.
char one[] = "Bye!"; char two[] = { 'B', 'y', 'e', '!'}; i. What does sizeof(one) return? What does sizeof(two) return? [2 marks] ii. Consider the following line of code. What value would you expect "x" to hold after the following function call? int x = strlen(one) [2 marks] iii. Consider the following line of code. What value would you expect "x" to hold after the following function call? int x = strlen(two)
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD