解码eval(base64_decode) [英] decoding eval(base64_decode))

查看:386
本文介绍了解码eval(base64_decode)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解码此代码. 我知道可以通过将eval更改为echo来完成.但是在这种情况下,它不起作用.我在犯任何错误吗?这是我的encode_file.php代码:

I am trying to decode this code. I know it can be done by changing eval to echo. But in this case its not working. Is i am making any mistake. This is my encoded_file.php code:

我已经尝试将eval更改为echo,但是它没有工作文件. 我也尝试过这个解码器:

i have tried to change eval to echo but its not working file. I also tried this decoder:

<?php

// Open and read the content of the encoded file into a variable
$file = file_get_contents('encoded_file.php');

// Strip php tags
$file = str_replace('<?php', "", $file);
$file = str_replace('<?', "", $file);
// Make sure to get rid of short tags....
$file = str_replace('?>', "", $file);

 // Strip new lines
$file = str_replace("\n", "", $file);

// Add semi colon to get around a parsing issue.
$file = $file.';';

// Change the Eval function
$file = str_replace('eval', 'echo ', $file);

// Function to eval the new string
function deval()
{
global $file;
ob_start();
eval($file);
$contents = ob_get_contents();
ob_end_clean();
return($contents);
}  

// Run the code thru once
$file = deval();

// Counter
$cnt = 1;

// Loop it till it's decoded
while(preg_match('/^\?><\?php eval/', $file))
{
$file = str_replace('?><?php eval', 'echo', $file);
$file = str_replace('?><?', "", $file);
$file = deval();
  $cnt;
}

//clean up some tags
$file = str_replace('?><?php', "", $file);
$file = str_replace('?><?', "", $file);

echo $cnt,' iterations<br/><br/>';
echo $file;
?>

但是它也不能很好地工作.任何解决方案如何解码或解码器代码出了什么问题.

but it also not working well. Any solution how to decode it or what's wrong in my decoder code.

推荐答案

以下是解码此内容所需的步骤(注意-为了清楚起见,我已将变量/函数重命名):

Here are the steps which are needed to decode this (note - I've renamed variables/functions for clarity):

1..我们看到此脚本读取了自身的内容,因此我们可以假设-我们无法更改此文件

1. We see that this script reads content of itself, so we can assume - we cannot change this file

因此,让我们使用此内容创建新文件并更改此文件:

so lets create new file with this content and change this file:

$encoded=file('another_file.txt');

2..然后我们可以将第一个评估更改为echo,并应注释所有其他评估:

2. Then we can change first eval to echo and all other evals should be commented:

这是第一行:

echo base64_decode("aWYoIWZ1bmN0aW9uX2V4aXN0cygiWWl1bklVWTc2YkJodWhOWUlPOCIpKXtmdW5jdGlvbiBZaXVuSVVZNzZiQmh1aE5ZSU84KCRnLCRiPTApeyRhPWltcGxvZGUoIlxuIiwkZyk7JGQ9YXJyYXkoNjU1LDIzNiw0MCk7aWYoJGI9PTApICRmPXN1YnN0cigkYSwkZFswXSwkZFsxXSk7ZWxzZWlmKCRiPT0xKSAkZj1zdWJzdHIoJGEsJGRbMF0rJGRbMV0sJGRbMl0pO2Vsc2UgJGY9dHJpbShzdWJzdHIoJGEsJGRbMF0rJGRbMV0rJGRbMl0pKTtyZXR1cm4oJGYpO319");

这将给我们:

if(!function_exists("getSubString"))
{
    function getSubString($g,$b=0)
    {
        $a=implode("\n",$g);
        $d=array(655,236,40);
        if($b==0) $f=substr($a,$d[0],$d[1]);
        elseif($b==1) $f=substr($a,$d[0]+$d[1],$d[2]);
        else $f=trim(substr($a,$d[0]+$d[1]+$d[2]));
        return $f;
    }
}

3..现在,我们可以删除第一个回声/评估并转到第二个:

3. Now we can remove first echo/eval and go to 2nd one:

这是第二行:

echo base64_decode(getSubString($encoded));

给我们

if(!function_exists("decodeCode"))
{
    function decodeCode($a,$h)
    {
        if($h==sha1($a))
        {
            return(gzinflate(base64_decode($a)));
        }
        else
        {
            echo("Error: File Modified");
        }
    }
}

4..我们可以将其删除并转到上一次评估:

4. we can remove it and go to last eval:

在这里:

echo decodeCode(getSubString($encoded,2),getSubString($encoded,1));

,我们看到了最终代码:

and we see final code:

/**
* @site #####
* @copyright 2010
*/
include 'config.php';
$id=$_GET['id'];
if(isset($id))
{
    header("Content-type: image/jpeg");
    $url='http://#####/siteuploads/thumb/'.$id;
    $path=pathinfo($url);
    header('Content-Disposition: attachment; filename="'.$path['basename'].'"');
    $img=imagecreatefromjpeg($url);
    $red=imagecolorallocate($img,255,155,255);
    imagestring($img,2,1,2,$site,$red);
    echo imagejpeg($img);
}

这篇关于解码eval(base64_decode)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆