[OverTheWire] Bandit Level 6 -> Level 7

King's meow·2023년 11월 9일

[Linux] 리눅스 공부

목록 보기
7/17
post-thumbnail

🤔 문제

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

✅ 풀이

server 내에 어딘가 존재한다.

  • user == bandit7
  • user == bandit6
  • size == 33 bytes

find / -user bandit7 -group bandit6 -size 33c

  • / : 서버의 최상위 경로
  • -user : 파일의 소유자를 찾는다.
  • -group : 파일이 속한 그룹을 찾는다.
  • -size : 파일의 사이즈를 찾는다.
  • c : bytes

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

  • 2 : 표준 에러를 나타내는 파일 디스크립터
  • > : 리다이렉트 연산자로 출력을 다른 곳으로 보낸다.
  • /dev/null : 리눅스의 쓰레기통, 아무것도 저장하지 않고 버릴 수 있는 장소

✏️ File Descriptor : 프로세스에서 특정 파일에 접근할 때 사용하는 추상적인 값

  • 0 : Standard input, 표준 입력
  • 1 : Standard output, 표준 출력
  • 2 : Standard error, 표준 에러

✏️ Redirection : 입출력의 방향을 지정할 때 사용

  • A > B : A의 결과를 B로 보낸다(저장).
  • A >> B : A의 결과를 기존 B의 데이터에 추가한다.
  • A < B : B의 데이터를 A에 입력한다.
bandit6@bandit:~$ ls                                                   
bandit6@bandit:~$ ls -al                                               
total 20                                                               
drwxr-xr-x  2 root root 4096 Oct  5 06:19 .                             
drwxr-xr-x 70 root root 4096 Oct  5 06:20 ..                           
-rw-r--r--  1 root root  220 Jan  6  2022 .bash_logout                 
-rw-r--r--  1 root root 3771 Jan  6  2022 .bashrc                       
-rw-r--r--  1 root root  807 Jan  6  2022 .profile                     
bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c         
find: ‘/etc/ssl/private’: Permission denied                             
find: ‘/etc/polkit-1/localauthority’: Permission denied                 
find: ‘/etc/sudoers.d’: Permission denied                               
find: ‘/etc/multipath’: Permission denied  

...                        

/var/lib/dpkg/info/bandit7.password                                     
find: ‘/var/log’: Permission denied                                     
find: ‘/var/cache/private’: Permission denied                           

...
                           
bandit6@bandit:~$ find / -user bandit7 -group bandit6 -size 33c 2>/dev/null                                             
/var/lib/dpkg/info/bandit7.password                                     
bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password               
z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S 

bandit7 : z7WtoNQU2XfjmMtWA8u5rN4vzqu4v99S

profile
백엔드 개발자가 되고 싶은 응애

0개의 댓글