๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ Web Hacking/Dreamhack

[Dreamhack] Proxy-1 ๋“œ๋ฆผํ•ต ์›Œ๊ฒŒ์ž„ ๋ฌธ์ œ ํ’€์ด

by A Lim Han 2022. 11. 7.

6 - 0 - 1. Proxy-1 ๋“œ๋ฆผํ•ต ๋ฌธ์ œ ํ’€์ด

 

 

 

# Proxy-1 ๋“œ๋ฆผํ•ต ๋ฌธ์ œ ํ’€์ด

1. ๋ฌธ์ œ ์ •๋ณด ํ™•์ธ ํ›„ ๋ฌธ์ œ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ

+ Raw Socket์ด๋ž€?

๋ณดํ†ต์˜ ์ธํ„ฐ๋„ท ํ†ต์‹ ์€ TCP/IP์˜ 4๊ณ„์ธต์— ๋”ฐ๋ฅธ ๋‹จ๊ณ„๋ณ„๋กœ ํฌ๋งทํŒ… ๋ฐ ์ „์†ก๋˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์น˜๋Š”๋ฐ, ํ”„๋กœํ† ์ฝœ์šฉ ์ „์†ก ๊ณ„์ธต ํฌ๋งทํŒ… ๊ณผ์ • ์—†์ด ์ธํ„ฐ๋„ท์˜ ํ”„๋กœํ† ์ฝœ ํŒจํ‚ท์„ ์ง์ ‘ ์ฃผ๊ณ  ๋ฐ›๋Š” ๊ฒƒ์„ ๋•๋Š” ์†Œ์ผ“.

-->  ์œ„ ์†Œ์ผ“์„ ํ†ตํ•ด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜(= Application) ๋‹จ๊ณ„์—์„œ ํ†ต์‹  ๋ฐ์ดํ„ฐ๋ฅผ ์กฐ์ž‘ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

 

 

 

2. ์ ‘์† ๋งํฌ ํ™•์ธ ํ›„ ์•ˆ๋‚ด๋œ ๋งํฌ๋กœ ์ ‘์†

 

 

 

 

 

3. Raw Socket Sender (Done)์„ ํด๋ฆญ ํ›„ host, port, Data ์— ๊ฐ๊ฐ 8000.0.0.1, 80, flags ์ž…๋ ฅ

 

host, port, Data ์— ๊ฐ๊ฐ 8000.0.0.1, 80, flags ์ž…๋ ฅ

 

 

+ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•จ์„ ํ™•์ธ ๊ฐ€๋Šฅ

 

 

 

 

4. ๋‹ค์šด๋ฐ›์€ ๋ฌธ์ œ ํŒŒ์ผ app.py ์„ ์—ด์–ด ์ฝ”๋“œ ๋ถ„์„

+ << Line 16 ~ 31 >>

: send ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ host, port, Data ๊ฐ’์ด ์ „์†ก

 

 

+ << Line 44 ~ 45 >>

: ์กฐ๊ฑด 1

-->  ์‚ฌ์šฉ์ž์˜ ip๊ฐ€ 127.0.0.1 ์ธ์ง€ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ

 

+ << Line 47 ~ 48 >>

: ์กฐ๊ฑด 2

-->  User-Agent Header ์˜ ๊ฐ’์ด Admin Browser ์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ

 

+ << Line 50 ~ 51 >>

: ์กฐ๊ฑด 3

-->  DreamhackUser Header ๊ฐ’์ด admin ์ธ์ง€์˜ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ

 

+ << Line 53 ~ 54 >>

: ์กฐ๊ฑด 4

-->  admin์˜ ์ฟ ํ‚ค ๊ฐ’์ด true์ธ์ง€ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ

 

+ << Line 56 ~ 57 >>

: ์กฐ๊ฑด 5

-->  userid์˜ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์ด admin์ธ์ง€ ํ™•์ธํ•˜๋Š” ์ฝ”๋“œ

 

+ << Line 59 >>

: ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ์ „์†ก๋œ ํŒจํ‚ท์ด ์กฐ๊ฑด 1 ~ 4๋ฅผ ๋ชจ๋‘ ๋งŒ์กฑํ•  ๊ฒฝ์šฐ Flag๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์ฝ”๋“œ

 

 

 

 

5. Raw Socket Sender ํŽ˜์ด์ง€์—์„œ ์กฐ๊ฑด์— ๋งž์ถ”์–ด host์— 127.0.0.1, port์— 8000, Data์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ž…๋ ฅํ•œ ๋‹ค์Œ Send ๋ฒ„ํŠผ ํด๋ฆญ

+ ํฌํŠธ ๋ฒˆํ˜ธ์˜ ๊ฒฝ์šฐ app.py์— ๋‚˜์˜จ '8000'์œผ๋กœ ์‚ฌ์šฉ

 

1 POST /admin HTTP/1.1
2 Host: host3.dreamhack.games:18853		//๋ณธ์ธ์˜ ์ ‘์† ์ •๋ณด์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” URL
3 Content-Length: 12		//userid=admin ๊ธ€์ž ์ˆ˜๋กœ, POST๋ฐฉ์‹์œผ๋กœ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ „๋‹ฌ ์‹œ ํ•„์š”
4 Content-Type: application/x-www-form-urlencoded		//POST ๋ฐฉ์‹์œผ๋กœ ํŒŒ๋ผ๋ฏธํ„ฐ ์ „๋‹ฌ ์‹œ ํ•„์š”
5 User-Agent: Admin Browser		//์กฐ๊ฑด 2
6 DreamhackUser: admin		//์กฐ๊ฑด 3
7 Cookie: admin=true		//์กฐ๊ฑด 4
8 Connection: close
9
10 userid=admin

+ << Line 7 >>

: Set - Cookie๊ฐ€ ์•„๋‹ˆ๋ผ Cookie:์„ ์‚ฌ์šฉํ•œ ์ด์œ ?

-->  ์ „์ž๋Š” ๊ธฐ์กด ์ฟ ํ‚ค๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ์ƒˆ ์ฟ ํ‚ค๋ฅผ ๋งŒ๋“ค ๋•Œ, ํ›„์ž๋Š” ๊ธฐ์กด ์ฟ ํ‚ค๊ฐ’ ๋ณ€๊ฒฝ ์‹œ ์‚ฌ์šฉ

 

 

 

 

6. Flag๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์ถœ๋ ฅ๋จ์„ ํ™•์ธ

Flag๋Š” DH{9bb7177b6267ff7288e24e06d8dd6df5}

 

 

 

 

+ ๋ฌธ์ œ ํ’€์ด ์ฐธ๊ณ 

https://mokpo.tistory.com/111