Level Goal

The password for the next level is stored somewhere on the server and has all of the following properties:

owned by user bandit7

owned by group bandit6

33 bytes in size

Commands you may need to solve this level

ls, cd, cat, file, du, find, grep

서버 어딘가에 존재하는 파일에 비밀번호가 있다고 합니다.

파일의 특징은 user bandit7, group bandit6이 소유하고 33byte의 크기를 가지고 있다네요.

문제풀이

서버 어딘가에 존재한다고 했으므로 검색 범위를 넓히기 위해 cd .. 명령어로 디렉토리를 빠져나갑니다.

home 디렉토리에는 있을 것 같아서 find -user bandit7 -group bandit6 -size 33c 를 통해 유저, 그룹, 크기 3가지의 조건에 맞는 파일을 찾아봤지만 없었습니다. 그래서 한번 더 디렉토리를 빠져나가 검색을 했더니 엄청나게 많은 파일이 나오고 그 중 권한이 필요없는 파일은

./var/lib/dpkg/info/bandit7.password

하나뿐이였네요... 찾기 힘들었네요. 이곳에 비밀번호가 있었습니다.

+ 만약 permission denied 된 파일을 제외하고 검색하고 싶다면.

find -user bandit7 -group bandit6 -size 33c 2>/dev/null

뒤에 2>dev/null 까지 적어주시면 됩니다.


**Linux 명령어 설명(누적)

ls : 현재 디렉토리에 있는 파일을 보여줍니다.

ls -a : 현재 디렉토리에 있는 파일을 숨겨진 파일까지 전부 보여줍니다.

cat [파일명] : [파일명]의 내용을 출력합니다.

cat ./[파일명] : 현재 디렉토리에 있는 [파일명]의 내용을 출력합니다.

cat [파\ 일\ 명] : linux는 공백을 기준으로 앞뒤를 서로 다른 파일로 인식합니다.

cd [디렉토리명] : 해당 디렉토리로 이동합니다.

cd .. : 현재 디렉토리의 상위 디렉토리로 이동합니다.(*)

file [파일명] : [파일명] 파일의 종류를 출력합니다.

find [파일명] : [파일명]으로 된 파일을 찾습니다.

find -size [용량][단위] : [용량][단위]인 파일을 찾습니다.

(b:block, c:bytes, w:2bytes, k:kbytes, M:mbytes, G:gbytes)

find -user [user이름] : 소유중인 user 이름이 [user이름]인 파일을 찾습니다.(*)

find -group [group이름] : 소유중인 group 이름이 [group이름]인 파일을 찾습니다.(*)

* : 와일드카드, 문자를 대체하여 사용합니다.

 

새로운 명령어를 확인하기 위해 추가한 명령어 뒤에 (*)를 붙여놓겠습니다.

'Hacking-기초 > Linux Bandit' 카테고리의 다른 글

Bandit Level 8 → Level 9  (0) 2020.04.10
Bandit Level 7 → Level 8  (0) 2020.04.10
Bandit Level 5 → Level 6  (0) 2020.04.10
Bandit Level 4 → Level 5  (1) 2020.04.10
Bandit Level 3 → Level 4  (0) 2020.04.10

+ Recent posts