Nmap

PORT     STATE  SERVICE VERSION
21/tcp   open   ftp     ProFTPD 1.3.5b
22/tcp   open   ssh     OpenSSH 7.4p1 Debian 10+deb9u7 (protocol 2.0)
| ssh-hostkey: 
|   2048 aa:77:6f:b1:ed:65:b5:ad:14:64:40:d2:24:d3:9c:0d (RSA)
|   256 a9:b4:4f:61:2e:2d:9d:4c:48:15:fe:70:8e:fa:af:b3 (ECDSA)
|_  256 92:56:eb:af:c9:34:af:ea:a1:cf:9f:e1:90:dd:2f:61 (ED25519)
53/tcp   closed domain
2222/tcp open   ssh     Dropbear sshd 2016.74 (protocol 2.0)
3000/tcp open   http    Golang net/http server
| http-methods: 
|_  Supported Methods: GET HEAD
|_http-title: Gitea: Git with a cup of tea
| fingerprint-strings: 
|   GenericLines, Help: 
|     HTTP/1.1 400 Bad Request
|     Content-Type: text/plain; charset=utf-8
|     Connection: close
|     Request
|   GetRequest: 
|     HTTP/1.0 200 OK
|     Content-Type: text/html; charset=UTF-8
|     Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
|     Set-Cookie: i_like_gitea=5fd37f96e20af3dc; Path=/; HttpOnly
|     Set-Cookie: _csrf=-2c8hW3laGg2I9EuE1JFAnF0gMw6MTc5MDYzNjkxNjQ5MTg4MDUwNQ%3D%3D; Path=/; Expire

Enumeration

FTP is up but does not allow anonymous logins.

SSH on 22 and 2222 (Dropbear)

Dropbear SSH is a lightweight, open-source Secure Shell (SSH) version 2 server and client software package designed by Matt Johnston==. It is written in C and optimized as a replacement for standard OpenSSH in low-resource environments, such as embedded systems, IoT devices, and router distributions like OpenWrt.

There is a Gitea instance on port 3000, version 1.7.5. It appears to be vulnerable to an RCE vulnerability. Let’s try it out.

Exploitation

To get a shell, we have to do some tweaking to the script:

  • Adding our credentials
  • Setting up a python web server
  • Creating a payload script with a bash reverse shell in it
  • Setting up a listener
  • Adjusting ports to coincide to our server and listener

Privilege Escalation

Chloe is in some weird groups, may be useful later:

I noticed that we are able to write to /usr/local/bin, and it is in the PATH before /usr/bin. Checking crontab, we notice that run-parts runs on a schedule. So we can make a run-parts script and move it to /usr/local/bin and it will run.

It runs every five minutes, so we set up a listener and wait.

Done!

Takeaways

  • I had to revert the machine once I had set up the exploit script. Something about running it with the wrong parameters made the exploit fail. So, when in doubt, revert the machine.
  • Always check writable directories
    • find / -writable -type d 2>/dev/null
  • Penelope is the shit.