본문 바로가기
IT 및 정보보호 관련 소식&정보

Linux study_Over The Wire_bandit[02: find -size, ls -alp, strings]

by 건행오 2020. 4. 19.
반응형

안녕하세요 은남입니다. :)

 

리눅스 공부차 포스팅합니다.

https://overthewire.org/wargames/bandit/

 

OverTheWire: Bandit

We're hackers, and we are good-looking. We are the 1%. Bandit The Bandit wargame is aimed at absolute beginners. It will teach the basics needed to be able to play other wargames. If you notice something essential is missing or have ideas for new levels, p

overthewire.org

Bandit Level 5 → Level 6

Level Goal

The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:

  • human-readable
  • 1033 bytes in size
  • not executable

inhere 디렉터리 내에 있는 파일인데 다음 속성들을 모두 가졌다. 사람이 읽을 수 있고, 1033바이트이며, 실행이 불가능함

 

find 명령어의 -size 사용하였습니다. 1033c에서 c의 경우 바이트 단위인 경우 붙인다고 합니다.(구글링 결과)

not executable이라 하여 -executable 조건에 반대의 의미인! ->! -executable

해당 결과를 받아서 파일 정보 출력 : | xargs file 

find . -size 1033c ! -executable | xargs file

./maybehere07/. file2에 저장되어 있네요.

패스워드가 확인되었습니다.


Bandit Level 6 → Level 7

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

이번엔 서버 내 어딘가에 있다네요. 속성들은 소유자가 bandit7 소유 그룹은 bandit6, size는 33바이트 라 합니다.

find 옵션 중

find / -user bandit7 -group bandit6 -size 33c |xargs file

/var/lib/dpkg/info/bandit7.password 파일의 속성이 ASCII text라고 검색됩니다.

패스워드가 확인되네요.

ls -alp 시 나오는 목록 내용은 다음을 의미합니다.

     (1)           (2)      (3)           (4)          (5)           (6)                 (7)

-rw-r-----    1    bandit7    bandit6       33   Oct 16 2018    bandit7.password  

(1) 제일 앞의 -는 파일을 나타내며 d인 경우 디렉터리, l인 경우 링크를 의미합니다.

그 외에는 파일 또는 디렉터리에 대한 권한을 의미하며, user, group, other에 대해 각각 rwx로 표현됩니다. 

즉, 앞에 3은 rw- 는 파일 소유자에 대한 권한으로 read, write 권한을 의미하며, 그 뒤 r--는 파일의 소유 그룹에 대한 접근 권한으로 읽기만 가능, 그 외 에는 (---) 접근권한이 없음을 의미합니다.

 

(2) 링크된 파일의 수를 의미합니다.

(3) 소유자를 의미하며 username 은 bandit7입니다.

(4) 소유 그룹을 의미하며, 그룹명은 bandit6입니다.

(5) 파일의 크기를 의미합니다. 33byte

(6) 파일이 생성된 일자를 의미합니다.

(7) 파일의 이름입니다.


Bandit Level 7 → Level 8

Level Goal

The password for the next level is stored in the file data.txt next to the word millionth

 

이번엔 data.txt 파일 내 millionth 다음에 비밀번호가 저장되어 있다고 합니다.

 

cat data.txt |grep millionth

파이프 및 grep 명령어를 넣어주면 검색이 됩니다.

패스워드가 확인되었으니 다음으로 넘어갑니다.

 


Bandit Level 8 → Level 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

 

이번에도 data.txt 파일 안에 저장되어 있는데 한 번만 발생하는 텍스트 한 줄이라 합니다...

 

유일한 거면 중복되는 걸 제거하고 남는 게 패스워드이지 싶습니다. 그냥 cat 하니 엄청나 오더라고요

그래서 정렬 및 중복 제거해서 열어봤습니다.

 

패스워드를 확인했으니 다음으로 넘어갑니다.

 


Bandit Level 9 → Level 10

Level Goal

The password for the next level is stored in the file data.txt in one of the few human-readable strings, beginning with several ‘=’ characters.

 

이번에도 data.txt 파일에 저장되어 있는데, 몇 개의 = 문자로 시작하여 사람이 읽을수 있는 몇 개의 문자 중 하나로 저장되어 있다네요

 

cat으로 읽어보니 사단이 나더라고요. binary였나 봅니다...

그래서 strings 명령어를 사용하였습니다. 해당 명령어는 바이너리 파일에서 문자열을 추출하기 위한 명령어입니다.

*바이너리 파일은 이진 파일이라 하며, 컴퓨터가 저장과 처리를 위해 생성된 컴퓨터 파일로 이진형식으로 인코딩 된 데이터라 보시면 됩니다.

strings 명령어는  strings [옵션] 파일로 사용하면 됩니다.

strings data.txt | grep =

패스워드가 확인되었습니다.

 

그럼 다음 편에서 이어서 나가보겠습니다. 이전 편은 아래 게시물을 확인 부탁드립니다.

 

2020/04/16 - [법대생이 공부하는 IT&정보보호 컴플라이언스] - Linux study_Over The Wire_bandit [01 : ls, cat, find -type ]

 

반응형

댓글