Linux/bandit
[Bandit] Bandit 0 -> 6 풀이
끊임없는정진
2022. 11. 2. 03:26
▶Bandit 0
SSH접속 양식 :
1
|
ssh [계정]@[시스템 주소] -p [포트번호]
|
cs |
▶Bandit 0 -> 1
(1) 홈디렉토리 확인
1
2
|
cat /etc/passwd 1 grep bandit
bandit0:x:11000:11000:bandit level 0:/home/bandit0:/bin/bash
|
cs |
홈디렉토리가 /home/bandit0 임을 확인할 수 있다.
(2) 현재경로 확인
1
2
|
bandit0@bandit:~$ pwd
/home/bandit0
|
cs |
현재 홈디렉토리에 있는 것을 확인할 수 있다.
(3) 현재 디렉토리에 파일 확인
1
2
|
bandit0@bandit:~$ ls
readme
|
cs |
'readme'파일이 있다는 것을 확인할 수 있다.
(4) 파일 읽기 : cat, more, vi
1
2
3
4
5
|
bandit0@bandit:~$ cat readme
NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL
bandit0@bandit:~$ more readme
NH2SXQwcBdpmTEzi3bvBHMM9H66vVXjL
|
cs |
▶Bandit 1 -> 2
cat, more, vi 모두 사용불가, 'cat - '명령어는 standard input(사용자 입력) 출력
방법1. 절대경로 사용
1
2
|
bandit1@bandit:~$ cat ./-
rRGizSaX8Mk1RTb1CNQoXTcYZWU6lgzi
|
cs |
▶Bandit 2 -> 3
띄어쓰기가 존재해서 파일을 읽을 수 없음
방법1. ""(따옴표) 사용
1
2
|
bandit2@bandit:~$ cat "spaces in this filename"
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG
|
cs |
방법2. \(역슬래쉬) 사용
1
2
|
bandit2@bandit:~$ cat spaces\ in\ this\ filename
aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG
|
cs |
▶ Bandit 3 -> 4
숨김 파일(hidden file)에 비밀번호가 있음.
(1) ls -al 이용해서 숨김파일을 찾기
1
2
3
4
5
|
bandit3@bandit:~/inhere$ ls -al
total 12
drwxr-xr-x 2 root root 4096 Sep 1 06:30 .
drwxr-xr-x 3 root root 4096 Sep 1 06:30 ..
-rw-r----- 1 bandit4 bandit3 33 Sep 1 06:30 .hidden
|
cs |
(2) ".hidden"파일 실행
1
2
|
bandit3@bandit:~/inhere$ cat .hidden
2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe
|
cs |
▶ Bandit 4 -> 5
inhere 디렉토리 중 human-readable 파일 찾기
file로 데이터타입을 찾는데 대상을 ./* (현재 디렉토리 전부)로 잡으면 ASCIItext로 된 파일 하나를 찾을 수 있다.
1
2
3
4
5
6
7
8
9
10
11
|
bandit4@bandit:~/inhere$ file ./*
./-file00: OpenPGP Public Key
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data
|
cs |
▶ Bandit 5 -> 6
human readable, 1033 bytes in size, not executable 의 조건에 맞는 파일을 찾는 문제
Find 명령어를 활용해서 푸는 문제, find -type f(파일 형식) -size 1033c(1033byte) ! -executable(실행불가)
1
2
3
|
find [경로] [option]
bandit5@bandit:~/inhere$ find ./ -type f -size 1033c ! -executable
./maybehere07/.file2
|
cs |
출처 : https://man7.org/linux/man-pages/