문제 설명
Description
Introducing DreamDocs: a platform for browsing docs!
![]()
이렇게 문서를 열람할 수 있는 서비스다.
flag_doc_id = random.randint(100, 999)
이 부분을 보면 flag가 들어있는 문서는 100부터 999까지의 무작위 문서 이다.
@app.route('/doc/<int:doc_id>')
def view_document(doc_id):
referer = request.headers.get('Referer', '')
user_level = request.headers.get('X-User', 'guest')
if doc_id < 0 or doc_id >= 1000:
abort(404)
if doc_id not in documents:
abort(404)
document = documents[doc_id]
if '/share' not in referer:
return render_template('error.html',
message="Access denied. Documents can only be accessed from the share page."), 403
if document['classification'] == 'confidential':
if user_level != 'admin':
return render_template('error.html',
message="Insufficient privileges. Administrator access required."), 403
elif document['classification'] == 'internal':
if user_level == 'guest':
return render_template('error.html',
message="Internal documents require user authentication."), 401
return render_template('document.html', doc=document, doc_id=doc_id)
이걸 보면 confidential 등급의 문서는 admin인 유저만 열람할 수 있는걸 알 수 있다.
@app.route('/api/docs')
def list_docs():
SHOW_COUNT = 15
user_level = request.headers.get('X-User', 'guest')
visible_docs = []
for doc_id, doc in documents.items():
if doc['classification'] == 'public':
visible_docs.append({'id': doc_id, 'title': doc['title'], 'classification': doc['classification']})
elif doc['classification'] == 'internal' and user_level != 'guest':
visible_docs.append({'id': doc_id, 'title': doc['title'], 'classification': doc['classification']})
elif doc['classification'] == 'confidential' and user_level == 'admin':
visible_docs.append({'id': doc_id, 'title': doc['title'], 'classification': doc['classification']})
if len(visible_docs) >= SHOW_COUNT:
break
return jsonify(visible_docs)
문서들의 정보를 볼 수 있는 페이지다.
![]()
/api/docs로 가는 패킷을 잡아서 X-user: admin을 추가했다.
![]()
960번 문서가 flag 문서라는 것을 알 수 있다.
![]()
다시 /share로 돌아와서 아무 문서나 클릭하고 이렇게 패킷을 고쳐준다.
![]()
다시 오는 패킷도 똑같이 수정해준다.
![]()
flag를 찾았다!