티스토리 뷰
728x90
반응형
페이지에 접속하면 간단한 입력창이 1개 떠있다.
아무거나 입력해서 보내면, Something wrong.. 이라는 문구가 출력된다.
#internal 폴더 app.py
from flask import Flask
from flask import request
from secret import FLAG
app = Flask(__name__)
@app.route('/flag', methods=['GET'])
def index():
if request.host == "flag.service":
return FLAG
else:
return "Nice try :)"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
#public 폴더 app.py
import urllib
import urllib.parse
import requests
import ipaddress
from flask import Flask
from flask import request
import socket
app = Flask(__name__)
data = """
<html>
<head>
<title>BabyWeb</title>
</head>
<body>
<form action="/" method="POST">
<input type="text" name="url">
<input type="submit">
</form>
</body>
</html>
"""
def valid_ip(ip):
try:
ip = socket.gethostbyname(ip)
is_internal = ipaddress.ip_address(ip).is_global
if(is_internal):
return False
else:
return True
except:
pass
@app.route('/', methods=['GET','POST'])
def index():
if request.method == "POST":
try:
url = request.form['url']
result = urllib.parse.urlparse(url)
if result.hostname == 'flag.service':
return "Not allow"
else:
if(valid_ip(result.hostname)):
return "huh??"
else:
return requests.get("http://"+result.hostname+result.path, allow_redirects=False).text
except:
return "Something wrong..."
elif request.method == "GET":
return data
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
internal 폴더의 app.py를 보면,
host는 flag.service 이고 /flag로 접속하면, flag를 return 해주고 있다.
즉, GET 방식으로 "https://flag.service/flag"로 접속해야 한다.
" https://flag.service/flag " 를 그대로 제출하면 Not allow가 출력된다.
필터링을 우회해야 하는 것 같다.
public 폴더의 app.py를 보면, flag.service 단어가 필터링 되고 있다.
URL Encoding으로 http://%66%6c%61%67%2e%73%65%72%76%69%63%65/flag 을
제출하면 FLAG 획득!
728x90
반응형
'CTF > Web' 카테고리의 다른 글
[LIT CTF 2023] My boss left (0) | 2023.08.07 |
---|---|
[AmateuresCTF 2023] Factorial Calculator (0) | 2023.07.24 |
[AmateuresCTF 2023] Waiting-an-eternity (0) | 2023.07.24 |
[n00bzCTF 2023] Club N00b (0) | 2023.06.11 |
[n00bzCTF 2023] Robots (0) | 2023.06.11 |
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Fiesta
- 리버싱
- cheatengine
- SQLi
- CTF
- mongodb
- Cookie
- web
- 인시큐어뱅크
- rev
- forensic
- AssaultCube
- 안드로이드
- sqlinjection
- Android
- 스테가노그래피
- reversing
- 해킹
- MISC
- 드림핵
- networking
- FTKImager
- 포렌식
- 모바일
- forensics
- dreamhack
- md5
- 취약점
- Steganography
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함