Understanding how some assembly code is translated

524 views Asked by At

Hi i'm currently doing a binary bomb and am wondering if I am understanding some stuff correctly. I have this;

   0x00000000004011d4 <+0>:     sub    $0x8,%rsp
   0x00000000004011d8 <+4>:     cmpb   $0x59,(%rdi)
   0x00000000004011db <+7>:     jne    0x4011fd <phase_1+41>
   0x00000000004011dd <+9>:     cmpb   $0x46,0x2(%rdi)
   0x00000000004011e1 <+13>:    jne    0x4011fd <phase_1+41>
   0x00000000004011e3 <+15>:    cmpb   $0x68,0x1(%rdi)
   0x00000000004011e7 <+19>:    je     0x40120b <phase_1+55>
   0x00000000004011e9 <+21>:    movsbl 0x10(%rdi),%ecx
   0x00000000004011ed <+25>:    movsbl 0x5(%rdi),%edx
   0x00000000004011f1 <+29>:    add    $0xb,%edx
   0x00000000004011f4 <+32>:    mov    $0x1,%eax
   0x00000000004011f9 <+37>:    cmp    %edx,%ecx
   0x00000000004011fb <+39>:    je     0x401210 <phase_1+60>
   0x00000000004011fd <+41>:    callq  0x401b20 <bomb_activation>
   0x0000000000401202 <+46>:    mov    $0xffffffffffffffff,%rax
   0x0000000000401209 <+53>:    jmp    0x401210 <phase_1+60>
   0x000000000040120b <+55>:    mov    $0x0,%eax
   0x0000000000401210 <+60>:    add    $0x8,%rsp
   0x0000000000401214 <+64>:    retq

and so far I have translated it to this;

if(arr[0] != 'Y'){
bomb_activation();
}
if(arr[2] != 'F'){
bomb_activation();
}
if(arr[1] == 'h'){
bomb_activation();
}

int a = arr[10];
int b = arr[5];
b += 11;
status = 1;

if(t1 != t2){
bomb_activation();
}
return status;
}

As you can probably tell i'm really confused on how exactly to read these lines, I see it as moving the 10th element of the array into the ecx registry and filling the rest of the registry with 0s and the same logic to edx, however i'm not too sure how to determine what the value of arr[5] or arr[10] is just from this.

   0x00000000004011e9 <+21>:    movsbl 0x10(%rdi),%ecx
   0x00000000004011ed <+25>:    movsbl 0x5(%rdi),%edx
   0x00000000004011f1 <+29>:    add    $0xb,%edx
   0x00000000004011f4 <+32>:    mov    $0x1,%eax
   0x00000000004011f9 <+37>:    cmp    %edx,%ecx

and more specifically how I am meant to determine the size of the array, maybe I am not understanding it at all though, any help would be great thanks.

0

There are 0 answers