Assembly code that deals with arrays and for-loops, and how to decode a map function
<p>Here is my assembly code:</p>

<pre><code>   0x000000000040114b &lt;+0&gt;:     push   %rbx
   0x000000000040114c &lt;+1&gt;:     mov    %rdi,%rbx
   0x000000000040114f &lt;+4&gt;:     callq  0x4013ab &lt;string_length&gt;
   0x0000000000401154 &lt;+9&gt;:     cmp    $0x6,%eax //expecting 6 characters
   0x0000000000401157 &lt;+12&gt;:    je     0x40115e &lt;phase_5+19&gt;
   0x0000000000401159 &lt;+14&gt;:    callq  0x4016a5 &lt;explode_bomb&gt;
   0x000000000040115e &lt;+19&gt;:    mov    $0x0,%eax
   0x0000000000401163 &lt;+24&gt;:    mov    $0x0,%edx
   0x0000000000401168 &lt;+29&gt;:    movzbl (%rbx,%rax,1),%ecx
   0x000000000040116c &lt;+33&gt;:    and    $0xf,%ecx
   0x000000000040116f &lt;+36&gt;:    add    0x402740(,%rcx,4),%edx
   0x0000000000401176 &lt;+43&gt;:    add    $0x1,%rax
   0x000000000040117a &lt;+47&gt;:    cmp    $0x6,%rax
   0x000000000040117e &lt;+51&gt;:    jne    0x401168 &lt;phase_5+29&gt;
   0x0000000000401180 &lt;+53&gt;:    cmp    $0x3d,%edx // 0x3d = 61
   0x0000000000401183 &lt;+56&gt;:    je     0x40118a &lt;phase_5+63&gt;
   0x0000000000401185 &lt;+58&gt;:    callq  0x4016a5 &lt;explode_bomb&gt;
   0x000000000040118a &lt;+63&gt;:    pop    %rbx
   0x000000000040118b &lt;+64&gt;:    retq
</code></pre>

<p>On line &lt;+36> is the following array table</p>

<pre><code>0x402740 &lt;array.3456&gt;:          2       10      6       1 
0x402750 &lt;array.3456+16&gt;:       12      16      9       3
0x402760 &lt;array.3456+32&gt;:       4       7       14      5
0x402770 &lt;array.3456+48&gt;:       11      8       15      13
</code></pre>

<p>On line &lt;+53> I see that I can avoid the bomb as long as %edx = 61</p>

<p>I understand that I need six integers from array table to add to 61. Such as 2+9+10+15+14+11 = 61</p>

<p>I understand how to find the address of the values. For an example:</p>

<p>x/w 0x402740 = 2</p>

<p>x/w 0x402744 = 10</p>

<p>etc</p>

<p>What I can't figure out is how to determine the function that would take a character i.e. 'q' and "map" it to a needed value such as 10.
Actually, I probably needed to reverse-map my 6 needed values. Like find what the value 10 is mapped from. </p>

<p>Any suggestions would be much appreciated! </p>

<p>UPDATE:</p>

<p>** I think the assembly code is something like this **</p>

<pre><code>void function(char *str)
{
    const uint32_t *table = 0x402740;
    if (strlen(str) == 6)
    {
        uint32_t j = 0;
        for (int i = 0; i &lt; 6; i++)
            j += table[str[i]];
        if (j == 0x3d)
            return;
    }
    call explode_bomb;
}
</code></pre>