{"id":3747,"date":"2026-05-16T13:40:52","date_gmt":"2026-05-16T06:40:52","guid":{"rendered":"https:\/\/daiilynews.cu.ma\/?p=3747"},"modified":"2026-05-16T13:40:52","modified_gmt":"2026-05-16T06:40:52","slug":"how-i-discovered-and-deobfuscated-a-hidden-php-backdoor-on-my-server","status":"publish","type":"post","link":"https:\/\/daiilynews.cu.ma\/?p=3747","title":{"rendered":"How I Discovered and Deobfuscated a Hidden PHP Backdoor on My Server"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<p>As developers and system architects, we often secure our code but neglect the silent threats lurking in old directories or clever obfuscations. Recently, I caught a stealthy PHP backdoor ((random_name).php) embedded in a system.<\/p>\n<p>Instead of just deleting it, I decided to perform a full reverse engineering to understand exactly how it works, how it bypasses scanners, and how it maintains persistence on a server.<\/p>\n<p>Here is a quick summary of what I found during the analysis.<\/p>\n<p>\ud83d\udd0d The Anatomy of the MalwareAt first glance, the file was heavily obfuscated using multiple layers of encoding to look like harmless gibberish. However, the core mechanism relied on a classic but dangerous pattern:<\/p>\n<p>PHP\/\/ The malicious pattern used to execute hidden codeeval(base64_decode($_POST(&#8216;encoded_payload&#8217;)));Key Techniques Used by the Attacker:Layered Obfuscation: The code utilized deep base64 nesting combined with string manipulation functions to evade signature-based security scanners.<\/p>\n<p>Hidden Tar Extraction: Deep inside the encoded strings, the malware contained a compressed TAR structure. Once triggered, it extracts a full-featured web shell into the server directories.<\/p>\n<p>SSH Persistence: The ultimate goal wasn&#8217;t just to execute commands once\u2014the script was designed to inject malicious public keys into the server&#8217;s ~\/.ssh\/authorized_keys file, granting the attacker permanent, direct SSH access without leaving a footprint in the web logs.<\/p>\n<p>\ud83d\udee0\ufe0f How to Protect Your SystemIf you suspect your server has been compromised, simply deleting the .php file might not be enough. You need to:<\/p>\n<p>Check your ~\/.ssh\/authorized_keys for unauthorized entries.<\/p>\n<p>Audit your system cronjobs to ensure the malware doesn&#8217;t have a re-infection script scheduled.<\/p>\n<p>Implement strict file permissions (chmod 644 for files, 755 for directories) and disable dangerous PHP functions like eval(), exec(), and passthru() in your php.ini.<\/p>\n<p>\ud83d\udcd6 Read the Full Deep DiveI have documented the complete step-by-step deobfuscation process, the code breakdown, directory structures, and full remediation steps on GitHub.<\/p>\n<p>\ud83d\udc49 See full analysis and source code breakdown here:<\/p>\n<p>https:\/\/github.com\/KhaiTrang1995\/Malware-Analysis-Reports-PHP-Backdoor<\/p>\n<p>Alternatively, you can view the repository directly:<\/p>\n<p>Tags: #php #security #devsecops #malware<\/p>\n<p><br \/>\n<br \/><a href=\"https:\/\/dev.to\/khaitrang1995\/how-i-discovered-and-deobfuscated-a-hidden-php-backdoor-on-my-server-4mod\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As developers and system architects, we often secure our code but neglect the silent threats lurking in old directories or clever obfuscations. Recently, I caught a stealthy PHP backdoor ((random_name).php) embedded in a system. Instead of just deleting it, I decided to perform a full reverse engineering to understand exactly how it works, how it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[676],"tags":[835,761,765,762,1447,1446,763,764,1086,760],"class_list":["post-3747","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-ai","tag-ai","tag-coding","tag-community","tag-development","tag-devsecops","tag-discuss","tag-engineering","tag-inclusive","tag-security","tag-software"],"_links":{"self":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/3747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3747"}],"version-history":[{"count":0,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/posts\/3747\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=\/wp\/v2\/media\/3748"}],"wp:attachment":[{"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daiilynews.cu.ma\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}