De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.
*Please note that not all obfuscation codes can be decoded.<?php namespace Mgt\Varnish\Model\Plugin; class LayoutPlugin { const ADMIN_AREA_CODE = "\x61\x64\155\151\x6e\150\164\155\154"; protected $request; protected $storeConfig; protected $varnishConfig; protected $response; protected $license; protected $logger; protected $cacheLifetime; protected $state; public function __construct() { goto afd93; afd93: $objectManager = $this->getObjectManager(); goto ab014; ab014: $this->request = $objectManager->get("\134\115\141\x67\145\156\x74\x6f\x5c\x46\162\x61\155\145\x77\157\162\x6b\x5c\x41\160\x70\x5c\x52\x65\161\165\145\x73\164\134\x48\x74\x74\x70"); goto D4328; F1d13: $this->license = $objectManager->get("\134\115\147\164\134\126\x61\x72\156\151\x73\150\134\115\x6f\144\145\x6c\x5c\x4c\x69\x63\x65\156\163\x65"); goto E821b; C397e: $this->logger = $objectManager->get("\134\120\163\162\x5c\x4c\x6f\x67\134\x4c\x6f\x67\147\x65\x72\111\x6e\164\145\162\x66\141\x63\x65"); goto D3fa8; D4328: $this->response = $objectManager->get("\134\115\141\147\x65\156\164\157\x5c\x46\162\x61\155\145\167\x6f\x72\153\134\x41\x70\x70\134\x52\145\163\x70\x6f\x6e\163\x65\x49\x6e\164\145\x72\x66\141\143\145"); goto f5405; f5405: $this->storeConfig = $objectManager->get("\x5c\115\141\147\x65\x6e\x74\x6f\134\120\x61\x67\x65\x43\x61\143\x68\x65\x5c\x4d\x6f\144\x65\x6c\134\x43\x6f\x6e\146\151\147"); goto c47a9; c47a9: $this->varnishConfig = $objectManager->get("\134\x4d\x67\164\x5c\x56\x61\162\x6e\151\x73\x68\x5c\x4d\x6f\144\145\154\x5c\x43\141\x63\150\145\x5c\103\x6f\156\x66\151\x67"); goto F1d13; E821b: $this->state = $objectManager->get("\x5c\x4d\141\x67\145\156\x74\x6f\134\106\162\x61\x6d\145\167\x6f\162\x6b\x5c\101\x70\x70\134\x53\164\x61\164\x65"); goto C397e; D3fa8: } public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result) { goto d8851; Ae73c: af441: goto Fe18e; Df184: F6f9d: goto e3e01; d8851: $isCacheable = $this->isCacheable($subject); goto B69e8; e3e01: return $result; goto Ef9ab; E201a: goto F6f9d; goto c92f9; B2cd3: $tags = []; goto aebda; E8292: $this->saveUrlInformation($tags); goto Df184; aebda: foreach ($subject->getAllBlocks() as $block) { goto Ae9eb; c3b0b: if (!($isVarnish && $isEsiBlock)) { goto Dff84; } goto f9fef; D3404: ef77a: goto b054d; d3e31: $isEsiBlock = $block->getTtl() > 0; goto D1822; C2c3e: aa6b1: goto D3404; c805f: Dff84: goto b9cec; Ae9eb: if (!$block instanceof \Magento\Framework\DataObject\IdentityInterface) { goto aa6b1; } goto d3e31; b9cec: $tags = array_merge($tags, $block->getIdentities()); goto C2c3e; f9fef: goto ef77a; goto c805f; D1822: $isVarnish = $this->storeConfig->getType() == \Magento\PageCache\Model\Config::VARNISH; goto c3b0b; b054d: } goto Ae73c; De2e3: $this->response->setHeader("\130\x2d\103\141\x63\150\x65\55\114\151\146\x65\164\151\x6d\x65", 0); goto E201a; f7aa7: $this->setResponseHeaders($tags); goto E8292; B69e8: if (true === $isCacheable) { goto F7b75; } goto D87b9; c92f9: F7b75: goto B2cd3; Fe18e: $tags = array_unique($tags); goto f7aa7; D87b9: $this->response->setNoCacheHeaders(); goto De2e3; Ef9ab: } protected function isCacheable(\Magento\Framework\View\Layout $subject) { goto A896d; A2ff6: $isAdminStore = $this->isAdminStore(); goto Bf80b; adb37: foreach ($excludedRoutes as $route) { goto b942e; D0358: f55f8: goto deb64; deb64: bbe2d: goto ac413; D4bd1: if (!(!empty($route) && strpos($fullActionName, $route) === 0)) { goto f55f8; } goto f4d7d; f4d7d: return false; goto D0358; b942e: $route = trim($route); goto D4bd1; ac413: } goto Cfbc8; E9c04: $excludedRoutes = $this->varnishConfig->getExcludedRoutes(); goto adb37; de90f: $excludedParams = $this->varnishConfig->getExcludedParams(); goto d6cb6; Edd31: B4f81: goto E7ae1; F1413: $hasLicense = $this->license->hasLicense($currentHost); goto Cc581; a95c8: $requestStringWithoutSlash = rtrim($requestString, "\x2f"); goto a01cd; Bf80b: if (!(true === $isAdminStore)) { goto c9fcd; } goto c9661; A896d: $isFullPageCacheEnabled = $this->storeConfig->isEnabled(); goto Ffbde; dfb83: return true; goto B93fb; f1638: c5d8a: goto de90f; A29e7: $excludedUrls = $this->varnishConfig->getExcludedUrls(); goto c9ede; Dc515: c9fcd: goto Cb6d2; Cfbc8: ff861: goto dfb83; da721: C3720: goto A2ff6; c9661: return false; goto Dc515; a01cd: $requestStringWithSlash = sprintf("\x25\163\57", $requestStringWithoutSlash); goto A29e7; c6da5: if (!(false === $isMgt)) { goto f393a; } goto c729e; bfd29: if (!(false === $isFullPageCacheEnabled || false === $isVarnishEnabled)) { goto C3720; } goto dbcca; C78c3: return false; goto f1638; c48af: $currentHost = isset($_SERVER["\110\x54\x54\x50\x5f\x48\x4f\x53\x54"]) ? $_SERVER["\x48\124\x54\x50\137\x48\x4f\x53\x54"] : ''; goto F1413; c9ede: foreach ($excludedUrls as $excludedUrl) { goto A8a03; A8a03: $excludedUrl = trim($excludedUrl); goto e8ed1; d5547: Dd500: goto Bddfc; Aa816: return false; goto d5547; Bddfc: Af210: goto f24c5; e8ed1: if (!($excludedUrl && true === in_array($excludedUrl, [$requestStringWithoutSlash, $requestStringWithSlash]))) { goto Dd500; } goto Aa816; f24c5: } goto Edd31; Ffbde: $isVarnishEnabled = $this->varnishConfig->isEnabled(); goto bfd29; c729e: return false; goto d67de; E7ae1: $fullActionName = $this->request->getFullActionName(); goto E9c04; Cc581: if (!(false === $hasLicense)) { goto c5d8a; } goto C78c3; D319e: $requestString = ltrim($this->request->getRequestString(), "\x2f"); goto a95c8; B717d: f3116: goto D319e; Cb6d2: $isMgt = isset($_SERVER["\115\x47\x54"]) && $_SERVER["\115\x47\x54"] == "\61" ? true : false; goto c6da5; d67de: f393a: goto c48af; dbcca: return false; goto da721; d6cb6: foreach ($excludedParams as $param) { goto d1211; Ea9e4: return false; goto ecc81; ecc81: D1f1e: goto e52bd; d1211: if (!$this->request->getParam(trim($param))) { goto D1f1e; } goto Ea9e4; e52bd: E8d09: goto Eb000; Eb000: } goto B717d; B93fb: } public function setResponseHeaders(array $tags) { goto b28cb; dca10: $this->response->setHeader("\x58\x2d\115\x61\x67\145\x6e\x74\x6f\55\124\x61\147\163", implode("\54", $tags)); goto Bba04; d11fc: $this->response->setHeader("\x58\55\x43\x61\143\x68\145\x2d\104\145\142\165\147", 1); goto a4237; a4237: $this->response->setHeader("\130\x2d\x4d\x61\147\145\156\x74\x6f\55\122\157\165\164\x65", $fullActionName); goto f517e; F283d: Aff7c: goto D4948; Bba04: $this->response->setPublicHeaders($this->cacheLifetime); goto b38b5; f45ba: $fullActionName = $this->request->getFullActionName(); goto Ada3b; f517e: fc26d: goto dca10; Dd2c0: $isDebugModeEnabled = $this->varnishConfig->isDebugModeEnabled(); goto f45ba; D4948: b17e9: goto b2315; b2315: if (!(true === $isDebugModeEnabled)) { goto fc26d; } goto d11fc; a040d: if (!($routesCacheLifetime && count($routesCacheLifetime))) { goto b17e9; } goto ca293; Ada3b: $routesCacheLifetime = $this->varnishConfig->getRoutesCacheLifetime(); goto a040d; ca293: foreach ($routesCacheLifetime as $routeConfig) { goto Ab840; f1773: $this->cacheLifetime = $routeCacheLifetime; goto Fabe9; Fabe9: goto Aff7c; goto E8911; Eb064: $routeCacheLifetime = isset($routeConfig["\x66\x69\x65\x6c\144\x32"]) ? $routeConfig["\146\x69\x65\154\x64\62"] : ''; goto dfa10; E8911: b7ba9: goto fb730; Ab840: $route = isset($routeConfig["\146\x69\145\154\x64\61"]) ? trim($routeConfig["\146\x69\x65\154\x64\61"]) : ''; goto Eb064; fb730: Be973: goto C739e; dfa10: if (!($route && $fullActionName == $route)) { goto b7ba9; } goto f1773; C739e: } goto F283d; b28cb: $this->cacheLifetime = $this->varnishConfig->getDefaultCacheLifetime(); goto Dd2c0; b38b5: $this->response->setHeader("\130\55\x43\x61\x63\x68\x65\55\114\x69\x66\145\164\151\x6d\145", $this->cacheLifetime); goto F9eda; F9eda: } protected function saveUrlInformation(array $tags) { goto D214f; e737d: a9775: goto C4f5f; D214f: $canSaveUrlInformation = $this->canSaveUrlInformation(); goto d7e52; a46b0: try { goto c72b5; ccfff: $storeId = $store->getStoreId(); goto e80c9; c72b5: $objectManager = $this->getObjectManager(); goto ea3d8; b81af: $url->setPath($path); goto Adcd0; B970e: $path = $this->request->getRequestUri(); goto Db9e7; d15e3: $store = $storeManager->getStore(); goto ccfff; acc5d: D9bdc: goto f86ee; dff9e: $url->delete(); goto b7fe3; Db9e7: if (!($storeBaseUri->getPath() != "\x2f")) { goto D9bdc; } goto D7b02; f86ee: $url = $objectManager->create("\115\x67\x74\134\126\141\162\x6e\x69\163\x68\134\x4d\157\x64\x65\154\134\125\x72\x6c"); goto C202a; A69e8: $cacheExpiredAt = $cacheExpiredAt->format("\131\x2d\x6d\x2d\144\x20\110\72\151\x3a\x73"); goto Ae5b2; ea3d8: $storeManager = $objectManager->get("\x5c\x4d\141\x67\145\156\164\x6f\134\x53\164\x6f\162\x65\134\115\157\x64\145\x6c\134\123\164\157\162\x65\x4d\141\x6e\x61\147\145\162\111\156\164\x65\x72\146\x61\x63\145"); goto d15e3; Adcd0: $url->setTags($tags); goto F8cac; F389f: $url->save(); goto ec5d5; c9520: $url->setCacheExpiredAt($cacheExpiredAt); goto F389f; Ae5b2: $url->setStoreId($storeId); goto b81af; fdadf: $cacheExpiredAt = new \DateTime("\x6e\x6f\x77", new \DateTimeZone("\125\124\x43")); goto cf280; e72c5: B7224: goto fdadf; cf280: $cacheExpiredAt->add(new \DateInterval(sprintf("\120\x54\45\x73\x53", $this->cacheLifetime))); goto A69e8; F8cac: $url->setCacheLifetime($this->cacheLifetime); goto c9520; b7fe3: $url = $objectManager->create("\x4d\147\x74\134\126\141\x72\x6e\151\163\x68\x5c\115\x6f\x64\145\154\x5c\x55\x72\154"); goto e72c5; d9810: if (!$url->getId()) { goto B7224; } goto dff9e; C202a: $url->loadByStoreIdAndPath($storeId, $path); goto d9810; e80c9: $storeBaseUri = new \Laminas\Uri\Uri($store->getBaseUrl()); goto B970e; D7b02: $path = "\57" . substr($path, strlen($storeBaseUri->getPath())); goto acc5d; ec5d5: } catch (\Exception $e) { $this->logger->critical($e); } goto e737d; d7e52: if (!(true === $canSaveUrlInformation)) { goto a9775; } goto a46b0; C4f5f: } protected function canSaveUrlInformation() { goto A2b79; cad0c: c51c8: goto f3a9a; d5713: return false; goto C2fe2; C569f: if (!(true === $isAdminStore)) { goto c51c8; } goto Fb544; a30b3: return false; goto B9e88; c0e1b: return false; goto E6371; e55fa: if (!(false === $isCacheWarmerEnabled)) { goto Ad45a; } goto c0e1b; ca21e: $requestParams = (array) $this->request->getQuery(); goto A2a16; f3a9a: $isCacheWarmerEnabled = $this->varnishConfig->isCacheWarmerEnabled(); goto e55fa; ac870: if (!(false === $cacheWarmerRouteFound)) { goto D9f45; } goto d5713; Ac322: $cacheWarmerRouteFound = false; goto Fcbcf; Fb544: return false; goto cad0c; C2fe2: D9f45: goto B9a53; Fcbcf: $fullActionName = $this->request->getFullActionName(); goto C8c52; E6371: Ad45a: goto ca21e; a292e: Cbfdb: goto ac870; B9a53: return true; goto Fc065; A2b79: $isAdminStore = $this->isAdminStore(); goto C569f; A2a16: if (!count($requestParams)) { goto E6b31; } goto a30b3; C8c52: $cacheWarmerRoutes = $this->varnishConfig->getCacheWarmerRoutes(); goto C0b01; C0b01: foreach ($cacheWarmerRoutes as $cacheWarmerRoute) { goto ad51c; Eb521: $cacheWarmerRouteFound = true; goto f72c5; c0237: C99f8: goto cfc1f; a59b6: A9520: goto c0237; f72c5: goto Cbfdb; goto a59b6; ad51c: if (!($cacheWarmerRoute == $fullActionName)) { goto A9520; } goto Eb521; cfc1f: } goto a292e; B9e88: E6b31: goto Ac322; Fc065: } protected function isAdminStore() { $isAdminStore = $this->state->getAreaCode() == self::ADMIN_AREA_CODE; return $isAdminStore; } protected function getObjectManager() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); return $objectManager; } }
<?php namespace Mgt\Varnish\Model\Plugin; class LayoutPlugin { const ADMIN_AREA_CODE = "adminhtml"; protected $request; protected $storeConfig; protected $varnishConfig; protected $response; protected $license; protected $logger; protected $cacheLifetime; protected $state; public function __construct() { $objectManager = $this->getObjectManager(); $this->request = $objectManager->get("\\Magento\\Framework\\App\\Request\\Http"); $this->response = $objectManager->get("\\Magento\\Framework\\App\\ResponseInterface"); $this->storeConfig = $objectManager->get("\\Magento\\PageCache\\Model\\Config"); $this->varnishConfig = $objectManager->get("\\Mgt\\Varnish\\Model\\Cache\\Config"); $this->license = $objectManager->get("\\Mgt\\Varnish\\Model\\License"); $this->state = $objectManager->get("\\Magento\\Framework\\App\\State"); $this->logger = $objectManager->get("\\Psr\\Log\\LoggerInterface"); } public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result) { $isCacheable = $this->isCacheable($subject); if (true === $isCacheable) { $tags = []; foreach ($subject->getAllBlocks() as $block) { if (!$block instanceof \Magento\Framework\DataObject\IdentityInterface) { goto aa6b1; } $isEsiBlock = $block->getTtl() > 0; $isVarnish = $this->storeConfig->getType() == \Magento\PageCache\Model\Config::VARNISH; if (!($isVarnish && $isEsiBlock)) { $tags = array_merge($tags, $block->getIdentities()); aa6b1: goto D3404; } D3404: } $tags = array_unique($tags); $this->setResponseHeaders($tags); $this->saveUrlInformation($tags); goto Df184; } $this->response->setNoCacheHeaders(); $this->response->setHeader("X-Cache-Lifetime", 0); Df184: return $result; } protected function isCacheable(\Magento\Framework\View\Layout $subject) { $isFullPageCacheEnabled = $this->storeConfig->isEnabled(); $isVarnishEnabled = $this->varnishConfig->isEnabled(); if (!(false === $isFullPageCacheEnabled || false === $isVarnishEnabled)) { $isAdminStore = $this->isAdminStore(); if (!(true === $isAdminStore)) { $isMgt = isset($_SERVER["MGT"]) && $_SERVER["MGT"] == "1" ? true : false; if (!(false === $isMgt)) { $currentHost = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : ''; $hasLicense = $this->license->hasLicense($currentHost); if (!(false === $hasLicense)) { $excludedParams = $this->varnishConfig->getExcludedParams(); foreach ($excludedParams as $param) { if (!$this->request->getParam(trim($param))) { } return false; } $requestString = ltrim($this->request->getRequestString(), "/"); $requestStringWithoutSlash = rtrim($requestString, "/"); $requestStringWithSlash = sprintf("%s/", $requestStringWithoutSlash); $excludedUrls = $this->varnishConfig->getExcludedUrls(); foreach ($excludedUrls as $excludedUrl) { $excludedUrl = trim($excludedUrl); if (!($excludedUrl && true === in_array($excludedUrl, [$requestStringWithoutSlash, $requestStringWithSlash]))) { } return false; } $fullActionName = $this->request->getFullActionName(); $excludedRoutes = $this->varnishConfig->getExcludedRoutes(); foreach ($excludedRoutes as $route) { $route = trim($route); if (!(!empty($route) && strpos($fullActionName, $route) === 0)) { } return false; } return true; } return false; } return false; } return false; } return false; } public function setResponseHeaders(array $tags) { $this->cacheLifetime = $this->varnishConfig->getDefaultCacheLifetime(); $isDebugModeEnabled = $this->varnishConfig->isDebugModeEnabled(); $fullActionName = $this->request->getFullActionName(); $routesCacheLifetime = $this->varnishConfig->getRoutesCacheLifetime(); if (!($routesCacheLifetime && count($routesCacheLifetime))) { goto b17e9; } foreach ($routesCacheLifetime as $routeConfig) { $route = isset($routeConfig["field1"]) ? trim($routeConfig["field1"]) : ''; $routeCacheLifetime = isset($routeConfig["field2"]) ? $routeConfig["field2"] : ''; if (!($route && $fullActionName == $route)) { } $this->cacheLifetime = $routeCacheLifetime; goto Aff7c; } Aff7c: b17e9: if (!(true === $isDebugModeEnabled)) { goto fc26d; } $this->response->setHeader("X-Cache-Debug", 1); $this->response->setHeader("X-Magento-Route", $fullActionName); fc26d: $this->response->setHeader("X-Magento-Tags", implode(",", $tags)); $this->response->setPublicHeaders($this->cacheLifetime); $this->response->setHeader("X-Cache-Lifetime", $this->cacheLifetime); } protected function saveUrlInformation(array $tags) { $canSaveUrlInformation = $this->canSaveUrlInformation(); if (!(true === $canSaveUrlInformation)) { goto a9775; } try { $objectManager = $this->getObjectManager(); $storeManager = $objectManager->get("\\Magento\\Store\\Model\\StoreManagerInterface"); $store = $storeManager->getStore(); $storeId = $store->getStoreId(); $storeBaseUri = new \Laminas\Uri\Uri($store->getBaseUrl()); $path = $this->request->getRequestUri(); if (!($storeBaseUri->getPath() != "/")) { goto D9bdc; } $path = "/" . substr($path, strlen($storeBaseUri->getPath())); D9bdc: $url = $objectManager->create("Mgt\\Varnish\\Model\\Url"); $url->loadByStoreIdAndPath($storeId, $path); if (!$url->getId()) { goto B7224; } $url->delete(); $url = $objectManager->create("Mgt\\Varnish\\Model\\Url"); B7224: $cacheExpiredAt = new \DateTime("now", new \DateTimeZone("UTC")); $cacheExpiredAt->add(new \DateInterval(sprintf("PT%sS", $this->cacheLifetime))); $cacheExpiredAt = $cacheExpiredAt->format("Y-m-d H:i:s"); $url->setStoreId($storeId); $url->setPath($path); $url->setTags($tags); $url->setCacheLifetime($this->cacheLifetime); $url->setCacheExpiredAt($cacheExpiredAt); $url->save(); } catch (\Exception $e) { $this->logger->critical($e); } a9775: } protected function canSaveUrlInformation() { $isAdminStore = $this->isAdminStore(); if (!(true === $isAdminStore)) { $isCacheWarmerEnabled = $this->varnishConfig->isCacheWarmerEnabled(); if (!(false === $isCacheWarmerEnabled)) { $requestParams = (array) $this->request->getQuery(); if (!count($requestParams)) { $cacheWarmerRouteFound = false; $fullActionName = $this->request->getFullActionName(); $cacheWarmerRoutes = $this->varnishConfig->getCacheWarmerRoutes(); foreach ($cacheWarmerRoutes as $cacheWarmerRoute) { if (!($cacheWarmerRoute == $fullActionName)) { } $cacheWarmerRouteFound = true; goto Cbfdb; } Cbfdb: if (!(false === $cacheWarmerRouteFound)) { return true; } return false; } return false; } return false; } return false; } protected function isAdminStore() { $isAdminStore = $this->state->getAreaCode() == self::ADMIN_AREA_CODE; return $isAdminStore; } protected function getObjectManager() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); return $objectManager; } }
Malware detection & removal plugin for WordPress
(C)2020 Wordpress Doctor All rights reserved.