[Dreamhack] Level 2: Relative Path Overwrite
ยท
CTF, War game
1. ๋ฌธ์ œhttps://dreamhack.io/wargame/challenges/439 Relative Path OverwriteDescription Exercise: Relative Path Overwrite์—์„œ ์‹ค์Šตํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ œ ์ˆ˜์ • ๋‚ด์—ญ 2023.08.10 bot.py ์ˆ˜์ •, Dockerfile ์ œ๊ณตdreamhack.io2. ํ•ด๊ฒฐ ๊ณผ์ •index.php ํŽ˜์ด์ง€์˜ ์ฝ”๋“œ์ด๋‹ค. page ๋ผ๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ฐ›์•„ ํ•ด๋‹น ํŽ˜์ด์ง€์— ๋งž๋Š” php ํŒŒ์ผ์„ includeํ•œ๋‹ค. ํ•ด๋‹น ์ฝ”๋“œ์—์„œ .., :, / ๊ณผ ๊ฐ™์€ ๋ฌธ์ž๋Š” ํ•„ํ„ฐ๋งํ•˜๊ธฐ ๋•Œ๋ฌธ์— LFI ๊ณต๊ฒฉ์€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.  vuln.php ์ฝ”๋“œ๋Š” filter.js ๋ผ๋Š” ํŒŒ์ผ์„ ์Šคํฌ๋ฆฝํŠธ ํƒœ๊ทธ์˜ src๋กœ ๋กœ๋“œํ•˜๊ณ (filter๋ผ๋Š” ๋ฐฐ์—ด์ด ์ •์˜๋˜์–ด ์žˆ์Œ),..
[์ทจ์•ฝ์ ] Relative Path Overwrite
ยท
Study/WebHacking
Relative Path Overwrite (RPO)Relative Path Overwrite (RPO)๋Š”  ์ƒ๋Œ€ ๊ฒฝ๋กœ์˜ URL์„ ๋ฎ์–ด์จ์„œ ์˜๋„ํ•˜์ง€ ์•Š์€ ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ณต๊ฒฉ ๋ฐฉ๋ฒ•์ด๋‹ค.์„œ๋ฒ„์™€ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ƒ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ํ•ด์„ํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์ฐจ์ด์ ์„ ์ด์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.  Relative Path Confusion์ด๋ผ๊ณ ๋„ ๋ถˆ๋ฆฐ๋‹ค.  RPO๋ฅผ ์›น์—์„œ ์ด์•ผ๊ธฐํ•  ๋• link, script ๋“ฑ resource๋ฅผ ์ฝ์–ด์˜ค๋Š” ๊ณผ์ •์—์„œ Host๊ฐ€ ํฌํ•จ๋˜์ง€ ์•Š์€ URL์„ Relative URL์ด๋ผ๊ณ  ํ•˜๊ณ , ์ด๋ฅผ Overwriteํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ์— resource์˜ ์ฃผ์†Œ ๋“ฑ์„ ์กฐ์ž‘ํ•˜์—ฌ ๊ณต๊ฒฉ์ž๊ฐ€ ์›ํ•˜๋Š” ์•ก์…˜์œผ๋กœ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค. (๋Œ€ํ‘œ์ ์œผ๋กœ XSS) Path Description ExampleAbsolute URL Hos..
[Dreamhack] Level 4: Flask-Dev
ยท
CTF, War game
1. ๋ฌธ์ œ https://dreamhack.io/wargame/challenges/74 Flask-Dev์ทจ์•ฝ์ ์„ ์ฐพ์•„ ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•ด๋ณด์„ธ์š”. ํ”Œ๋ž˜๊ทธ๋Š” /flag ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ฌธ์ œ๋Š” ์ˆ™๋ จ๋œ ์›นํ•ด์ปค๋ฅผ ์œ„ํ•œ ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.dreamhack.io 2. ํ•ด๊ฒฐ ๊ณผ์ •์ฝ”๋“œ์˜ ์•„๋ž˜ ๋ถ€๋ถ„์„ ๋ณด๋ฉด, debug=True๋ผ๊ณ  ๋˜์–ด์žˆ๋‹ค. Flask์—์„œ Dubugger ๋ชจ๋“œ๊ฐ€ ํ™œ์„ฑํ™”๋˜์–ด ์žˆ์„ ๋•Œ, ์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ ์—๋Ÿฌ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ํŽ˜์ด์ง€๊ฐ€ ์ถœ๋ ฅ๋œ๋‹ค. ํ•ด๋‹น ์—๋Ÿฌ ํŽ˜์ด์ง€์—์„œ๋Š” ์ฝ˜์†”์„ ์‹คํ–‰์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š”๋ฐ, ์ด๋•Œ ์ฝ˜์†”์„ ์‹คํ–‰์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ๋Š” PIN์ด ํ•„์š”ํ•˜๋‹ค. #!/usr/bin/python3from flask import Flaskimport osapp = Flask(__name__)app.secret_key = os...
[Dreamhack] Level 3: CSS Injection
ยท
CTF, War game
1. ๋ฌธ์ œhttps://dreamhack.io/wargame/challenges/421 CSS InjectionDescription Exercise: CSS Injection์—์„œ ์‹ค์Šตํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ œ ์ˆ˜์ • ๋‚ด์—ญ 2023.08.09 Dockerfile ๋ฐ bot ์ผ๋ถ€ ์ˆ˜์ • 2023.11.27 main.py ๋ฐ requirements.txt ์ˆ˜์ •dreamhack.io 2. ํ•ด๊ฒฐ ๊ณผ์ •(1) ์ฝ”๋“œ ๋ถ„์„์ „์ฒด ์ฝ”๋“œ๋”๋ณด๊ธฐ#!/usr/bin/python3import hashlib, os, binascii, random, stringfrom flask import Flask, request, render_template, redirect, url_for, session, g, flashfrom functools i..
[์ทจ์•ฝ์ ] CSS Injection
ยท
Study/WebHacking
Cascading Style Sheet (CSS)๋Š” HTML๋กœ ์ •์˜๋œ ๋ฌธ์„œ๋ฅผ ๋‹ค์ฑ„๋กญ๊ฒŒ ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.๊ฐœ๋ฐœ์ž๋Š” CSS๋กœ HTML ์š”์†Œ๋“ค์ด ์‚ฌ์šฉ์ž์—๊ฒŒ ์–ด๋–ป๊ฒŒ ๋ณด์—ฌ์งˆ์ง€ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ฌธ์„œ์˜ ๋ฐฐ๊ฒฝ ์‚ฌ์ง„, ์ƒ‰์ƒ์„ ๋น„๋กฏํ•ด ๋ฒ„ํŠผ์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ค๋‘์—ˆ์„ ๋•Œ ์–ด๋–ค ์ƒ‰์ƒ๊ณผ ์†๋„๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ‘œํ˜„์— ์‚ฌ์šฉ๋  ์ž„์˜์˜ CSS ์ฝ”๋“œ๋ฅผ ์ฃผ์ž…์‹œ์ผœ ์˜๋„ํ•˜์ง€ ์•Š์€ ์†์„ฑ์ด ์ •์˜๋˜๋Š” ๊ฒƒ์„ CSS Injection์ด๋ผ๊ณ  ํ•œ๋‹ค. CSS Injection์€ XSS์™€ ๋น„์Šทํ•˜๊ฒŒ ์›น ํŽ˜์ด์ง€ ๋กœ๋”ฉ ์‹œ ์•…์˜์ ์ธ ๋ฌธ์ž์—ด์„ ์‚ฝ์ž…ํ•˜์—ฌ ์•…์˜์ ์ธ ๋™์ž‘์„ ์ด๋„๋Š” ๊ณต๊ฒฉ์ด๋‹ค.๊ณต๊ฒฉ์ž๊ฐ€ ์ž„์˜ CSS ์†์„ฑ์„ ์‚ฝ์ž…ํ•ด ์›นํŽ˜์ด์ง€์˜ UI (์ƒ๊น€์ƒˆ)๋ฅผ ๋ณ€์กฐํ•˜๊ฑฐ๋‚˜ CSS ์†์„ฑ์˜ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ํ†ตํ•ด ์›น ํŽ˜์ด์ง€๋‚ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์™ธ๋ถ€๋กœ ํ›”์น  ์ˆ˜ ์žˆ๋‹ค.์ด๋•Œ CSS Injection์„..
[Dreamhack] Level 2: crawling
ยท
CTF, War game
1. ๋ฌธ์ œ https://dreamhack.io/wargame/challenges/274 crawling ๋“œ๋ฆผ์ด๋Š” ์›น ํฌ๋กค๋ง ์‚ฌ์ดํŠธ๋ฅผ ๊ตฌ์ถ•ํ–ˆ์Šต๋‹ˆ๋‹ค. ํฌ๋กค๋ง ์‚ฌ์ดํŠธ์—์„œ ์ทจ์•ฝ์ ์„ ์ฐพ๊ณ  flag๋ฅผ ํš๋“ํ•˜์„ธ์š”! ๋ฌธ์ œ ์ˆ˜์ • ๋‚ด์—ญ 2024.02.13 ํ’€์ด์ž์—๊ฒŒ ์ œ๊ณต๋˜๋Š” ํŒŒ์ผ ์ผ๋ถ€๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. dreamhack.io 2. ํ•ด๊ฒฐ ๊ณผ์ • ํฌ๋กค๋งํ•  URL์„ ์ž…๋ ฅํ•˜๋Š” ํ™”๋ฉด์ด ๋ณด์ธ๋‹ค. #app.py from re import split import socket import requests import ipaddress from urllib.parse import urlparse from flask import Flask, request, render_template app = Flask(__name__) app.flag ..
[์ทจ์•ฝ์ ] SSRF
ยท
Study/WebHacking
1. CSRF vs SSRF ์„œ๋น„์Šค ๊ฐ„ HTTP ํ†ต์‹ ์ด ์ด๋ค„์งˆ ๋•Œ ์š”์ฒญ ๋‚ด์— ์ด์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์ด ํฌํ•จ๋  ์ˆ˜ ์žˆ๋Š”๋ฐ, ์ด๋•Œ ์ด์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์œผ๋กœ ์ธํ•ด ๊ฐœ๋ฐœ์ž๊ฐ€ ์˜๋„ํ•˜์ง€ ์•Š์€ ์š”์ฒญ์ด ์ „์†ก๋  ์ˆ˜ ์žˆ๋‹ค. Server-side Request Forgery(SSRF)๋Š” ์›น ์„œ๋น„์Šค์˜ ์š”์ฒญ์„ ๋ณ€์กฐํ•˜๋Š” ์ทจ์•ฝ์ ์œผ๋กœ, ์„œ๋ฒ„ ์ธก์—์„œ ์œ„์กฐ๋œ HTTP ์š”์ฒญ์„ ๋ฐœ์ƒ์‹œ์ผœ ์ง์ ‘์ ์ธ ์ ‘๊ทผ์ด ์ œํ•œ๋œ ์„œ๋ฒ„ ๋‚ด๋ถ€ ์ž์›์— ์ ‘๊ทผํ•˜์—ฌ ์™ธ๋ถ€๋กœ ๋ฐ์ดํ„ฐ ์œ ์ถœ ๋ฐ ์˜ค๋™์ž‘์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ณต๊ฒฉํ˜•ํƒœ๋งŒ ๋ณด๋ฉด ์œ„์กฐ๋œ HTTP ์š”์ฒญ(Request Forgery)๋ฅผ ์ด์šฉํ•œ ๊ณต๊ฒฉ์ด๊ธฐ ๋•Œ๋ฌธ์— CSRF(Cross Site Request Forgery)์™€ ์œ ์‚ฌํ•˜๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์œผ๋‚˜ ๊ณต๊ฒฉ์ž์˜ ๊ณต๊ฒฉ์ด ๋ฐœํ˜„๋˜๋Š” ์ง€์ ์ด ์„œ๋ฒ„ ์ธก(Server Side)์ธ์ง€ ํด๋ผ์ด์–ธํŠธ ์ธก(Clien..
[Dreamhack] Level 2: login-1
ยท
CTF, War game
1. ๋ฌธ์ œ login-1python์œผ๋กœ ์ž‘์„ฑ๋œ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. "admin" ๊ถŒํ•œ์„ ๊ฐ€์ง„ ์‚ฌ์šฉ์ž๋กœ ๋กœ๊ทธ์ธํ•˜์—ฌ ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. Reference Server-side Basicdreamhack.io2. ํ•ด๊ฒฐ ๊ณผ์ •๋ฌธ์ œ์— ์ ‘์†ํ•˜๋‹ˆ, ๋กœ๊ทธ์ธ/ ํšŒ์›๊ฐ€์ž…/๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ๊ธฐ๋Šฅ์ด ์žˆ๋Š” ํŽ˜์ด์ง€๊ฐ€ ๋ณด์ธ๋‹ค.   ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€์—์„œ admin/admin ์œผ๋กœ ์ž…๋ ฅํ•ด๋ณด์•˜๋”๋‹ˆ ํ‹€๋ ธ๋‹ค๊ณ  ๋‚˜์˜จ๋‹ค.  ์ฝ”๋“œ ํ™•์ธ @app.route('/')def index(): return render_template('index.html')@app.route('/login', methods=['GET', 'POST'])def login(): if request.method == 'GET': return ..
[Dreamhack] Level 3: blind sql injection advanced
ยท
CTF, War game
1. ๋ฌธ์ œhttps://dreamhack.io/wargame/challenges/411 blind sql injection advancedDescription Exercise: Blind SQL Injection Advanced์—์„œ ์‹ค์Šตํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” "์•„์Šคํ‚ค์ฝ”๋“œ"์™€ "ํ•œ๊ธ€"๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ œ ์ˆ˜์ • ๋‚ด์—ญ 2023.07.20 Dockerfile ์ œ๊ณตdreamhack.io 2. ํ•ด๊ฒฐ ๊ณผ์ •๋ฌธ์ œ์— '๊ด€๋ฆฌ์ž์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” "์•„์Šคํ‚ค์ฝ”๋“œ"์™€ "ํ•œ๊ธ€"๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.' ๋ผ๊ณ  ์ž‘์„ฑ๋˜์–ด ์žˆ๋‹ค. ์ฆ‰, ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฐ˜๋“œ์‹œ ์•„์Šคํ‚ค ๋ฒ”์œ„๋กœ ๊ตฌ์„ฑ๋˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋ผ๋Š” ๊ฒƒ์ด๋‹ค.  ๋ฌธ์ œํ™”๋ฉด์—๋Š” uid๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” form์ด ์กด์žฌํ•œ๋‹ค.  test๋ฅผ ์ž…๋ ฅํ•ด๋ณด๋‹ˆ ์กด์žฌํ•œ๋‹ค๋Š” ๋ฌธ์ž์—ด์ด ..
[Dreamhcak] Level 3: Login Page
ยท
CTF, War game
๋ณดํ˜ธ๋˜์–ด ์žˆ๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.
mnzy๐ŸŒฑ
mnzy๐ŸŒฑ
-->