PHP,eval加密破解

最近碰到了一點小麻煩,項目引用的一小部分核心代碼被是被人用eval加密的,於是被要求將源碼析出,防止後門問題。

看看百度上面,也沒有什麼好的解決方案,只有自己倒騰了。

eval加密,主要是將源代碼經過多層編碼,我們可以很輕鬆地將eval改成echo,看到第一層被編碼的文件,但是下一層,可能就不是那麼容易看到了。

倒騰了半天,最終自己寫了一個PHP腳本,經過自己測試,完美解決eval加密的問題,現在貢獻出來,希望能幫到需要的人,互相學習~

 <?php
class eval_decode{
    public $sourse;
    public $include = <<<EOF
    \$pos=strpos(\$this->sourse,'eval');
        if(\$pos===false){
            //沒找到
            return \$this->sourse;
       }else{
            \$str=str_ireplace('eval', '\$this->set_sourse', \$this->sourse);
            eval(\$str.\$this->include);
        }
EOF;
    function __construct($sourse){
        $this->sourse = $sourse;
    }
    function eval_decode(){
        $pos=strpos($this->sourse,'eval');
        if($pos===false){
            //沒找到
            return $this->sourse;
        }else{
            $str=str_ireplace('eval', '$this->set_sourse', $this->sourse);
            eval($str.$this->include);
        }
    }
    function  set_sourse($sourse){
        $this->sourse = $sourse;
    }
}

$core_str = '作者zhanqing,blog:http://zhangyii.blog.51cto.com/,有問題請留言';//這裏請放置你被加密的內容,注意,不要有<?php 與  ?>
$a=new eval_decode($core_str);
$a->eval_decode();
echo $a->sourse;

?>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章