반응형
문제 풀이
app.py
/user-page에서 url 파라미터에 url을 입력하여 해당 url의 response를 확인할 수 있다.
ALLOW_HOST 중 하나 포함되고, BLASK_LIST에서는 하나도 포함되면 안된다.
TOKEN = "{**SWAPED**}"
FLAG = "SWAP{sample_flag}"
BLACK_LIST = ['file', 'dict', 'sftp', 'tftp', 'ldap', 'netdoc', 'localhost', 'gopher', '127.0.0.1']
PASSWORD = f"{random.randint(0, 255):02X}"
ALLOW_HOST = ['abcd.com', 'asdf.com', 'example.com']
print("password is : " + PASSWORD)
@app.route('/')
def swap():
return render_template('index.html')
@app.route('/user-page', methods=['GET'])
def user():
url = request.args.get('url')
if not url:
return jsonify({"swap": "Write URL"}), 400
if not any(allow in url for allow in ALLOW_HOST):
return jsonify({"swap": "URL not allowed"}), 403
for bad in BLACK_LIST:
if bad in url.lower():
return jsonify({"swap": "BAN LIST"}), 403
try:
result = subprocess.run(
["curl", "-s", url],
text=True,
capture_output=True,
check=True
)
return jsonify({"response": result.stdout})
except subprocess.CalledProcessError as e:
return jsonify({"swap": "Error!~", "details": str(e)}), 500
@app.route('/access-token', methods=['GET'])
def admin():
if request.remote_addr in ["127.0.0.1"]:
password = request.args.get("password")
if password:
if password == PASSWORD:
return jsonify({"server": TOKEN}), 200
else:
return jsonify({"server": "Nop~ Password Wrong><"}), 403
else:
return jsonify({"server": "Write Password!"}), 400
else:
return jsonify({"server": "Only Localhost Can Access : )"}), 403
@app.route('/admin', methods=['GET'])
def check():
if request.args.get("token") == TOKEN:
return "<h1>dotori-company : $#@&*(@#&*(@)) BeePPP.. </h1>" + FLAG
else:
return jsonify({"server": "you are not admin..."}), 403
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True)
print("Ready Yeah~! made by swap ENJOY:)")
curl에서 http://<username>@<host>:<port>로 요청을 하게 되는데 @뒤에 host:port로 요청을 하게 된다.
http://example.com@127.0.0.2:5000 으로 요청이 가능하다.
access-token 경로에 password를 전달하여 token을 획득해야 한다. 경우의 수가 많지 않아 brute force 공격을 통해 진행한다. 아래 python 코드를 통해 wordlist를 생성한다.
burp를 사용하여 brute force 결과 Password를 확인 하였다.
/admin 경로에 token을 전달하여 flag를 확인하였다.
반응형
'WEB hacking > 드림핵(dreamhack)' 카테고리의 다른 글
Dreamhack safe input WriteUp (2) | 2025.07.22 |
---|---|
Dreamhack curling WriteUp (0) | 2025.07.21 |
Dreamhack Special Letter Translator WriteUp (2) | 2025.07.17 |
Dreamhack Are you admin? WriteUp (0) | 2025.07.15 |
Dreamhack PTML WriteUp (0) | 2025.07.13 |