PluginProbe
The WP Remote WordPress Plugin / 4.69
The WP Remote WordPress Plugin v4.69
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | callback/request.php +29 -85 5.164.69 View file →
@@ -9,9 +9,9 @@
9 9 public $is_afterload;
10 10 public $is_admin_ajax;
11 11 public $is_debug;
12 12 public $account;
13 - public $settings;
13 + public $calculated_mac;
14 14 public $sig;
15 15 public $time;
16 16 public $version;
17 17 public $is_sha1;
@@ -17,14 +17,12 @@
17 17 public $is_sha1;
18 18 public $bvb64stream;
19 19 public $bvb64cksize;
20 20 public $checksum;
21 - public $error = array();
22 21
23 - public function __construct($account, $in_params, $settings) {
22 + public function __construct($account, $in_params) {
24 23 $this->params = array();
25 24 $this->account = $account;
26 - $this->settings = $settings;
27 25 $this->wing = $in_params['wing'];
28 26 $this->method = $in_params['bvMethod'];
29 27 $this->is_afterload = array_key_exists('afterload', $in_params);
30 28 $this->is_admin_ajax = array_key_exists('adajx', $in_params);
@@ -85,10 +83,9 @@
85 83 public function info() {
86 84 $info = array(
87 85 "requestedsig" => $this->sig,
88 86 "requestedtime" => $this->time,
89 - "requestedversion" => $this->version,
90 - "error" => $this->error
87 + "requestedversion" => $this->version
91 88 );
92 89 if ($this->is_debug) {
93 90 $info["inreq"] = $this->params;
94 91 }
@@ -97,8 +94,11 @@
97 94 }
98 95 if ($this->is_afterload) {
99 96 $info["afterload"] = true;
100 97 }
98 + if ($this->calculated_mac) {
99 + $info["calculated_mac"] = $this->calculated_mac;
100 + }
101 101 return $info;
102 102 }
103 103
104 104 public function processParams($in_params) {
@@ -129,11 +129,20 @@
129 129 }
130 130
131 131 if (array_key_exists('bvprms', $in_params) && isset($in_params['bvprms']) &&
132 132 array_key_exists('bvprmsmac', $in_params) && isset($in_params['bvprmsmac'])) {
133 + $digest_algo = 'SHA1';
134 + $sent_mac = WPRAccount::sanitizeKey($in_params['bvprmsmac']);
133 135
134 - if ($this->verify($in_params['bvprms'], base64_decode($in_params['bvprmsmac'])) === true) {
136 + if (array_key_exists('bvprmshshalgo', $in_params) && isset($in_params['bvprmshshalgo'])) {
137 + $digest_algo = $in_params['bvprmshshalgo'];
138 + }
135 139
140 + $calculated_mac = hash_hmac($digest_algo, $in_params['bvprms'], $this->account->secret);
141 + $this->calculated_mac = substr($calculated_mac, 0, 6);
142 +
143 + if ($this->compare_mac($sent_mac, $calculated_mac) === true) {
144 +
136 145 if (array_key_exists('b64', $in_params)) {
137 146 foreach ($in_params['b64'] as $key) {
138 147 if (is_array($in_params[$key])) {
139 148 $in_params[$key] = array_map('base64_decode', $in_params[$key]);
@@ -171,9 +180,9 @@
171 180 }
172 181 }
173 182
174 183 if (array_key_exists('memset', $in_params)) {
175 - $val = intval($in_params['memset']);
184 + $val = intval(urldecode($in_params['memset']));
176 185 @ini_set('memory_limit', $val.'M');
177 186 }
178 187
179 188 return $params;
@@ -182,96 +191,31 @@
182 191
183 192 return false;
184 193 }
185 194
186 - public static function serialization_safe_decode($data) {
187 - if (is_array($data)) {
188 - $data = array_map(array('BVCallbackRequest', 'serialization_safe_decode'), $data);
189 - } elseif (is_string($data)) {
190 - $data = base64_decode($data);
191 - }
192 -
193 - return $data;
194 - }
195 -
196 - public function authenticate() {
197 - if (!$this->account) {
198 - array_push($this->error, "ACCOUNT_NOT_FOUND");
195 + private function compare_mac($l_hash, $r_hash) {
196 + if (!is_string($l_hash) || !is_string($r_hash)) {
199 197 return false;
200 198 }
201 199
202 - $bv_last_recv_time = $this->settings->getOption('bvLastRecvTime');
203 - if ($this->time < intval($bv_last_recv_time) - 300) {
200 + if (strlen($l_hash) !== strlen($r_hash)) {
204 201 return false;
205 202 }
206 203
207 - $data = $this->method.$this->account->secret.$this->time.$this->version;
208 - if (!$this->verify($data, base64_decode($this->sig))) {
209 - return false;
210 - }
211 - $this->settings->updateOption('bvLastRecvTime', $this->time);
212 -
213 - return 1;
214 - }
215 -
216 - public function verify($data, $sig) {
217 - if (!function_exists('openssl_verify')) {
218 - array_push($this->error, "OPENSSL_VERIFY_FUNC_NOT_FOUND");
219 - return false;
220 - }
221 -
222 - $key_file = dirname( __FILE__ ) . '/../public_keys/m_public.pub';
223 - if (!file_exists($key_file)) {
224 - array_push($this->error, "PUBLIC_KEY_NOT_FOUND");
225 - return false;
226 - }
227 - $public_key = file_get_contents($key_file);
228 - if (!$public_key) {
229 - array_push($this->error, "UNABLE_TO_LOAD_PUBLIC_KEY");
230 - return false;
231 - }
232 -
233 - $verify = openssl_verify($data, $sig, $public_key);
234 - if ($verify === 1) {
235 - return true;
236 - } elseif ($verify === 0) {
237 - array_push($this->error, "INCORRECT_SIGNATURE");
204 + if (function_exists('hash_equals')) {
205 + return hash_equals($l_hash, $r_hash);
238 206 } else {
239 - array_push($this->error, "OPENSSL_VERIFY_FAILED");
207 + return $l_hash === $r_hash;
240 208 }
241 - return false;
242 209 }
243 210
244 - public function corruptedParamsResp() {
245 - $bvinfo = new WPRInfo($this->settings);
246 -
247 - return array(
248 - "account_info" => $this->account->info(),
249 - "request_info" => $this->info(),
250 - "bvinfo" => $bvinfo->info(),
251 - "statusmsg" => "BVPRMS_CORRUPTED"
252 - );
253 - }
254 -
255 - public function authFailedResp() {
256 - $api_public_key = WPRAccount::getApiPublicKey($this->settings);
257 - $default_secret = WPRRecover::getDefaultSecret($this->settings);
258 - $bvinfo = new WPRInfo($this->settings);
259 - $resp = array(
260 - "request_info" => $this->info(),
261 - "bvinfo" => $bvinfo->info(),
262 - "statusmsg" => "FAILED_AUTH",
263 - "api_pubkey" => substr($api_public_key, 0, 8),
264 - "def_sigmatch" => substr(hash('sha1', $this->method.$default_secret.$this->time.$this->version), 0, 8)
265 - );
266 -
267 - if ($this->account) {
268 - $resp["account_info"] = $this->account->info();
269 - $resp["sigmatch"] = substr(hash('sha1', $this->method.$this->account->secret.$this->time.$this->version), 0, 6);
270 - } else {
271 - $resp["account_info"] = array("error" => "ACCOUNT_NOT_FOUND");
211 + public static function serialization_safe_decode($data) {
212 + if (is_array($data)) {
213 + $data = array_map(array('BVCallbackRequest', 'serialization_safe_decode'), $data);
214 + } elseif (is_string($data)) {
215 + $data = base64_decode($data);
272 216 }
273 217
274 - return $resp;
218 + return $data;
275 219 }
276 220 }
277 221 endif;