Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Web
- CodeEngn
- 소프트웨어
- 시스템해킹
- dreamhack
- System
- ftz
- 리버싱
- webhacking
- TCP
- 드림핵
- 웹해킹
- 네트워크
- 소프트웨어보안
- hacking
- bee-box
- 해킹
- WarGame
- 네트워크보안
- 모의해킹
- 웹
- 순서도
- 비박스
- 시스템
- Webhaking
- network
- 워게임
- XSS
- reversing
- 알고리즘
Archives
- Today
- Total
Without a Break
[Dreamhack] command-injection-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')
- 코드에 cmd 변수를 보면 어디에 코드를 작성하는지 나와있음
=> OR(|) 연산을 사용해보자
풀이
index 페이지의 모습
Ping 페이지로 들어가면 명령어를 입력할 수 있는 곳이 나온다.
| ls
먼저 ls 명령을 ping으로 보내 파일 목록을 확인해보자.
flag.py가 있는 것을 찾을 수 있었다.
| cat flag.py
flag.py의 내용을 보기 위해 cat 명령을 사용해줬다.
플래그 발견!
'Web > Wargame' 카테고리의 다른 글
[Dreamhack] [wargame.kr] strcmp (0) | 2023.08.29 |
---|---|
[Dreamhack] simple_sqli_chatgpt (0) | 2023.08.28 |
[Dreamhack] ex-reg-ex (0) | 2023.08.27 |
[Dreamhack] Flying Chars (0) | 2023.08.26 |
[Dreamhack] XSS Filtering Bypass (0) | 2023.08.25 |