Japanese English

PHP deobfuscation, decryption, reconstruction tool

De-obfuscate PHP malware/viruses and tampering code on Wordpress to original readable code.

*Please note that not all obfuscation codes can be decoded.

Decoded the code below.

<?php namespace Mgt\Varnish\Model\Plugin; class LayoutPlugin { const ADMIN_AREA_CODE = "\x61\x64\x6d\151\156\150\x74\x6d\154"; protected $request; protected $storeConfig; protected $varnishConfig; protected $response; protected $license; protected $logger; protected $cacheLifetime; protected $sta...



Obfuscated php code

<?php
 namespace Mgt\Varnish\Model\Plugin; class LayoutPlugin { const ADMIN_AREA_CODE = "\x61\x64\x6d\151\156\150\x74\x6d\154"; protected $request; protected $storeConfig; protected $varnishConfig; protected $response; protected $license; protected $logger; protected $cacheLifetime; protected $state; public function __construct() { goto Bf583; F6d47: $this->storeConfig = $objectManager->get("\134\x4d\x61\x67\x65\x6e\164\157\134\x50\141\x67\x65\x43\x61\x63\x68\x65\134\115\157\x64\145\154\134\103\157\156\146\151\x67"); goto b90af; A5d26: $this->logger = $objectManager->get("\134\120\x73\162\134\114\x6f\x67\134\x4c\x6f\x67\x67\145\162\x49\156\x74\145\x72\146\141\x63\x65"); goto a6a04; b90af: $this->varnishConfig = $objectManager->get("\134\115\x67\x74\x5c\126\x61\162\x6e\151\x73\150\x5c\x4d\x6f\144\x65\x6c\134\103\141\143\150\x65\134\103\157\x6e\146\151\147"); goto A7c99; e3eb7: $this->state = $objectManager->get("\134\115\x61\147\145\156\x74\157\134\106\162\141\155\145\167\x6f\162\x6b\x5c\101\x70\160\134\x53\164\141\164\145"); goto A5d26; Bf583: $objectManager = $this->getObjectManager(); goto A11aa; A7c99: $this->license = $objectManager->get("\x5c\115\x67\x74\x5c\126\x61\162\x6e\x69\163\150\134\115\157\144\x65\x6c\x5c\114\x69\x63\x65\x6e\x73\145"); goto e3eb7; A11aa: $this->request = $objectManager->get("\x5c\x4d\x61\147\x65\x6e\x74\x6f\x5c\106\162\141\x6d\x65\167\157\162\153\x5c\x41\x70\160\134\x52\x65\161\x75\145\x73\164\x5c\x48\x74\164\x70"); goto Cc30d; Cc30d: $this->response = $objectManager->get("\x5c\115\x61\147\x65\x6e\x74\157\x5c\x46\x72\x61\155\145\167\x6f\x72\x6b\134\x41\160\x70\x5c\122\x65\x73\x70\x6f\156\163\x65\111\x6e\x74\145\x72\146\141\x63\x65"); goto F6d47; a6a04: } public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result) { goto c8fe0; Efd3b: return $result; goto E7dec; d52d2: a7491: goto Af342; Ecbae: $this->response->setHeader("\x58\x2d\103\x61\143\x68\145\55\114\x69\146\x65\164\x69\x6d\x65", 0); goto f2724; deb1f: bfbed: goto Efd3b; b060e: $this->response->setNoCacheHeaders(); goto Ecbae; abb10: if (true === $isCacheable) { goto a7491; } goto b060e; c319e: E6c73: goto A0a19; Af342: $tags = []; goto e3512; bbbaf: $this->saveUrlInformation($tags); goto deb1f; b605b: $this->setResponseHeaders($tags); goto bbbaf; e3512: foreach ($subject->getAllBlocks() as $block) { goto B853e; ceb6c: c6a56: goto Aa82b; D0810: F0e3e: goto Be10c; ff81b: if (!($isVarnish && $isEsiBlock)) { goto F0e3e; } goto F41ab; Cac14: $isEsiBlock = $block->getTtl() > 0; goto Ed219; Ed219: $isVarnish = $this->storeConfig->getType() == \Magento\PageCache\Model\Config::VARNISH; goto ff81b; B853e: if (!$block instanceof \Magento\Framework\DataObject\IdentityInterface) { goto c6a56; } goto Cac14; Aa82b: C9dcd: goto e1948; F41ab: goto C9dcd; goto D0810; Be10c: $tags = array_merge($tags, $block->getIdentities()); goto ceb6c; e1948: } goto c319e; f2724: goto bfbed; goto d52d2; A0a19: $tags = array_unique($tags); goto b605b; c8fe0: $isCacheable = $this->isCacheable($subject); goto abb10; E7dec: } protected function isCacheable(\Magento\Framework\View\Layout $subject) { goto f674c; fd52a: c261f: goto cbe0e; d9074: $requestString = ltrim($this->request->getRequestString(), "\57"); goto cac43; cac43: $requestStringWithoutSlash = rtrim($requestString, "\x2f"); goto Fa27c; e73f3: $isMgt = isset($_SERVER["\x4d\107\124"]) && $_SERVER["\115\x47\x54"] == "\x31" ? true : false; goto C74cb; ea887: $isVarnishEnabled = $this->varnishConfig->isEnabled(); goto fa290; f674c: $isFullPageCacheEnabled = $this->storeConfig->isEnabled(); goto ea887; E3377: foreach ($excludedParams as $param) { goto a390b; b6d42: bfb6c: goto cd400; cd400: E5508: goto C43fc; f216e: return false; goto b6d42; a390b: if (!$this->request->getParam(trim($param))) { goto bfb6c; } goto f216e; C43fc: } goto A630b; A86cf: D6324: goto d6728; E95f7: return false; goto fd52a; d6728: $isAdminStore = $this->isAdminStore(); goto A354f; A630b: Df3f6: goto d9074; db41f: $excludedParams = $this->varnishConfig->getExcludedParams(); goto E3377; A2920: a3ebc: goto b0756; Dcdf6: $excludedUrls = $this->varnishConfig->getExcludedUrls(); goto cd6ac; C74cb: if (!(false === $isMgt)) { goto c261f; } goto E95f7; A354f: if (!(true === $isAdminStore)) { goto d0f11; } goto E5c98; b0756: $fullActionName = $this->request->getFullActionName(); goto A9e69; d43af: d0f11: goto e73f3; F6349: return false; goto A86cf; E5c98: return false; goto d43af; E757e: $hasLicense = $this->license->hasLicense($currentHost); goto Dcd38; Dcd38: if (!(false === $hasLicense)) { goto E0dc2; } goto b592d; fa290: if (!(false === $isFullPageCacheEnabled || false === $isVarnishEnabled)) { goto D6324; } goto F6349; Fa27c: $requestStringWithSlash = sprintf("\x25\163\57", $requestStringWithoutSlash); goto Dcdf6; cbe0e: $currentHost = isset($_SERVER["\x48\x54\124\120\137\x48\117\123\124"]) ? $_SERVER["\110\x54\x54\120\137\x48\x4f\x53\124"] : ''; goto E757e; B6082: return true; goto e4142; bc00b: foreach ($excludedRoutes as $route) { goto Afedc; d18c9: f0087: goto a3978; A91a6: if (!(!empty($route) && strpos($fullActionName, $route) === 0)) { goto f0087; } goto E96d1; a3978: A54af: goto Ffba5; E96d1: return false; goto d18c9; Afedc: $route = trim($route); goto A91a6; Ffba5: } goto E6f57; E6f57: Cb4cd: goto B6082; Aead1: E0dc2: goto db41f; cd6ac: foreach ($excludedUrls as $excludedUrl) { goto a7f06; a8ed7: if (!($excludedUrl && true === in_array($excludedUrl, [$requestStringWithoutSlash, $requestStringWithSlash]))) { goto a46d3; } goto fbb85; ee496: dbb0c: goto D84c4; fbb85: return false; goto F19e2; a7f06: $excludedUrl = trim($excludedUrl); goto a8ed7; F19e2: a46d3: goto ee496; D84c4: } goto A2920; b592d: return false; goto Aead1; A9e69: $excludedRoutes = $this->varnishConfig->getExcludedRoutes(); goto bc00b; e4142: } public function setResponseHeaders(array $tags) { goto Efc66; F441f: $this->response->setHeader("\x58\55\x43\x61\x63\x68\x65\x2d\114\x69\146\x65\164\x69\155\145", $this->cacheLifetime); goto F933f; fcd71: $fullActionName = $this->request->getFullActionName(); goto bc2d5; F4a52: $this->response->setHeader("\x58\x2d\115\141\x67\x65\x6e\x74\157\x2d\122\x6f\165\164\145", $fullActionName); goto E1bfb; add0a: foreach ($routesCacheLifetime as $routeConfig) { goto E083b; f3124: D11ea: goto Cac70; cc457: goto Ef622; goto f3124; E083b: $route = isset($routeConfig["\146\x69\145\154\144\61"]) ? trim($routeConfig["\146\x69\x65\x6c\144\x31"]) : ''; goto a7212; cf350: if (!($route && $fullActionName == $route)) { goto D11ea; } goto e8c7e; e8c7e: $this->cacheLifetime = $routeCacheLifetime; goto cc457; Cac70: e34ed: goto A5849; a7212: $routeCacheLifetime = isset($routeConfig["\x66\x69\145\x6c\x64\x32"]) ? $routeConfig["\x66\x69\145\154\x64\x32"] : ''; goto cf350; A5849: } goto d6cef; A1e36: if (!($routesCacheLifetime && count($routesCacheLifetime))) { goto b0013; } goto add0a; d6cef: Ef622: goto c3d02; E1bfb: A76f8: goto ea92f; d934c: $this->response->setHeader("\130\x2d\103\141\143\x68\x65\x2d\104\x65\x62\x75\147", 1); goto F4a52; bc2d5: $routesCacheLifetime = $this->varnishConfig->getRoutesCacheLifetime(); goto A1e36; Ab60e: $this->response->setPublicHeaders($this->cacheLifetime); goto F441f; Fe607: if (!(true === $isDebugModeEnabled)) { goto A76f8; } goto d934c; ea92f: $this->response->setHeader("\130\55\x4d\x61\147\145\x6e\164\x6f\55\124\x61\147\x73", implode("\x2c", $tags)); goto Ab60e; eafd9: $isDebugModeEnabled = $this->varnishConfig->isDebugModeEnabled(); goto fcd71; Efc66: $this->cacheLifetime = $this->varnishConfig->getDefaultCacheLifetime(); goto eafd9; c3d02: b0013: goto Fe607; F933f: } protected function saveUrlInformation(array $tags) { goto A8424; Ab7fa: try { goto c4b7d; b9e19: Cb822: goto a0d4c; B821c: $url->setStoreId($storeId); goto baf8e; C33e1: $path = $this->request->getRequestUri(); goto Cbda8; baf8e: $url->setPath($path); goto bfb89; E288d: $path = "\57" . substr($path, strlen($storeBaseUri->getPath())); goto b9e19; Bda0f: if (!$url->getId()) { goto C7d17; } goto f8a47; c4b7d: $objectManager = $this->getObjectManager(); goto f2571; f2571: $storeManager = $objectManager->get("\134\x4d\x61\x67\145\x6e\x74\157\134\x53\164\x6f\x72\145\x5c\115\x6f\x64\x65\154\134\x53\164\x6f\x72\145\x4d\141\156\141\x67\145\x72\x49\156\x74\x65\162\146\x61\x63\145"); goto D9db9; bdd71: $storeId = $store->getStoreId(); goto dc909; b5565: $url->setCacheLifetime($this->cacheLifetime); goto B9d93; Cbda8: if (!($storeBaseUri->getPath() != "\57")) { goto Cb822; } goto E288d; bb088: $cacheExpiredAt->add(new \DateInterval(sprintf("\x50\x54\x25\x73\123", $this->cacheLifetime))); goto A5f41; bcd43: $cacheExpiredAt = new \DateTime("\156\157\167", new \DateTimeZone("\x55\124\103")); goto bb088; f8a47: $url->delete(); goto F48e1; B9d93: $url->setCacheExpiredAt($cacheExpiredAt); goto Eb523; dc909: $storeBaseUri = new \Zend\Uri\Uri($store->getBaseUrl()); goto C33e1; F48e1: $url = $objectManager->create("\x4d\147\x74\134\x56\141\x72\x6e\151\163\x68\x5c\x4d\x6f\144\145\154\134\x55\162\x6c"); goto E7129; adfd6: $url->loadByStoreIdAndPath($storeId, $path); goto Bda0f; E7129: C7d17: goto bcd43; Eb523: $url->save(); goto a70f8; D9db9: $store = $storeManager->getStore(); goto bdd71; a0d4c: $url = $objectManager->create("\x4d\x67\164\x5c\126\x61\x72\156\x69\163\150\x5c\115\x6f\144\145\154\x5c\x55\162\154"); goto adfd6; bfb89: $url->setTags($tags); goto b5565; A5f41: $cacheExpiredAt = $cacheExpiredAt->format("\x59\55\155\x2d\144\40\110\72\151\x3a\x73"); goto B821c; a70f8: } catch (\Exception $e) { $this->logger->critical($e); } goto d456f; B0363: if (!(true === $canSaveUrlInformation)) { goto c4b98; } goto Ab7fa; A8424: $canSaveUrlInformation = $this->canSaveUrlInformation(); goto B0363; d456f: c4b98: goto e03c2; e03c2: } protected function canSaveUrlInformation() { goto Ea507; af981: return false; goto Adb8d; b6e7c: afb22: goto Fb630; A028a: if (!count($requestParams)) { goto D9252; } goto Da5d7; cedcb: if (!(false === $isCacheWarmerEnabled)) { goto D3ab2; } goto d25fa; F4c11: D3ab2: goto cb3ac; Ee081: if (!(true === $isAdminStore)) { goto e2358; } goto af981; Fb630: if (!(false === $cacheWarmerRouteFound)) { goto f3f87; } goto f4b90; D8caf: $isCacheWarmerEnabled = $this->varnishConfig->isCacheWarmerEnabled(); goto cedcb; cb3ac: $requestParams = (array) $this->request->getQuery(); goto A028a; d25fa: return false; goto F4c11; ba3a8: return true; goto A06d1; De5f8: D9252: goto Ffaff; F826c: $cacheWarmerRoutes = $this->varnishConfig->getCacheWarmerRoutes(); goto B83eb; Da5d7: return false; goto De5f8; Adb8d: e2358: goto D8caf; B83eb: foreach ($cacheWarmerRoutes as $cacheWarmerRoute) { goto b4f7e; c02c3: $cacheWarmerRouteFound = true; goto e49c4; D52ba: B8b1f: goto feaff; b4f7e: if (!($cacheWarmerRoute == $fullActionName)) { goto B8b1f; } goto c02c3; feaff: fabf2: goto E3871; e49c4: goto afb22; goto D52ba; E3871: } goto b6e7c; ae5c7: $fullActionName = $this->request->getFullActionName(); goto F826c; f4b90: return false; goto E9f2d; Ea507: $isAdminStore = $this->isAdminStore(); goto Ee081; Ffaff: $cacheWarmerRouteFound = false; goto ae5c7; E9f2d: f3f87: goto ba3a8; A06d1: } protected function isAdminStore() { $isAdminStore = $this->state->getAreaCode() == self::ADMIN_AREA_CODE; return $isAdminStore; } protected function getObjectManager() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); return $objectManager; } }

Decoded(de-Obfuscated) php code

<?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 c6a56;
                }
                $isEsiBlock = $block->getTtl() > 0;
                $isVarnish = $this->storeConfig->getType() == \Magento\PageCache\Model\Config::VARNISH;
                if (!($isVarnish && $isEsiBlock)) {
                    $tags = array_merge($tags, $block->getIdentities());
                    c6a56:
                    goto Aa82b;
                }
                Aa82b:
            }
            $tags = array_unique($tags);
            $this->setResponseHeaders($tags);
            $this->saveUrlInformation($tags);
            goto deb1f;
        }
        $this->response->setNoCacheHeaders();
        $this->response->setHeader("X-Cache-Lifetime", 0);
        deb1f:
        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 b0013;
        }
        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 Ef622;
        }
        Ef622:
        b0013:
        if (!(true === $isDebugModeEnabled)) {
            goto A76f8;
        }
        $this->response->setHeader("X-Cache-Debug", 1);
        $this->response->setHeader("X-Magento-Route", $fullActionName);
        A76f8:
        $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 c4b98;
        }
        try {
            $objectManager = $this->getObjectManager();
            $storeManager = $objectManager->get("\\Magento\\Store\\Model\\StoreManagerInterface");
            $store = $storeManager->getStore();
            $storeId = $store->getStoreId();
            $storeBaseUri = new \Zend\Uri\Uri($store->getBaseUrl());
            $path = $this->request->getRequestUri();
            if (!($storeBaseUri->getPath() != "/")) {
                goto Cb822;
            }
            $path = "/" . substr($path, strlen($storeBaseUri->getPath()));
            Cb822:
            $url = $objectManager->create("Mgt\\Varnish\\Model\\Url");
            $url->loadByStoreIdAndPath($storeId, $path);
            if (!$url->getId()) {
                goto C7d17;
            }
            $url->delete();
            $url = $objectManager->create("Mgt\\Varnish\\Model\\Url");
            C7d17:
            $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);
        }
        c4b98:
    }
    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 afb22;
                    }
                    afb22:
                    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.