I am new to reverse engineering and try to solve a crackme with radare2.
My problem is understanding of the following lines:
| 0x000007a9 c745b8000000. mov dword [var_48h], 0
| 0x000007b0 c745bc000000. mov dword [var_44h], 0
| 0x000007cd 8b45b8 mov eax, dword [var_48h]
| 0x000007d0 4898 cdqe
| 0x000007d2 0fb64405c0 movzx eax, byte [rbp + rax - 0x40]
From the bottom part of this code surrounding them:
| 0x0000076a 55 push rbp
| 0x0000076b 4889e5 mov rbp, rsp
| 0x0000076e 4883ec50 sub rsp, 0x50
| 0x00000772 64488b042528. mov rax, qword fs:[0x28] ; [0x28:8]=0x19c0 ; '('
| 0x0000077b 488945f8 mov qword [canary], rax
| 0x0000077f 31c0 xor eax, eax
| 0x00000781 c645b700 mov byte [var_49h], 0
| 0x00000785 488d3d580100. lea rdi, qword str.Enter_password: ; 0x8e4 ; "Enter password:" ; const char *s
| 0x0000078c e87ffeffff call sym.imp.puts ; int puts(const char *s)
| 0x00000791 488d45c0 lea rax, qword [var_40h]
| 0x00000795 4889c6 mov rsi, rax
| 0x00000798 488d3d550100. lea rdi, qword [0x000008f4] ; "%s" ; const char *format
| 0x0000079f b800000000 mov eax, 0
| 0x000007a4 e897feffff call sym.imp.__isoc99_scanf ; String! ; int scanf(const char *format)
| 0x000007a9 c745b8000000. mov dword [var_48h], 0
| 0x000007b0 c745bc000000. mov dword [var_44h], 0
| 0x000007cd 8b45b8 mov eax, dword [var_48h]
| 0x000007d0 4898 cdqe
| 0x000007d2 0fb64405c0 movzx eax, byte [rbp + rax - 0x40]
| 0x000007d7 84c0 test al, al
I understand the output and that there is the input wanted (scanf
). After that var_48h
, var_44h
and eax
are set to 0. The next lines i don't understand at all. Beside the cdqe
instruction there is some calculation(?) with the variables rbp
and rax
(=var_49h
?).
Maybe you can help me to understand that?
Thank you in advance!