[๋ฌธ์ ]
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๋ฅผ ์ป์ ์ ์์๋ค.