728x90

[๋ฌธ์ œ]

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

 

baby-Case

Description Bypass ๐Ÿ‘ถfilter

dreamhack.io

 


[๋ฌธ์ œ ํ’€์ด]

  • ๋จผ์ € ๋“ค์–ด๊ฐ€๋‹ˆ hi guest ๊ธ€์ž๋งŒ ๋‚˜์˜ค๋Š” ํŽ˜์ด์ง€๊ฐ€ ์ถœ๋ ฅ๋๋‹ค.
  • ๊ทธ๋ž˜์„œ, ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค.
const express = require("express")
const words = require("./ag")

const app = express()
const PORT = 3000
app.use(express.urlencoded({ extended: true }))

function search(words, leg) {
    return words.find(word => word.name === leg.toUpperCase())
}

app.get("/",(req, res)=>{
    return res.send("hi guest")
})

app.post("/shop",(req, res)=>{
    const leg = req.body.leg

    if (leg == 'FLAG'){
        return res.status(403).send("Access Denied")
    }

    const obj = search(words,leg)

    if (obj){
        return res.send(JSON.stringify(obj))
    }
    
    return res.status(404).send("Nothing")
})

app.listen(PORT,()=>{
    console.log(`[+] Started on ${PORT}`)
})
  • Search ํ•จ์ˆ˜๋Š” words ๋ฐฐ์—ด์—์„œ leg ๊ฐ’์„ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•œ ํ›„, ํ•ด๋‹น name ์†์„ฑ๊ณผ ์ผ์น˜ํ•˜๋Š” ๊ฐ์ฒด๋ฅผ ์ฐพ์•„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
  • ์ด ์ฝ”๋“œ๋Š” /shop ์—”๋“œํฌ์ธํŠธ์—์„œ POST ์š”์ฒญ์„ ๋ฐ›์•„ ํŠน์ • ์กฐ๊ฑด์— ๋”ฐ๋ผ ์‘๋‹ต์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
    • leg๋ผ๋Š” ์š”์ฒญ ๋ณธ๋ฌธ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ถ”์ถœํ•˜๊ณ  leg๊ฐ€ 'FLAG'์ด๋ฉด, 403 Forbidden ์ƒํƒœ ์ฝ”๋“œ์™€ ํ•จ๊ป˜ "Access Denied"๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
    • search ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ leg์™€ ์ผ์น˜ํ•˜๋Š” ๊ฐœ์ฒด๋ฅผ ๊ฐ์ฒด๋ฅผ ์ฐพ๊ณ  ๊ฐ์ฒด๋ฅผ ์ฐพ์œผ๋ฉด JSON ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™”ํ•˜์—ฌ ์‘๋‹ตํ•˜๊ณ  ์ฐพ์ง€ ๋ชปํ•˜๋ฉด 404 Not Found ์ƒํƒœ ์ฝ”๋“œ์™€ ํ•จ๊ป˜ "Nothing"์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
  • ์„œ๋ฒ„๊ฐ€ PORT ๋ฒˆํ˜ธ์—์„œ ๋ฆฌ์Šจ์„ ์‹œ์ž‘ํ•˜๋ฉฐ, ์„ฑ๊ณต์ ์œผ๋กœ ์‹œ์ž‘๋˜๋ฉด ์ฝ˜์†”์— ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
module.exports = [
    {
        "id": 1,
        "name": "FLAG",
        "description": "DH{fake_flag}"
    },
    {
        "id": 2,
        "name": "DRAG",
        "description": "To pull something along forcefully, often on the ground or another surface, causing friction or resistance. It also refers to the delay in performance or response time."
    },
    {
        "id": 3,
        "name": "SLAG",
        "description": "The waste material produced by the smelting process, which involves separating metal from its ore. Slag is typically a mixture of metal oxides and silicon dioxide."
    },
    {
        "id": 4,
        "name": "SWAG",
        "description": "Refers to stylish confidence in one's appearance or demeanor. It can also mean promotional goods or items given away for free as a form of advertising."
    }
]
  • ์ด ์ฝ”๋“œ๋Š” word์˜ ๋ฆฌ์ŠคํŠธ ์˜ˆ์‹œ์ด๋‹ค.
events {
    worker_connections  1024;
}

http {
    server {
        listen 80;
        listen [::]:80;
        server_name  _;
        
        location = /shop {
            deny all;
        }

        location = /shop/ {
            deny all;
        }

        location / {
            proxy_pass http://app:3000/;
        }

    }

}
  • nginx.conf ํŒŒ์ผ ์ฝ”๋“œ๋„ ๋ถ„์„ํ•ด ๋ณด๋ฉด /shop์— ๋Œ€ํ•œ ๋ชจ๋“  ์š”์ฒญ์ด deny ๋˜๋„๋ก ์„ค์ •๋˜์–ด ์žˆ๋‹ค.

  • postman์„ ํ†ตํ•ด ํ™•์ธํ•ด๋ณธ ๊ฒฐ๊ณผ, deny ๋˜๋Š” ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

https://www.hahwul.com/2021/10/08/bypass-403/

 

403 forbidden์„ ์šฐํšŒํ•˜๋Š” 4๊ฐ€์ง€ ๋ฐฉ๋ฒ•๋“ค

๋•Œ๋•Œ๋กœ ๋ณด์•ˆ ํ…Œ์ŠคํŒ… ์‹œ WAF๋‚˜ Application์˜ ๋กœ์ง์— ๋”ฐ๋ผ 403 Forbidden ์œผ๋กœ ์ ‘๊ทผ์ด ์ œํ•œ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณดํ†ต์€ ๋ฐฑ์—”๋“œ์˜ ์ฒ˜๋ฆฌ ๋กœ์ง์„ ๋ด์•ผ ์ •ํ™•ํ•˜๊ฒŒ ์šฐํšŒํ•  ์ˆ˜ ์žˆ๋Š” ํฌ์ธํŠธ๋ฅผ ์žก๊ฒ ์ง€๋งŒ, ๋ช‡๊ฐ€์ง€

www.hahwul.com

  • ์ด ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•ด ์šฐํšŒํ•˜๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜์ธ Letter Case๋ฅผ ์ด์šฉํ•ด shop์„ SHOP์œผ๋กœ ๋ณ€๊ฒฝํ•ด ํฌ์ŠคํŠธ ์š”์ฒญ์„ ํ•ด๋ณด์•˜๋‹ค.
  • ๊ทธ ๊ฒฐ๊ณผ, Flag๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

+ Recent posts