C99 is a PHP webshell. Attackers uploads it on web server in order to get informations and above all execute commands with web user privileges (ex: www-data).
This webshell is protected by a customizable password, so interface access is limited to people who know the password.
But the password verification mechanism is vulnerable ... in fact the flaw was deliberately inserted into the code to permit the webshell author to bypass it.
Username and password are hardcoded to be easily editable.
Next, login and password are checked by the following code:
If login and password are not correct, an error page indicate that access is forbidden.
But checking is processed only if login is not empty:
$login is normally initialized staticly at the begining but after that the variable can be modified by
extract() function :
PHP documentation say :
(PHP 4, PHP 5, PHP 7)
extract — Import variables into the current symbol table from an array Description Import variables from an array into the current symbol table.
Checks each key to see whether it has a valid variable name. It also checks for collisions with existing variables in the symbol table.
extract() is mostly used to initialize variables from an array.
So for each line of the array, the key becomes the variable name and the value is given to the variable.
This function is dangerous because of it default behaviour : if a key of the extracted array match with an existant variable, the variable value will be replaced by the value of the array given in paramteter to extract().
Bypass authentification is very simple : overwrite
It's possible because of:
Why a backdoor?
Pirates infect websites with webshells, but because this webshell is backdoored other pirates (authors of the webshell) will be able to control the server too.
extract() function and
c999shcook array are useless for the webshell but allow to overwrite any variables in the PHP script.
There is another flaw
The simplest versions of c99 include a clear script:
Others like c99-bd try to poorly obfuscate it:
But a simple HTML decoder will decode
Others like c100, r57, c999 or updated c99 version have more sophisticated method like packing the script:
and unpack code can be a lot more complex than only base64_decode it or hex_to_ascii it.
The goal is always the same : each time the page is displayed, the website hosting the webshell will do a request to the malicious address and send the URL where it comes from, permiting to the malicious author to know all the website hosting the backdoored webshell.
The malicious script from
http://www.r57.gen.tr/yazciz/ciz.js looks like this:
Script kiddies, lamers, and inattentive pirates will use webshells without looking carefully at the code. The combo flaw + inventory of infected website is an easy way, for webshells' authors, to control a network of server (ex: creating a botnet) by letting to others the system corruption task.
More sophisticated piracy tools have some vulnerabilities too. Malwares like Smoke Loader (SQL injection), CrimePack (SQL injection) or Zeus (remote access via upload) have been corrupted.
When using tools, be carefull, backdoors may be hidden. Pay attention to images, scripts, css, external request, mail functions, encoded code, ...
Source: C99.php : Quand même les backdoors sont backdoorées by Hugo Ballesteros