wargame ๐Ÿด‍โ˜ ๏ธ write-up/H4CKING GAME 4

[Web Hacking] Calculator v2

0x01 ๋ฌธ์ œ ์„ค๋ช…์ด์ „ Calculator ๋ฌธ์ œ์™€ ์ด์–ด์ง€๋Š” ๋ฒ„์ „์˜ ๋ฌธ์ œ๋‹ค. ์„ค๋ช…์— ๋”ฐ๋ฅด๋ฉด ์ทจ์•ฝ์ ์„ ๋ฐฉ์–ดํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ ํ•˜์˜€๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.0x02 ํ’€์ด ๊ณผ์ •_ , . , mro ๋“ฑ ๊ณผ ๊ฐ™์€ ๋ฌธ์ž๋“ค์ด ์ถ”๊ฐ€๋กœ ํ•„ํ„ฐ๋ง ๋˜๊ณ ์žˆ๋‹ค. ์ด์ „ ๋ฌธ์ œ์™€ ๊ฐ™์ด fileloader๋ฅผ ์ด์šฉํ•˜์—ฌ /flag ๋ฅผ ์ฝ์–ด์˜ฌ ์˜ˆ์ •์ด๋‹ค. SSTI ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ณผ์ •์€ Calculator ์—์„œ ๋‹ค๋ค˜๊ธฐ์—, ์ด๋ฒˆ์— ์‚ฌ์šฉํ•œ ํ•„ํ„ฐ๋ง ์šฐํšŒ์— ๊ด€ํ•ด์„œ๋งŒ ์ด์•ผ๊ธฐํ•ด ๋ณผ ๊ฒƒ์ด๋‹ค.. ํ•„ํ„ฐ๋ง ์šฐํšŒA.B -> A|attr('B')ํŠน์ • ๋ฌธ์ž ํ•„ํ„ฐ๋ง ์šฐํšŒ__class__data=request.form.get('a')&a=__class__์œ„์™€๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ''.class.mro[1].subclasses()[99].get_data('/flag') ๋ฅผ ์šฐํšŒํ•œ ๊ฒฐ..

[Web Hacking] Real PHP LFI

0x01 ๋ฌธ์ œ ์„ค๋ช…0x02 ํ’€์ด ๊ณผ์ •์ฒจ๋ถ€๋œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด, index.php ์—์„œ $_SERVER[’QUERY_STRING’] ์„ ํ†ตํ•ด ์ฟผ๋ฆฌ ์ •๋ณด๋ฅผ ๋ฐ›์•„์˜ค๊ณ , config.php ์—์„œ ๋ฌธ์ž ํ•„ํ„ฐ๋ง์„ ์ง„ํ–‰ํ•œ๋‹ค. ๋งˆ์ง€๋ง‰์—๋Š” include($_SESSION['include_path']) ๋กœ nav.php ๋ฅผ ๋ถˆ๋Ÿฌ์˜จ๋‹ค. ์ทจ์•ฝ์ ์€ index.php ์—์„œ ๋ฐœ์ƒํ•œ๋‹ค.foreach($arr as $key=>$value){ $$key = fuck_path_change_or_check($value);}$$ ๋Š” php์˜ ๊ฐ€๋ณ€๋ณ€์ˆ˜ ์„ ์–ธ ์‹œ ์‚ฌ์šฉํ•˜๋Š” ๊ตฌ๋ฌธ์ด๋‹ค. ์—ฌ๊ธฐ์„œ $_SESSION[’include_path’] ์„ ๋ฎ๋Š”๋‹ค๋ฉด ์›ํ•˜๋Š” ๋กœ์ปฌ ํŒŒ์ผ์„ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.GET ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ํ†ตํ•ด ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•˜์˜€๋‹ค. GET ํŒŒ๋ผ๋ฏธํ„ฐ๋Š”..

[Web Hacking] Smuggling

0x01 ๋ฌธ์ œ ์„ค๋ช…0x02 ํ’€์ด ๊ณผ์ •A) ์ดˆ๊ธฐ ๋ถ„์„python flask ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด๋‹ค. ์ฒจ๋ถ€๋œ ์ฝ”๋“œ ์ค‘ docker-compose.yml ํŒŒ์ผ ์†์—” haproxy 2.2.16 ๋ฒ„์ „์„ ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ๋ช…์‹œ๋˜์–ด์žˆ๋‹ค. ๋˜ํ•œ haproxy.cfg ํŒŒ์ผ์—๋Š” front-end ์„œ๋ฒ„ ์„ ์—์„œ ํŠน์ • ๊ฒฝ๋กœ์— ๋Œ€ํ•œ ์ ‘๊ทผ์„ ์ฐจ๋‹จ ํ•˜๋ฉฐ http ํ†ต์‹ ์„ ์žฌ์‚ฌ์šฉ(reuse) ํ•œ๋‹ค.frontend web bind *:8000 http-request deny if { path_beg /flag } http-request deny if { path_beg // } default_backend websrvsbackend websrvs http-reuse always server srv1 flask:5..

[Web Hacking] Calculator

0x01 ๋ฌธ์ œ ์„ค๋ช…0x02 ํ’€์ด ๊ณผ์ •๊ฐ„๋‹จํ•œ ๊ณ„์‚ฐ๊ธฐ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. ์—ฌ๋Ÿฌ ๊ฐ’์„ ๋„ฃ๊ณ  ํ…Œ์ŠคํŠธ ํ•œ ๊ฒฐ๊ณผ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.1+2 → 33*4 → 12‘7’*7 → 7777777config → SSTI (Server Side Template Injection) ์ทจ์•ฝ์ ์ด ์žˆ๋Š”๊ฒƒ์œผ๋กœ ํ™•์ธ๋˜๋ฉฐ, {{ }} ${ } ์™€ ๊ฐ™์€ ๊ตฌ๋ฌธ ์—†์ด ๋ฐ”๋กœ ์ ์šฉ๋จ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค. ์•„๋ž˜์™€ ์ฝ”๋“œ ๊ฐ™์ด ์ค‘์ฒฉ๊ด„ํ˜ธ๋ฅผ ์‚ฌ์šฉํ•œ ํ™˜๊ฒฝ์„ ์˜ˆ์ƒํ•ด๋ณธ๋‹ค.from flask import Flask, request, render_template_stringapp = Flask(__name__)@app.route('/', methods=['GET'])def index(): expression = request.args.get('expression', '') ..