OverTheWire - Bandit
강의목차: Level 8 → Level 9(sort, uniq)
Bandit 웹페이지
https://overthewire.org/wargames/bandit/
1. Bandit Level 8 → 9
Level Goal
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
다음 레벨 패스워드는 data.txt 파일에 저장되어 있지만, 단 한 번만 나타난다. ( 중복되지 않은 값 )
Level 8 접속
$ ssh -p 2220 bandit8@bandit.labs.overthewire.org
Level 8 패스워드: TESKZC0XvTetK0S9xNwm25STk5iWrBvP
$ ls -al
$ file ./data.txt
$ cat ./data.txt
위 명령어들을 입력했을 때 확인할 수 있는 점은 총 세 가지 이다.
1. data.txt 파일의 크기는 약 33KB 이다. ( 뒤에서 부터 세자리씩 끊는다. )
2. data.txt 파일은 ASCII text 파일이다.
3. data.txt 파일 내부는 패스워드처럼 보이는 다량의 값들로 구성되어있다.
파일 내 특정 위치에 플래그가 존재한다는 것을 알고 있다. ( 중복되지 않은 값 )
내용이 랜덤으로 배치되어 있기 때문에, 먼저 정렬 후 각 문자열이 몇 번 나타는지 확인한다.
sort → 파일의 내용을 정렬하여 화면에 출력.
uniq → 파일의 내용을 중복된 내용을 제거하고 출력하는 명령어.
uniq 는 입력 내용에서 중복된 항목을 제거하는 커맨드 라인 유틸리티이다.
보통 sort 명령어로 정렬을 한 결과를 파이프로 uniq 에 전달해서 중복 내용을 제거한다.
$ cat ./data.txt | sort | uniq -c
→ cat 명령어를 사용해서 읽어온 data.txt 정보들을 sort 로 넘기고 uniq 로 넘겨 출력한다.
→ uniq -c 옵션 사용 시 각 라인별 중복 횟수를 계산해서 좌측에 표시한다.
좌측에 10 이라는 숫자와 여러 값들이 보인다.
중간에 보면 1 이라는 숫자와 함께 플래그(패스워드)를 확인할 수 있다.
1 이라는 숫자는 중복 횟수가 한번이므로 조건에서 말한 중복되지 않은 값, 즉 패스워드임을 알 수 있다.
패스워드: EN632PlfYiZbn3PhVK3XOGSlNInNE00t
$ exit ( ssh 접속 상태에서 홈으로 나가기 )
Level 9 로그인 시도
$ ssh -p 2220 bandit9@bandit.labs.overthewire.org
Level 9 패스워드: EN632PlfYiZbn3PhVK3XOGSlNInNE00t
$ whoami
$ id
입력하여 현재 로그인한 계정 확인
취미로 해킹1 강의 : https://www.inflearn.com/course/linux-3
'보안 > Bandit 워게임' 카테고리의 다른 글
OverTheWire - Bandit : Level 10 → Level 11 (0) | 2023.04.06 |
---|---|
OverTheWire - Bandit : Level 9 → Level 10 (0) | 2023.04.05 |
OverTheWire - Bandit : Level 7 → Level 8 (0) | 2023.04.03 |
OverTheWire - Bandit : Level 6 → Level 7 (0) | 2023.03.31 |
OverTheWire - Bandit : Level 5 → Level 6 (0) | 2023.03.30 |