CTF - Kioptrix Level 4 - Walkthrough Step by Step: @hackermuxam - Edu.vn
CTF - Kioptrix Level 4 - Walkthrough Step by Step: @hackermuxam - Edu.vn
vn
Previously we’ve covered up to 3 Levels of Kioptrix series CTF which you can find by this link.
Alright lets start the 4th level of Kioptrix series.
As always, when you try to solve any Vulnhub VM, your first step is to host discovery with the
help of following command:
From above output, we got to know that the IP Address of Kioptrix Level 4 VM is
192.168.36.134.
From here, we can run a NMAP against the above IP to check the open ports/services.
From initial Scans, you can see that the port number 22, 80, 139 and 445 are in open state.
Furthermore, you can easily enumerate the usernames through NetBIOS using nmap by typing
the following command:
As you can see that, we got 5 username (john, loneferret, nobody, robert, root). Let’s try to
connect the SMB shares on Kioptrix with the help of the following command:
We were able to login successfully but there are no public shares so you can just skip this part
and further do scanning with Nikto which is again one of the most popular open source
vulnerability scanner.
Let’s move on, and try to access the IP address in your browser i.e. http://192.168.36.134/
because the PORT 80 is open.
@hackermuxam.edu.vn
Yuppie, we found a login page, let’s go ahead and attempt SQL Injection by typing single quote
(‘) in both username and password field.
@hackermuxam.edu.vn
So here we confirmed that, the SQL Injection vulnerability is there so try to put some
combinations like this:
So here we successfully logged in with username (john) and password (1′ or ‘1’=’1). It also
seems like we got the John’s real password. You can do the same with the other users.
Let’s try to do SSH with username john and password (MyNameIsJohn) by typing the
following command in your terminal.
It seems that its a limited/restricted shell because only few command works which you can easily
get it by typing (help or ?) command.
To bypass this limited shell, there is a simple trick/code through which lshell can easily be
bypassed with the help of echo or vim command.
Okay! now that we have more access as you can see that, we are now able to
execute pwd command which tells your present working directory.
@hackermuxam.edu.vn
Furthermore, you can also grep processes run by root user by typing the following command:
To check whether mysql service is running or not, type ps -ef | grep root | grep mysql
And yes, MySQL service is running by root user so we can think about privilege escalation with
MySQL User Defined Functions (UDF).
Let’s see if we can find the DB username and DB password details in config file located at
/var/www directory.
@hackermuxam.edu.vn
As you can see that, there is no password, so you can easily bypass MYSQL with UDF which
you can learn more about at this link. It means you can easily escalate the privileges to root but
before to proceed, you need to first check whether the mysql service is running with root
privileges or not by typing the following command:
Yes, the mysql service is running with root privileges, so now you can directly access the
database with mysql client.
“show databases;” will give you a list of all databases hosted at your target IP and furthermore,
run a usermod command with sys_exec to give john admin privileges.
Using sys_exec we were able to run usermod which added john to the admin group.
You can also use select sys_exec(‘chmod u+s /bin/bash’); for privilege escalation to get the
bash shell with full permissions.
@hackermuxam.edu.vn