Note that there are some explanatory texts on larger screens.

plurals
  1. PODecoding and understanding assembly code
    primarykey
    data
    text
    <p>So a little background. I am a beginner with c and assembly code, we have an "bomb" assignment (written in c)which calls methods that require certain passwords, but the code is not visible and I need to determine the correct password by looking at the assembly code.</p> <p>The code indicates the password for this method is 6 numbers, which is passed as "input" to method phase 2 (I am trying to avoid triggering ). </p> <p>The part I am getting confused on is is jumping from +64 to +42. It seems to be a loop but I am unsure how the stack is affected with each pass. It looks like the loop exits if the last two numbers are the same, and it has something to do with adding and subtracting 4 but I am unsure how the addresses are traversed. If anyone can translate what exactly is going on, or if i need to look in any particular registers/locations it would help greatly. There are 4 more phases which are each supposed to be more complex so I want to get a good understanding in how to approach reading these.</p> <p>Also if anyone has a good resource (like a printable table) with assembly code keywords that would be helpful too, and also if there are any differences between 32-bit and 64-bit registers i need to worry about other than the register names..</p> <pre><code> 82 phase_2(input); (gdb) disas phase_2 Dump of assembler code for function phase_2: 0x000000000040106b &lt;phase_2+0&gt;: push %rbp 0x000000000040106c &lt;phase_2+1&gt;: push %rbx 0x000000000040106d &lt;phase_2+2&gt;: sub $0x28,%rsp 0x0000000000401071 &lt;phase_2+6&gt;: mov %rsp,%rsi 0x0000000000401074 &lt;phase_2+9&gt;: callq 0x401457 &lt;read_six_numbers&gt; 0x0000000000401079 &lt;phase_2+14&gt;: cmpl $0x0,(%rsp) 0x000000000040107d &lt;phase_2+18&gt;: jne 0x401086 &lt;phase_2+27&gt; 0x000000000040107f &lt;phase_2+20&gt;: cmpl $0x1,0x4(%rsp) 0x0000000000401084 &lt;phase_2+25&gt;: je 0x40108b &lt;phase_2+32&gt; 0x0000000000401086 &lt;phase_2+27&gt;: callq 0x401421 &lt;explode_bomb&gt; 0x000000000040108b &lt;phase_2+32&gt;: lea 0x8(%rsp),%rbx 0x0000000000401090 &lt;phase_2+37&gt;: lea 0x18(%rsp),%rbp 0x0000000000401095 &lt;phase_2+42&gt;: mov -0x8(%rbx),%eax 0x0000000000401098 &lt;phase_2+45&gt;: add -0x4(%rbx),%eax 0x000000000040109b &lt;phase_2+48&gt;: cmp %eax,(%rbx) 0x000000000040109d &lt;phase_2+50&gt;: je 0x4010a4 &lt;phase_2+57&gt; 0x000000000040109f &lt;phase_2+52&gt;: callq 0x401421 &lt;explode_bomb&gt; 0x00000000004010a4 &lt;phase_2+57&gt;: add $0x4,%rbx 0x00000000004010a8 &lt;phase_2+61&gt;: cmp %rbp,%rbx 0x00000000004010ab &lt;phase_2+64&gt;: jne 0x401095 &lt;phase_2+42&gt; 0x00000000004010ad &lt;phase_2+66&gt;: add $0x28,%rsp 0x00000000004010b1 &lt;phase_2+70&gt;: pop %rbx 0x00000000004010b2 &lt;phase_2+71&gt;: pop %rbp 0x00000000004010b3 &lt;phase_2+72&gt;: retq </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload