[Write-up] dreamhack - baby case
2024. 9. 2. 13:53ㆍ카테고리 없음
반응형
https://dreamhack.io/wargame/challenges/1401
baby-Case
Description Bypass 👶filter
dreamhack.io
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}`)
})
app.js로 위 코드가 주어진다.
추가로 ag.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."
}
]
app.js를 보면, /shop에서 request를 받아서 받은 data를 if문에서 비교하고, 해당 데이터의 문자열이 FLAG라면
403 에러와 에러메세지를 반환한다.
flag를 얻기 위해서는 리퀘에 flag를 보내야하는데, 에러가 반환되어서 정상적으로 flag를 확인할 수가 없다.
이를 우회하기 위해서 https://www.hahwul.com/2021/10/08/bypass-403/
403 forbidden을 우회하는 4가지 방법들
때때로 보안 테스팅 시 WAF나 Application의 로직에 따라 403 Forbidden 으로 접근이 제한되는 경우가 있습니다. 보통은 백엔드의 처리 로직을 봐야 정확하게 우회할 수 있는 포인트를 잡겠지만, 몇가지
www.hahwul.com
해당 글을 참고하여, /shop이 아니라 /SHOP으로 익스코드에 엔드포인트를 바꿔적었고, data를 보냈더니
정상적으로 flag가 반환되었다.
import requests
url = "http://host3.dreamhack.games:9405/"
data = {
'leg' : 'flag'
}
res = requests.post(url+'SHOP', data=data)
print(res.text)
반응형