Skip to content

Commit 1a10c27

Browse files
author
jvazquez-r7
committed
Merge branch 'sap_rfc_system_info' of https://github.com/ChrisJohnRiley/metasploit-framework into ChrisJohnRiley-sap_rfc_system_info
2 parents 4085fa7 + d497972 commit 1a10c27

File tree

2 files changed

+238
-202
lines changed

2 files changed

+238
-202
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
##
9+
# This module is based on, inspired by, or is a port of a plugin available in
10+
# the Onapsis Bizploit Opensource ERP Penetration Testing framework -
11+
# http://www.onapsis.com/research-free-solutions.php.
12+
# Mariano Nunez (the author of the Bizploit framework) helped me in my efforts
13+
# in producing the Metasploit modules and was happy to share his knowledge and
14+
# experience - a very cool guy. I'd also like to thank Chris John Riley,
15+
# Ian de Villiers and Joris van de Vis who have Beta tested the modules and
16+
# provided excellent feedback. Some people just seem to enjoy hacking SAP :)
17+
##
18+
19+
require 'msf/core'
20+
21+
class Metasploit4 < Msf::Auxiliary
22+
23+
include Msf::Exploit::Remote::HttpClient
24+
include Msf::Auxiliary::Report
25+
include Msf::Auxiliary::Scanner
26+
27+
def initialize
28+
super(
29+
'Name' => 'SAP /sap/public/info RFC_SYSTEM_INFO Function Sensitive Information Gathering',
30+
'Description' => %q{
31+
This module uses the RFC_SYSTEM_INFO function within SAP Internet Communication
32+
Framework (ICF) to obtain the operating system version, SAP version, IP address
33+
and other information through /sap/public/info
34+
35+
},
36+
'Author' =>
37+
[
38+
# original sap_soap_rfc_system_info module
39+
'Agnivesh Sathasivam',
40+
'nmonkee',
41+
# repurposed for /sap/public/info (non-RFC)
42+
'ChrisJohnRiley'
43+
],
44+
'License' => MSF_LICENSE
45+
)
46+
register_options(
47+
[
48+
OptString.new('PATH', [true, 'Path to SAP Application Server', '/'])
49+
], self.class)
50+
end
51+
52+
def extract_field(data, elem)
53+
if data =~ /<#{elem}>([^<]+)<\/#{elem}>/i
54+
return $1
55+
end
56+
nil
57+
end
58+
59+
def report_note_sap(type, data, value)
60+
# create note
61+
report_note(
62+
:host => rhost,
63+
:port => rport,
64+
:proto => 'tcp',
65+
:sname => 'sap',
66+
:type => type,
67+
:data => data + value
68+
) if data
69+
# update saptbl for output
70+
@saptbl << [ data, value ]
71+
end
72+
73+
def run_host(ip)
74+
75+
print_status("[SAP] #{ip}:#{rport} - Sending RFC_SYSTEM_INFO request to SAP Application Server")
76+
uri = normalize_uri(datastore['PATH'] + '/sap/public/info')
77+
begin
78+
res = send_request_raw({ 'uri' => uri }, 20)
79+
if res and res.code != 200
80+
print_error("[SAP] #{ip}:#{rport} - Server did not respond as expected")
81+
return
82+
elsif not res
83+
print_error("[SAP] #{ip}:#{rport} - Server did not respond")
84+
return
85+
end
86+
rescue ::Rex::ConnectionError
87+
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
88+
return
89+
end
90+
91+
print_status("[SAP] #{ip}:#{rport} - Response received")
92+
93+
# create table for output
94+
@saptbl = Msf::Ui::Console::Table.new(
95+
Msf::Ui::Console::Table::Style::Default,
96+
'Header' => "[SAP] ICF RFC_SYSTEM_INFO",
97+
'Prefix' => "\n",
98+
'Postfix' => "\n",
99+
'Indent' => 1,
100+
'Columns' =>[
101+
"Key",
102+
"Value"
103+
])
104+
105+
response = res.body
106+
107+
# extract data from response body
108+
rfcproto = extract_field(response, 'rfcproto')
109+
rfcchartyp = extract_field(response, 'rfcchartyp')
110+
rfcinttyp = extract_field(response, 'rfcinttyp')
111+
rfcflotyp = extract_field(response, 'rfcflotyp')
112+
rfcdest = extract_field(response, 'rfcdest')
113+
rfchost = extract_field(response, 'rfchost')
114+
rfcsysid = extract_field(response, 'rfcsysid')
115+
rfcdbhost = extract_field(response, 'rfcdbhost')
116+
rfcdbsys = extract_field(response, 'rfcdbsys')
117+
rfcsaprl = extract_field(response, 'rfcsaprl')
118+
rfcmach = extract_field(response, 'rfcmach')
119+
rfcopsys = extract_field(response, 'rfcopsys')
120+
rfctzone = extract_field(response, 'rfctzone')
121+
rfcdayst = extract_field(response, 'rfcdayst')
122+
rfcipaddr = extract_field(response, 'rfcipaddr')
123+
rfckernrl = extract_field(response, 'rfckernrl')
124+
rfcipv6addr = extract_field(response, 'rfcipv6addr')
125+
126+
# report notes / create saptbl output
127+
report_note_sap('sap.version.release','Release Status of SAP System: ',rfcsaprl) if rfcsaprl
128+
report_note_sap('sap.version.rfc_log','RFC Log Version: ',rfcproto) if rfcproto
129+
report_note_sap('sap.version.kernel','Kernel Release: ',rfckernrl) if rfckernrl
130+
report_note_sap('system.os','Operating System: ',rfcopsys) if rfcopsys
131+
report_note_sap('sap.db.hostname','Database Host: ',rfcdbhost) if rfcdbhost
132+
report_note_sap('sap.db_system','Central Database System: ',rfcdbsys) if rfcdbsys
133+
report_note_sap('system.hostname','Hostname: ',rfchost) if rfchost
134+
report_note_sap('system.ip.v4','IPv4 Address: ',rfcipaddr) if rfcipaddr
135+
report_note_sap('system.ip.v6','IPv6 Address: ',rfcipv6addr) if rfcipv6addr
136+
report_note_sap('sap.instance','System ID: ',rfcsysid) if rfcsysid
137+
report_note_sap('sap.rfc.destination','RFC Destination: ',rfcdest) if rfcdest
138+
report_note_sap('system.timezone','Timezone (diff from UTC in seconds): ',rfctzone.gsub(/\s+/, "")) if rfctzone
139+
report_note_sap('system.charset','Character Set: ',rfcchartyp) if rfcchartyp
140+
report_note_sap('sap.daylight_saving_time','Daylight Saving Time: ',rfcdayst) if rfcdayst
141+
report_note_sap('sap.machine_id','Machine ID: ',rfcmach.gsub(/\s+/,"")) if rfcmach
142+
143+
if rfcinttyp == 'LIT'
144+
report_note_sap('system.endianness','Integer Format: ', 'Little Endian')
145+
elsif rfcinttyp
146+
report_note_sap('system.endianness','Integer Format: ', 'Big Endian')
147+
end
148+
149+
if rfcflotyp == 'IE3'
150+
report_note_sap('system.float_type','Float Type Format: ', 'IEEE')
151+
elsif rfcflotyp
152+
report_note_sap('system.float_type','Float Type Format: ', 'IBM/370')
153+
end
154+
155+
# output table
156+
print(@saptbl.to_s)
157+
158+
end
159+
end

0 commit comments

Comments
 (0)