<문제>
File Download 취약점이 존재하는 웹 서비스입니다.
flag.py를 다운로드 받으면 플래그를 획득할 수 있습니다.
@APP.route('/upload', methods=['GET', 'POST'])
def upload_memo():
if request.method == 'POST':
filename = request.form.get('filename')
content = request.form.get('content').encode('utf-8')
if filename.find('..') != -1:
return render_template('upload_result.html', data='bad characters,,')
with open(f'{UPLOAD_DIR}/{filename}', 'wb') as f:
f.write(content)
return redirect('/')
return render_template('upload.html')
upload 링크에서 파일을 업로드하고
@APP.route('/read')
def read_memo():
error = False
data = b''
filename = request.args.get('name', '')
try:
with open(f'{UPLOAD_DIR}/{filename}', 'rb') as f:
data = f.read()
except (IsADirectoryError, FileNotFoundError):
error = True
return render_template('read.html',
filename=filename,
content=data.decode('utf-8'),
error=error)
read에서 읽을 수 있다.
파일 업로드 부분에서 php 코드를 올리면 실행되나 싶어서 .php 확장자로 파일 이름을 설정하고 업로드 해봤는데
php 코드가 실행되지 않는다.
파일 이름에 ..을 넣을 수 없게 필터링 되어 있는 걸 보고 파일 이름을 조작할 수 없다는 걸 알게 되었는데 고민하다 보니
read 링크에는 .. 필터링이 없다.
url을 조작해서 원하는 파일을 읽어오면 될거 같아서
?name=../flag.py를 했더니
flag가 나온다.
'웹해킹' 카테고리의 다른 글
드림핵 web-ssrf 롸업 (0) | 2023.11.05 |
---|---|
ServerSide: SSRF (0) | 2023.11.05 |
드림핵 image-storage 롸업 (0) | 2023.11.05 |
ServerSide: File Vulnerability (0) | 2023.11.04 |
드림핵 command-injection-1 롸업 (0) | 2023.11.04 |