Skip to content

Commit

Permalink
添加 web/GET
Browse files Browse the repository at this point in the history
  • Loading branch information
13m0n4de committed Oct 15, 2023
1 parent adfc664 commit 216d530
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/chal.web.get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Challenge get

on:
push:
branches: ["main"]
paths:
- "!**/README.md"
- "challenges/web/get/build/**"
workflow_dispatch:

env:
TYPE: web
NAME: get
REGISTRY: ghcr.io

jobs:
challenge-build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.NAME }}
tags: |
latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: challenges/${{ env.TYPE }}/${{ env.NAME }}/build
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
11 changes: 11 additions & 0 deletions challenges/web/get/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GET

- **作者**:ksks
- **参考**:-
- **难度**:Easy
- **分类**:Web
- **暴露端口**:80

## 题目描述

## 题目解析
12 changes: 12 additions & 0 deletions challenges/web/get/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:alpine

ENV FLASK_APP=app FLASK_ENV=production FLASK_ENV_DEBUG=False

RUN pip install flask gunicorn --no-cache-dir

COPY --chmod=500 init.sh /init.sh
COPY ./app /app

WORKDIR /app

CMD ["/init.sh"]
15 changes: 15 additions & 0 deletions challenges/web/get/build/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from flask import Flask, request


app = Flask(__name__)

FLAG = os.getenv("GZCTF_FLAG", "flag{test_flag}")


@app.route("/")
def index():
if want := request.args.get("want"):
return FLAG
else:
return "请用 GET 方式提交一个名为 want,值为 flag 的变量"
3 changes: 3 additions & 0 deletions challenges/web/get/build/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

gunicorn main:app -b 0.0.0.0:80

0 comments on commit 216d530

Please sign in to comment.