Bashed
Machine Level: Easy OS: Linux
Scanning
I ran an nmap scan using the aggressive flag to identify some services.
ajread@aj-ubuntu:~$ nmap -A [REDACTED]
Starting Nmap 7.80 ( https://nmap.org ) at 2023-01-16 21:14 CST
Nmap scan report for [REDACTED]
Host is up (0.19s latency).
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Arrexel's Development Site
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 24.51 secondsEnumeration
I conducted some enumeration using gobuster and found that there was an interesing subdirectory on port 80 as /dev/phpbash.php. At the directory, there is a command line for me to use.
The commandline has me as user www-data.
Initial Access
With the command line in the phpbash.php, I was able to navigate to the user home directory and read the user flag.
Privilege Escalation
Going through some normal privilege escalation checks, I wanted to see if I was able to run anything as sudo. It turned out that I was able to run a scriptmanager with such privileges.
I found a /scripts folder that I was able to read the contents of using scriptmanager permissions.
It looked like test.py writes to test.txt.
Now, I rewrote the test.py file since it was able to be edited by scriptmanager but only run by root because it required the ability to write to a test.txt file that is owned by root. I changed the file to be a reverse shell in python with a connection back to my local IP and port using echo and tee.
I had some issues setting up the python reverse shell. I had to create one that was a one liner without spaces, found here.
I opened a listener on my local machine and waited for the connection to come through. And it did!
I was able to read the root flag as well.
Last updated