Hacking

With this PHP rootkit you can take over a server hiding it in PHP server modules

The Dutch developer Luke Paris has created a PHP rootkit that hides in PHP server modules, he also explained why it is more dangerous of classic rootkits.

The Dutch developer Luke Paris has created a rootkit that hides in PHP server modules that could be used by attackers to take over web servers.

While classic rootkits work on the lowest levels of the operating system, intercepting kernel operations to perform malicious actions, Luke Paris successfully attempted to create a rootkit that interacts with the PHP interpreter, instead of the OS kernel that is much more complex.

“The first and very obvious reason why you would write a rootkit as a PHP module is accessibility. Learning how to use the Zend Engine (the framework the entire PHP language is built with) is a lot easier than learning how to write kernel modules, simply because the code base itself is smaller, better documented and a lot less complex,” Paris explained. “Even without good documentation or tutorials, I managed to learn the basics of writing a PHP module within a day. If I (a novice C developer) can do it, the bad guys definitely can.

Paris’ PHP rootkit allows attackers to gain persistence on the hacked server without getting detected.

According to Paris, the use of PHP modules to hide rootkits is very effective for the following reasons:

Accessibility – Writing a rootkit as a PHP module is a lot easier than learning how to write kernel modules. Developers can use smaller portions of code, Paris explained that he has learned the basics of writing a PHP module in just one day.

Stability – Rootkits are designed to run in kernel space, this implies that poorly written malware can crash the entire system. Using PHP rootkits this problem is overwhelmed. A poorly written PHP rootkit can’t crash the entire system.

“In the worst-case scenario, a rootkit will cause a segmentation fault and just interrupt the current request (note: most web servers report this in their error log, so this could raise suspicion).” states Paris.

Detectability – PHP Rootkits are difficult to detect because of the lack of checks of PHP modules.

“Furthermore, kernel rootkits require you to hook system calls for every process rather than just one, this slows down your machine drastically, which might lead to more suspicion.” stated the developer.

Portability – PHP rootkits are cross-platform rootkits because PHP is (in most cases) platform-independent.

Luke Paris published on GitHub a Proof of concept PHP rootkit, it is an open-source project.  The PoC code developed by Paris hooks into the PHP server’s “hash” and “sha1” functions, the rootkit is composed of only 80 lines of code, and it is quite easy for a hacker to hide it in legitimate modules.

To prevent attackers from using his code, Paris has omitted some of its parts, making compilation harder for non-expert PHP developers.

The post also includes a recommendation for administrators:

Keep a list of the module hashes after installing PHP. Administrators can use a cron job that tries to hash all files in the extension directory and compares them to the current hash. Paris also published a Python script that checks the SHA1 hashes of a user’s PHP modules.

[adrotate banner=”9″]

Pierluigi Paganini

(Security Affairs – PHP rootkit, hacking)

[adrotate banner=”13″]

Pierluigi Paganini

Pierluigi Paganini is member of the ENISA (European Union Agency for Network and Information Security) Threat Landscape Stakeholder Group and Cyber G7 Group, he is also a Security Evangelist, Security Analyst and Freelance Writer. Editor-in-Chief at "Cyber Defense Magazine", Pierluigi is a cyber security expert with over 20 years experience in the field, he is Certified Ethical Hacker at EC Council in London. The passion for writing and a strong belief that security is founded on sharing and awareness led Pierluigi to find the security blog "Security Affairs" recently named a Top National Security Resource for US. Pierluigi is a member of the "The Hacker News" team and he is a writer for some major publications in the field such as Cyber War Zone, ICTTF, Infosec Island, Infosec Institute, The Hacker News Magazine and for many other Security magazines. Author of the Books "The Deep Dark Web" and “Digital Virtual Currency and Bitcoin”.

Recent Posts

Microsoft Patch Tuesday security updates for May 2025 fixed 5 actively exploited zero-days

Microsoft Patch Tuesday security updates for May 2025 addressed 75 security flaws across multiple products, including…

6 hours ago

Fortinet fixed actively exploited FortiVoice zero-day<gwmw style="display:none;"></gwmw><gwmw style="display:none;"></gwmw>

Fortinet fixed a critical remote code execution zero-day vulnerability actively exploited in attacks targeting FortiVoice…

8 hours ago

How Interlock Ransomware Affects the Defense Industrial Base Supply Chain

Interlock Ransomware 's attack on a defense contractor exposed global defense supply chain details, risking…

20 hours ago

Marks and Spencer confirms data breach after April cyber attack

Marks and Spencer (M&S) confirms that threat actors stole customer data in the ransomware attack…

22 hours ago

Moldovan Police arrested a 45-year-old foreign man participating in ransomware attacks on Dutch companies

A 45-year-old foreign man has been arrested in Moldova for allegedly participating in ransomware attacks…

1 day ago

APT group exploited Output Messenger Zero-Day to target Kurdish military operating in Iraq

A Türkiye-linked group used an Output Messenger zero-day to spy on Kurdish military targets in…

1 day ago