As we can see from the nmap output above, port 139 and 445 is open.
We can then use smbclients to see what shares is available to let user to access it.
We try to access the Development share
Access Denied :(
We further try to access the Secret share.
It has a hidden secret file laying in this share.
Got a credential, maybe useful at some places 👀
HTTP
port 80 is open! Lets navigate through.
We got a apache page, we can try to directory brute force it using gobuster
We got few result, let's navigate to /project
Ah, a web application, the first thing we look for is the version of the qdPM it is using. As we can see, it is using version 9.1
We can use searchsploit to find the RCE script.
Let's use the Remote Code Execution that is Authentication Version 2
Exploit
We need to specify the parameter in order to exploit the vulnerable web application. We will use the credential we found at the SMB secret share.
Navigate to the backdoor.
Backdoor is working!
Reverse Shell
Go to revshell to generate a reverse shell payload.
What I like to use for this type of command reverse shell is mkfifo reverse (Work most of the time).
You need to encode with URL Encode.
Got a reverse shell!
We then need to spawn a proper shell by using python
User Escalation
After come poking around, we found out that the user flag is at the user chris folder.
And currently we don't have permission to read it.
We remembered there is a wordpress folder being scanned during the gobuster session.
We can see there is a wp-config.php.bak is laying around there!
Upon reading the file, we found out that there is a credential of Chris in there.
We can then switch user to Chris and get the user flag!
Since we have the credentials, we might as well use SSH for the stable connection.
Privilege Escalation
By supplying sudo -l we can see that user Chris can execute a script using sudo!
We can go to read this script for a better understanding of what it does.
addKey function
What this function does it creates a temporary file inside /tmp and it copy the sshKey into the created file. Then, it copies the content from the file into root ssh authorized_keys file.
How can we exploit this? Since the sshKey that it writes into the temporary file is static, we can write our own public key to the authorized_keys faster than the script itself. Therefore, this is a Race Condition exploit.
As we know, if inside the authorized_keys file has the public key of our key, we can ssh into the user without needing any password.
we can go ahead to create a ssh key.
Don't need any password, press enter all the way.
We can then open another session of ssh
At second session, we can do nano exploit.sh
Run the second session exploit first with your exploit.
Then only run the first session sudo script.
Then, we can go to our Kali machine and login using the private key that we created pair with the public key