1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
| kali@kali:~/CTFs/tryhackme/Reverse Engineering$ r2 -d ./crackme3.bin
Process with PID 78868 started...
= attach 78868 78868
bin.baddr 0x5613e9b22000
Using 0x5613e9b22000
asm.bits 64
Warning: r_bin_file_hash: file exceeds bin.hashlimit
[0x7f6163ed6090]> aaa
[x] Analyze all flags starting with sym. and entry0 (aa)
[x] Analyze function calls (aac)
[x] Analyze len bytes of instructions for references (aar)
[x] Check for objc references
[x] Check for vtables
[TOFIX: aaft can't run in debugger mode.ions (aaft)
[x] Type matching analysis for all functions (aaft)
[x] Propagate noreturn information
[x] Use -AA or aaaa to perform additional experimental analysis.
[0x7f6163ed6090]> afl
0x5613e9b22610 1 42 entry0
0x5613e9d22fe0 1 4124 reloc.__libc_start_main
0x5613e9b22640 4 50 -> 40 sym.deregister_tm_clones
0x5613e9b22680 4 66 -> 57 sym.register_tm_clones
0x5613e9b226d0 5 58 -> 51 entry.fini0
0x5613e9b22600 1 6 sym..plt.got
0x5613e9b22710 1 10 entry.init0
0x5613e9b22840 1 2 sym.__libc_csu_fini
0x5613e9b22844 1 9 sym._fini
0x5613e9b227d0 4 101 sym.__libc_csu_init
0x5613e9b2271a 9 170 main
0x5613e9b225a0 3 23 sym._init
0x5613e9b225d0 1 6 sym.imp.puts
0x5613e9b225e0 1 6 sym.imp.__stack_chk_fail
0x5613e9b22000 2 25 map.home_kali_CTFs_tryhackme_Reverse_Engineering_crackme3.bin.r_x
0x5613e9b225f0 1 6 sym.imp.__isoc99_scanf
[0x7f6163ed6090]> pdf @main
; DATA XREF from entry0 @ 0x5613e9b2262d
β 170: int main (int argc, char **argv, char **envp);
β ; var int64_t var_28h @ rbp-0x28
β ; var int64_t var_23h @ rbp-0x23
β ; var int64_t var_21h @ rbp-0x21
β ; var int64_t var_20h @ rbp-0x20
β ; var int64_t var_8h @ rbp-0x8
β 0x5613e9b2271a 55 push rbp
β 0x5613e9b2271b 4889e5 mov rbp, rsp
β 0x5613e9b2271e 4883ec30 sub rsp, 0x30
β 0x5613e9b22722 64488b042528. mov rax, qword fs:[0x28]
β 0x5613e9b2272b 488945f8 mov qword [var_8h], rax
β 0x5613e9b2272f 31c0 xor eax, eax
β 0x5613e9b22731 66c745dd617a mov word [var_23h], 0x7a61 ; 'az'
β 0x5613e9b22737 c645df74 mov byte [var_21h], 0x74 ; 't' ; 116
β 0x5613e9b2273b 488d3d120100. lea rdi, qword str.enter_your_password ; 0x5613e9b22854 ; "enter your password"
β 0x5613e9b22742 e889feffff call sym.imp.puts ; int puts(const char *s)
β 0x5613e9b22747 488d45e0 lea rax, qword [var_20h]
β 0x5613e9b2274b 4889c6 mov rsi, rax
β 0x5613e9b2274e 488d3d130100. lea rdi, qword [0x5613e9b22868] ; "%s"
β 0x5613e9b22755 b800000000 mov eax, 0
β 0x5613e9b2275a e891feffff call sym.imp.__isoc99_scanf ; int scanf(const char *format)
β 0x5613e9b2275f c745d8000000. mov dword [var_28h], 0
β ββ< 0x5613e9b22766 eb2f jmp 0x5613e9b22797
β βββ> 0x5613e9b22768 8b45d8 mov eax, dword [var_28h]
β ββ 0x5613e9b2276b 4898 cdqe
β ββ 0x5613e9b2276d 0fb65405e0 movzx edx, byte [rbp + rax - 0x20]
β ββ 0x5613e9b22772 8b45d8 mov eax, dword [var_28h]
β ββ 0x5613e9b22775 4898 cdqe
β ββ 0x5613e9b22777 0fb64405dd movzx eax, byte [rbp + rax - 0x23]
β ββ 0x5613e9b2277c 38c2 cmp dl, al
β ββββ< 0x5613e9b2277e 7413 je 0x5613e9b22793
β βββ 0x5613e9b22780 488d3de40000. lea rdi, qword str.password_is_incorrect ; 0x5613e9b2286b ; "password is incorrect"
β βββ 0x5613e9b22787 e844feffff call sym.imp.puts ; int puts(const char *s)
β βββ 0x5613e9b2278c b800000000 mov eax, 0
β βββββ< 0x5613e9b22791 eb1b jmp 0x5613e9b227ae
β βββββ> 0x5613e9b22793 8345d801 add dword [var_28h], 1
β β ββ ; CODE XREF from main @ 0x5613e9b22766
β β βββ> 0x5613e9b22797 837dd802 cmp dword [var_28h], 2
β β βββ< 0x5613e9b2279b 7ecb jle 0x5613e9b22768
β β 0x5613e9b2279d 488d3ddd0000. lea rdi, qword str.password_is_correct ; 0x5613e9b22881 ; "password is correct"
β β 0x5613e9b227a4 e827feffff call sym.imp.puts ; int puts(const char *s)
β β 0x5613e9b227a9 b800000000 mov eax, 0
β β ; CODE XREF from main @ 0x5613e9b22791
β βββββ> 0x5613e9b227ae 488b4df8 mov rcx, qword [var_8h]
β 0x5613e9b227b2 6448330c2528. xor rcx, qword fs:[0x28]
β ββ< 0x5613e9b227bb 7405 je 0x5613e9b227c2
β β 0x5613e9b227bd e81efeffff call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
β ββ> 0x5613e9b227c2 c9 leave
β 0x5613e9b227c3 c3 ret
[0x7f6163ed6090]>
[0x5613e9b2275f]> ds
[0x5613e9b22766]> pdf @main
; DATA XREF from entry0 @ 0x5613e9b2262d
β 170: int main (int argc, char **argv, char **envp);
β ; var int64_t var_28h @ rbp-0x28
β ; var int64_t var_23h @ rbp-0x23
β ; var int64_t var_21h @ rbp-0x21
β ; var int64_t var_20h @ rbp-0x20
β ; var int64_t var_8h @ rbp-0x8
β 0x5613e9b2271a 55 push rbp
β 0x5613e9b2271b 4889e5 mov rbp, rsp
β 0x5613e9b2271e 4883ec30 sub rsp, 0x30
β 0x5613e9b22722 64488b042528. mov rax, qword fs:[0x28]
β 0x5613e9b2272b 488945f8 mov qword [var_8h], rax
β 0x5613e9b2272f 31c0 xor eax, eax
β 0x5613e9b22731 66c745dd617a mov word [var_23h], 0x7a61 ; 'az'
β 0x5613e9b22737 c645df74 mov byte [var_21h], 0x74 ; 't' ; 116
β 0x5613e9b2273b 488d3d120100. lea rdi, qword str.enter_your_password ; 0x5613e9b22854 ; "enter your password"
β 0x5613e9b22742 e889feffff call sym.imp.puts ; int puts(const char *s)
β 0x5613e9b22747 488d45e0 lea rax, qword [var_20h]
β 0x5613e9b2274b 4889c6 mov rsi, rax
β 0x5613e9b2274e 488d3d130100. lea rdi, qword [0x5613e9b22868] ; "%s"
β 0x5613e9b22755 b800000000 mov eax, 0
β 0x5613e9b2275a e891feffff call sym.imp.__isoc99_scanf ; int scanf(const char *format)
β 0x5613e9b2275f b c745d8000000. mov dword [var_28h], 0
β ;-- rip:
β ββ< 0x5613e9b22766 eb2f jmp 0x5613e9b22797
β βββ> 0x5613e9b22768 8b45d8 mov eax, dword [var_28h]
β ββ 0x5613e9b2276b 4898 cdqe
β ββ 0x5613e9b2276d 0fb65405e0 movzx edx, byte [rbp + rax - 0x20]
β ββ 0x5613e9b22772 8b45d8 mov eax, dword [var_28h]
β ββ 0x5613e9b22775 4898 cdqe
β ββ 0x5613e9b22777 0fb64405dd movzx eax, byte [rbp + rax - 0x23]
β ββ 0x5613e9b2277c 38c2 cmp dl, al
β ββββ< 0x5613e9b2277e 7413 je 0x5613e9b22793
β βββ 0x5613e9b22780 488d3de40000. lea rdi, qword str.password_is_incorrect ; 0x5613e9b2286b ; "password is incorrect"
β βββ 0x5613e9b22787 e844feffff call sym.imp.puts ; int puts(const char *s)
β βββ 0x5613e9b2278c b800000000 mov eax, 0
β βββββ< 0x5613e9b22791 eb1b jmp 0x5613e9b227ae
β βββββ> 0x5613e9b22793 8345d801 add dword [var_28h], 1
β β ββ ; CODE XREF from main @ 0x5613e9b22766
β β βββ> 0x5613e9b22797 837dd802 cmp dword [var_28h], 2
β β βββ< 0x5613e9b2279b b 7ecb jle 0x5613e9b22768
β β 0x5613e9b2279d 488d3ddd0000. lea rdi, qword str.password_is_correct ; 0x5613e9b22881 ; "password is correct"
β β 0x5613e9b227a4 e827feffff call sym.imp.puts ; int puts(const char *s)
β β 0x5613e9b227a9 b800000000 mov eax, 0
β β ; CODE XREF from main @ 0x5613e9b22791
β βββββ> 0x5613e9b227ae 488b4df8 mov rcx, qword [var_8h]
β 0x5613e9b227b2 6448330c2528. xor rcx, qword fs:[0x28]
β ββ< 0x5613e9b227bb 7405 je 0x5613e9b227c2
β β 0x5613e9b227bd e81efeffff call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
β ββ> 0x5613e9b227c2 c9 leave
β 0x5613e9b227c3 c3 ret
[0x5613e9b22766]> px @ rbp-0x28
- offset - 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF
0x7ffc957a00a8 0000 0000 0061 7a74 3132 3300 1356 0000 .....azt123..V..
0x7ffc957a00b8 1026 b2e9 1356 0000 c001 7a95 fc7f 0000 .&...V....z.....
0x7ffc957a00c8 00ab 71c8 1002 107d d027 b2e9 1356 0000 ..q....}.'...V..
0x7ffc957a00d8 cacc d163 617f 0000 c801 7a95 fc7f 0000 ...ca.....z.....
0x7ffc957a00e8 0000 0000 0100 0000 1a27 b2e9 1356 0000 .........'...V..
0x7ffc957a00f8 d9c7 d163 617f 0000 0000 0000 0000 0000 ...ca...........
0x7ffc957a0108 4133 bc38 9e6d 2fdc 1026 b2e9 1356 0000 A3.8.m/..&...V..
0x7ffc957a0118 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x7ffc957a0128 0000 0000 0000 0000 4133 dc76 0e94 f18f ........A3.v....
0x7ffc957a0138 4133 1aee 5979 ca8e 0000 0000 0000 0000 A3..Yy..........
0x7ffc957a0148 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x7ffc957a0158 0100 0000 0000 0000 c801 7a95 fc7f 0000 ..........z.....
0x7ffc957a0168 d801 7a95 fc7f 0000 8011 f063 617f 0000 ..z........ca...
0x7ffc957a0178 0000 0000 0000 0000 0000 0000 0000 0000 ................
0x7ffc957a0188 1026 b2e9 1356 0000 c001 7a95 fc7f 0000 .&...V....z.....
0x7ffc957a0198 0000 0000 0000 0000 0000 0000 0000 0000 ................
|