SWLUG/์›น ํ•ดํ‚น

[Dreamhack/๋“œ๋ฆผํ•ต] csrf-1

waterproof 2023. 11. 10. 23:20

 

 

 

 

 

  https://dreamhack.io/wargame/challenges/26

 

csrf-1

์—ฌ๋Ÿฌ ๊ธฐ๋Šฅ๊ณผ ์ž…๋ ฅ๋ฐ›์€ URL์„ ํ™•์ธํ•˜๋Š” ๋ด‡์ด ๊ตฌํ˜„๋œ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค. CSRF ์ทจ์•ฝ์ ์„ ์ด์šฉํ•ด ํ”Œ๋ž˜๊ทธ๋ฅผ ํš๋“ํ•˜์„ธ์š”. ๋ฌธ์ œ ์ˆ˜์ • ๋‚ด์—ญ 2023.07.18 css, html ์ œ๊ณต ๋ฐ read_url() ์ฝ”๋“œ ์ผ๋ถ€๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Referen

dreamhack.io


[1] ๋ฌธ์ œ ๋ถ„์„

 

# ๋ฌธ์ œ ํŽ˜์ด์ง€ ๋ถ„์„

 

(1) ์ดˆ๊ธฐ ํ™”๋ฉด (Home)

 

 

 

 

(1) /vuln(csrf) page

 

 

script ๊ฐ€ *๋กœ ์น˜ํ™˜๋˜์–ด์žˆ๋‹ค.

/script๋Š” ์ œ๊ฑฐ๋˜์—ˆ๋‹ค.

 

 

 

์†Œ์Šค ์ฝ”๋“œ์—์„œ๋Š” ์•Œ์•„๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด ์—†์—ˆ๋‹ค.

 

 

(2) /memo

 

 

 

URL์„ ๋ณด๋ฉด /memo ํŽ˜์ด์ง€์—์„œ memo ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ hello๋ฅผ ๋ฐ›์•„๋“ค์—ฌ์„œ ํŽ˜์ด์ง€ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

์ฆ‰ ?memo= ๋‹ค์Œ์— hi๋ฅผ ์ž…๋ ฅํ•˜๋ฉด,

 

 

์ด๋ ‡๊ฒŒ ๋ฐ˜์˜์ด ๋œ๋‹ค.

 

 

 

๊ทธ๋ฆฌ๊ณ  ํŽ˜์ด์ง€๋ฅผ ๋‹ค์‹œ ๋“ค์–ด๊ฐˆ ๋•Œ๋งˆ๋‹ค ์ด์ „์— ์ถœ๋ ฅ๋˜์—ˆ๋˜ ๋ฌธ์ž์—ด ์˜† "hello"๊ฐ€ ์ถ”๊ฐ€๋˜์–ด์„œ ์ถœ๋ ฅ๋œ๋‹ค.

 

 

(3) /notice flag ํŽ˜์ด์ง€

 

 

์ฃผ์†Œ๋Š”  /admin/notice_flag ์ด๊ณ  "Access Denied"๋ผ๋Š” ๋ฌธ๊ตฌ๊ฐ€ ์ถœ๋ ฅ๋˜์—ˆ๋‹ค.

 

 

 

์†Œ์Šค์ฝ”๋“œ๋ฅผ ํ™•์ธํ•ด๋„ ์•Œ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด ์—†์—ˆ๋‹ค.

 

 

 

(4) /flag ํŽ˜์ด์ง€

 

 

์ด์ „์— ํ’€์—ˆ๋˜ ๋“œ๋ฆผํ•ต์˜ xss ๋ฌธ์ œ๋“ค์—์„œ ๋ดค๋˜ ๊ฒƒ์ฒ˜๋Ÿผ

/vulnํŽ˜์ด์ง€์˜ "param" ๋งค๊ฐœ๋ณ€์ˆ˜์— ๊ฐ’์„ ๋„ฃ์–ด์„œ ์ œ์ถœํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ํ˜•์‹์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋‹ค.

 

 

์•„๋ž˜์—์„œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด๋„๋ก ํ•˜๊ฒ ๋‹ค.

 

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/static/css/non-responsive.css">
    <title>Index CSRF-1</title>
    
  
  <style type="text/css">
    .important { color: #336699; }
  </style>

  </head>
<body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="/">CSRF-1</a>
        </div>
        <div id="navbar">
          <ul class="nav navbar-nav">
            <li><a href="/">Home</a></li>
          </ul>

          <ul class="nav navbar-nav navbar-right">
          </ul>

        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
      
  <form method="POST">
    http://127.0.0.1:8000/vuln?param=<input type="text" name="param"/><br/>
    <input type="submit"/><br/>
  </form>

    </div> <!-- /container -->

    <!-- Bootstrap core JavaScript -->
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script> 
</body>
</html>

 

๋‹ค๋ฅธ ๋ˆˆ์— ๋„๋Š” ๋ถ€๋ถ„์€ ๋”ฑํžˆ ์—†๊ณ ...

POST ๋ฐฉ์‹์œผ๋กœ ๋นˆ์นธ์— ์ž…๋ ฅํ•œ ๊ฐ’์„ param์œผ๋กœ ๋ฐ›์•„๋“ค์—ฌ ์ œ์ถœํ•˜๊ฒŒ ๋˜๋Š” ํผ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

ํฌ๊ฒŒ ์•Œ์•„๋‚ธ ๊ฒƒ์ด ์—†์—ˆ๋‹ค.

.

.

.

๊ทธ๋ ‡๋‹ค๋ฉด ์ด์ œ ๋‹ค์šด๋กœ๋“œํ•œ ๋ฌธ์ œ ํŒŒ์ผ์„ ์‚ดํŽด๋ณด๊ฒ ๋‹ค.

 

 

 

# ๋‹ค์šด๋กœ๋“œํ•œ ๋ฌธ์ œ ํŒŒ์ผ ๋ถ„์„

 

โš™๏ธ app.py

 

#!/usr/bin/python3
from flask import Flask, request, render_template
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import urllib
import os

app = Flask(__name__)
app.secret_key = os.urandom(32)

try:
    FLAG = open("./flag.txt", "r").read()
except:
    FLAG = "[**FLAG**]"


def read_url(url, cookie={"name": "name", "value": "value"}):
    cookie.update({"domain": "127.0.0.1"})
    try:
        service = Service(executable_path="/chromedriver")
        options = webdriver.ChromeOptions()
        for _ in [
            "headless",
            "window-size=1920x1080",
            "disable-gpu",
            "no-sandbox",
            "disable-dev-shm-usage",
        ]:
            options.add_argument(_)
        driver = webdriver.Chrome(service=service, options=options)
        driver.implicitly_wait(3)
        driver.set_page_load_timeout(3)
        driver.get("http://127.0.0.1:8000/")
        driver.add_cookie(cookie)
        driver.get(url)
    except Exception as e:
        driver.quit()
        print(str(e))
        # return str(e)
        return False
    driver.quit()
    return True


def check_csrf(param, cookie={"name": "name", "value": "value"}):
    url = f"http://127.0.0.1:8000/vuln?param={urllib.parse.quote(param)}"
    return read_url(url, cookie)


@app.route("/")
def index():
    return render_template("index.html")


@app.route("/vuln")
def vuln():
    param = request.args.get("param", "").lower()
    xss_filter = ["frame", "script", "on"]
    for _ in xss_filter:
        param = param.replace(_, "*")
    return param


@app.route("/flag", methods=["GET", "POST"])
def flag():
    if request.method == "GET":
        return render_template("flag.html")
    elif request.method == "POST":
        param = request.form.get("param", "")
        if not check_csrf(param):
            return '<script>alert("wrong??");history.go(-1);</script>'

        return '<script>alert("good");history.go(-1);</script>'


memo_text = ""


@app.route("/memo")
def memo():
    global memo_text
    text = request.args.get("memo", None)
    if text:
        memo_text += text
    return render_template("memo.html", memo=memo_text)


@app.route("/admin/notice_flag")
def admin_notice_flag():
    global memo_text
    if request.remote_addr != "127.0.0.1":
        return "Access Denied"
    if request.args.get("userid", "") != "admin":
        return "Access Denied 2"
    memo_text += f"[Notice] flag is {FLAG}\n"
    return "Ok"


app.run(host="0.0.0.0", port=8000)

 

 

 

def read_url(url, cookie={"name": "name", "value": "value"}):

def read_url(url, cookie={"name": "name", "value": "value"}):
    # ๊ธฐ๋ณธ ์ฟ ํ‚ค์— ๋„๋ฉ”์ธ ์ •๋ณด ์ถ”๊ฐ€
    cookie.update({"domain": "127.0.0.1"})
    
    try:
        # Chrome ์›น ๋“œ๋ผ์ด๋ฒ„ ์„ค์ •
        service = Service(executable_path="/chromedriver")
        options = webdriver.ChromeOptions()
        
        # Chrome ์˜ต์…˜ ์„ค์ •
        for _ in [
            "headless",
            "window-size=1920x1080",
            "disable-gpu",
            "no-sandbox",
            "disable-dev-shm-usage",
        ]:
            options.add_argument(_)
        
        # ์›น ๋“œ๋ผ์ด๋ฒ„ ์ƒ์„ฑ ๋ฐ ์„ค์ •
        driver = webdriver.Chrome(service=service, options=options)
        driver.implicitly_wait(3)
        driver.set_page_load_timeout(3)
        
        # ์ฒซ ๋ฒˆ์งธ ํŽ˜์ด์ง€๋กœ ์ด๋™
        driver.get("http://127.0.0.1:8000/")
        
        # ์ฟ ํ‚ค ์ถ”๊ฐ€
        driver.add_cookie(cookie)
        
        # ์ฃผ์–ด์ง„ URL๋กœ ์ด๋™
        driver.get(url)
        
    except Exception as e:
        # ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ ๋“œ๋ผ์ด๋ฒ„ ์ข…๋ฃŒ ๋ฐ ์˜ค๋ฅ˜ ์ถœ๋ ฅ
        driver.quit()
        print(str(e))
        return False
    
    # ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰๋˜๋ฉด ๋“œ๋ผ์ด๋ฒ„ ์ข…๋ฃŒ ๋ฐ ์„ฑ๊ณต ๋ฐ˜ํ™˜
    driver.quit()
    return True

 

์Œ... ์•„์ง์€ ์ด ๋ถ€๋ถ„์—์„œ ๋ฌด์–ธ๊ฐ€๋ฅผ ์•Œ์•„์ฐจ๋ฆด ์ˆ˜๋Š” ์—†์—ˆ๋‹ค.

 

 

def check_csrf(param, cookie={"name": "name", "value": "value"}):

 

def check_csrf(param, cookie={"name": "name", "value": "value"}):
    # CSRF ๊ณต๊ฒฉ์„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ํ•˜๊ธฐ ์œ„ํ•ด URL์„ ์ƒ์„ฑ
    url = f"http://127.0.0.1:8000/vuln?param={urllib.parse.quote(param)}"
    
    # ์ƒ์„ฑ๋œ URL์— ๋Œ€ํ•œ ์š”์ฒญ์„ ๋ณด๋‚ด๊ณ  ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜
    return read_url(url, cookie)

 

์ด ์ฝ”๋“œ์˜ ๋ชฉ์ ์€ CSRF ๊ณต๊ฒฉ์„ ๊ฒ€์‚ฌํ•œ๋‹ค.

 

1. 'urllib.parse.quote(param)' ์„ ํ†ตํ•ด param ๊ฐ’์„ URL์— ์•ˆ์ „ํ•˜๊ฒŒ ํฌํ•จ์‹œํ‚จ๋‹ค. ์ด ํ•จ์ˆ˜๋Š” URL์— ์‚ฌ์šฉ๋  ์ˆ˜ ์—†๋Š” ๋ฌธ์ž๋ฅผ ์ ์ ˆํ•œ ํ˜•ํƒœ๋กœ ์ธ์ฝ”๋”ฉํ•œ๋‹ค.

(๊ตฌ์ฒด์ ์œผ๋กœ ๊ณต๋ฐฑ์„ '%20', URL์—์„œ ์‚ฌ์šฉ๋˜๋ฉด์„œ ํŠน๋ณ„ํ•œ ์˜๋ฏธ๋ฅผ ๊ฐ–๋Š” ๋ฌธ์ž๋“ค์„ %๋‹ค์Œ์— ๋‘ ์ž๋ฆฌ 16์ง„์ˆ˜๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค๊ณ  ํ•œ๋‹ค. )

 

2. url = f"http://127.0.0.1:8000/vuln?param={urllib.parse.quote(param)}" ๋ถ€๋ถ„์—์„œ, ์‹œ๋ฎฌ๋ ˆ์ด์…˜๋œ CSRF ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด, "http://127.0.0.1:8000/vuln" ๊ฒฝ๋กœ๋กœ ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” URL์„ ์ƒ์„ฑํ•œ๋‹ค. param์€ urllib.parse.quote๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•ˆ์ „ํ•˜๊ฒŒ ์ธ์ฝ”๋”ฉ๋˜์–ด ํฌํ•จ๋œ๋‹ค.

(์ด ๋ถ€๋ถ„์ด ์ดํ•ด๊ฐ€ ์ž˜ ๊ฐ€์ง€ ์•Š์•˜๋‹ค...)

 

3. return read_url(url, cookie): ์ƒ์„ฑ๋œ URL์— ๋Œ€ํ•œ ์š”์ฒญ์„ read_url ํ•จ์ˆ˜์—๊ฒŒ ์œ„์ž„ํ•˜๊ณ , ํ•ด๋‹น ํ•จ์ˆ˜์—์„œ์˜ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

 

 

 

@app.route("/vuln")

 

 

์ด ๋ถ€๋ถ„์€ /vuln ํŽ˜์ด์ง€์— ๋Œ€ํ•œ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•œ๋‹ค.

 

 

๊ธฐ๋Šฅ ์„ค๋ช…:

 

1. "param" ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์„ ๊ฐ€์ ธ์™€์„œ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•œ ํ›„ "param"์— ์ €์žฅํ•˜๊ณ , ๋งŒ์•ฝ "param"์ด๋ผ๋Š” ์ด๋ฆ„์˜ ์ฟผ๋ฆฌ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ์—†์œผ๋ฉด ๋นˆ ๋ฌธ์ž์—ด์„ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. 

 

2. xss_filter ๋ผ๋Š” ๋ฆฌ์ŠคํŠธ์— "frame", "script", "on"์ด๋ผ๋Š” ๋ฌธ์ž์—ด์„ ํฌํ•จ์‹œํ‚จ๋‹ค.

 

3. xss_filter์— ์žˆ๋Š” ๊ฐ ๋ฌธ์ž์—ด์„ param์—์„œ "*"๋กœ ๋Œ€์ฒดํ•œ๋‹ค.

 

4. 'return param'์„ ํ†ตํ•ด ์ฒ˜๋ฆฌ๋œ param ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

>> xss ๊ณต๊ฒฉ์„ ๋ฐฉ์ง€ํ•˜๋Š” ๋ถ€๋ถ„์œผ๋กœ "frame", "script", "on"์„ "*"๋กœ ๋Œ€์ฒดํ•˜๋ฉฐ ํ•„ํ„ฐ๋งํ•ด์ค€๋‹ค.

.

.

.

 

@app.route("/flag", methods=["GET", "POST"])

 

 

"/flag" ํŽ˜์ด์ง€์— ๋Œ€ํ•œ GET ๋ฐ POST ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๋Š” ๋ถ€๋ถ„์ด๋‹ค.

 

 

์ฃผ๋กœ GET ์š”์ฒญ ์‹œ์—๋Š” "flag.html"์„ ๋ Œ๋”๋งํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ณด์—ฌ์ฃผ๊ณ ,

 

POST ์š”์ฒญ ์‹œ์—๋Š” chech_csrf ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ CSRF ๊ฒ€์ฆ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ์‘๋‹ต์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ์šฉ๋„๋กœ ์‚ฌ์šฉ๋œ๋‹ค.

.

.

.

 

 

@app.route("/memo")

 

 

์ด ์ฝ”๋“œ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ "/memo" ํŽ˜์ด์ง€๋กœ ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด,

์š”์ฒญ์— ํฌํ•จ๋œ "memo"๋ผ๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์„ memo_text์— ๋ง๋ถ™์ด๊ณ ,

๊ทธ ๊ฒฐ๊ณผ๋ฅผ "memo.html" ํ…œํ”Œ๋ฆฟ์„ ์‚ฌ์šฉํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

 

>> ์‚ฌ์šฉ์ž๊ฐ€ ๋ฉ”๋ชจ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ๊ทธ ๋‚ด์šฉ์„ ์‹œ๊ฐ์ ์œผ๋กœ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ๋‹ค.

.

.

.

 

@app.route("/admin/notice_flag")

 

 

1. ํด๋ผ์ด์–ธํŠธ์˜ IP ์ฃผ์†Œ๊ฐ€ "127.0.0.1"(๋กœ์ปฌํ˜ธ์ŠคํŠธ)์ด ์•„๋‹Œ ๊ฒฝ์šฐ,  "Access Denied"์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

 

2. ์š”์ฒญ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ ์ค‘ "userid"๊ฐ€ "admin"์ด ์•„๋‹Œ ๊ฒฝ์šฐ, "Access Denied 2"๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

์ด๋Š” ํ˜ธ์ถœ์ž๊ฐ€ ํŠน์ • ์‚ฌ์šฉ์ž ID("admin")๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์–ด์•ผ๋งŒ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค.

 

3. ํ•จ์ˆ˜๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด, memo_text์— ๋ฌธ์ž์—ด "[Notice] flag is {FLAG}"๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

 

 


[2] ๊ณต๊ฒฉ ์‹คํ–‰

 

 

"on", "frame", "script"๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๊ณต๊ฒฉํ•  ์ˆ˜ ์—†์œผ๋ฏ€๋กœ,

๋ฌธ์ž์—ด ์น˜ํ™˜ ๋ฐฉ์‹์ด๋‚˜, ์ค‘๊ฐ„์— %00์„ ์‚ฝ์ž…ํ•˜๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ด๋ณด์•˜๋Š”๋ฐ ๊ณต๊ฒฉ์ด ๋˜์ง€ ์•Š์•„์„œ

(xss ๊ณต๊ฒฉ ๋ฌธ์ œ๊ฐ€ ์•„๋‹ˆ๋ผ์„œ ์ด ๋ฐฉํ–ฅ์€ ์•„๋‹Œ ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ–ˆ๋‹ค.)

๊ทธ๋ƒฅ '<img src=~' ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ถˆ๋Ÿฌ์˜ค๋Š” ๊ฒƒ์œผ๋กœ ํ•˜๋ ค๊ณ  ํ–ˆ๋‹ค.

 

๊ทธ๋Ÿฐ๋ฐ ๋ฌธ์ œ ํŒŒ์ผ์„ ๋ฐ›์•„์„œ ๋ถ„์„ํ•ด๋ณด์•„๋„ ์–ด๋–ป๊ฒŒ ๊ณต๊ฒฉํ•ด์•ผ ํ•˜๋Š”์ง€ ๊ฐ์ด ์˜ค์ง€ ์•Š์•˜๋‹ค.

 

IP์ฃผ์†Œ๊ฐ€ "127.0.0.1"(๋กœ์ปฌํ˜ธ์ŠคํŠธ)๊ฐ€ ์•„๋‹ˆ๋ฉด /notice_flag ํŽ˜์ด์ง€์—์„œ Access Denied๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒƒ์„ ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ•ด์•ผ ํ• ์ง€ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ํ’€์ด๋ฅผ ์ฐพ์•„๋ณด์•˜๋‹ค.

 


 

์ด ๋ฌธ์ œ์˜ ์ด๋ฆ„์ด "csrf-1"์ธ ๋งŒํผ, xss ๊ณต๊ฒฉ๊ณผ crsf ๊ณต๊ฒฉ์˜ ์ฐจ์ด์ ์„ ๋จผ์ € ์งš๊ณ  ๊ฐ€์ž๋ฉด

 

xss ๊ณต๊ฒฉ์€ ๊ณต๊ฒฉ์ž๊ฐ€ ์•…์˜์ ์ธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์›น ํŽ˜์ด์ง€์— ์‚ฝ์ž…ํ•˜๋Š” ๊ณต๊ฒฉ์ด๋ฉฐ ํด๋ผ์ด์–ธํŠธ์—์„œ ์‹คํ–‰๋˜๊ณ 
csrf ๊ณต๊ฒฉ์€ ๊ณต๊ฒฉ์ž๊ฐ€ ํ”ผํ•ด์ž์˜ ์ธ์ฆ๋œ ์„ธ์…˜์„ ์ด์šฉํ•˜์—ฌ ์›น ์„œ๋ฒ„์— ์•…์˜์ ์ธ ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ๊ณต๊ฒฉ์ด๋ฉฐ ์„œ๋ฒ„์—์„œ ์‹คํ–‰๋œ๋‹ค.

 

 

์œ„์—์„œ ๋ฌธ์ œ ํŒŒ์ผ ๋ถ„์„์„ ํ•  ๋•Œ,

 

/notice_flag ๊ฒฝ๋กœ์—์„œ

1. ๋กœ์ปฌํ˜ธ์ŠคํŠธ๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒฝ์šฐ

2. ?userid=admin์ธ ๊ฒฝ์šฐ flag ๊ฐ’์„ ์–ป๊ธฐ ์œ„ํ•œ ๊ฒฝ๋กœ๋กœ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ–ˆ๊ธฐ ๋•Œ๋ฌธ์—

 

 

1. /flag ํŽ˜์ด์ง€๋ฅผ ํ†ตํ•ด /vuln์— ์š”์ฒญ์„ ๋ณด๋‚ด๋Š” ํผ์„ ์ œ์ถœํ•˜๋ฉฐ

2. <img src="/admin/notice_flag?userid=admin" /> ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ๋ฉด ๋œ๋‹ค๊ณ  ํ•œ๋‹ค.

 

 

 

 

 

๋ฌธ์ œ ํ’€์ด ์™„๋ฃŒ!


[3] ์ฐธ๊ณ 

 https://goldsony.tistory.com/261

 

[์›น ํ•ดํ‚น] Dreamhack csrf-1(Level 1)

#261 1. ๊ฐœ์š” ์›Œ๊ฒŒ์ž„ ๋ช… : csrf-1 ๋‚œ์ด๋„ : Level 1 ๊ด€๋ จ ๊ฐœ๋… : Javascript, CSRF, Cookie ๋ฌธ์ œ : CSRF ์ทจ์•ฝ์ ์„ ์ด์šฉํ•˜์—ฌ FLAG ๊ฐ’ ํš๋“ * XSS์™€ CSRF์˜ ์ฐจ์ด์  - XSS : ๊ณต๊ฒฉ์ž๊ฐ€ ์•…์˜์ ์ธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์›น ํŽ˜์ด์ง€์— ์‚ฝ์ž…

goldsony.tistory.com

 


[4] ๋Š๋‚€ ์ 

 

1. ์™œ ์ด๊ฒŒ crsf ๊ณต๊ฒฉ์ธ์ง€ ์ž˜ ์ดํ•ด๋˜์ง€ ์•Š๋Š”๋‹ค.

2. ํŠนํžˆ ๋กœ์ปฌํ˜ธ์ŠคํŠธ๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ฉด ์•ˆ ๋œ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ, ๋‚ด๊ฐ€ ์ดํ•ดํ•œ ๋ฐ”๋กœ๋Š” ?userid=admin ์กฐ๊ฑด๋งŒ ์ถฉ์กฑ์‹œํ‚จ ๊ฒƒ ๊ฐ™์ด ๋Š๊ปด์กŒ๋‹ค.

 

๋ฌธ์ œ๊ฐ€ ๊ฐœ์ •๋œ์ง€ ์–ผ๋งˆ๋˜์ง€ ์•Š์•„์„œ ๊ตฌ๊ธ€๋ง์„ ํ•ด๋„ ์ •๋ณด๊ฐ€ ๋งŽ์ด ๋‚จ์•„์žˆ์ง€ ์•Š์•„ ๊ถ๊ธˆ์ฆ์„ ํ•ด๊ฒฐํ•˜์ง€ ๋ชปํ•ด ์•„์‰ฌ์› ๋‹ค...

 

ํ•™ํšŒ ๋ฌธ์ œ ํ’€์ด์‹œ๊ฐ„์— ์งˆ๋ฌธํ•ด์•ผ ๊ฒ ๋‹ค!

'SWLUG > ์›น ํ•ดํ‚น' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Dreamhack/๋“œ๋ฆผํ•ต] baby-linux  (0) 2023.11.16
[Dreamhack/๋“œ๋ฆผํ•ต] csrf-2  (1) 2023.11.11
[Dreamhack/๋“œ๋ฆผํ•ต] XSS Filtering Bypass  (0) 2023.11.10
[webhacking.kr] Challenge old-23  (0) 2023.11.09
[Dreamhack/๋“œ๋ฆผํ•ต] xss-2  (0) 2023.11.06