The following problem concerns the following, low-quality code:
void foo(int x)
{
int a[3];
char buf[1];
a[1] = x;
a[2] = 0xA0B1C2D3;
gets(buf);
printf("a[0] = 0x%x, a[2] = 0x%x, buf = %s\n", a[0], a[2],
buf);
}
In a program containing this code, procedure foo has the following disassembled form on an x86/64 machine:
000000000040057d <foo>:
40057d: push %rbp
40057e: mov %rsp,%rbp
400581: sub $0x30,%rsp
400585: mov %edi,-0x24(%rbp)
400588: mov -0x24(%rbp),%eax
40058b: mov %eax,-0xc(%rbp)
40058e: movl $0xa0b1c2d3,-0x8(%rbp)
400595: lea -0x11(%rbp),%rax
400599: mov %rax,%rdi
40059c: mov $0x0,%eax
4005a1: callq 400480 <gets@plt>
4005a6: mov -0x8(%rbp),%edx
4005a9: mov -0xc(%rbp),%eax
4005ac: lea -0x11(%rbp),%rcx
4005b0: mov %eax,%esi
4005b2: mov $0x400670,%edi
4005b7: mov $0x0,%eax
4005bc: callq 400450 <printf@plt>
4005c1: leaveq
4005c2: retq
For the following questions, recall that:
• gets is a standard C library routine that reads the input from a
user.
• x86/64 machines are little-endian.
• C strings are null-terminated (i.e., terminated by a character
with value 0x00).
• Characters ‘a’ through ‘z’ have ASCII codes 0x61 through
0x7a.
Consider the case where procedure foo is called with argument x equal to 0xB0E2B4E6, and we type "abcdefghijk" in response to gets().
Fill in each input box at the bottom with your answer to each blank in the following questions. The number before each blank indicates its corresponding input box number.
1. Express where on the stack the following program values are located as hex offsets (positive or negative) relative to register %rbp:
Program Value Hex Offset
a 1.________________________
a[1] 2.________________________
a[2] 3.________________________
buf 4.________________________
2. What will the printf function print for the following:
a[0] (hexadecimal): 5.________________________
a[2] (hexadecimal): 6.________________________
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
The following problem concerns the following, low-quality code: void foo(int x) { int a[3]; char buf[1];...
Binary Bomb phase 4 Dump of assembler code for function phase_4: > 0x0000000000400fe7 <+0>: sub $0x18,%rsp 0x0000000000400feb <+4>: lea 0x8(%rsp),%rcx 0x0000000000400ff0 <+9>: lea 0xc(%rsp),%rdx 0x0000000000400ff5 <+14>: mov $0x40290d,%esi 0x0000000000400ffa <+19>: mov $0x0,%eax 0x0000000000400fff <+24>: callq 0x400c00 <__isoc99_sscanf@plt> 0x0000000000401004 <+29>: cmp $0x2,%eax 0x0000000000401007 <+32>: jne 0x401010 <phase_4+41> 0x0000000000401009 <+34>: cmpl $0xe,0xc(%rsp) 0x000000000040100e <+39>: jbe 0x401015 <phase_4+46> 0x0000000000401010 <+41>: callq 0x401662 <explode_bomb> 0x0000000000401015 <+46>: mov $0xe,%edx 0x000000000040101a <+51>: mov $0x0,%esi...
Using Microsoft Visual Studio. 1) Complete the following C++ program by adding more line of code for 8-bit signed array, 16-bit unsigned array, 16-bit signed array, 32-bit signed array and 32-bit signed array. 2) Fill in all the blanks in Table 1 using your completed code, following the hints provided within the table. 3) Fill in all the blanks in Table 2 using your completed code, following the hints provided within the table. C++ Program #include <stdio.h> #include <iostream> int...