Another Login Challenge
·
Alpacahack
문제설명Topic: Login분야: Web난이도: MediumLogin!, login!, and login!문제 URL: https://alpacahack.com/daily/challenges/alert-my-flag코드 분석let users = { admin: { password: crypto.randomBytes(32).toString("base64"), },};users는 사용자 정보를 저장한 객체현재 admin 한 명만 있음password는 랜덤한 비밀번호 생성app.get("/", (req, res) => { res.send(` Login Login `);});GET / 요청 시 로그인 폼 HTML을 보여줌브라우..
Alert my Flag
·
Alpacahack
문제설명Topic: XSS분야: Web난이도: MediumRun alert(flag) to win!코드분석if(type === "alert" && message === FLAG) { successful = true; } await dialog.accept(); });visit 함수 일부분alert의 메시지가 FLAG와 같으면 성공app.get("/", async (req, res) => { const flag = req.cookies.flag ?? "fake_flag"; const username = req.query.username ?? "guest"; let result; if(username.includes("flag") || username.include..
Rock Paper Scissors Lizard Spock
·
Alpacahack
문제설명Topic: General분야: Web난이도: Hard코드분석const valid_inputs = ["rock", "paper", "scissors", "lizard", "spock"];입력값은 총 5개로 이뤄져 있음const winsAgainst = { rock: ["scissors", "lizard"], paper: ["rock", "spock"], scissors: ["paper", "lizard"], lizard: ["spock", "paper"], spock: ["scissors", "rock"],};rock 선택 시 scissors와 lizard 경우 승리paper 선택시 rock와 spock 경우 승리scissors 선택 시 paper 와 lizard 경우 승리lizard 선..
Alpaca Rangers
·
Alpacahack
문제설명Topic: LFI분야: Web난이도: MediumHero of Justice, Alpaca Rangers!코드분석buffer($contents) ?: 'application/octet-stream'; $dataUri = 'data:' . $mimeType . ';base64,' . base64_encode($contents); } }}?>URL의 ?img= ... 값을 가져옴 없으면 공백img의 값이 있을 때 수행/ 또는 \\로 시작하면 차단, ..이 포함되어도 차단 → 차단할때 에러메시지 출력사용자 입력 경로의 파일 내용을 읽음 @는 에러메시지를 숨김만약 파일 읽기 실패 시 not found 출력파일 내용을 base64로 인코딩해서 data: URL 문자열..
omikuji
·
Alpacahack
문제설명Topic: [Mirror] TSG LIVE! CTF주제: Web난이도: MediumCaffe-de-mancy코드분석function randomString() { return Math.floor(Math.random() * 4294967296).toString(16)}0 ~ 2^32 까지의 난수생성하고 16진수 문자열로 바꿈async function getResultContent(type) { return await readFile(`${import.meta.dirname}/${type}`, 'utf-8')}import.meta.dirname: 이 코드를 담고 있는 파일이 위치한 폴더 경로를 뜻함 WORKDIR /appserver.js를 /app/로 복사CMD ["node", "server.j..
Emojify
·
Alpacahack
문제설명Topic: Server-Side주제: Web난이도: Medium:pizza: -> 🍕코드분석frontend / index.jsconst waf = (path) => { if (typeof path !== "string") throw new Error("Invalid types"); if (!path.startsWith("/")) throw new Error("Invalid 1"); if (!path.includes("emoji")) throw new Error("Invalid 2"); return path;};waf은 경로가 문자열이어야 하고, "/" 로 시작하며, emoji를 포함하고 있어야 한다.express() .get("/", (req, res) => res.type("html..
Log Viewer
·
Alpacahack
문제설명Topic: Remote Code Execution분야: Web난이도: MediumSimple log viewer with regex feature.코드분석@app.route("/", methods=["GET", "POST"])def index(): query = "" log = "" if request.method == "POST": query = request.form.get("query", "") command = ["awk", f"/{query}/", "info.log"] result = subprocess.run( command, capture_output=True, timeo..
You are being redirected
·
Alpacahack
문제설명Topic: Client-Side분야: Web난이도: MediumYou don't want the browser to go to external websites without warning, do you?코드분석bot / bot.jstry { const page = await browser.newPage(); await page.setCookie({ name: "FLAG", value: FLAG, domain: new URL(APP_URL).hostname, path: "/", }); await page.goto(url, { timeout: 5000 }); await sleep(5000); await page.close(); }..
Inu Profile
·
Alpacahack
Topic: JavaScript분야: Web난이도: Very HardI made a Web application that dogs can introduce themselves.코드 분석const app = fastify();app.register(fastifyCookie);app.register(fastifySession, { secret: crypto.randomBytes(16).toString('hex'), cookie: { secure: false }});쿠키랑 세션 등록secret과 cookie 설정const DEFAULT_PROFILE = { 'avatar': '\u{1f436}', 'description': 'bow wow!'};DEFAULT_PROFILE 설정 (기본 프..
Plz Login
·
Alpacahack
Topic: Flask분야: Web난이도: MediumPlease login! I won't tell you the password tho!코드분석@app.post("/login")def login(): username = request.form.get("username", "") password = request.form.get("password", "") if username[0] not in "aA" or username[1:] != "dmin" or password != "**REDACTED**": return render_template("login.html", error="You are not Admin"), 401 return render_template("..