baby-Case

2026. 2. 9. 20:25·Dreamhack 워게임/Lv.1
반응형

문제설명

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
'Dreamhack 워게임/Lv.1' 카테고리의 다른 글
  • what-is-my-ip
  • Dream Badge
  • simple-phparse
  • BypassIF
y3onbug5
y3onbug5
y3onbug5 님의 블로그 입니다.
  • y3onbug5
    y3onbug5 님의 블로그
    y3onbug5
  • 전체
    오늘
    어제
    • 분류 전체보기 (167) N
      • Alpacahack (19) N
      • Dreamhack 워게임 (49)
        • Lv.1 (40)
        • Lv.0 (4)
        • LV.2 (3)
        • LV.3 (2)
      • [Dreamhack] Web Beginner (3)
      • [Dreamhack] Web Hacking (17)
        • 웹 기초 지식 (4)
        • Cookie & Session (2)
        • Cross-Site Scripting(XSS) (1)
        • Cross-Site Request Forgery (1)
        • SQL Injection (4)
        • NoSQL Injection (2)
        • Command Injection (1)
        • File Vulnerability (1)
        • Server-Side Request Forgery (1)
      • [Dreamhack] Web Hacking Client-Side (10)
        • XSS Filtering Bypass (2)
        • Content Security Policy (CSP) (2)
        • CSRF,CORS Bypass (2)
        • Client-Side Template Injection (CSTI) (1)
        • CSS Injection (1)
        • Relative Path Overwrite (RPO) (1)
        • DOM Vulnerability (1)
      • [Dreamhack] Web Hacking Server-Side (15)
        • SQL Injection Advanced (4)
        • SQL Injection Advanced - Fingerprinting (2)
        • NoSQL Injection Advanced (3)
        • Command Injection Advanced - Web Servers (3)
        • File Vulnerability Advanced - Web Server (3)
      • [Dreamhack]Black-Box Penetration Testing (15)
        • DreamCommunity Penetration Testing (11)
      • [Dreamhack] LLM (2)
        • [Dreamhack] LLM과 프롬프트 엔지니어링 (2)
      • Web 공부 (4)
      • Web Study (15)
      • JavaScript (17)
        • 기초 (12)
        • 중급 (4)
      • 웹 개발(Flask) (0)
      • [Security First] web 기초교육 (1) N
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    JS
    xss
    드림핵
    webstudy
    alpacahack
    LLM
    hacking
    CSRF
    web
    DreamHack
    webhacking
    JavaScript
    cve
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
y3onbug5
baby-Case
상단으로

티스토리툴바