Web Hacking 학습 정리

마지막 수정일: 2026년 05월 19일

Web basic knowledge



Cross-Site-Scripting (XSS)


Cross Site Request Forgery (CSRF)


SQL Injection


Command Injection

Command Injection: 사용자의 입력을 시스템 명령어로 실행하게 하는 취약점

Command Injection 실습 (Docker 환경 구축)

[ app.py ]

from flask import Flask, render_template, request
import os

app = Flask(__name__)

flag_path = "/flag.txt"
with open(flag_path, "w", encoding="utf-8") as flag:
   flag.write("NULLBINS{" + os.urandom(32).hex() + "}")

@app.route('/')
def index():
   return f"<h1>Welcome to Web Site</h1><p>Current path: {request.path}</p>"

@app.route('/ping', methods=['GET', 'POST'])
def ping():
   ip = request.form.get("ip", "")
   cmd = f"ping -c 1 {ip}"
   result = os.popen(cmd).read()
   return f"""
           <h2>Command</h2>
           <div class="cmd"><form action="/ping" method="POST">
           <input type="text" name="ip" id="ip" placeholder="127.0.0.1"/><input type="submit" value="enter"/>
           </form></div>
           <pre>{cmd}</pre><h2>Result</h2><pre>{result}</pre>
           """

if __name__ == '__main__':
   app.run(host="0.0.0.0", port=5000)

[ Dockerfile ]

FROM alpine:latest

RUN apk add --no-cache python3 py3-pip iputils
RUN pip3 install flask --break-system-packages

WORKDIR /app
COPY app.py .

EXPOSE 5000
CMD ["python3", "app.py"]

[ docker-compose.yaml ]

services:
 rce-server:
   build:
     context: .
     dockerfile: Dockerfile
   image: rce-server:v1
   container_name: rce-server
   hostname: rce-server
   restart: always
   networks:
     docker-network:
       ipv4_address: 192.168.10.100
networks:
 docker-network:
   external: true

[ rc.local ]

# Virtual Network Bridge
ip link add docknet link ens32 type macvlan mode bridge
ip addr add 192.168.10.254/24 dev docknet
ip link set docknet up
ip route add 192.168.10.0/24 dev docknet
ip addr show docknet | grep "inet"
ip route show | grep "docknet"
docker network create -d macvlan --subnet 192.168.10.0/24 --gateway 192.168.10.2 -o parent=ens32 docker-network
docker compose up -d --build

IMAGE IMAGE

File Vulnerability