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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
| kali@kali:~/CTFs/tryhackme/Reversing ELF$ r2 -d crackme6
Process with PID 16349 started...
= attach 16349 16349
bin.baddr 0x00400000
Using 0x400000
asm.bits 64
Warning: r_bin_file_hash: file exceeds bin.hashlimit
[0x7ff486423090]> 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.
[0x7ff486423090]> afl
0x00400490 1 41 entry0
0x00400470 1 6 sym.imp.__libc_start_main
0x004004c0 4 41 sym.deregister_tm_clones
0x004004f0 4 57 sym.register_tm_clones
0x00400530 3 28 entry.fini0
0x00400550 4 45 -> 42 entry.init0
0x004007d0 1 2 sym.__libc_csu_fini
0x004007d4 1 9 sym._fini
0x004006d1 4 64 sym.compare_pwd
0x00400760 4 101 sym.__libc_csu_init
0x00400711 4 74 main
0x0040057d 28 340 sym.my_secure_test
0x00400418 3 26 sym._init
0x00400480 1 6 loc.imp.__gmon_start
0x00400450 1 6 sym.imp.puts
0x00400460 1 6 sym.imp.printf
[0x7ff486423090]> pdf @main
; DATA XREF from entry0 @ 0x4004ad
β 74: int main (int argc, char **argv, char **envp);
β ; var int64_t var_10h @ rbp-0x10
β ; var int64_t var_4h @ rbp-0x4
β ; arg int argc @ rdi
β ; arg char **argv @ rsi
β 0x00400711 55 push rbp
β 0x00400712 4889e5 mov rbp, rsp
β 0x00400715 4883ec10 sub rsp, 0x10
β 0x00400719 897dfc mov dword [var_4h], edi ; argc
β 0x0040071c 488975f0 mov qword [var_10h], rsi ; argv
β 0x00400720 837dfc02 cmp dword [var_4h], 2
β ββ< 0x00400724 741b je 0x400741
β β 0x00400726 488b45f0 mov rax, qword [var_10h]
β β 0x0040072a 488b00 mov rax, qword [rax]
β β 0x0040072d 4889c6 mov rsi, rax
β β 0x00400730 bf10084000 mov edi, str.Usage_:__s_password__Good_luck__read_the_source ; 0x400810 ; "Usage : %s password\nGood luck, read the source\n"
β β 0x00400735 b800000000 mov eax, 0
β β 0x0040073a e821fdffff call sym.imp.printf ; int printf(const char *format)
β βββ< 0x0040073f eb13 jmp 0x400754
β βββ> 0x00400741 488b45f0 mov rax, qword [var_10h]
β β 0x00400745 4883c008 add rax, 8
β β 0x00400749 488b00 mov rax, qword [rax]
β β 0x0040074c 4889c7 mov rdi, rax
β β 0x0040074f e87dffffff call sym.compare_pwd
β β ; CODE XREF from main @ 0x40073f
β βββ> 0x00400754 b800000000 mov eax, 0
β 0x00400759 c9 leave
β 0x0040075a c3 ret
[0x7ff486423090]> pdf @sym.comare_pwd
Invalid address (sym.comare_pwd)
|ERROR| Invalid command 'pdf @sym.comare_pwd' (0x70)
[0x7ff486423090]> pdf @sym.compare_pwd
; CALL XREF from main @ 0x40074f
β 64: sym.compare_pwd (int64_t arg1);
β ; var int64_t var_8h @ rbp-0x8
β ; arg int64_t arg1 @ rdi
β 0x004006d1 55 push rbp
β 0x004006d2 4889e5 mov rbp, rsp
β 0x004006d5 4883ec10 sub rsp, 0x10
β 0x004006d9 48897df8 mov qword [var_8h], rdi ; arg1
β 0x004006dd 488b45f8 mov rax, qword [var_8h]
β 0x004006e1 4889c7 mov rdi, rax
β 0x004006e4 e894feffff call sym.my_secure_test
β 0x004006e9 85c0 test eax, eax
β ββ< 0x004006eb 750c jne 0x4006f9
β β 0x004006ed bfe8074000 mov edi, str.password_OK ; 0x4007e8 ; "password OK"
β β 0x004006f2 e859fdffff call sym.imp.puts ; int puts(const char *s)
β βββ< 0x004006f7 eb16 jmp 0x40070f
β βββ> 0x004006f9 488b45f8 mov rax, qword [var_8h]
β β 0x004006fd 4889c6 mov rsi, rax
β β 0x00400700 bff4074000 mov edi, str.password___s__not_OK ; 0x4007f4 ; "password \"%s\" not OK\n"
β β 0x00400705 b800000000 mov eax, 0
β β 0x0040070a e851fdffff call sym.imp.printf ; int printf(const char *format)
β β ; CODE XREF from sym.compare_pwd @ 0x4006f7
β βββ> 0x0040070f c9 leave
β 0x00400710 c3 ret
[0x7ff486423090]> pdf @sym.my_secure_test
; CALL XREF from sym.compare_pwd @ 0x4006e4
β 340: sym.my_secure_test (int64_t arg1);
β ; var int64_t var_8h @ rbp-0x8
β ; arg int64_t arg1 @ rdi
β 0x0040057d 55 push rbp
β 0x0040057e 4889e5 mov rbp, rsp
β 0x00400581 48897df8 mov qword [var_8h], rdi ; arg1
β 0x00400585 488b45f8 mov rax, qword [var_8h]
β 0x00400589 0fb600 movzx eax, byte [rax]
β 0x0040058c 84c0 test al, al
β ββ< 0x0040058e 740b je 0x40059b
β β 0x00400590 488b45f8 mov rax, qword [var_8h]
β β 0x00400594 0fb600 movzx eax, byte [rax]
β β 0x00400597 3c31 cmp al, 0x31 ; 49
β βββ< 0x00400599 740a je 0x4005a5
β βββ> 0x0040059b b8ffffffff mov eax, 0xffffffff ; -1
β βββ< 0x004005a0 e92a010000 jmp 0x4006cf
β βββ> 0x004005a5 488b45f8 mov rax, qword [var_8h]
β β 0x004005a9 4883c001 add rax, 1
β β 0x004005ad 0fb600 movzx eax, byte [rax]
β β 0x004005b0 84c0 test al, al
β βββ< 0x004005b2 740f je 0x4005c3
β ββ 0x004005b4 488b45f8 mov rax, qword [var_8h]
β ββ 0x004005b8 4883c001 add rax, 1
β ββ 0x004005bc 0fb600 movzx eax, byte [rax]
β ββ 0x004005bf 3c33 cmp al, 0x33 ; 51
β ββββ< 0x004005c1 740a je 0x4005cd
β ββββ> 0x004005c3 b8ffffffff mov eax, 0xffffffff ; -1
β ββββ< 0x004005c8 e902010000 jmp 0x4006cf
β ββββ> 0x004005cd 488b45f8 mov rax, qword [var_8h]
β ββ 0x004005d1 4883c002 add rax, 2
β ββ 0x004005d5 0fb600 movzx eax, byte [rax]
β ββ 0x004005d8 84c0 test al, al
β ββββ< 0x004005da 740f je 0x4005eb
β βββ 0x004005dc 488b45f8 mov rax, qword [var_8h]
β βββ 0x004005e0 4883c002 add rax, 2
β βββ 0x004005e4 0fb600 movzx eax, byte [rax]
β βββ 0x004005e7 3c33 cmp al, 0x33 ; 51
β βββββ< 0x004005e9 740a je 0x4005f5
β βββββ> 0x004005eb b8ffffffff mov eax, 0xffffffff ; -1
β βββββ< 0x004005f0 e9da000000 jmp 0x4006cf
β βββββ> 0x004005f5 488b45f8 mov rax, qword [var_8h]
β βββ 0x004005f9 4883c003 add rax, 3
β βββ 0x004005fd 0fb600 movzx eax, byte [rax]
β βββ 0x00400600 84c0 test al, al
β βββββ< 0x00400602 740f je 0x400613
β ββββ 0x00400604 488b45f8 mov rax, qword [var_8h]
β ββββ 0x00400608 4883c003 add rax, 3
β ββββ 0x0040060c 0fb600 movzx eax, byte [rax]
β ββββ 0x0040060f 3c37 cmp al, 0x37 ; 55
β ββββββ< 0x00400611 740a je 0x40061d
β ββββββ> 0x00400613 b8ffffffff mov eax, 0xffffffff ; -1
β ββββββ< 0x00400618 e9b2000000 jmp 0x4006cf
β ββββββ> 0x0040061d 488b45f8 mov rax, qword [var_8h]
β ββββ 0x00400621 4883c004 add rax, 4
β ββββ 0x00400625 0fb600 movzx eax, byte [rax]
β ββββ 0x00400628 84c0 test al, al
β ββββββ< 0x0040062a 740f je 0x40063b
β βββββ 0x0040062c 488b45f8 mov rax, qword [var_8h]
β βββββ 0x00400630 4883c004 add rax, 4
β βββββ 0x00400634 0fb600 movzx eax, byte [rax]
β βββββ 0x00400637 3c5f cmp al, 0x5f ; 95
β βββββββ< 0x00400639 740a je 0x400645
β βββββββ> 0x0040063b b8ffffffff mov eax, 0xffffffff ; -1
β βββββββ< 0x00400640 e98a000000 jmp 0x4006cf
β βββββββ> 0x00400645 488b45f8 mov rax, qword [var_8h]
β βββββ 0x00400649 4883c005 add rax, 5
β βββββ 0x0040064d 0fb600 movzx eax, byte [rax]
β βββββ 0x00400650 84c0 test al, al
β βββββββ< 0x00400652 740f je 0x400663
β ββββββ 0x00400654 488b45f8 mov rax, qword [var_8h]
β ββββββ 0x00400658 4883c005 add rax, 5
β ββββββ 0x0040065c 0fb600 movzx eax, byte [rax]
β ββββββ 0x0040065f 3c70 cmp al, 0x70 ; 112
β ββββββββ< 0x00400661 7407 je 0x40066a
β ββββββββ> 0x00400663 b8ffffffff mov eax, 0xffffffff ; -1
β ββββββββ< 0x00400668 eb65 jmp 0x4006cf
β ββββββββ> 0x0040066a 488b45f8 mov rax, qword [var_8h]
β ββββββ 0x0040066e 4883c006 add rax, 6
β ββββββ 0x00400672 0fb600 movzx eax, byte [rax]
β ββββββ 0x00400675 84c0 test al, al
β ββββββββ< 0x00400677 740f je 0x400688
β βββββββ 0x00400679 488b45f8 mov rax, qword [var_8h]
β βββββββ 0x0040067d 4883c006 add rax, 6
β βββββββ 0x00400681 0fb600 movzx eax, byte [rax]
β βββββββ 0x00400684 3c77 cmp al, 0x77 ; 119
β ββββββββ< 0x00400686 7407 je 0x40068f
β ββββββββ> 0x00400688 b8ffffffff mov eax, 0xffffffff ; -1
β ββββββββ< 0x0040068d eb40 jmp 0x4006cf
β ββββββββ> 0x0040068f 488b45f8 mov rax, qword [var_8h]
β βββββββ 0x00400693 4883c007 add rax, 7
β βββββββ 0x00400697 0fb600 movzx eax, byte [rax]
β βββββββ 0x0040069a 84c0 test al, al
β ββββββββ< 0x0040069c 740f je 0x4006ad
β βββββββ 0x0040069e 488b45f8 mov rax, qword [var_8h]
β βββββββ 0x004006a2 4883c007 add rax, 7
β βββββββ 0x004006a6 0fb600 movzx eax, byte [rax]
β βββββββ 0x004006a9 3c64 cmp al, 0x64 ; 100
β ββββββββ< 0x004006ab 7407 je 0x4006b4
β ββββββββ> 0x004006ad b8ffffffff mov eax, 0xffffffff ; -1
β ββββββββ< 0x004006b2 eb1b jmp 0x4006cf
β ββββββββ> 0x004006b4 488b45f8 mov rax, qword [var_8h]
β βββββββ 0x004006b8 4883c008 add rax, 8
β βββββββ 0x004006bc 0fb600 movzx eax, byte [rax]
β βββββββ 0x004006bf 84c0 test al, al
β ββββββββ< 0x004006c1 7407 je 0x4006ca
β βββββββ 0x004006c3 b8ffffffff mov eax, 0xffffffff ; -1
β ββββββββ< 0x004006c8 eb05 jmp 0x4006cf
β ββββββββ> 0x004006ca b800000000 mov eax, 0
β βββββββ ; XREFS: CODE 0x004005a0 CODE 0x004005c8 CODE 0x004005f0 CODE 0x00400618 CODE 0x00400640 CODE 0x00400668
β βββββββ ; XREFS: CODE 0x0040068d CODE 0x004006b2 CODE 0x004006c8
β ββββββββ> 0x004006cf 5d pop rbp
β 0x004006d0 c3 ret
|