๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ฐ˜์‘ํ˜•

๐Ÿด‍โ˜ ๏ธ CTF ๐Ÿด‍โ˜ ๏ธ/๐Ÿงฎ ์•”ํ˜ธํ•™ ๐Ÿงฎ

(17)
[Dream Hack - Pwnable] baby-bof Buffer Over Flow ํ”„๋กœ๊ทธ๋žจ์ด ํŠน์ • ํฌ๊ธฐ์˜ ๋ฉ”๋ชจ๋ฆฌ ๋ฒ„ํผ๋ฅผ ๋„˜์–ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์“ธ ๋•Œ ๋ฐœ์ƒ ์ทจ์•ฝ์ ์€ ๊ณต๊ฒฉ์ž๊ฐ€ ์•…์˜์ ์ธ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ฑฐ๋‚˜ ์‹œ์Šคํ…œ์˜ ๋™์ž‘์„ ๋ณ€์กฐํ•˜๋Š” ๋ฐ ์ด์šฉ๊ฐ€๋Šฅ ํ’€์ด๋ฐฉ๋ฒ• 1. name์„ ์ž…๋ ฅ๋ฐ›์•„์„œ ์ž‘์„ฑ | 7ffdc4799ed0 | 7ffdc4799ed8 | ์— ์ž…๋ ฅํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ stack ์•ˆ์— ์ €์žฅ๋˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. $ nc host3.dreamhack.games 17378 the main function doesn't call win function (0x40125b)! name: AAAAAAAAA GM GA GE GV AAAAAAAAA!! : | addr| value| | 7ffdc4799ed0| 4141414141414141| | 7ffdc4799ed8| 400041..
[Dream Hack - Crypto] RSA-wiener Wiener ๊ณต๊ฒฉ ์œ„๋„ˆ(Wiener)์˜ ๊ณต๊ฒฉ์€ RSA ์•”ํ˜ธํ™” ๋ฐฉ์‹์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์ทจ์•ฝ์„ฑ์„ ์ด์šฉํ•œ ๊ณต๊ฒฉ ๊ธฐ๋ฒ• ์ค‘ ํ•˜๋‚˜์ด๋‹ค. RSA๋Š” ๊ณต๊ฐœํ‚ค ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋ฉฐ, ํฐ ์†Œ์ˆ˜์ธ ๋‘ ๊ฐœ์˜ ์†Œ์ˆ˜๋ฅผ ๊ธฐ๋ฐ˜์„ ํ•œ๋‹ค. ํ•˜์ง€๋งŒ ์œ„๋„ˆ์˜ ๊ณต๊ฒฉ์€ ํŠน์ • ์กฐ๊ฑด์ด ์ถฉ์กฑ๋  ๋•Œ, RSA์˜ ๊ฐœ์ธํ‚ค๋ฅผ ๋ณต๊ตฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ๋‹ค. ์œ„๋„ˆ์˜ ๊ณต๊ฒฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ „์ œ ์กฐ๊ฑด์„ ํ•„์š”๋กœ ํ•œ๋‹ค: ์†Œ์ˆ˜ p์™€ q๊ฐ€ n = p x q๋กœ๋ถ€ํ„ฐ ๊ณ„์‚ฐ๋˜์—ˆ์„ ๋•Œ, p์™€ q์˜ ํฌ๊ธฐ๊ฐ€ ๋„ˆ๋ฌด ์ž‘์•„ n์„ ๊ณ„์‚ฐํ•˜๋Š” ๋ฐ ์ƒ๋‹นํ•œ ๋น„์šฉ์ด ๋“ค์ง€ ์•Š๋Š” ๊ฒฝ์šฐ. e๊ฐ€ ๋งค์šฐ ํฐ ๊ฒฝ์šฐ. ๋ณดํ†ต RSA์—์„œ๋Š” ๊ณต๊ฐœ ์ง€์ˆ˜ e๋กœ ์ž‘์€ ์†Œ์ˆ˜, ์ฃผ๋กœ 3 ๋˜๋Š” 65537(2^16 + 1)์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ e๊ฐ€ ๋งค์šฐ ํฐ ๊ฒฝ์šฐ์—๋Š” ์œ„๋„ˆ์˜ ๊ณต๊ฒฉ์ด ์ ์šฉ๋  ์ˆ˜ ์žˆ๋‹ค. ์œ„ ์กฐ๊ฑด์„ ์ถฉ์กฑํ•˜๋Š” ๊ฒฝ์šฐ, ์œ„..
[Dream Hack - Crypto] fuzzy flag ํ’€์ด ๋ฐฉ๋ฒ• 1. flag์— 0~51 ์ค‘ ํ•˜๋‚˜์˜ ์ˆซ์ž๊ฐ€ ๋žจ๋˜์œผ๋กœ ๋”ํ•ด์ง€๋Š” ํ˜•ํƒœ์ด๋‹ค. ๋”ฐ๋ผ์„œ flag์˜ ascii ์ฝ”๋“œ ๊ฐ’ ๋ณด๋‹ค ์ž‘์€ ๊ฐ’์€ ์ถœ๋ ฅ๋  ์ˆ˜ ์žˆ๋‹ค. fuzzy = [c + randbelow(len(string.ascii_letters)) for c in flag] 2. ์—ฌ๋Ÿฌ๋ฒˆ ๋ฐ˜๋ณตํ•˜์—ฌ ๊ฐ index์˜ ๊ฐ€์žฅ ์ž‘์€ ๊ฐ’๋งŒ ์ €์žฅํ•œ๋‹ค. 3. ์ž‘์€ ๊ฐ’๋งŒ ์ €์žฅ๋œ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณ€ํ™˜ํ•˜๋ฉด! flag๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค. ํ’€์ด ์ฝ”๋“œ from pwn import * import time ## 185 ๊ธ€์ž min_data_list = [255] * 185 for count in range(0, 216) : p = remote("host3.dreamhack.games", 21384) data = p.recvline().decode..
[Dream Hack - Crypto] chinese what? ํ’€์ด ๊ณผ์ • M ๊ณ„์‚ฐ: M์€ ๋ชจ๋“  pi (์—ฌ๊ธฐ์„œ๋Š” p1, p2, p3) ๊ฐ’์„ ๊ณฑํ•œ ๊ฐ’์ž…๋‹ˆ๋‹ค. M = p1 * p2 * p3 mi ๊ณ„์‚ฐ: mi๋Š” M์„ ํ•ด๋‹น ์†Œ์ˆ˜ pi๋กœ ๋‚˜๋ˆˆ ๋ชซ์ž…๋‹ˆ๋‹ค. m1 = M // p1, m2 = M // p2, m3 = M // p3 ์—ญ์› ๊ณ„์‚ฐ: mi์˜ ์—ญ์› yi๋Š” mi๋ฅผ ๋ชจ๋“ˆ๋กœ pi๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€์™€ ๊ณฑํ–ˆ์„ ๋•Œ 1์ด ๋˜๋Š” ๊ฐ’์ž…๋‹ˆ๋‹ค. ์—ญ์›์€ ๋ชจ๋“ˆ๋กœ ์—ฐ์‚ฐ์—์„œ ๋‚˜๋ˆ—์…ˆ์˜ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. ์—ญ์›์€ ํ™•์žฅ๋œ ์œ ํด๋ฆฌ๋“œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋“ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ณ„์‚ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณต์›: ์ด์ œ ์—ญ์›๊ณผ mi ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ flag ๊ฐ’์„ ๋ณต์›ํ•ฉ๋‹ˆ๋‹ค. flag = (c1 * y1 * m1 + c2 * y2 * m2 + c3 * y3 * m3) % M ํ’€์ด ์ฝ”๋“œ from Crypto.Util.number import long_..
[Dream Hack - Crypto] ICM2022 ํ’€์ด ๊ณผ์ • 1. enc ํ•จ์ˆ˜์—์„œ q ๊ฐ’์€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‹์„ ๋งŒ์กฑํ•œ๋‹ค. 2. n = 3, key2 = 95 ์ผ๋•Œ, q = -200640142664324295933714 ์„ ๋งŒ์กฑํ•˜๋Š” p, key1 ์„ ๊ตฌํ•˜์ž! 3. key1 < key2 ์ด๋ฏ€๋กœ 0 ≤ key1 < 95 ์ด๊ณ , ์ž„์˜์˜ key1 ๊ฐ’์— ๋Œ€ํ•œ p ๊ฐ’์„ ํ™•์ธํ•˜์—ฌ flag๋ฅผ ์ถ”๋ก ํ•˜์ž!! 4. p ๊ฐ’์„ ํ™•์ธํ•˜๋Š” dec ํ•จ์ˆ˜๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์‹์„ ๋งŒ์กฑํ•œ๋‹ค. 5. dec ๋ฅผ ํ†ตํ•ด p ๋ฅผ ๊ตฌํ•˜๊ณ , enc ์— p ๋ฅผ ๋Œ€์ž…ํ•˜์—ฌ q_test ๊ตฌํ•œ ํ›„ ๊ธฐ์กด p ๊ฐ’๊ณผ ๋น„๊ตํ•œ๋‹ค. ํ’€์ด ์ฝ”๋“œ import random from fractions import Fraction # ์ฃผ์–ด์ง„ ๊ฐ’ p๋ฅผ n, key1, key2๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•”ํ˜ธํ™”ํ•˜๋Š” ํ•จ์ˆ˜ def enc(p, n, key1..
[Dream Hack - Crypto] darimchal_001 ๋ฌธ์ œ ํ•ด์„ pwd ^ KEY = JOKER ๋ฅผ ๋งŒ์กฑํ•˜๋ฉด ๋ณตํ˜ธํ™”๊ฐ€ ๋œ๋‹ค. ์ฝ”๋“œ ํ•ด์„ #include #include #include // ์ดˆ๊ธฐํ™”๋œ ๊ฐ’์œผ๋กœ ์ •์˜ํ•œ ๋ฌธ์ž์—ด ์ƒ์ˆ˜๋“ค #define JOKER "\\x40\\x53\\x06\\x03\\x43\\x52\\x54\\x3b" #define KEY "023661dd4\\0" #define TRUE 1 #define FALSE 0 #define OK 0 #define ERRO -1 // ์†Œํ”„ํŠธ์›จ์–ด ์ด๋ฆ„๊ณผ ์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜ void __print_sw_title (char *sw_name); // ์ฃผ์–ด์ง„ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์œ ํšจํ•œ์ง€ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜ int __is_valid_pwd (char *pwd); // ์ฃผ์–ด์ง„ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ‚ค๋ฅผ ์ด์šฉํ•ด ๋‚œ๋…ํ™”ํ•˜๋Š” ํ•จ์ˆ˜ cha..
[Dream Hack - Crypto] ROT128 ๋ฌธ์ œ ํ•ด์„ flag.png ๋ฅผ ์ œ๊ณต๋œ ์ฝ”๋“œ๋กœ ์•”ํ˜ธํ™”ํ•˜์—ฌ encfile ์„ ์ž‘์„ฑํ•˜์˜€๋‹ค. png ํŒŒ์ผ์„ 128byte ๋งŒํผ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ฐ€์–ด์„œ utf-8๋กœ ์ธ์ฝ”๋”ฉ ๋œ ์•”ํ˜ธํ™” ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค. ์•”ํ˜ธํ™”๋œ ํŒŒ์ผ์„ byte ๋‹จ์œ„๋กœ ์ฝ์–ด์™€ ๋‹ค์‹œ ์™ผ์ชฝ์œผ๋กœ 128byte ๋งŒํผ ๋ฐ€์–ด bin ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ๋‹ค. ์ฝ”๋“œ ํ•ด์„ # ์ดˆ๊ธฐ 0๋ถ€ํ„ฐ 255๊นŒ์ง€์˜ ์ˆซ์ž๋ฅผ 16์ง„์ˆ˜๋กœ ํ‘œํ˜„ํ•œ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. hex_list = [(hex(i)[2:].zfill(2).upper()) for i in range(256)] # print(hex_list) # 'flag.png' ํŒŒ์ผ์„ ๋ฐ”์ด๋„ˆ๋ฆฌ ๋ชจ๋“œ๋กœ ์—ด์–ด์„œ ๋‚ด์šฉ์„ ์ฝ์–ด์˜ต๋‹ˆ๋‹ค. with open('flag.png', 'rb') as f: plain_s = f.read() # 'plain_s' ๋ฐ”..
[Dream Hack - Crypto] Robot Only ํ’€์ด ๋ฐฉ๋ฒ• ๋กœ๋ด‡์ž„์„ ์ธ์ฆ ์ถœ๋ ฅ๋˜๋Š” ํ† ํฐ์„ ์žฌ์ž…๋ ฅ ๋ฐฐํŒ…์„ ํ†ตํ•ด ๋ˆ์„ ๋ฒ”๋ฐฐํŒ…ํ•˜๋Š” ๋ˆ์ด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ˆ๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธ. ์Œ์ˆ˜์˜ ๋ˆ์„ ๋ฐฐํŒ…ํ•˜์—ฌ ๋ฐฐํŒ…์—์„œ ์ง€๋Š” ๊ฒฝ์šฐ, money - bet ์‹์„ ํ†ตํ•ด ์˜คํžˆ๋ ค ๋ˆ์„ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธ bet = int(input('how much money do you want to bet (your money: ${0})? '.format(money))) if money < bet: print('you don\\'t have enough money (your money: ${0}).'.format(money)) return ๋ˆ์ฃผ๊ณ  flag๋ฅผ ์‚ฐ๋‹ค. ์ฝ”๋“œ from pwn import * import time p = remote("host3.dreamhack...

๋ฐ˜์‘ํ˜•