반응형
문제설명
Bypass 👶filter
코드 분석
app.js
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}`)
})
- leg == FLAG이면 403 Access Denied출력
- obj는 leg와 매칭되는 단어 찾음. 성공 시 JSON으로 출력하는 듯
- 또한 leg가 소문자면 대문자로 바꿈
nginx.conf
http {
server {
listen 80;
listen [::]:80;
server_name _;
location = /shop {
deny all;
}
location = /shop/ {
deny all;
}
location / {
proxy_pass http://app:3000/;
}
}
}
- /shop이랑 /shop/ 이면 거부당함
ah.js
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."
}
]
- 이름 별로 값을 알려주는 듯하다.
취약점 분석
- 필터링이 /shop 또는 /shop/ 인지만 파악하고 필터링함
- FLAG도 대문자만 막고 있음
익스플로잇

다음과 같은 요청을 가로채서

POST로 바꿔준 후 /shop, /shop/이 우회되니 대문자로 바꿔준다.
또한 leg= FLAG인지만 파악하기 때문에 flag로 바꿔줘도 위 코드에서 대문자로 바꿔준대서 FLAG로 해석하게 되어 우회가 가능

타입 에러가 뜬다 아마 요청에서 Content-Type을 요청할 때 안보내줘서 오류가 난 거 같다.
Content-Type: application/x-www-form-urlencoded
요청에 다음과 같은 헤더를 추가해 주자.

Caido에서 여러번 요청 보냈더니 오류떠서 Burpsuite에서 다시 열고 풀었습니다.
반응형
'Dreamhack 워게임 > Lv.1' 카테고리의 다른 글
| what-is-my-ip (0) | 2026.02.14 |
|---|---|
| Dream Badge (0) | 2026.02.09 |
| simple-phparse (0) | 2026.02.09 |
| BypassIF (0) | 2026.02.09 |
| Type c-j (0) | 2026.02.08 |