2024. 11. 16. 16:21ㆍInformation Security 정보보안/DreamHack
배울내용 :
dreamhack,
web hacking,
개발자도구,
dreamhack 풀이,
dreamhack baby-Case 문제,
dreamhack web 풀이 ,
Postman
문제
이번문제의 설명은 조금 많이 부족해 보인다
우선 VM을 켜서 웹해킹 문제를 보니 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}`)
})
이중에서 app.get("/") 이란 함수가 실행 되었을때 hi guest 문구가 나오는걸 봤을때
아래의app.post 를 보면 /shop 이 들어가면 FLAG를 얻을수있을것같다. 그냥 shop 으로 가는거 뿐만아니라 req( request ) 에 FLAG 를 넣으면 403 이 되는걸 볼수있다 .
다른 코드로는 아래와 같다 확인해보자
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."
}
]
위에서 본것 처럼 FLAG 는 fake_flag 를 준다 그러면 POSTMAN 을 이용해 FLAG (대문자) 가 아닌 flag(소문자) 로 보내보면 어떨까?
우선 당연히 shop 에 leg=flag 만 했는데도 아래처럼 403 이 뜨는걸 볼수있다
이번에는 될거라는 생각에 곰곰히 생각하는 와중 nginx의 설정파일(nginx.conf) 을 확인해 보았다
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/;
}
}
}
그랬더니 shop에서 오는건 모두 deny 를 해버리니 /shop, /shop/ 에 대한 모든 요청이 deny되도록 설정되어있기 때문에 안된 것이였다. 따라서 이를 우회해서 post 요청을 보내야 한다
그런데 /shop 이나 /shop/ 을 보면 대소문자가 따로 구별이 되기때문에 /shop 을 막을거면 upcase 나 lowcase로 문자를 바꿔준뒤에 검사해야하는데 그런게 없는게 확인 되었다. 즉, /shop 은 안되어도 /SHOP은 가능할지도 모른다는 생각에 이번엔 /SHOP 으로 요청을 전송해보았다
그랬더니 성공적으로 플레그를 뛰울수있었다
'Information Security 정보보안 > DreamHack' 카테고리의 다른 글
[DreamHack] [web] [LEVEL 1] access-log 풀이 (1) | 2024.11.17 |
---|---|
[DreamHack] [web] [LEVEL 1] simple-phparse 풀이 (2) | 2024.11.17 |
[DreamHack] [web] [beginner] cookie 풀이 (0) | 2024.11.15 |
[DreamHack] [web] [beginner] pathtraversal 풀이 (0) | 2024.11.14 |
[DreamHack] [web] [beginner] file-download-1 풀이 (2) | 2024.11.14 |