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 207 208 209 210 211 212 213
| hacker@program-security~does-it-buzz:~$ r2 -A -q -c "pdf @ sym.challenge; pdf @ sym.win" /challenge/does-it-buzz ┌ 507: sym.challenge (char **arg1, char **arg2, int64_t arg3); │ `- args(rdi, rsi, rdx) vars(9:sp[0x10..0x90]) │ 0x000013d0 f30f1efa endbr64 │ 0x000013d4 55 push rbp │ 0x000013d5 4889e5 mov rbp, rsp │ 0x000013d8 4881ec9000.. sub rsp, 0x90 │ 0x000013df 897d8c mov dword [var_74h], edi ; arg1 │ 0x000013e2 48897580 mov qword [var_80h], rsi ; arg2 │ 0x000013e6 48899578ff.. mov qword [var_88h], rdx ; arg3 │ 0x000013ed 64488b0425.. mov rax, qword fs:[0x28] │ 0x000013f6 488945f8 mov qword [canary], rax │ 0x000013fa 31c0 xor eax, eax │ 0x000013fc 488d5590 lea rdx, [buf] │ 0x00001400 b800000000 mov eax, 0 │ 0x00001405 b90c000000 mov ecx, 0xc │ 0x0000140a 4889d7 mov rdi, rdx │ 0x0000140d f348ab rep stosq qword [rdi], rax │ 0x00001410 488d4590 lea rax, [buf] │ 0x00001414 4883c004 add rax, 4 │ 0x00001418 488945e8 mov qword [dest], rax │ 0x0000141c 488d4590 lea rax, [buf] │ 0x00001420 4883c014 add rax, 0x14 │ 0x00001424 488945e0 mov qword [src], rax │ 0x00001428 c745dc0000.. mov dword [var_24h], 0 │ 0x0000142f c745901000.. mov dword [buf], 0x10 │ 0x00001436 488d4590 lea rax, [buf] │ 0x0000143a 4883c044 add rax, 0x44 │ 0x0000143e c70042757a7a mov dword [rax], 0x7a7a7542 ; 'Buzz' │ ; [0x7a7a7542:4]=-1 │ 0x00001444 66c740040a00 mov word [rax + 4], 0xa │ 0x0000144a 488d3dbb0c.. lea rdi, str.Welcome_to_Fizz_Buzz_ ; 0x210c ; "Welcome to Fizz Buzz!" ; const char *s │ 0x00001451 e8eafcffff call sym.imp.puts ; int puts(const char *s) │ 0x00001456 c745dc0000.. mov dword [var_24h], 0 │ ┌─< 0x0000145d e944010000 jmp 0x15a6 │ │ ; CODE XREF from sym.challenge @ 0x15ae(x) │ ┌──> 0x00001462 8b55dc mov edx, dword [var_24h] │ ╎│ 0x00001465 4863c2 movsxd rax, edx │ ╎│ 0x00001468 4869c08988.. imul rax, rax, 0xffffffff88888889 │ ╎│ 0x0000146f 48c1e820 shr rax, 0x20 │ ╎│ 0x00001473 01d0 add eax, edx │ ╎│ 0x00001475 c1f803 sar eax, 3 │ ╎│ 0x00001478 89c1 mov ecx, eax │ ╎│ 0x0000147a 89d0 mov eax, edx │ ╎│ 0x0000147c c1f81f sar eax, 0x1f │ ╎│ 0x0000147f 29c1 sub ecx, eax │ ╎│ 0x00001481 89c8 mov eax, ecx │ ╎│ 0x00001483 89c1 mov ecx, eax │ ╎│ 0x00001485 c1e104 shl ecx, 4 │ ╎│ 0x00001488 29c1 sub ecx, eax │ ╎│ 0x0000148a 89d0 mov eax, edx │ ╎│ 0x0000148c 29c8 sub eax, ecx │ ╎│ 0x0000148e 85c0 test eax, eax │ ┌───< 0x00001490 7510 jne 0x14a2 │ │╎│ 0x00001492 488d05ff2b.. lea rax, obj.fuzzbuzz ; 0x4098 ; "FizzBuzz\n" │ │╎│ 0x00001499 488945e0 mov qword [src], rax │ ┌────< 0x0000149d e980000000 jmp 0x1522 │ ││╎│ ; CODE XREF from sym.challenge @ 0x1490(x) │ │└───> 0x000014a2 8b4ddc mov ecx, dword [var_24h] │ │ ╎│ 0x000014a5 4863c1 movsxd rax, ecx │ │ ╎│ 0x000014a8 4869c05655.. imul rax, rax, 0x55555556 │ │ ╎│ 0x000014af 48c1e820 shr rax, 0x20 │ │ ╎│ 0x000014b3 4889c2 mov rdx, rax │ │ ╎│ 0x000014b6 89c8 mov eax, ecx │ │ ╎│ 0x000014b8 c1f81f sar eax, 0x1f │ │ ╎│ 0x000014bb 89d6 mov esi, edx │ │ ╎│ 0x000014bd 29c6 sub esi, eax │ │ ╎│ 0x000014bf 89f0 mov eax, esi │ │ ╎│ 0x000014c1 89c2 mov edx, eax │ │ ╎│ 0x000014c3 01d2 add edx, edx │ │ ╎│ 0x000014c5 01c2 add edx, eax │ │ ╎│ 0x000014c7 89c8 mov eax, ecx │ │ ╎│ 0x000014c9 29d0 sub eax, edx │ │ ╎│ 0x000014cb 85c0 test eax, eax │ │┌───< 0x000014cd 750d jne 0x14dc │ ││╎│ 0x000014cf 488d05ba2b.. lea rax, obj.fizz ; 0x4090 ; "Fizz\n" │ ││╎│ 0x000014d6 488945e0 mov qword [src], rax │ ┌─────< 0x000014da eb46 jmp 0x1522 │ │││╎│ ; CODE XREF from sym.challenge @ 0x14cd(x) │ ││└───> 0x000014dc 8b4ddc mov ecx, dword [var_24h] │ ││ ╎│ 0x000014df 4863c1 movsxd rax, ecx │ ││ ╎│ 0x000014e2 4869c06766.. imul rax, rax, 0x66666667 │ ││ ╎│ 0x000014e9 48c1e820 shr rax, 0x20 │ ││ ╎│ 0x000014ed 89c2 mov edx, eax │ ││ ╎│ 0x000014ef d1fa sar edx, 1 │ ││ ╎│ 0x000014f1 89c8 mov eax, ecx │ ││ ╎│ 0x000014f3 c1f81f sar eax, 0x1f │ ││ ╎│ 0x000014f6 29c2 sub edx, eax │ ││ ╎│ 0x000014f8 89d0 mov eax, edx │ ││ ╎│ 0x000014fa 89c2 mov edx, eax │ ││ ╎│ 0x000014fc c1e202 shl edx, 2 │ ││ ╎│ 0x000014ff 01c2 add edx, eax │ ││ ╎│ 0x00001501 89c8 mov eax, ecx │ ││ ╎│ 0x00001503 29d0 sub eax, edx │ ││ ╎│ 0x00001505 85c0 test eax, eax │ ││┌───< 0x00001507 750e jne 0x1517 │ │││╎│ 0x00001509 488d4590 lea rax, [buf] │ │││╎│ 0x0000150d 4883c044 add rax, 0x44 │ │││╎│ 0x00001511 488945e0 mov qword [src], rax │ ┌──────< 0x00001515 eb0b jmp 0x1522 │ ││││╎│ ; CODE XREF from sym.challenge @ 0x1507(x) │ │││└───> 0x00001517 488d05822b.. lea rax, obj.nothing ; 0x40a0 ; "\n" │ │││ ╎│ 0x0000151e 488945e0 mov qword [src], rax │ │││ ╎│ ; CODE XREFS from sym.challenge @ 0x149d(x), 0x14da(x), 0x1515(x) │ └└└────> 0x00001522 8b45dc mov eax, dword [var_24h] │ ╎│ 0x00001525 89c6 mov esi, eax │ ╎│ 0x00001527 488d3df40b.. lea rdi, str._d: ; 0x2122 ; "%d: " ; const char *format │ ╎│ 0x0000152e b800000000 mov eax, 0 │ ╎│ 0x00001533 e838fcffff call sym.imp.printf ; int printf(const char *format) │ ╎│ 0x00001538 488d4590 lea rax, [buf] │ ╎│ 0x0000153c 4883c014 add rax, 0x14 │ ╎│ 0x00001540 ba50000000 mov edx, 0x50 ; 'P' ; size_t nbyte │ ╎│ 0x00001545 4889c6 mov rsi, rax ; void *buf │ ╎│ 0x00001548 bf00000000 mov edi, 0 ; int fildes │ ╎│ 0x0000154d e83efcffff call sym.imp.read ; ssize_t read(int fildes, void *buf, size_t nbyte) │ ╎│ 0x00001552 488d4590 lea rax, [buf] │ ╎│ 0x00001556 4883c014 add rax, 0x14 │ ╎│ 0x0000155a 4889c6 mov rsi, rax │ ╎│ 0x0000155d 488d3dc30b.. lea rdi, str.You_entered:__s_n ; 0x2127 ; "You entered: %s\n" ; const char *format │ ╎│ 0x00001564 b800000000 mov eax, 0 │ ╎│ 0x00001569 e802fcffff call sym.imp.printf ; int printf(const char *format)
│ ╎│ 0x0000156e c645a400 mov byte [var_5ch], 0 │ ╎│ 0x00001572 488b55e0 mov rdx, qword [src] │ ╎│ 0x00001576 488b45e8 mov rax, qword [dest] │ ╎│ 0x0000157a 4889d6 mov rsi, rdx ; const char *src │ ╎│ 0x0000157d 4889c7 mov rdi, rax ; char *dest │ ╎│ 0x00001580 e8abfbffff call sym.imp.strcpy ; char *strcpy(char *dest, const char *src) │ ╎│ 0x00001585 488b45e8 mov rax, qword [dest] │ ╎│ 0x00001589 4889c6 mov rsi, rax │ ╎│ 0x0000158c 488d3da50b.. lea rdi, str.Correct_answer:__s_n ; 0x2138 ; "Correct answer: %s\n" ; const char *format │ ╎│ 0x00001593 b800000000 mov eax, 0 │ ╎│ 0x00001598 e8d3fbffff call sym.imp.printf ; int printf(const char *format) │ ╎│ 0x0000159d 8b45dc mov eax, dword [var_24h] │ ╎│ 0x000015a0 83c001 add eax, 1 │ ╎│ 0x000015a3 8945dc mov dword [var_24h], eax │ ╎│ ; CODE XREF from sym.challenge @ 0x145d(x) │ ╎└─> 0x000015a6 8b55dc mov edx, dword [var_24h] │ ╎ 0x000015a9 8b4590 mov eax, dword [buf] │ ╎ 0x000015ac 39c2 cmp edx, eax │ └──< 0x000015ae 0f8caefeffff jl 0x1462 │ 0x000015b4 90 nop │ 0x000015b5 488b75f8 mov rsi, qword [canary] │ 0x000015b9 6448333425.. xor rsi, qword fs:[0x28] │ ┌─< 0x000015c2 7405 je 0x15c9 │ │ 0x000015c4 e897fbffff call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void) │ │ ; CODE XREF from sym.challenge @ 0x15c2(x) │ └─> 0x000015c9 c9 leave └ 0x000015ca c3 ret ┌ 263: sym.win (); │ 0x000012c9 f30f1efa endbr64 │ 0x000012cd 55 push rbp │ 0x000012ce 4889e5 mov rbp, rsp │ 0x000012d1 488d3d300d.. lea rdi, str.You_win__Here_is_your_flag: ; 0x2008 ; "You win! Here is your flag:" ; const char *s │ 0x000012d8 e863feffff call sym.imp.puts ; int puts(const char *s) │ 0x000012dd be00000000 mov esi, 0 ; int oflag │ 0x000012e2 488d3d3b0d.. lea rdi, str._flag ; 0x2024 ; "/flag" ; const char *path │ 0x000012e9 b800000000 mov eax, 0 │ 0x000012ee e8bdfeffff call sym.imp.open ; int open(const char *path, int oflag) │ 0x000012f3 8905e72d0000 mov dword [obj.flag_fd.5698], eax ; [0x40e0:4]=0 │ 0x000012f9 8b05e12d0000 mov eax, dword [obj.flag_fd.5698] ; [0x40e0:4]=0 │ 0x000012ff 85c0 test eax, eax │ ┌─< 0x00001301 794d jns 0x1350 │ │ 0x00001303 e818feffff call sym.imp.__errno_location │ │ 0x00001308 8b00 mov eax, dword [rax] │ │ 0x0000130a 89c7 mov edi, eax ; int errnum │ │ 0x0000130c e8bffeffff call sym.imp.strerror ; char *strerror(int errnum) │ │ 0x00001311 4889c6 mov rsi, rax │ │ 0x00001314 488d3d150d.. lea rdi, str._n__ERROR:_Failed_to_open_the_flag_____s__n ; 0x2030 ; "\n ERROR: Failed to open the flag -- %s!\n" ; const char *format │ │ 0x0000131b b800000000 mov eax, 0 │ │ 0x00001320 e84bfeffff call sym.imp.printf ; int printf(const char *format) │ │ 0x00001325 e856feffff call sym.imp.geteuid ; uid_t geteuid(void) │ │ 0x0000132a 85c0 test eax, eax │ ┌──< 0x0000132c 7418 je 0x1346 │ ││ 0x0000132e 488d3d2b0d.. lea rdi, str.__Your_effective_user_id_is_not_0_ ; 0x2060 ; " Your effective user id is not 0!" ; const char *s │ ││ 0x00001335 e806feffff call sym.imp.puts ; int puts(const char *s) │ ││ 0x0000133a 488d3d470d.. lea rdi, str.__You_must_directly_run_the_suid_binary_in_order_to_have_the_correct_permissions_ ; 0x2088 ; " You must directly run the suid binary in order to have the correct permissions!" ; const char *s │ ││ 0x00001341 e8fafdffff call sym.imp.puts ; int puts(const char *s) │ ││ ; CODE XREF from sym.win @ 0x132c(x) │ └──> 0x00001346 bfffffffff mov edi, 0xffffffff ; -1 ; int status │ │ 0x0000134b e870feffff call sym.imp.exit ; void exit(int status) │ │ ; CODE XREF from sym.win @ 0x1301(x) │ └─> 0x00001350 8b058a2d0000 mov eax, dword [obj.flag_fd.5698] ; [0x40e0:4]=0 │ 0x00001356 ba00010000 mov edx, 0x100 ; size_t nbyte │ 0x0000135b 488d359e2d.. lea rsi, obj.flag.5697 ; 0x4100 ; void *buf │ 0x00001362 89c7 mov edi, eax ; int fildes │ 0x00001364 e827feffff call sym.imp.read ; ssize_t read(int fildes, void *buf, size_t nbyte) │ 0x00001369 8905912e0000 mov dword [obj.flag_length.5699], eax ; [0x4200:4]=0 │ 0x0000136f 8b058b2e0000 mov eax, dword [obj.flag_length.5699] ; [0x4200:4]=0 │ 0x00001375 85c0 test eax, eax │ ┌─< 0x00001377 7f2c jg 0x13a5 │ │ 0x00001379 e8a2fdffff call sym.imp.__errno_location │ │ 0x0000137e 8b00 mov eax, dword [rax] │ │ 0x00001380 89c7 mov edi, eax ; int errnum │ │ 0x00001382 e849feffff call sym.imp.strerror ; char *strerror(int errnum) │ │ 0x00001387 4889c6 mov rsi, rax │ │ 0x0000138a 488d3d4f0d.. lea rdi, str._n__ERROR:_Failed_to_read_the_flag_____s__n ; 0x20e0 ; "\n ERROR: Failed to read the flag -- %s!\n" ; const char *format │ │ 0x00001391 b800000000 mov eax, 0 │ │ 0x00001396 e8d5fdffff call sym.imp.printf ; int printf(const char *format) │ │ 0x0000139b bfffffffff mov edi, 0xffffffff ; -1 ; int status │ │ 0x000013a0 e81bfeffff call sym.imp.exit ; void exit(int status) │ │ ; CODE XREF from sym.win @ 0x1377(x) │ └─> 0x000013a5 8b05552e0000 mov eax, dword [obj.flag_length.5699] ; [0x4200:4]=0 │ 0x000013ab 4898 cdqe │ 0x000013ad 4889c2 mov rdx, rax ; size_t nbytes │ 0x000013b0 488d35492d.. lea rsi, obj.flag.5697 ; 0x4100 ; const char *ptr │ 0x000013b7 bf01000000 mov edi, 1 ; int fd │ 0x000013bc e88ffdffff call sym.imp.write ; ssize_t write(int fd, const char *ptr, size_t nbytes) │ 0x000013c1 488d3d420d.. lea rdi, [0x0000210a] ; "\n" ; const char *s │ 0x000013c8 e873fdffff call sym.imp.puts ; int puts(const char *s) │ 0x000013cd 90 nop │ 0x000013ce 5d pop rbp └ 0x000013cf c3 ret
|