개발세발보안중
[드림핵]command-injection-1 Write up 본문
#!/usr/bin/env python3
import subprocess
from flask import Flask, request, render_template, redirect
from flag import FLAG
APP = Flask(__name__)
@APP.route('/')
def index():
return render_template('index.html')
@APP.route('/ping', methods=['GET', 'POST'])
def ping():
if request.method == 'POST':
host = request.form.get('host')
cmd = f'ping -c 3 "{host}"'
try:
output = subprocess.check_output(['/bin/sh', '-c', cmd], timeout=5)
return render_template('ping_result.html', data=output.decode('utf-8'))
except subprocess.TimeoutExpired:
return render_template('ping_result.html', data='Timeout !')
except subprocess.CalledProcessError:
return render_template('ping_result.html', data=f'an error occurred while executing the command. -> {cmd}')
return render_template('ping.html')
if __name__ == '__main__':
APP.run(host='0.0.0.0', port=8000)
플라스크(Flask)는2004년 오스트리아의 오픈소스 개발자 아르민 로나허(Armin Ronacher)가 만든 웹 프레임워크다.
페이지의 입력 형식을 지운다 (안그러면 8.8.8.8 형식 외에는 거부)
그리고 sql injection문을 작성하여 Ping! 버튼 누르면 flag가 나올 것이다
'CTF' 카테고리의 다른 글
[드림핵]pathtraversal Write Up (0) | 2023.05.10 |
---|---|
[드림핵]broken-png Write Up (0) | 2023.05.10 |
[드림핵]error based sql injection Write up (0) | 2023.05.03 |
[드림핵]sql injection bypass WAF Write up (1) | 2023.05.03 |
[wargame.kr]tmitter Write-up (0) | 2023.04.12 |
Comments