X微e-office的那个前台任意文件上传漏洞已经被爆出一段时间了,相关的漏洞利用脚本甚至是漏洞批量利用脚本
也有很多。在这里根据系统代码结合POC来分析一下这个漏洞点。
定位漏洞点
根据poc中的上传路径可以知道,漏洞点存在于/general/index/UploadFile.php文件。产生漏洞的代码是下边这一串。
else if ( $uploadType == "eoffice_logo" )
{
$targetPath = $_SERVER['DOCUMENT_ROOT']."/images/logo/";
if ( !file_exists( $targetPath ) )
{
mkdir( $targetPath, 511, true );
}
$ext = $_FILES['Filedata']['name']( $_FILES['Filedata']['name'] );
$_targetFile = "logo-eoffice".$ext;
$targetFile = str_replace( "//", "/", $targetPath )."/".$_targetFile;
if ( move_uploaded_file( $tempFile, $targetFile ) )
{
$query = "SELECT * FROM sys_para WHERE PARA_NAME = 'SYS_LOGO'";
$result = exequery( $connection, $query );
$row = mysql_fetch_array( $result );
$param1 = $param2 = false;
if ( !$row )
{
$query = "INSERT INTO sys_para VALUES('SYS_LOGO','{$_targetFile}')";
$param1 = exequery( $connection, $query );
}
else