Skip to content

Commit 91b81be

Browse files
committed
made requested changes
1 parent e053c4a commit 91b81be

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_read_table.rb

Lines changed: 27 additions & 27 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,28 +27,28 @@ class Metasploit4 < Msf::Auxiliary
2727
def initialize
2828
super(
2929
'Name' => 'SAP RFC RFC_READ_TABLE',
30-
'Version' => '$Revision: $0.1',
3130
'Description' => %q{
32-
This module makes use of the RFC_READ_TABLE Remote Function Call (via SOAP) to read data from tables.
31+
This module makes use of the RFC_READ_TABLE Remote Function Call (via SOAP) to read
32+
data from tables.
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
)
38-
38+
3939
register_options(
4040
[
4141
OptString.new('CLIENT', [true, 'Client', nil]),
4242
OptString.new('USERNAME', [true, 'Username', nil]),
4343
OptString.new('PASSWORD', [true, 'Password', nil]),
4444
OptString.new('TABLE', [true, 'Table to read', nil]),
45-
OptString.new('FIELDS', [true, 'Fields to read', '*']),
45+
OptString.new('FIELDS', [true, 'Fields to read', '*'])
4646
], self.class)
4747
end
48-
48+
4949
def run_host(ip)
5050
columns = []
51-
columns.push ('*') if datastore['FIELDS'].nil?
51+
columns << '*' if datastore['FIELDS'].nil?
5252
if datastore['FIELDS']
5353
columns.push (datastore['FIELDS']) if datastore['FIELDS'] =~ /^\w?/
5454
columns = datastore['FIELDS'].split(',') if datastore['FIELDS'] =~ /\w*,\w*/
@@ -59,7 +59,7 @@ def run_host(ip)
5959
end
6060
exec(ip,fields)
6161
end
62-
62+
6363
def exec(ip,fields)
6464
data = '<?xml version="1.0" encoding="utf-8" ?>'
6565
data << '<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
@@ -88,27 +88,27 @@ def exec(ip,fields)
8888
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
8989
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
9090
'Authorization' => 'Basic ' + user_pass,
91-
'Content-Type' => 'text/xml; charset=UTF-8',
91+
'Content-Type' => 'text/xml; charset=UTF-8'
9292
}
9393
}, 45)
94-
if (res and res.code != 500 and res.code != 200)
94+
if res and res.code ! 500 and res.code != 200
9595
# to do - implement error handlers for each status code, 404, 301, etc.
9696
if res.body =~ /<h1>Logon failed<\/h1>/
9797
print_error("[SAP] #{ip}:#{rport} - login failed!")
9898
else
9999
print_error("[SAP] #{ip}:#{rport} - something went wrong!")
100100
end
101101
return
102-
elsif res.body =~ /Exception/
102+
elsif res and res.body =~ /Exception/
103103
response = res.body
104104
error = response.scan(%r{<faultstring>(.*?)</faultstring>})
105105
success = false
106106
return
107107
else
108-
response = res.body
108+
response = res.body if res
109109
success = true
110110
end
111-
if success == true
111+
if success
112112
output = response.scan(%r{<WA>([^<]+)</WA>}).flatten
113113
print_status("[SAP] #{ip}:#{rport} - got response")
114114
saptbl = Msf::Ui::Console::Table.new(
@@ -117,21 +117,21 @@ def exec(ip,fields)
117117
'Prefix' => "\n",
118118
'Postfix' => "\n",
119119
'Indent' => 1,
120-
'Columns' => ["Returned Data"],
120+
'Columns' => ["Returned Data"]
121121
)
122-
for i in 0..output.length-1
122+
0.upto(output.length-1) do |i|
123123
saptbl << [output[i]]
124124
end
125125
print(saptbl.to_s)
126126
end
127-
if success == false
128-
for i in 0..error.length-1
127+
if !success
128+
0.upto(error.length-1) do |i|
129129
print_error("[SAP] #{ip}:#{rport} - error #{error[i]}")
130130
end
131131
end
132-
rescue ::Rex::ConnectionError
133-
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
134-
return
135-
end
132+
rescue ::Rex::ConnectionError
133+
print_error("[SAP] #{ip}:#{rport} - Unable to connect")
134+
return false
136135
end
137-
end
136+
end
137+
end

0 commit comments

Comments
 (0)