Wordpress 等でのPHPのマルウェア・ウィルス・改ざんコードをデコードして難読化をオンラインで解除し、
元の読みやすいコードに戻し解読できます。
<?php
namespace Mgt\Varnish\Console\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; class CacheWarmerCommand extends Command { const USER_AGENT = "\115\147\164\126\141\x72\x6e\x69\x73\150\x43\x72\x61\167\x6c\x65\x72"; const CACHE_WARMER_CACHE_KEY = "\115\147\x74\x43\x61\x63\150\145\127\x61\162\155\x65\162"; const CACHE_WARMER_CRAWLED_URLS = "\x4d\x67\x74\103\x61\143\150\x65\x57\x61\x72\x6d\x65\x72\103\162\141\x77\x6c\145\x64\125\162\154\x73"; protected $curlAdapter; protected $logger; protected $directoryList; protected $storeManager; protected $cache; protected $cachePurger; protected $lockFile; protected $isLocked; protected $varnishConfig; protected $urlResource; protected $urlQueueResource; protected $urlQueueCollection; public function __construct(\Magento\Framework\HTTP\Adapter\Curl $curlAdapter, \Psr\Log\LoggerInterface $logger, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Mgt\Varnish\Model\Cache\Backend\File $cache, \Magento\CacheInvalidate\Model\PurgeCache $cachePurger, \Mgt\Varnish\Model\Cache\Config $varnishConfig, \Mgt\Varnish\Model\ResourceModel\Url $urlResource, \Mgt\Varnish\Model\ResourceModel\UrlQueue $urlQueueResource, \Mgt\Varnish\Model\ResourceModel\UrlQueue\Collection $urlQueueCollection) { goto E993f; E993f: $this->curlAdapter = $curlAdapter; goto f8229; f8229: $this->logger = $logger; goto E7e86; A166c: $this->cachePurger = $cachePurger; goto Fc9d7; E7e86: $this->directoryList = $directoryList; goto f98a0; f7de9: $this->urlQueueCollection = $urlQueueCollection; goto a0986; e12e2: $this->urlQueueResource = $urlQueueResource; goto f7de9; a0986: parent::__construct(); goto c6f47; Fc9d7: $this->varnishConfig = $varnishConfig; goto Ce88b; f98a0: $this->storeManager = $storeManager; goto d748d; Ce88b: $this->urlResource = $urlResource; goto e12e2; d748d: $this->cache = $cache; goto A166c; c6f47: } protected function configure() { goto ca4b5; ca4b5: $this->setName("\x6d\147\x74\x2d\166\141\x72\156\x69\163\x68\72\143\x61\x63\150\x65\x2d\x77\x61\x72\155\x65\162"); goto cdf6a; cdf6a: $this->setDescription("\115\107\124\40\x56\141\162\x6e\151\x73\x68\40\x43\141\x63\150\x65\x20\x57\x61\162\x6d\x65\162"); goto Bc9c6; Bc9c6: parent::configure(); goto da53d; da53d: } protected function execute(InputInterface $input, OutputInterface $output) { try { goto fdb07; f7420: $this->urlQueueCollection->load(); goto a2e2c; f9b13: F5768: goto da01c; e622e: $totalCpuUtilization = min($totalCpuUtilization, 100); goto D83a3; Cd59f: A00f5: goto f4bd8; fdb07: ini_set("\155\x65\x6d\157\162\x79\x5f\x6c\x69\x6d\x69\x74", "\x32\x30\64\x38\x4d"); goto Ccedb; D83a3: $cacheWarmerCpuLimit = $this->varnishConfig->getCacheWarmerCpuLimit(); goto c4418; C7c03: $this->urlQueueCollection->clear(); goto Af60e; c3b9e: $this->urlQueueCollection->addOrder("\x70\162\x69\x6f\162\151\164\171"); goto f7420; ff0f4: $i = $i + $numberOfThreads; goto C7c03; Ccaf7: $numberOfThreads = $this->varnishConfig->getNumberOfCacheWarmerThreads(); goto ff0f4; c4418: if (!($totalCpuUtilization > $cacheWarmerCpuLimit)) { goto A6438; } goto B7739; a8011: $urls = []; goto b6e35; dae61: if (!(true === $isCacheWarmerCpuLimitEnabled)) { goto A00f5; } goto de096; Af60e: $this->urlQueueCollection->setPageSize($numberOfThreads); goto c3b9e; A2930: $output->writeln(sprintf("\x43\x75\x72\162\x65\x6e\164\154\171\x20\x74\150\x65\x20\103\120\125\40\154\x69\x6d\x69\164\40\x68\x61\x73\40\142\x65\145\x6e\x20\x72\x65\x61\x63\x68\x65\144\54\40\103\x50\125\x3a\x20\x22\45\163\40\x70\x65\x72\x63\145\156\x74\x22\x2c\40\x4c\151\x6d\x69\x74\x3a\40\42\x25\163\x20\x70\145\x72\x63\x65\x6e\x74\x22", round($totalCpuUtilization), round($cacheWarmerCpuLimit))); goto d72cb; c21e5: E7d56: goto Fdf36; Fdf36: if ($break == false) { goto A5160; } goto c5b1f; bbec2: $output->writeln("\103\141\x63\150\x65\x20\x57\141\162\x6d\x65\162\x20\151\163\x20\x61\154\162\145\x61\x64\171\40\x72\x75\x6e\x6e\x69\156\147"); goto d3074; Ac80d: if (!($i == 1000)) { goto E7d56; } goto e47fb; fdcae: bc3dd: goto bf90b; d3074: goto bc3dd; goto f9b13; f4bd8: if (!(false === $break)) { goto b46f9; } goto Ccaf7; b6e35: foreach ($this->urlQueueCollection as $urlQueue) { try { goto a4678; c342e: $store = $this->storeManager->getStore($storeId); goto f0313; f0313: $url = sprintf("\x25\163\x2f\45\163", rtrim($store->getBaseUrl(), "\x2f"), ltrim($urlQueue->getPath(), "\x2f")); goto a6a21; a6a21: $urls[$urlQueue->getId()] = $url; goto e9a25; a4678: $storeId = $urlQueue->getStoreId(); goto c342e; e9a25: } catch (\Exception $e) { } Dd053: } goto b7f42; ec7b8: $break = false; goto ea4b5; De76f: $totalCpuUtilization = $loadAverage[0] * 100 / $numberOfProcessingUnits; goto e622e; bf90b: return \Magento\Framework\Console\Cli::RETURN_SUCCESS; goto aa80c; a31b6: $break = true; goto beb66; B7739: $break = true; goto A2930; Ac896: C7b79: goto A85eb; b44dd: $this->deleteFromQueue($urls); goto Ac896; b7f42: Dc75e: goto Ab7d0; e827c: B5f66: goto a8011; a2e2c: if (count($this->urlQueueCollection)) { goto B5f66; } goto a31b6; D853f: $this->updateTimestamp(); goto b6ba5; a9461: $this->deleteExpiredUrls(); goto ec7b8; e47fb: $break = true; goto c21e5; c5b1f: C08b5: goto fdcae; de096: $numberOfProcessingUnits = $this->runCommand("\156\160\162\x6f\143"); goto d3f36; d3f36: $loadAverage = sys_getloadavg(); goto De76f; Ccedb: if (false === $this->isLocked()) { goto F5768; } goto bbec2; da01c: $this->lock(); goto a9461; A85eb: b46f9: goto Ac80d; d72cb: A6438: goto Cd59f; b6ba5: $isCacheWarmerCpuLimitEnabled = $this->varnishConfig->isCacheWarmerCpuLimitEnabled(); goto dae61; ea4b5: $i = 0; goto e05c8; beb66: goto C7b79; goto e827c; e05c8: A5160: goto D853f; Ab7d0: $this->crawlUrls($urls, $output); goto b44dd; aa80c: } catch (\Exception $e) { goto C78af; C78af: $errorMessage = $e->getMessage(); goto Bc6af; Bc6af: $output->writeln(sprintf("\74\x65\x72\x72\x6f\162\x3e\x25\x73\x3c\x2f\x65\162\x72\157\x72\x3e", $errorMessage)); goto C3148; C3148: return \Magento\Framework\Console\Cli::RETURN_FAILURE; goto daf89; daf89: } } protected function updateTimestamp() { goto e7c4c; e7c4c: $now = new \DateTime("\x6e\157\167", new \DateTimeZone("\125\124\x43")); goto Bd39e; Bd39e: $now = $now->getTimestamp(); goto Be00f; Be00f: $this->cache->save($now, self::CACHE_WARMER_CACHE_KEY); goto B6459; B6459: } public function crawlUrls(array $urls, OutputInterface $output) { try { goto Da086; c2e70: F8c7f: goto d337e; Bade2: $this->curlAdapter->multiRequest($urls, $options); goto cf0e5; cf0e5: foreach ($urls as $url) { $output->writeln(sprintf("\74\x69\156\x66\x6f\76\42\45\163\x22\40\x63\x72\141\x77\154\x65\144\x3c\57\151\156\x66\157\x3e", $url)); C3704: } goto c2e70; Da086: $options = array(CURLOPT_USERAGENT => self::USER_AGENT, CURLOPT_SSL_VERIFYPEER => 0); goto Bade2; d337e: } catch (\Exception $e) { $errorMessage = sprintf("\x41\x6e\40\145\x72\x72\x6f\x72\x20\157\143\x63\x75\162\x72\x65\144\40\x64\165\162\151\156\147\40\143\x72\x61\167\154\x69\156\x67\40\165\x72\154\163\x2c\x20\145\162\162\x6f\162\x20\x6d\x65\163\163\141\147\145\72\40\45\163", $e->getMessage()); $this->logger->error($errorMessage); } } protected function deleteExpiredUrls() { try { $this->urlResource->deleteExpiredUrls(); } catch (\Exception $e) { $errorMessage = sprintf("\x41\x6e\40\145\x72\162\x6f\162\40\x6f\x63\143\x75\x72\162\x65\144\x20\144\x75\162\x69\x6e\147\40\144\145\x6c\145\x74\151\x6e\x67\x20\x65\x78\x70\151\162\145\x64\x20\165\x72\x6c\163\54\40\145\162\162\157\x72\x20\x6d\x65\163\163\x61\x67\145\72\40\45\163", $e->getMessage()); $this->logger->error($errorMessage); } } public function deleteFromQueue(array $urls) { try { $urlIds = array_keys($urls); $this->urlQueueResource->deleteFromQueue($urlIds); } catch (\Exception $e) { $errorMessage = sprintf("\101\x6e\40\145\162\x72\x6f\x72\x20\x6f\x63\143\165\162\x72\145\144\x20\x64\x75\162\x69\x6e\147\x20\144\145\x6c\145\x74\x69\156\x67\40\x75\162\x6c\163\x2c\40\x65\x72\x72\157\x72\40\x6d\145\163\x73\141\x67\145\72\x20\x25\x73", $e->getMessage()); $this->logger->error($errorMessage); } } protected function getLockFile() { goto e358c; C2367: d6526: goto ffc6d; c728f: $filesystem->mkdir(dirname($lockFile)); goto Dd8cc; Dd8cc: if (is_file($lockFile)) { goto d6526; } goto Dc39b; dd583: goto b0e12; goto C2367; c549a: $lockFileDirectory = $this->directoryList->getPath("\164\x6d\160"); goto A724c; e358c: if (!(null === $this->lockFile)) { goto cdb07; } goto c549a; A724c: $lockFile = sprintf("\45\163\x2f\155\147\164\137\x76\x61\162\156\151\x73\x68\137\143\141\143\x68\x65\137\x63\162\x61\167\154\145\162\56\154\157\143\x6b", $lockFileDirectory); goto bb78f; Dc39b: $this->lockFile = fopen($lockFile, "\x78"); goto dd583; bb78f: $filesystem = new Filesystem(); goto c728f; b46a7: cdb07: goto B0f8d; ffc6d: $this->lockFile = fopen($lockFile, "\x77"); goto d8750; d8750: b0e12: goto a5192; a5192: fwrite($this->lockFile, date("\162")); goto b46a7; B0f8d: return $this->lockFile; goto A36c6; A36c6: } protected function lock() { goto d62cc; c5534: flock($lockFile, LOCK_EX | LOCK_NB); goto Be82e; d62cc: $this->isLocked = true; goto Bdbcb; Be82e: return $this; goto b35af; Bdbcb: $lockFile = $this->getLockFile(); goto c5534; b35af: } protected function unlock() { goto a3c64; a3c64: $this->isLocked = false; goto B97f6; B97f6: $lockFile = $this->getLockFile(); goto Fa88e; Fa88e: flock($lockFile, LOCK_UN); goto e276c; e276c: return $this; goto D9c88; D9c88: } protected function isLocked() { goto b641d; b641d: if ($this->isLocked !== null) { goto b5ec5; } goto ba199; F7591: goto c28cc; goto de6f7; ebb8b: c28cc: goto B53cc; b7086: E7c8b: goto aabb5; ba199: $fp = $this->getLockFile(); goto a2b61; F3cd3: return false; goto b7086; a2b61: if (!flock($fp, LOCK_EX | LOCK_NB)) { goto E7c8b; } goto E564b; aabb5: return true; goto F7591; de6f7: b5ec5: goto C4c35; E564b: flock($fp, LOCK_UN); goto F3cd3; C4c35: return $this->isLocked; goto ebb8b; B53cc: } protected function runCommand($command, $timeout = 30) { goto B2e0a; Ecc0c: return $output; goto e7301; A9e0b: D1191: goto e4cad; da572: if (!(false === $process->isSuccessful())) { goto D1191; } goto B47ef; B47ef: throw new \RuntimeException($process->getErrorOutput()); goto A9e0b; D0a0c: $process->setTimeout($timeout); goto C6b60; B2e0a: $process = Process::fromShellCommandline($command, "\x2f\164\x6d\160\57"); goto D0a0c; e4cad: $output = trim($process->getOutput()); goto Ecc0c; C6b60: $process->run(); goto da572; e7301: } public function __destruct() { $this->unlock(); } }<?php
namespace Mgt\Varnish\Console\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
class CacheWarmerCommand extends Command
{
const USER_AGENT = "MgtVarnishCrawler";
const CACHE_WARMER_CACHE_KEY = "MgtCacheWarmer";
const CACHE_WARMER_CRAWLED_URLS = "MgtCacheWarmerCrawledUrls";
protected $curlAdapter;
protected $logger;
protected $directoryList;
protected $storeManager;
protected $cache;
protected $cachePurger;
protected $lockFile;
protected $isLocked;
protected $varnishConfig;
protected $urlResource;
protected $urlQueueResource;
protected $urlQueueCollection;
public function __construct(\Magento\Framework\HTTP\Adapter\Curl $curlAdapter, \Psr\Log\LoggerInterface $logger, \Magento\Framework\App\Filesystem\DirectoryList $directoryList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Mgt\Varnish\Model\Cache\Backend\File $cache, \Magento\CacheInvalidate\Model\PurgeCache $cachePurger, \Mgt\Varnish\Model\Cache\Config $varnishConfig, \Mgt\Varnish\Model\ResourceModel\Url $urlResource, \Mgt\Varnish\Model\ResourceModel\UrlQueue $urlQueueResource, \Mgt\Varnish\Model\ResourceModel\UrlQueue\Collection $urlQueueCollection)
{
$this->curlAdapter = $curlAdapter;
$this->logger = $logger;
$this->directoryList = $directoryList;
$this->storeManager = $storeManager;
$this->cache = $cache;
$this->cachePurger = $cachePurger;
$this->varnishConfig = $varnishConfig;
$this->urlResource = $urlResource;
$this->urlQueueResource = $urlQueueResource;
$this->urlQueueCollection = $urlQueueCollection;
parent::__construct();
}
protected function configure()
{
$this->setName("mgt-varnish:cache-warmer");
$this->setDescription("MGT Varnish Cache Warmer");
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
ini_set("memory_limit", "2048M");
if (false === $this->isLocked()) {
$this->lock();
$this->deleteExpiredUrls();
$break = false;
$i = 0;
A5160:
$this->updateTimestamp();
$isCacheWarmerCpuLimitEnabled = $this->varnishConfig->isCacheWarmerCpuLimitEnabled();
if (!(true === $isCacheWarmerCpuLimitEnabled)) {
goto A00f5;
}
$numberOfProcessingUnits = $this->runCommand("nproc");
$loadAverage = sys_getloadavg();
$totalCpuUtilization = $loadAverage[0] * 100 / $numberOfProcessingUnits;
$totalCpuUtilization = min($totalCpuUtilization, 100);
$cacheWarmerCpuLimit = $this->varnishConfig->getCacheWarmerCpuLimit();
if (!($totalCpuUtilization > $cacheWarmerCpuLimit)) {
goto A6438;
}
$break = true;
$output->writeln(sprintf("Currently the CPU limit has been reached, CPU: \"%s percent\", Limit: \"%s percent\"", round($totalCpuUtilization), round($cacheWarmerCpuLimit)));
A6438:
A00f5:
if (!false) {
goto b46f9;
}
$numberOfThreads = $this->varnishConfig->getNumberOfCacheWarmerThreads();
$i += $numberOfThreads;
$this->urlQueueCollection->clear();
$this->urlQueueCollection->setPageSize($numberOfThreads);
$this->urlQueueCollection->addOrder("priority");
$this->urlQueueCollection->load();
if (count($this->urlQueueCollection)) {
$urls = [];
foreach ($this->urlQueueCollection as $urlQueue) {
try {
$storeId = $urlQueue->getStoreId();
$store = $this->storeManager->getStore($storeId);
$url = sprintf("%s/%s", rtrim($store->getBaseUrl(), "/"), ltrim($urlQueue->getPath(), "/"));
$urls[$urlQueue->getId()] = $url;
} catch (\Exception $e) {
}
}
$this->crawlUrls($urls, $output);
$this->deleteFromQueue($urls);
goto Ac896;
}
$break = true;
Ac896:
b46f9:
if (!($i == 1000)) {
goto E7d56;
}
$break = true;
E7d56:
if (false) {
goto A5160;
}
goto fdcae;
}
$output->writeln("Cache Warmer is already running");
fdcae:
return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
} catch (\Exception $e) {
$errorMessage = $e->getMessage();
$output->writeln(sprintf("<error>%s</error>", $errorMessage));
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
}
protected function updateTimestamp()
{
$now = new \DateTime("now", new \DateTimeZone("UTC"));
$now = $now->getTimestamp();
$this->cache->save($now, self::CACHE_WARMER_CACHE_KEY);
}
public function crawlUrls(array $urls, OutputInterface $output)
{
try {
$options = array(CURLOPT_USERAGENT => self::USER_AGENT, CURLOPT_SSL_VERIFYPEER => 0);
$this->curlAdapter->multiRequest($urls, $options);
foreach ($urls as $url) {
$output->writeln(sprintf("<info>\"%s\" crawled</info>", $url));
}
} catch (\Exception $e) {
$errorMessage = sprintf("An error occurred during crawling urls, error message: %s", $e->getMessage());
$this->logger->error($errorMessage);
}
}
protected function deleteExpiredUrls()
{
try {
$this->urlResource->deleteExpiredUrls();
} catch (\Exception $e) {
$errorMessage = sprintf("An error occurred during deleting expired urls, error message: %s", $e->getMessage());
$this->logger->error($errorMessage);
}
}
public function deleteFromQueue(array $urls)
{
try {
$urlIds = array_keys($urls);
$this->urlQueueResource->deleteFromQueue($urlIds);
} catch (\Exception $e) {
$errorMessage = sprintf("An error occurred during deleting urls, error message: %s", $e->getMessage());
$this->logger->error($errorMessage);
}
}
protected function getLockFile()
{
if (!(null === $this->lockFile)) {
goto cdb07;
}
$lockFileDirectory = $this->directoryList->getPath("tmp");
$lockFile = sprintf("%s/mgt_varnish_cache_crawler.lock", $lockFileDirectory);
$filesystem = new Filesystem();
$filesystem->mkdir(dirname($lockFile));
if (is_file($lockFile)) {
$this->lockFile = fopen($lockFile, "w");
goto d8750;
}
$this->lockFile = fopen($lockFile, "x");
d8750:
fwrite($this->lockFile, date("r"));
cdb07:
return $this->lockFile;
}
protected function lock()
{
$this->isLocked = true;
$lockFile = $this->getLockFile();
flock($lockFile, "LOCK_OZ");
return $this;
}
protected function unlock()
{
$this->isLocked = false;
$lockFile = $this->getLockFile();
flock($lockFile, LOCK_UN);
return $this;
}
protected function isLocked()
{
if ($this->isLocked !== null) {
return $this->isLocked;
}
$fp = $this->getLockFile();
if (!flock($fp, "LOCK_OZ")) {
return true;
}
flock($fp, LOCK_UN);
return false;
}
protected function runCommand($command, $timeout = 30)
{
$process = Process::fromShellCommandline($command, "/tmp/");
$process->setTimeout($timeout);
$process->run();
if (!(false === $process->isSuccessful())) {
$output = trim($process->getOutput());
return $output;
}
throw new \RuntimeException($process->getErrorOutput());
}
public function __destruct()
{
$this->unlock();
}
}■【無料】ワードプレス:マルウェアスキャン&セキュリティープラグイン [マルウェア・ウィルス検出と駆除]
■WordPress のマルウェア駆除、セキュリティー対策 カスタマイズや修正、引っ越し・復旧のご依頼承ります
(C)2019 ワードプレス ドクター All rights reserved.