首頁 >後端開發 >PHP7 >來咯,你想要的goto解密腳本它真的來咯!

來咯,你想要的goto解密腳本它真的來咯!

醉折花枝作酒筹
醉折花枝作酒筹轉載
2021-07-27 09:22:257803瀏覽

GOTO解密脚本,破解微擎模块必备的解密工具,玩微擎的都知道,基本上微擎大部分都是goto加密的,看到好的模块,想要去学习他的代码,加密是万万不行的,所以用这个脚本就能无限解密模块加密文件,你想怎么学习就怎么学习。

來咯,你想要的goto解密腳本它真的來咯!

因站长有phpgoto解密并且做一些二开,找了5-6小时后,在某站花168元在买的,亲测后两个字“完美”。

其它很多php源码会进行goto加密,比如很多微擎应用。对于已加密的应用很多人是不敢直接使用的,因为不知道里面有些什么内容。 今天,分享源码网为您整理分享一套goto解密的源码 直接上传服务器就可以使用的。PHP7及以上。

将要解密的代码上传到decodeFile文件夹,然后访问index.php文件即可

解压出来的文件在complete文件。 当然如果你有能力二开的话可以将这套封装成付费解压的小工具。这套我自己现在也在用。

代码如下:

<?php

namespace app\acquiring\controller;

use PhpParser\Error;
use PhpParser\NodeDumper;
use PhpParser\ParserFactory;
use PhpParser\NodeTraverser;
use PhpParser\PrettyPrinter;
use PhpParser\NodeVisitor;
use PhpParser\Node;
use PhpParser\Node\Stmt\Function_;
use PhpParser\NodeVisitorAbstract;


foreach ([__DIR__ . &#39;/vendor/autoload.php&#39;, __DIR__ . &#39;/vendor/nikic/php-parser/vendor/autoload.php&#39;] as $file) {
    if (file_exists($file)) {
        require $file;
        break;
    }
}
date_default_timezone_set(&#39;PRC&#39;);
    $decodeObj = new Decode();
    $decodeObj->batchDecode();

//  $decodePath = __DIR__.&#39;\\&#39;.&#39;decodeFile&#39;;

class Decode
{
    //注意windos下和linux下路线格式不同
    public $decodePath = __DIR__ .DIRECTORY_SEPARATOR. &#39;decodeFile&#39;;
    public $completePath = __DIR__ . DIRECTORY_SEPARATOR . &#39;complete&#39;.DIRECTORY_SEPARATOR;
    public $replaceTipStr = "change_code_";
    public $replaceTip = "<?php change_code_;";
    public $replaceTipAst;
    public $allTable = "";
    public $tempObject = null;
    public $parserObj;
    public $printCount = 0;
    public $printCount1 = 0;
    public $printCount2 = 0;
    public $functionType = 1;
    public $foreachType = 2;
    public $switchType = 3;
    public $classType = 4;
    public $allFindLabel = "";
    public $allFindLabelStr = "";
    public $existValue = "1";
    public $notLabelNum = 0;

    /** 遍历解密文件*/
    public function batchDecode()
    {
        echo "解密后的文件存放路径:".$this->completePath;
        echo "<br>";
        echo "获取需要解密的文件";
        echo "<br>";
        $file_list = $this->get_file_list($this->decodePath);
        echo "获取文件数:".count($file_list);
        echo "<br>";
        foreach ($file_list as $fileName) {
            $this->startDecode($fileName);
        }
    }

    public function get_file_list($file_path)
    {
        if (empty($file_path)) {
            echo "未设置路径";
            return false;
        }
        $file_list = [];
//        $file_path = resource_path($path);
        if (is_dir($file_path)) {
            $handler = opendir($file_path);
            while (($filename = readdir($handler)) !== false) {
                if ($filename != "." && $filename != "..") {
                    $file_list[] = $filename;
                }
            }
            closedir($handler);
            return $file_list;
        } else {
            echo "文件目录不存在";
            echo "<br>";
            return array();
        }
    }


    //开始解密
    public function startDecode($fileName)
    {
        if (empty($fileName)) {
            echo "未选择解密文件";
            return false;
        }
        $code = file_get_contents($this->decodePath . &#39;/&#39; . $fileName);

        $parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
        $this->parserObj = $parser;
        $traverser = new NodeTraverser();
        $prettyPrinter = new PrettyPrinter\Standard;

        // echo "<style>body{ background-color:#0C0C0C; color:green} font{  color: green;} </style>";
        $dumper = new NodeDumper;
        try {
            $ast = $parser->parse($code);
            $satrt_ast = $traverser->traverse($ast);
            if(count($satrt_ast) >0 && get_class($satrt_ast[0]) == "PhpParser\Node\Stmt\Namespace_"){
                $emptyStmts =  array();
                $stmtsArray = $satrt_ast[0] ->stmts;
                $satrt_ast[0] ->stmts = $emptyStmts;
                $satrt_ast = array_merge($satrt_ast,$stmtsArray);
            }
            // halt($ast);
//          $test_me = $prettyPrinter->prettyPrint($ast);

            // $dumper = new NodeDumper;
            // echo "<pre class="brush:php;toolbar:false">";
            // echo $dumper->dump($ast);die;

            $ast = $this->check_two_data($satrt_ast);
            $newdata = [];
            $alldata = $this->check_first_data($ast, $newdata);

            $newdata = $alldata[&#39;newdata&#39;];
            if(!empty($alldata[&#39;startdata&#39;])){
                $startdata = $alldata[&#39;startdata&#39;];
                $nextgoto_old = &#39;&#39;;
                foreach ($newdata as $key => $value) {
                    if ($key == $startdata) {
                        $nextgoto_old = $value->name->nextgoto;
                        break;
                    }
                }
                $newdata = $this->sortIfData($newdata,$startdata);
            }
            $newdata = $this->checkIfData($newdata, 0);

            if (!empty($alldata[&#39;startdata&#39;])) {
                // code...
                $startdata = $alldata[&#39;startdata&#39;];
                // halt($newdata);
                $firset_data = [];
                $nextgoto_old = &#39;&#39;;
                foreach ($newdata as $key => $value) {
                    if ($key == $startdata) {
                        if(get_class($value) != &#39;PhpParser\Node\Stmt\Goto_&#39;){
                            $firset_data[] = $value;
                        }
                        $nextgoto_old = $value->name->nextgoto;
                        break;
                    }
                }
                // halt($firset_data);
                $res = $this->checkdata2($firset_data, $newdata, $nextgoto_old);
                $tempArray = array();
                foreach ($newdata as $key_new => $value_new) {
                    if($key_new == "startGoto"){
                        break;
                    }
                    if(strstr($key_new, "notLabel")){
                        $tempArray[] = $value_new;
                    }
                }
                if(count($tempArray) > 0){
                    $res = array_merge_recursive($tempArray,$res);
                }
            } else {
                $res = $ast;
            }

            //一句一句解析。
//            $contentCode = $this->getPrettyCode($prettyPrinter,$res);
//          $this->prettyWriteCode($this->completePath . &#39;\\&#39; . $fileName, $prettyPrinter,$res);
            echo "解密中...";
            //直接全部一次性解析,大文件有可能会内存溢出
          $contentCode = $prettyPrinter->prettyPrint($res);
          $contentCode = "<?php" . "\n" . $contentCode;
          $this->writeFile($this->completePath . $fileName, $contentCode);
          echo $fileName."解密成功";
        } catch (Error $error) {
            echo "Parse error: {$error->getMessage()}\n";
            return;
        }

    }

    public function check_two_data($ast)
    {
        $nodeValue = "1";
        foreach ($ast as $key => $value) {
            if(get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($value->stmts[0]) && get_class($value->stmts[0]) == &#39;PhpParser\Node\Stmt\Function_&#39;){
                $fore_arry = array();
                $fore_arry[0] = $value->stmts[0];
                $foreachData = $this->check_two_data($fore_arry);
                $ast[$key]->stmts[0] = $foreachData[0];
            }

            if (get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\TryCatch&#39;) {
                if (!empty($value->stmts[0]->name->name)) {
                    $startdata = $value->stmts[0]->name->name;
                    // var_dump($startdata);die;
                    $newdata_new = [];
                    $firset_data = [];
                    $nextgoto_old = &#39;&#39;;
                    foreach ($value->stmts as $key99 => $value99) {
                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                            $fore_arry[0] = $value99;
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                            $fore_arry[0] = $value99;
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Function_&#39;) {
                            $fore_arry[0] = $value99;
                            $value->stmts[$key99] = $this->check_two_data($fore_arry);
                        }
                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                            // var_dump($value99);die;
                            // $newdata[$value->name->name] = $ast[$key+1];
                            if (!empty($value->stmts[$key99 + 1])) {
                                if (get_class($value->stmts[$key99 + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 2]->name->name;
                                }
                                if (get_class($value->stmts[$key99 - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;

                                    foreach ($value->stmts as $key_node => $value_node){
                                        if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; &&$value_node->name->name == $value->stmts[$key99 + 1]->name->name){
                                            if(!empty($value->stmts[$key_node + 1])){
                                                $value->stmts[$key_node+1]->name->isNode = &$nodeValue;
                                                $value_node->name->isNode = &$nodeValue;
                                            }else{
                                                $value->stmts[$key_node]->name->isNode = &$nodeValue;
                                            }
                                            break;
                                        }
                                    }
                                }
                                if (get_class($value->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;
                                }
                            }else {
                                $newdata_new[$value99->name->name] = $value->stmts[$key99];
                                $value->stmts[$key99]->name->finish = &$nodeValue;
                            }
                        }
                    }

                    foreach ($newdata_new as $key998 => $value998) {
                        if (empty($value998->name->nextgoto)) {
                            $newdata_new[$key998]->name->nextgoto = null;
                        }
                        if ($key998 == $startdata) {
                            if(get_class($value998) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value998) != &#39;PhpParser\Node\Stmt\Label&#39;){
                                $firset_data[] = $value998;
                            }
                            $nextgoto_old = $value998->name->nextgoto;
                        }
                    }

                    $newdata_new = $this->sortIfData($newdata_new,$startdata);
                    $newdata_new = $this->checkIfData($newdata_new, $this->functionType);
                    if(count($firset_data)>0  && get_class($firset_data[0]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        $nextgoto_old = $firset_data[0]->name->nextgoto;
                    }
                    $res = $this->checkdata2($firset_data, $newdata_new, $nextgoto_old,$this->functionType);
                    // var_dump($prettyPrinter->prettyPrint($res));
                    // die;
                    // halt($res);
                    $ast[$key]->stmts = $res;
                }
            }

            if (get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\Function_&#39;) {
                // foreach ($ast[$key] as $key2 => $value2) {
                if (!empty($value->stmts[0]->name->name)) {
                    $startdata = $value->stmts[0]->name->name;
                    // var_dump($startdata);die;
                    $newdata_new = [];
                    $firset_data = [];
                    $nextgoto_old = &#39;&#39;;
                    foreach ($value->stmts as $key99 => $value99) {
                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                            $fore_arry[0] = $value99;
                            //halt($fore_arry);
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
//                            $value->stmts[$key99] = $this->check_two_data($fore_arry);
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\TryCatch&#39;) {
                            $fore_arry[0] = $value99;
                            // halt($fore_arry);
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                            $fore_arry[0] = $value99;
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Function_&#39;) {
                            $fore_arry[0] = $value99;
                            // halt($fore_arry);
                            $value->stmts[$key99] = $this->check_two_data($fore_arry);
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                            // var_dump($value99);die;
                            // $newdata[$value->name->name] = $ast[$key+1];
                            if (!empty($value->stmts[$key99 + 1])) {
                                if (get_class($value->stmts[$key99 + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 2]->name->name;
                                }
                                if (get_class($value->stmts[$key99 - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;
                                    foreach ($value->stmts as $key_node => $value_node){
                                        if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; &&$value_node->name->name == $value->stmts[$key99 + 1]->name->name){
                                            if(!empty($value->stmts[$key_node + 1])){
                                                $value->stmts[$key_node+1]->name->isNode = &$nodeValue;
                                                $value_node->name->isNode = &$nodeValue;
                                            }else{
                                                $value->stmts[$key_node]->name->isNode = &$nodeValue;
                                            }
                                            break;
                                        }
                                    }
                                }
                                if (get_class($value->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;
                                }
                            }else {
                                $newdata_new[$value99->name->name] = $value->stmts[$key99];
                                $value->stmts[$key99]->name->finish = &$nodeValue;
                            }
                        }elseif (get_class($value99) != &#39;PhpParser\Node\Stmt\Goto_&#39;){
                            if($key99 == 0 || ($key99 > 0 && get_class($value->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39;)){
                                $tempKey = "notLabel".$this->notLabelNum;
                                $this->notLabelNum = $this->notLabelNum + 1;
                                $newdata_new[$tempKey] = $value->stmts[$key99];
                                if($key99 >0 && empty($value->stmts[$key99 - 1]->name->nextgoto)){
                                    if(empty($value->stmts[$key99 - 1]->name)){
                                        $value->stmts[$key99 - 1]->name = new \stdClass();
                                    }
                                    $value->stmts[$key99 - 1]->name->nextgoto = $tempKey;
                                }
                                $astLength = count($value->stmts);
                                if($key99 + 1 < $astLength && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                                    if(empty($value->stmts[$key99]->name)){
                                        $value->stmts[$key99]->name = new \stdClass();
                                    }
                                    $value->stmts[$key99]->name->nextgoto = $value->stmts[$key99 + 1]->name->name;
                                }
                            }
                        }
                    }
                    foreach ($newdata_new as $key998 => $value998) {
                        if (empty($value998->name->nextgoto)) {
                            // var_dump($value998->name);die;
                            $newdata_new[$key998]->name->nextgoto = null;
                        }
                        if ($key998 == $startdata) {
                            if(get_class($value998) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value998) != &#39;PhpParser\Node\Stmt\Label&#39;){
                                $firset_data[] = $value998;
                            }
                            $nextgoto_old = $value998->name->nextgoto;
                        }

                    }

                    // $test_code =  $prettyPrinter->prettyPrint($newdata_new);
                    // halt($newdata_new);

//                    $newdata_new = $this->chekif($newdata_new, 2);
                    $newdata_new = $this->sortIfData($newdata_new,$startdata);
                    $newdata_new = $this->checkIfData($newdata_new, $this->functionType);
                    if(count($firset_data)>0  && get_class($firset_data[0]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        $nextgoto_old = $firset_data[0]->name->nextgoto;
                    }
                    $res = $this->checkdata2($firset_data, $newdata_new, $nextgoto_old,$this->functionType);
                    // var_dump($prettyPrinter->prettyPrint($res));
                    // die;
                    // halt($res);
                    $ast[$key]->stmts = $res;
                }elseif(get_class($value->stmts[0]) == &#39;PhpParser\Node\Stmt\TryCatch&#39;){
                    $fore_arry[0] = $value->stmts[0];
                    // halt($fore_arry);
                    $foreachData = $this->check_two_data($fore_arry);
                    $value->stmts[0] = $foreachData[0];
                }
            }
            if (get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\Foreach_&#39; || get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\While_&#39;) {
                // foreach ($ast[$key] as $key2 => $value2) {
                if (!empty($value->stmts[0]->name->name)) {
                    $startdata = $value->stmts[0]->name->name;
                    // var_dump($startdata);die;
                    $newdata_new = [];
                    $firset_data = [];
                    $nextgoto_old = &#39;&#39;;
                    foreach ($value->stmts as $key99 => $value99) {
                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                            $fore_arry[0] = $value99;
                            // halt($fore_arry);
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\TryCatch&#39;) {
                            $fore_arry[0] = $value99;
                            // halt($fore_arry);
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                            $fore_arry[0] = $value99;
                            $foreachData = $this->check_two_data($fore_arry);
                            $value->stmts[$key99] = $foreachData[0];
                        }

                        // $startdata = &#39;&#39;;
                        if (get_class($value99) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                            // var_dump($value99);die;
                            // $newdata[$value->name->name] = $ast[$key+1];
                            if (!empty($value->stmts[$key99 + 1])) {
                                if (get_class($value->stmts[$key99 + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 2]->name->name;
                                }
                                if (get_class($value->stmts[$key99 - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;
                                    foreach ($value->stmts as $key_node => $value_node){
                                        if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; &&$value_node->name->name == $value->stmts[$key99 + 1]->name->name){
                                            if(!empty($value->stmts[$key_node + 1])){
                                                $value->stmts[$key_node+1]->name->isNode = &$nodeValue;
                                                $value_node->name->isNode = &$nodeValue;
                                            }else{
                                                $value->stmts[$key_node]->name->isNode = &$nodeValue;
                                            }
                                            break;
                                        }
                                    }
                                }
                                if (get_class($value->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99 + 1];
                                    $value->stmts[$key99 + 1]->name->nextgoto =  &$value->stmts[$key99 + 1]->name->name;
                                }
                            } else {
                                    $newdata_new[$value99->name->name] = $value->stmts[$key99];
                                    $value->stmts[$key99]->name->finish = &$nodeValue;
                             }
                        }

                    }

                    foreach ($newdata_new as $key998 => $value998) {
                        if (empty($value998->name->nextgoto)) {
                            // var_dump($value998->name);die;
                            $newdata_new[$key998]->name->nextgoto = null;
                        }
                        if ($key998 == $startdata) {
                            if(get_class($value998) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value998) != &#39;PhpParser\Node\Stmt\Label&#39;){
                                $firset_data[] = $value998;
                            }
                            $nextgoto_old = $value998->name->nextgoto;
                        }
                    }

                    $newdata_new = $this->sortIfData($newdata_new,$startdata);
                    $newdata_new = $this->checkIfData($newdata_new, $this->foreachType);
                    if(count($firset_data)>0  && get_class($firset_data[0]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        $nextgoto_old = $firset_data[0]->name->nextgoto;
                    }
                    $res = $this->checkdata2($firset_data, $newdata_new, $nextgoto_old,$this->foreachType);

                    $ast[$key]->stmts = $res;

                } else {
                    if (!empty($ast[$key]->stmts)) {
                        foreach ($ast[$key]->stmts as $key9527 => $value9527) {
                            // halt($ast[$key]->stmts);
                            if (get_class($ast[$key]->stmts[$key9527]) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                                unset($ast[$key]->stmts[$key9527]);
                            }
                        }
                    }
                }
            }

            if (get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                foreach ($ast[$key]->cases as $key2 => $value2) {
                    if (!empty($value2->stmts[0]->name->name)) {
                        $startdata = $value2->stmts[0]->name->name;
                        // var_dump($startdata);die;
                        $newdata_new = [];
                        $firset_data = [];
                        $fore_arry = [];
                        $nextgoto_old = &#39;&#39;;
                        foreach ($value2->stmts as $key99 => $value99) {
                            if (get_class($value99) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                                $fore_arry[0] = $value99;
                                // halt($fore_arry);
                                $foreachData = $this->check_two_data($fore_arry);
                                $value2->stmts[$key99] = $foreachData[0];
//                                $value2->stmts[$key99] = $this->check_two_data($fore_arry);
                            }

                            if (get_class($value99) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                                $fore_arry[0] = $value99;
                                $foreachData = $this->check_two_data($fore_arry);
                                $value->stmts[$key99] = $foreachData[0];
                            }

                            // $startdata = &#39;&#39;;
                            if (get_class($value99) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                                // var_dump($value99);die;
                                // $newdata[$value->name->name] = $ast[$key+1];
                                if (!empty($value2->stmts[$key99 + 1])) {
                                    if (get_class($value2->stmts[$key99 + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                        $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                        $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 2]->name->name;
                                    }
                                    if (get_class($value2->stmts[$key99 - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value2->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                        $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                        $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 1]->name->name;
                                        foreach ($value2->stmts as $key_node => $value_node){
                                            if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; &&$value_node->name->name == $value2->stmts[$key99 + 1]->name->name){
                                                if(!empty($value2->stmts[$key_node + 1])){
                                                    $value2->stmts[$key_node+1]->name->isNode = &$nodeValue;
                                                    $value_node->name->isNode = &$nodeValue;
                                                }else{
                                                    $value2->stmts[$key_node]->name->isNode = &$nodeValue;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                    if (get_class($value2->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value2->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                        $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                        $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 1]->name->name;
                                    }
                                }else {
                                    $newdata_new[$value99->name->name] = $value2->stmts[$key99];
                                    $value2->stmts[$key99]->name->finish = &$nodeValue;
                                }
                            }
                        }
                        foreach ($newdata_new as $key998 => $value998) {
                            if (empty($value998->name->nextgoto)) {
                                // var_dump($value998->name);die;
                                $newdata_new[$key998]->name->nextgoto = null;
                            }
                            if ($key998 == $startdata) {
                                if(get_class($value998) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value998) != &#39;PhpParser\Node\Stmt\Label&#39;){
                                    $firset_data[] = $value998;
                                }
                                $nextgoto_old = $value998->name->nextgoto;
                            }
                        }

                        // $test_code =  $prettyPrinter->prettyPrint($newdata_new);
                        // halt($newdata_new);
                        $newdata_new = $this->sortIfData($newdata_new,$startdata);
                        $newdata_new = $this->checkIfData( $newdata_new, $this->switchType);
                        if(count($firset_data)>0  && get_class($firset_data[0]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                            $nextgoto_old = $firset_data[0]->name->nextgoto;
                        }
//                      var_dump($newdata_new);
                        // halt($newdata_new);
                        $res = $this->checkdata2($firset_data, $newdata_new, $nextgoto_old,$this->switchType);
                        // var_dump($prettyPrinter->prettyPrint($res));
                        // halt($res);
                        $ast[$key]->cases[$key2]->stmts = $res;
                    }else {
                        if (!empty($value2) && !empty($value2->stmts)) {
                            foreach ($value2->stmts as $key_remove => $value_remove) {
                                // halt($ast[$key]->stmts);
                                if (get_class($value_remove) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                                    unset($value2->stmts[$key_remove]);
                                }
                                if(get_class($value_remove) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                                    $attributes = array();
                                    $breakStd = new \PhpParser\Node\Stmt\Break_(null,$attributes);
                                    $value2->stmts[$key_remove] = $breakStd;
                                }
                            }
                        }
                    }
                }
            }
            if (get_class($ast[$key]) == &#39;PhpParser\Node\Stmt\Class_&#39;) {
                foreach ($ast[$key]->stmts as $key2 => $value2) {
                    if (get_class($value2) == &#39;PhpParser\Node\Stmt\ClassMethod&#39;) {
                        if (!empty($value2->stmts[0]->name->name)) {
                            $startdata = $value2->stmts[0]->name->name;
                            // var_dump($startdata);die;
                            $newdata_new = [];
                            $firset_data = [];
                            $nextgoto_old = &#39;&#39;;
                            foreach ($value2->stmts as $key99 => $value99) {
                                if (get_class($value99) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                                    $fore_arry[0] = $value99;
                                    // halt($fore_arry);
                                    $foreachData = $this->check_two_data($fore_arry);
                                    $value2->stmts[$key99] = $foreachData[0];
                                }

                                if (get_class($value99) == &#39;PhpParser\Node\Stmt\TryCatch&#39;) {
                                    $fore_arry[0] = $value99;
                                    // halt($fore_arry);
                                    $foreachData = $this->check_two_data($fore_arry);
                                    $value2->stmts[$key99] = $foreachData[0];
                                }

                                if (get_class($value99) == &#39;PhpParser\Node\Stmt\Function_&#39;) {
                                    $fore_arry[0] = $value99;
                                    $foreachData = $this->check_two_data($fore_arry);
                                    $value2->stmts[$key99] = $foreachData[0];
                                }

                                if (get_class($value99) == &#39;PhpParser\Node\Stmt\Switch_&#39;) {
                                    $fore_arry[0] = $value99;
                                    $foreachData = $this->check_two_data($fore_arry);
                                    $value2->stmts[$key99] = $foreachData[0];
                                }

                                // $startdata = &#39;&#39;;
                                if (get_class($value99) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                                    // var_dump($value99);die;
                                    // $newdata[$value->name->name] = $ast[$key+1];
                                    if (!empty($value2->stmts[$key99 + 1])) {
                                        if (get_class($value2->stmts[$key99 + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
//                                            if($value99->name->name == "g0ibM"){
//                                                echo "g0ibM";
//                                            }
                                            $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                            $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 2]->name->name;
                                        }
                                        if (get_class($value2->stmts[$key99 - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value2->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                            $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                            $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 1]->name->name;
//                                            $value2->stmts[$key99 + 1]->name->isNode = &$nodeValue;
                                            foreach ($value2->stmts as $key_node => $value_node){
                                                if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; &&$value_node->name->name == $value2->stmts[$key99 + 1]->name->name){
                                                    if(!empty($value2->stmts[$key_node + 1])){
                                                        $value2->stmts[$key_node+1]->name->isNode = &$nodeValue;
                                                        $value_node->name->isNode = &$nodeValue;
                                                    }else{
                                                        $value2->stmts[$key_node]->name->isNode = &$nodeValue;
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        if (get_class($value2->stmts[$key99 - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($value2->stmts[$key99 + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                                            $newdata_new[$value99->name->name] = $value2->stmts[$key99 + 1];
                                            $value2->stmts[$key99 + 1]->name->nextgoto =  &$value2->stmts[$key99 + 1]->name->name;
                                        }
                                    }else {
                                        $newdata_new[$value99->name->name] = $value2->stmts[$key99];
                                        $value2->stmts[$key99]->name->finish = &$nodeValue;
                                    }
                                }
                            }

                            foreach ($newdata_new as $key998 => $value998) {
                                if (empty($value998->name->nextgoto)) {
                                    // var_dump($value998->name);die;
                                    $newdata_new[$key998]->name->nextgoto = null;
                                }
                                if ($key998 == $startdata) {
                                    if(get_class($value998) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value998) != &#39;PhpParser\Node\Stmt\Label&#39;){
                                        $firset_data[] = $value998;
                                    }
                                    $nextgoto_old = $value998->name->nextgoto;
                                }
                            }

                            $newdata_new = $this->sortIfData($newdata_new,$startdata);
                            $newdata_new = $this->checkIfData($newdata_new, $this->classType);
                            if(count($firset_data)>0  && get_class($firset_data[0]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                                $nextgoto_old = $firset_data[0]->name->nextgoto;
                            }
                            $res = $this->checkdata2($firset_data, $newdata_new, $nextgoto_old,$this->classType);
                            
                            $ast[$key]->stmts[$key2]->stmts = $res;
                        }else{
                            if (!empty($value2) && !empty($value2->stmts)) {
                                foreach ($value2->stmts as $key_search => $value_search) {
                                    if (get_class($value_search) == &#39;PhpParser\Node\Stmt\TryCatch&#39; || get_class($value_search) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                                        $fore_arry[0] = $value_search;
                                        // halt($fore_arry);
                                        $foreachData = $this->check_two_data($fore_arry);
                                        $value2->stmts[$key_search] = $foreachData[0];
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return $ast;
    }

    public function check_first_data($ast, $newdata)
    {
        $nodeValue = "1";
        $emptyString = "";
        $astLength = count($ast);
        $classLabel = "";
        $nodeLabel = "";
        foreach ($ast as $key => $value) {
            if (get_class($value) == &#39;PhpParser\Node\Stmt\Label&#39; && ($key + 1 < $astLength) && get_class($ast[$key + 1]) == &#39;PhpParser\Node\Stmt\Class_&#39;) {
                $classLabel = $classLabel.$ast[$key]->name->name.",";
            }
        }
        foreach ($ast as $key => $value) {
            if (get_class($value) == &#39;PhpParser\Node\Stmt\Goto_&#39; && empty($startdata)) {
                $startdata = $ast[$key]->name->name;
                $newdata[&#39;startGoto&#39;] = $ast[$key];
                $alldata[&#39;startdata&#39;] = $startdata;
            }
            if (get_class($value) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                
            }
            if (get_class($value) == &#39;PhpParser\Node\Stmt\Label&#39;) {
                if (!empty($ast[$key + 1]) && !empty($ast[$key + 2])) {
                    if (get_class($ast[$key + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                        $newdata[$value->name->name] = $ast[$key + 1];
                        $ast[$key + 1]->name->nextgoto =  &$ast[$key + 2]->name->name;
                    }
                    if (get_class($ast[$key - 1]) == &#39;PhpParser\Node\Stmt\Label&#39; && get_class($ast[$key + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                        $newdata[$value->name->name] = $ast[$key + 1];
                        $ast[$key + 1]->name->nextgoto =  &$ast[$key + 1]->name->name;

                        if(!empty($ast[$key + 1]->name->name)){
                            if(!strstr($nodeLabel, $ast[$key + 1]->name->name)){
                                $nodeLabel =  $nodeLabel.$ast[$key + 1]->name->name.",";
                            }
                        }

                    }
                    if (get_class($ast[$key - 1]) != &#39;PhpParser\Node\Stmt\Label&#39; && get_class($ast[$key + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                        $newdata[$value->name->name] = $ast[$key + 1];
                        $ast[$key + 1]->name->nextgoto =  &$ast[$key + 1]->name->name;
                    }
                }else if(!empty($ast[$key + 1]) && ($key + 2 == $astLength)){
                    if (get_class($ast[$key + 1]) != &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                        $newdata[$value->name->name] = $ast[$key + 1];
                    }
                    if (get_class($ast[$key + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;) {
                        $newdata[$value->name->name] = $ast[$key + 1];
                        $ast[$key + 1]->name->nextgoto =  &$ast[$key + 1]->name->name;

                    }
                }elseif(($key + 1 == $astLength)){
                    $newdata[$value->name->name] = $ast[$key];
                    $value->name->finish = &$nodeValue;
                    $value->name->exitFinish = &$nodeValue;
                    if(get_class($ast[$key - 1]) == &#39;PhpParser\Node\Stmt\Label&#39;){
                        $value->name->otherFinishLabel = &$ast[$key - 1]->name->name;
                    }
                }
            }elseif (get_class($value) != &#39;PhpParser\Node\Stmt\Goto_&#39;){
                if($key == 0 || ($key > 0 && get_class($ast[$key - 1]) != &#39;PhpParser\Node\Stmt\Label&#39;)){
                    $tempKey = "notLabel".$this->notLabelNum;
                    $this->notLabelNum = $this->notLabelNum + 1;
                    $newdata[$tempKey] = $ast[$key];
                    if($key >0 && empty($ast[$key - 1]->name->nextgoto)){
                        if(empty($ast[$key - 1]->name)){
                            $ast[$key - 1]->name = new \stdClass();
                        }
                        $ast[$key - 1]->name->nextgoto = $tempKey;
                    }
                    if($key + 1 < $astLength && get_class($ast[$key + 1]) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                        if(empty($ast[$key]->name)){
                            $ast[$key]->name = new \stdClass();
                        }
                        $ast[$key]->name->nextgoto = $ast[$key + 1]->name->name;
                    }
                }
            }
        }


        foreach ($ast as $key_node => $value_node){
            if(!empty($value_node->name->name) && get_class($value_node) != &#39;PhpParser\Node\Stmt\Goto_&#39; && strstr($nodeLabel, $value_node->name->name)){
                if(!empty($ast[$key_node + 1])){
                    $ast[$key_node+1]->name->isNode = &$nodeValue;
                    $value_node->name->isNode = &$nodeValue;
                }else{
                    $ast[$key_node]->name->isNode = &$nodeValue;
                }
            }
        }

        foreach ($newdata as $key => $value) {
            if (empty($value->name->nextgoto)) {
                $newdata[$key]->name->nextgoto = &$emptyString;
                $newdata[$key]->name->nextgoto = null;
            }
        }
        $alldata[&#39;newdata&#39;] = $newdata;

        return $alldata;
    }


    public function checkdata($firset_data, $newdata, $nextgoto_new)
    {
        MYGOD:
        foreach ($newdata as $key2 => $value2) {
            if ($nextgoto_new == $key2) {
                $firset_data[] = $value2;
                if (!empty($value2->name->nextgoto)) {
                    $nextgoto_new = $value2->name->nextgoto;
                    goto MYGOD;
                }
            }
        }
        return $firset_data;
    }

    public function packageData($firset_data, $newdata, $nextgoto_new,$stopStr="")
    {
        $this->allFindLabel = "";
        if(empty($newdata)){
            return $firset_data;
        }elseif($nextgoto_new == $stopStr){
            return $firset_data;
        }
        $lastKey = "";
        MYGOD:
        foreach ($newdata as $key2 => $value2) {
            if ($nextgoto_new == $key2) {
                if(!strstr($this->allFindLabel, $key2)){
                    $this->allFindLabel = $this->allFindLabel.$key2.";";
                }else{
                    if(get_class($value2) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        if(!empty($value2->stmts[0]->name->name)){
                            $nextgoto_new = $value2->stmts[0]->name->name;
                            goto MYGOD;
                        }
                    }
                    goto MYGOD2;
                }
                if (get_class($value2) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value2) != &#39;PhpParser\Node\Stmt\Label&#39;) {
                    $firset_data[$key2] = $value2;
                }
                if(get_class($value2) == &#39;PhpParser\Node\Stmt\Label&#39; && !empty($value2->name->finish) && $value2->name->finish == "1"){
                    $firset_data[$key2] = $value2;
                }
                if (!empty($value2->name->nextgoto)) {
                    if(!empty($stopStr)){
                        if($value2->name->nextgoto == $stopStr){
                            goto MYGOD2;
                        }
                    }
                    $nextgoto_new = $value2->name->nextgoto;
                    $lastKey = $key2;
                    if(empty($newdata[$nextgoto_new])){
                        $firset_data[$key2] = $value2;
                    }
                    goto MYGOD;
                }
            }
        }
        MYGOD2:
        return $firset_data;
    }

    public function checkLoopData($firset_data, $newdata, $nextgoto_new,$type = 0,$stopStr="")
    {
        $this->allFindLabel = "";
        if(empty($newdata)){
            return $firset_data;
        }
        $lastKey = "";
        MYGOD:
        foreach ($newdata as $key2 => $value2) {
            if ($nextgoto_new == $key2) {
                if(!strstr($this->allFindLabel, $key2)){
                    $this->allFindLabel = $this->allFindLabel.$key2.";";
                }else{
                    goto MYGOD2;
                }
                if (get_class($value2) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value2) != &#39;PhpParser\Node\Stmt\Label&#39;) {
                    $firset_data[] = &$value2;
                }
                if (get_class($value2) == &#39;PhpParser\Node\Stmt\Return_&#39;) {
                    // code...
                    goto MYGOD2;
                }
                if (!empty($value2->expr)) {
                    if (get_class($value2->expr) == &#39;PhpParser\Node\Expr\Exit_&#39;) {
                        // code...
                        // var_dump(get_class($value2->expr));
                        goto MYGOD2;
                    }
                }
                if (!empty($value2->name->nextgoto)) {
                    $nextgoto_new = $value2->name->nextgoto;
                    if($type == $this->switchType && empty($newdata[$nextgoto_new])){
                        $attributes = array();
                        $breakStd = new \PhpParser\Node\Stmt\Break_(null,$attributes);
                        $firset_data[] = $breakStd;
                    }
                    if(!empty($stopStr)){
                        if($value2->name->nextgoto == $stopStr){
                            goto MYGOD2;
                        }
                    }

                    $lastKey = $key2;
                    goto MYGOD;
                }
            }
        }
        MYGOD2:
        return $firset_data;
    }

   //提取if的语句
    public function extractIfData($newdata,$nextgoto_new,$lastLabel=""){
        $ifDataArray = [];
//        $lastLabel = "";
        while (!empty($nextgoto_new)){
            if(!empty($newdata[$nextgoto_new]) && !strstr($this->allFindLabel, $nextgoto_new)){
                $this->allFindLabel = $this->allFindLabel.$nextgoto_new.";";
                $value = $newdata[$nextgoto_new];
                if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39;) {
                    if(empty($value->name)){
                        $value->name = new \stdClass();
                    }
                    if(empty($value->name->lastLabelOne)){
                        $value->name->lastLabelOne = $lastLabel;
                    }else{
                        $value->name->lastLabelTwo = $lastLabel;
                    }
                    $ifDataArray[$nextgoto_new] = $value;
                    if(!empty($value->stmts) && !empty($value->stmts[0]->name->name)){
                        if (get_class($value) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value) != &#39;PhpParser\Node\Stmt\Label&#39;){
                            $lastLabel = $nextgoto_new;
                        }
                        $insideArray = $this->extractIfData($newdata,$value->stmts[0]->name->name,$lastLabel);
                        $ifDataArray = array_merge($ifDataArray,$insideArray);
                    }
                }
                if (!empty($value->name->nextgoto)) {
                    if (get_class($value) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value) != &#39;PhpParser\Node\Stmt\Label&#39;){
                        $lastLabel = $nextgoto_new;
                    }
//                    $lastLabel = $nextgoto_new;
                    $nextgoto_new = $value->name->nextgoto;
                }else{
                    $nextgoto_new = "";
                }
            }else {
                $nextgoto_new = "";
            }
        }

        return $ifDataArray;
    }

    //把if按顺序排
    public function sortIfData($newdata,$nextgoto_new)
    {
        $this->allFindLabel = "";
        $ifDataArray = [];
//        $allDataArray = [];
        if(empty($newdata)){
            return $ifDataArray;
        }

        $ifDataArray = $this->extractIfData($newdata,$nextgoto_new);

        $otherDataArray = array();
        foreach ($newdata as $key => $value){
            if(empty($ifDataArray[$key])){
//                $ifDataArray[$key] = $value;
                $otherDataArray[$key] = $value;
            }
        }

        $allDataArray = array_merge_recursive($otherDataArray,$ifDataArray);
        return $allDataArray;
    }


    public function checkdata2($firset_data, &$newdata, $nextgoto_new,$type = 0,$stopStr="",$nowKey="")
    {
        $start_nextgot = $nextgoto_new;
        $this->allFindLabel = "";
        if(!empty($nowKey)){
            $this->allFindLabel = $nowKey.",";
        }
        if(empty($newdata)){
            return $firset_data;
        }

        $lastKey = "";
        MYGOD:
        foreach ($newdata as $key2 => $value2) {
            if ($nextgoto_new == $key2) {
                if(!strstr($this->allFindLabel, $key2)){
                    $this->allFindLabel = $this->allFindLabel.$key2.",";
                }else{
                    if($nowKey == $key2){
                        $newdata["$nowKey"]->name->isWhile = &$this->existValue;
                    }
                    goto MYGOD2;
                }
                if (get_class($value2) != &#39;PhpParser\Node\Stmt\Goto_&#39; && get_class($value2) != &#39;PhpParser\Node\Stmt\Label&#39;) {
                    $firset_data[] = $value2;
                }
                if (get_class($value2) == &#39;PhpParser\Node\Stmt\Return_&#39;) {
                    // code...
                    goto MYGOD2;
                }
                if (!empty($value2->expr)) {
                    if (get_class($value2->expr) == &#39;PhpParser\Node\Expr\Exit_&#39;) {
                        goto MYGOD2;
                    }
                }
                //最后一个label
                if(!empty($value2->name->exitFinish) && $value2->name->exitFinish == 1 && get_class($value2) == &#39;PhpParser\Node\Stmt\Label&#39;){
                    if(!empty($nowKey) && get_class($newdata[$nowKey]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        if($start_nextgot != $newdata[$nowKey]->name->nextgoto){
                            $attributes = array();
                            $attributes[&#39;kind&#39;] = 1;
                            $exitStd = new \PhpParser\Node\Expr\Exit_(null,$attributes);
                            $expressionStd = new \PhpParser\Node\Stmt\Expression($exitStd,$attributes);
                            $firset_data[] = $expressionStd;
                        }
                    }
                }

                if (!empty($value2->name->nextgoto)) {
                    $nextgoto_new = $value2->name->nextgoto;
                    if($type == $this->switchType && empty($newdata[$nextgoto_new])){
                        $attributes = array();
                        $breakStd = new \PhpParser\Node\Stmt\Break_(null,$attributes);
                        $firset_data[] = $breakStd;
                    }
                    if(!empty($stopStr)){
                        if($value2->name->nextgoto == $stopStr){
                            goto MYGOD2;
                        }
                    }

                    $lastKey = $key2;
                    goto MYGOD;
                }
            }
        }
        MYGOD2:
        return $firset_data;
    }

    //检查if语句部分的代码是否需要反向解密
    public function checkIfData($newdata,$type)
    {
        foreach ($newdata as $key => $value) {
            if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39; || get_class($value) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                // halt($value);
                if (!empty($value->stmts[0]->name->name)) {
                    $insideLabel  = $value->stmts[0]->name->name;
                    if(!empty($newdata[$insideLabel])){
                        $firset_data = [];
//                        if($key == "YwAsH"){
//                            echo "UZkI3";
//                        }
                        if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($value->name->nextgoto)){
                            $firstStr = $this->findIFLabel($value->stmts[0]->name->name, $newdata);
                            if(!empty($firstStr) && empty($newdata[$firstStr]->name->nextgoto) && !empty($newdata[$firstStr]->name->finish) &&
                                $newdata[$firstStr]->name->finish == "1"){
                                if(!empty($newdata[$firstStr]->name->otherFinishLabel)){
                                    $firstStr = $newdata[$firstStr]->name->otherFinishLabel;
                                }
                            }
//                            echo "key:".$key.";";
                            $this->allFindLabelStr = "";
                            $nextStr = $this->compareNextLabel($value->name->nextgoto, $newdata,$firstStr,$type,$key);
                            if(!empty($nextStr) && !empty($value->name->whileLabel) && $nextStr == $newdata[$value->name->whileLabel]->name->nextgoto){
                                $nextStr = "";
                            }elseif(!empty($value->name->whileLabel) && $value->name->whileLabel == $value->name->nextgoto){
                                $nextStr = "";
                                $value->name->isChange = "";
                            }
                            if(!empty($nextStr) || !empty($value->name->isChange) || !empty($value->name->isWhile) || !empty($value->name->isBreak)){
//                               //条件跳转跟下一句的nextgoto跳转相同
//                               //条件需要反向的处理
                                if(get_class($value->cond) == &#39;PhpParser\Node\Expr\BooleanNot&#39;){
                                    $tempCond = $value->cond->expr;
                                    $value->cond = $tempCond;
                                }else{
                                    $tempCond = $value->cond;
                                    $attributes = $tempCond->getAttributes();;
                                    $user = new \PhpParser\Node\Expr\BooleanNot($tempCond,$attributes);
                                    $value->cond = $user;
                                }
                                $value->stmts[0]->name->name = $value->name->nextgoto;
                                $value->name->nextgoto = $firstStr;

                                if(!empty($value->name->isInsideLoop) && empty($value->name->isWhile)){
                                    $value->name->stopgoto = $value->name->isInsideLoop;
                                    $value->name->isWhile = &$this->existValue;
                                }

                                if(!empty($value->name->isWhile) && !empty($this->allFindLabelStr)){
                                    $this->allFindLabel = $key.",";
                                    $this->setWhileData($value->stmts[0]->name->name,$newdata,$key);
                                }
                                if(!empty($nextStr)){
                                    $value->name->stopgoto = $nextStr;
                                }elseif(!empty($value->name->isChange)){
                                    $value->name->stopgoto = $value->name->isChange;
                                    if(!empty($value->name->isWhile)){
                                        $checkDataResult = $this->packageData($firset_data, $newdata, $value->stmts[0]->name->name,$key);
                                    }else{
                                        $checkDataResult = $this->packageData($firset_data, $newdata, $value->stmts[0]->name->name);
                                    }
                                    $firset_data = [];
                                    $checkNextDataResult = $this->packageData($firset_data, $newdata, $value->name->nextgoto,$value->name->stopgoto);
                                    $sameNodeStr = $this->selectSameNode($checkDataResult,$checkNextDataResult);
                                    if(!empty($sameNodeStr)){
                                        //存在else的情况
                                        $value->name->elseStr = $sameNodeStr;
                                        $newdata[$key]->name->oldnextgoto = $value->name->nextgoto;
                                        $newdata[$key]->name->nextgoto = $sameNodeStr;
                                        $value->name->stopgoto = "";
                                    }
                                }elseif(!empty($value->name->isWhile) && empty($value->name->stopgoto)){
                                    $value->name->stopgoto = $key;
                                }
                                else {
//                                    $value->name->stopgoto = $value->name->isBreak;
                                }
                            }elseif(!empty($value->name->isInsideLoop)){
                                $value->name->stopgoto = $value->name->isInsideLoop;
                                $value->name->isWhile = &$this->existValue;
                            }
                            else{
                                if(!empty($value->name->whileLabel)){
                                    $whileLabel = $value->name->whileLabel;
                                }else{
                                    $whileLabel = "";
                                }
                                $checkDataResult = $this->packageData($firset_data, $newdata, $insideLabel,$whileLabel);
                                $checkNextDataResult = $this->packageData($firset_data, $newdata, $value->name->nextgoto,$whileLabel);
                                $sameNodeStr = $this->selectSameNode($checkDataResult,$checkNextDataResult);
                                if(!empty($sameNodeStr)){
                                    //存在else的情况
                                    $value->name->elseStr = $sameNodeStr;
                                    $newdata[$key]->name->oldnextgoto = $value->name->nextgoto;
                                    $newdata[$key]->name->nextgoto = $sameNodeStr;
                                }
                            }
                            $newdata[$key]->name->oldIfLabel = $key;
                        }
                    }
                }
            }
        }
        //处理if中的
        foreach ($newdata as $key => $value) {
            if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39; || get_class($value) == &#39;PhpParser\Node\Stmt\Foreach_&#39;) {
                // halt($value);
                if (!empty($value->stmts[0]->name->name)) {
                    foreach ($newdata as $key996 => $value996) {
                        if ($key996 == $value->stmts[0]->name->name) {
                            $firset_data = [];
                            if($type == $this->foreachType || $type == $this->switchType){
                                $code2 = &#39;<?php break;&#39;;
                                $code2 = $this->parserObj->parse($code2);
                            }else {
                                $code2 = &#39;<?php return false;&#39;;
                                $code2 = $this->parserObj->parse($code2);
                            }
//                            if($key == "UZkI3"){
//                                echo "UZkI3";
//                            }
                            if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($value->name->nextgoto)){
                                if(!empty($value->name->stopgoto)){
                                    if(!empty($value->name->isWhile)){
//                                        $this ->restoreWhile($key,$newdata);
//                                        $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,$stopStr);
                                      $checkDataResult = $this->checkdata2($firset_data, $newdata,  $value->stmts[0]->name->name,0,$value->name->stopgoto,$key);
                                      $newdata[$key]->stmts = !empty($checkDataResult) ? $checkDataResult : $code2;
                                    }else{
                                        $stopStr = $value->name->stopgoto;
                                        $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,$stopStr,$key);
                                        if(!empty($value->name->whileLabel)){
                                            if(!empty($value->name->isChange)){
                                               $tempWhileLabel = $value->name->isChange;
                                            }else {
                                                $tempWhileLabel = $value->name->whileLabel;
                                            }
                                            //判断是否有break的情况
                                            $whileLabelNext = $newdata[$tempWhileLabel]->name->nextgoto;
                                            if(strstr($this->allFindLabel,$whileLabelNext)){
                                                $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,$whileLabelNext,$key);
                                                $attributes = array();
                                                $breakStd = new \PhpParser\Node\Stmt\Break_(null,$attributes);
                                                $checkDataResult[] = $breakStd;
                                            }
                                        }
                                        $newdata[$key]->stmts = !empty($checkDataResult) ? $checkDataResult : $code2;
                                    }
                                }elseif(!empty($value->name->elseStr)){
//                                        $this->judgeElseIf($newdata,$sameNodeStr,$key,$key996,$value->name->oldnextgoto,$type);
                                    //存在else的情况
                                    $sameNodeStr = $value->name->elseStr;
                                    $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,$sameNodeStr,$key);
                                    $newdata[$key]->stmts = $checkDataResult;
                                    $firset_data = [];
                                    $checkNextDataResult = $this->checkdata2($firset_data, $newdata, $value->name->oldnextgoto,$type,$sameNodeStr,$key);
                                    $attributes = array();
                                    $elseStd = new \PhpParser\Node\Stmt\Else_($checkNextDataResult,$attributes);
                                    $newdata[$key]->else = $elseStd;
                                    $newdata[$key]->name->nextgoto = $sameNodeStr;
                                }else{
                                    if(!empty($value->name->whileLabel)){
                                        $stopStr = $value->name->whileLabel;
                                    }else{
                                        $stopStr = "";
                                    }
                                    $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,$stopStr,$key);
                                    $newdata[$key]->stmts = !empty($checkDataResult) ? $checkDataResult : $code2;
                                }
                            }else{
                                $checkDataResult = $this->checkdata2($firset_data, $newdata, $key996,$type,"",$key);
                                $newdata[$key]->stmts = !empty($checkDataResult) ? $checkDataResult : $code2;
                            }
                            break;
                        }
                    }
                }
            }
        }
        $this->allFindLabelStr ="";
        foreach ($newdata as $key => $value){
            if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39;){
                $this->allFindLabelStr = $key.",";
                if(!empty($value->name->isWhile)){
                    //条件跳转跟下一句的nextgoto跳转相同
                    //条件反向的处理,并把if改为while
                    $oldName = $value->name;
                    $attributes = $value->cond->getAttributes();
                    $whileObj = new \PhpParser\Node\Stmt\While_(  $value->cond,$value->stmts,$attributes);
                    $value = $whileObj;
                    $value->name = $oldName;
                    $newdata[$key] = $value;
                    if( !empty($newdata[$key] ->stmts)){
                        $this->restoreWhile($newdata[$key] ->stmts);
                        $this->allFindLabelStr ="";
                    }
                }elseif(!empty($newdata[$key] ->stmts)){
                    $this->restoreWhile($newdata[$key] ->stmts);
                    $this->allFindLabelStr ="";
                    if(!empty($newdata[$key] ->else->stmts)){
                        $this->restoreWhile($newdata[$key] ->else->stmts);
                        $this->allFindLabelStr ="";
                    }

                }
            }
        }
//        $this->restoreWhile($newdata);
        return $newdata;
    }


//    /* 判断是否存在elseIf的情况 */
//    public function judgeElseIf(&$newdata, $sameNodeStr,$key,$startLabel,$oldnextgoto,$type){
//        $firstStr = $this->findIFLabel($sameNodeStr, $newdata);
//        $elseIfArray = array();
//        while(!empty($firstStr) && !empty($newdata[$firstStr]) && get_class($newdata[$firstStr]) == "PhpParser\Node\Stmt\If_"){
//            $firset_data = [];
//            //存在elseif的情况
//            $checkDataResult = $this->checkdata2($firset_data, $newdata, $startLabel,$type,$sameNodeStr);
//            $newdata[$key]->stmts = $checkDataResult;
//            $checkNextDataResult = $this->checkdata2($firset_data, $newdata, $oldnextgoto,$type,$sameNodeStr);
//            $attributes = array();
            $newdata[$key]->elseifs[] =
//            $elseStd = new \PhpParser\Node\Stmt\Else_($checkNextDataResult,$attributes);
//            $elseIfArray
//            $newdata[$key]->else = $elseStd;
//            $newdata[$key]->name->nextgoto = $sameNodeStr;
//        }
//        if(!empty($firstStr) && !empty($newdata[$firstStr]) && get_class($newdata[$firstStr]) == "PhpParser\Node\Stmt\If_"){
//
//        }
//    }

    public function selectSameNode($startArray, $nextArray){
        $tabelStr = "";
        if(empty($startArray) || empty($nextArray)){
            return $tabelStr;
        }
        $firstArray = array();
        $secondArray = array();
        foreach ($startArray as $key =>$value){
            if(!empty($value->name->isNode) && $value->name->isNode == 1 ){
                $firstArray[$key] = $value;
            }
        }

        foreach ($nextArray as $key =>$value){
            if(!empty($value->name->isNode) && $value->name->isNode == 1 ){
                $secondArray[$key] = $value;
            }
        }
        if(empty($firstArray) || empty($secondArray)){
            return $tabelStr;
        }
        foreach ($secondArray as $key_second =>$value_second){
            foreach ($firstArray as $key_first =>$value_first){
                if($key_second == $key_first){
                    $tabelStr = $key_second;
                    return $tabelStr;
                }
            }

        }
        return $tabelStr;
    }

    //寻找if语句goto的第一条有效代码的label
    public function findIFLabel($findStr, $res){
        $tabelStr = "";
        foreach ($res as $keyFind => $valueFind) {
            if ($keyFind == $findStr) {
                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                    $tabelStr = $this->findIFLabel($valueFind->name,$res);
                }elseif (get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && !empty($valueFind->name->nextgoto)){
                    $tabelStr = $this->findIFLabel($valueFind->name->nextgoto,$res);
                } else{
                    $tabelStr = $keyFind;
                }
                break;
            }
        }
        return $tabelStr;
    }

    public function findFirstNextLabel($findStr, $res,$rowCount){
        $tabelStr = "";
        foreach ($res as $keyFind => $valueFind) {
            if ($keyFind == $findStr) {
                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                    $tabelStr = $this->findFirstNextLabel($valueFind->name,$res,$rowCount);
                }elseif(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && empty($valueFind->stmts)){
                    $tabelStr = $this->findFirstNextLabel($valueFind->name->nextgoto,$res,$rowCount);
                }
                else{
                    if($rowCount != 0){
                        $rowCount = $rowCount - 1;
                        $tabelStr = $this->findFirstNextLabel($valueFind->name->nextgoto,$res,$rowCount);
                    }else{
                        $tabelStr = $keyFind;
                    }
//                    $tabelStr = $keyFind;
                }
                break;
            }
        }
        return $tabelStr;
    }

    public function compareNextLabel2($findStr, &$res,$compareStr,$whileLabel = ""){
        if(empty($compareStr) || empty($res)){
            return "";
        }
        STARTCOMPARE:
        $tabelStr = "";
        if(!empty($res[$findStr])){
            $valueFind = $res[$findStr];
            //判断是否进入死循环
            if(!strstr($this->allFindLabel, $findStr)){
                $this->allFindLabel = $this->allFindLabel.$findStr.",";
            }else{
                return "";
            }
            if(!empty($whileLabel) && $findStr == $whileLabel){
                return "";
            }
            if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
//                $tabelStr = $this->compareNextLabel2($valueFind->name->name,$res,$compareStr,$whileLabel);
                $findStr = $valueFind->name->name;
                goto STARTCOMPARE;
            }elseif(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && empty($valueFind->stmts) && !empty($valueFind->name->nextgoto)){
//                $tabelStr = $this->compareNextLabel2($valueFind->name->nextgoto,$res,$compareStr,$whileLabel);
                $findStr = $valueFind->name->nextgoto;
                goto STARTCOMPARE;
            }
            else{
                if($findStr == $compareStr){
                    if( $this->checkExistWhile($this->allFindLabelStr,$res)){
                        return "";
                    }
                    $tabelStr = $findStr;
                    goto STOPCOMPARE;
                }else{
                    if(!empty($this->allFindLabel)){
                        $allLabelAry = explode(&#39;,&#39;, $this->allFindLabel);
                        if(count($allLabelAry)>480){
                            return "";
                        }
                    }
                    if(!empty($valueFind->name->nextgoto)){
//                        $tabelStr = $this->compareNextLabel2($valueFind->name->nextgoto,$res,$compareStr,$whileLabel);
                        $findStr = $valueFind->name->nextgoto;
                        goto STARTCOMPARE;
                    }
                }
            }
        }else{
            return "";
        }
        STOPCOMPARE:
        return $tabelStr;
    }


//    public function compareNextLabel2($findStr, &$res,$compareStr,$whileLabel = ""){
//        if(empty($compareStr)){
//            return "";
//        }
//        $tabelStr = "";
//        foreach ($res as $keyFind => $valueFind) {
//            if ($keyFind == $findStr) {
//                //判断是否进入死循环
//                if(!strstr($this->allFindLabel, $keyFind)){
//                    $this->allFindLabel = $this->allFindLabel.$keyFind.",";
                    echo "$this->allFindLabel";
                    echo "<br>";
//                }else{
                    if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        $tempNextgoto = $valueFind->stmts[0]->name->name;
                        $ifNodeStr = $keyFind;
                    }else{
                        $allLabelAry = explode(&#39;,&#39;, $this->allFindLabel);
                        $ifNodeStr = $allLabelAry[count($allLabelAry)-2];
                        $tempNextgoto = $res[$ifNodeStr] ->stmts[0]->name->name;
                    }
                    $res[$ifNodeStr] ->name->isWhile = &$this->existValue;
//                    $this->restoreWhile($ifNodeStr,$res);
                    $tabelStr = $this->compareNextLabel2($tempNextgoto,$res,$compareStr);
//                      return "";
//                }
//
//                if(!empty($whileLabel) && $keyFind == $whileLabel){
//                    return "";
//                }
//                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
//                    $tabelStr = $this->compareNextLabel2($valueFind->name->name,$res,$compareStr,$whileLabel);
//                }elseif(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && empty($valueFind->stmts) && !empty($valueFind->name->nextgoto)){
//                    $tabelStr = $this->compareNextLabel2($valueFind->name->nextgoto,$res,$compareStr,$whileLabel);
//                }
//                else{
//                    if($keyFind == $compareStr){
//                        if( $this->checkExistWhile($this->allFindLabelStr,$res)){
//                            return "";
//                        }
//                        $tabelStr = $keyFind;
//                    }else{
//                        if(!empty($this->allFindLabel)){
//                            $allLabelAry = explode(&#39;,&#39;, $this->allFindLabel);
//                            if(count($allLabelAry)>480){
//                                return "";
//                            }
//                        }
//                        if(!empty($valueFind->name->nextgoto)){
//                            $tabelStr = $this->compareNextLabel2($valueFind->name->nextgoto,$res,$compareStr,$whileLabel);
//                        }
//                    }
//                }
//                break;
//            }
//        }
//        return $tabelStr;
//    }


    //比较后面代码是否有相同的label
    public function compareNextLabel($findStr, &$res,$compareStr,$type=0,$ifKey=""){
        if(empty($compareStr)){
            return "";
        }

        if(empty($this->allFindLabelStr)){
            if(get_class($res[$ifKey]) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($res[$ifKey]->stmts)){
                $this->allFindLabel = "";
                if(!empty($res[$ifKey]->stmts[0]->name->name)){
                    $tabelStr = $this->compareNextLabel2($res[$ifKey]->stmts[0]->name->name,$res,$ifKey);
                    if(!empty($tabelStr)){
                        if(!empty($res[$ifKey]->name->lastLabelOne) && strstr($this->allFindLabel, $res[$ifKey]->name->lastLabelOne)){
                            echo "tabelStr=".$tabelStr;
                        }else{
  //                        $res[$ifKey]->name->isWhile = &$this->existValue;
                            $res[$ifKey]->name->isInsideLoop = $tabelStr;
                        }
                    }
                }
            }
        }

        $tabelStr = "";
        foreach ($res as $keyFind => $valueFind) {
            if ($keyFind == $findStr) {
                if($keyFind == $ifKey){
                    if( $this->checkExistWhile($this->allFindLabelStr,$res)){
                        return "";
                    }
                    $tempNextgoto = $valueFind->stmts[0]->name->name;
                    $res[$keyFind] ->name->isWhile = &$this->existValue;
//                    $tabelStr = $this->compareNextLabel($tempNextgoto,$res,$compareStr,$type,$ifKey);
                    return $keyFind;
                }

                if(!empty($this->allFindLabelStr)){
                    $allLabelAry = explode(&#39;,&#39;, $this->allFindLabelStr);
                    if(count($allLabelAry)>480){
                        return "";
                    }
                }

                //判断是否进入死循环
                if(!strstr($this->allFindLabelStr, $keyFind)){
                    $this->allFindLabelStr = $this->allFindLabelStr.$keyFind.",";
                }else{
                    if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\If_&#39;){
                        $tempNextgoto = $valueFind->stmts[0]->name->name;
                        $ifNodeStr = $keyFind;
                        if($valueFind != $ifKey){
                            $tabelStr = $this->compareNextLabel($tempNextgoto,$res,$compareStr,$type,$ifKey);
                            return $tabelStr;
                        }
                    }else{
                        $allLabelAry = explode(&#39;,&#39;, $this->allFindLabelStr);
                        $ifNodeStr = $allLabelAry[count($allLabelAry)-2];
                        if(get_class( $res[$ifNodeStr]) != &#39;PhpParser\Node\Stmt\If_&#39;){
                            return "";
                        }
                    }
                    $res[$ifNodeStr] ->name->isWhile = &$this->existValue;
//                    $this->restoreWhile($ifNodeStr,$res);
//                    $tabelStr = $this->compareNextLabel($tempNextgoto,$res,$compareStr,$type,$ifKey);
                   return $keyFind;
                }

                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($valueFind->stmts)){
                    $this->allFindLabel = "";
                    if(!empty($valueFind->stmts[0]->name->name)){
                        if(!empty($res[$ifKey]->name->whileLabel)){
                            $whileLabel = $res[$ifKey]->name->whileLabel;
                        }else{
                            $whileLabel = "";
                        }
                        $tabelStr = $this->compareNextLabel2($valueFind->stmts[0]->name->name,$res,$ifKey,$whileLabel);
                        if(!empty($tabelStr)){
                            if(!empty($res[$ifKey]->name->lastLabelOne) && strstr($this->allFindLabel, $res[$ifKey]->name->lastLabelOne)){
                                $tabelStr = "";
                            }else{
                                $res[$ifKey]->name->isWhile = &$this->existValue;
                                $res[$keyFind]->name->isChange = $tabelStr;
                            }
                        }
                    }
                }

                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                    if(empty($res[$valueFind->name->name]) && $type == $this->foreachType){
                        $res[$ifKey]->name->isBreak = $valueFind->name->name;
                    }
                    $tabelStr = $this->compareNextLabel($valueFind->name->name,$res,$compareStr,$type,$ifKey);
                }elseif(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && empty($valueFind->stmts) && !empty($valueFind->name->nextgoto)){
                    $tabelStr = $this->compareNextLabel($valueFind->name->nextgoto,$res,$compareStr,$type,$ifKey);
                }
                else{
                    if($keyFind == $compareStr){
                        $tabelStr = $keyFind;
                    }else{
                        if(!empty($valueFind->name->nextgoto)){
                            $tabelStr = $this->compareNextLabel($valueFind->name->nextgoto,$res,$compareStr,$type,$ifKey);
                        }
                    }
                }
                break;
            }
        }
        return $tabelStr;
    }

    //给while块里面的if语句设置标签
    public function setWhileData($findStr,&$res,$compareStr,$stopLabel=""){
        if(empty($compareStr)){
            return "";
        }
        $tabelStr = "";
        foreach ($res as $keyFind => $valueFind) {
            if ($keyFind == $findStr) {
                //判断是否进入死循环
                if(!strstr($this->allFindLabel, $keyFind)){
                    $this->allFindLabel = $this->allFindLabel.$keyFind.",";
                }else{
                    return "";
                }
                if(get_class($res[$keyFind]) == &#39;PhpParser\Node\Stmt\If_&#39;){
                    $res[$keyFind]->name->whileLabel = $compareStr;
                    if(!empty($valueFind->stmts[0]->name->name)){
                        $tabelStr = $this->setWhileData($valueFind->stmts[0]->name->name,$res,$compareStr,$stopLabel);
                    }
                }
                if(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Goto_&#39;){
                    $tabelStr = $this->setWhileData($valueFind->name->name,$res,$compareStr,$stopLabel);
                }elseif(get_class($valueFind) == &#39;PhpParser\Node\Stmt\Label&#39; && empty($valueFind->stmts) && !empty($valueFind->name->nextgoto)){
                    $tabelStr =
                        $this->setWhileData($valueFind->name->nextgoto,$res,$compareStr,$stopLabel);
                }
                else{
                    if($keyFind == $compareStr){
                        $tabelStr = $keyFind;
                    }else{
                        if(!empty($this->allFindLabel)){
                            $allLabelAry = explode(&#39;,&#39;, $this->allFindLabel);
                            if(count($allLabelAry)>480){
                                return "";
                            }
                        }
                        if(!empty($valueFind->name->nextgoto)){
                            $tabelStr = $this->setWhileData($valueFind->name->nextgoto,$res,$compareStr,$stopLabel);
                        }
                    }
                }
                break;
            }
        }
        return $tabelStr;
    }

    //检查是否存在while语句
    public function checkExistWhile($allFindStr,$res){
        $allLabelAry = explode(&#39;,&#39;, $allFindStr);
        foreach ($allLabelAry as $key => $value){
            if(!empty($value) && get_class($res[$value]) == "PhpParser\Node\Stmt\If_"){
                if(!empty($res[$value]->name->isWhile) && $res[$value]->name->isWhile == $this->existValue){
                    return true;
                }
            }
        }
        return false;
    }


    //检查while语句
    public function checkWhile($whileKey,&$res,$whileNext){

        foreach ($res as $key => $value ){
            if(get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39; && empty($value->name->oldIfLabel)){
                if(!empty($value->stmts) && count($value->stmts)>0){
                    $this->checkWhile($whileKey,$value->stmts,$whileNext);
                }
            }elseif(get_class($value) == &#39;PhpParser\Node\Stmt\While_&#39;){
                if(!empty($value->stmts) && count($value->stmts)>0){
                    $this->checkWhile($whileKey,$value->stmts,$whileNext);
                }
            }else {
                if(!empty($value->name->oldIfLabel) && $value->name->oldIfLabel == $whileNext){
                    $attributes = array();
                    $breakStd = new \PhpParser\Node\Stmt\Break_(null,$attributes);
                    $res[$key] = $breakStd;
                }
            }
        }
    }

    //恢复while语句
    public function restoreWhile(&$res){
        foreach ($res as $key => $value){
            if (get_class($value) == &#39;PhpParser\Node\Stmt\If_&#39;){
                if(empty($res[$key]->name->oldIfLabel)){
                    continue;
                }
                $ifLabel = $res[$key]->name->oldIfLabel;
                if(!strstr($this->allFindLabelStr, $ifLabel)){
                    $this->allFindLabelStr = $this->allFindLabelStr.$ifLabel.",";
//                    $failLabel = "t6X3c,IxelL,OTFhY,Ab4dP,c4iI1,wWVDk,aBDVw,cGQ2R,Hhab6,hxI8v";
//                    if(strstr($failLabel,$ifLabel)){
//                        echo $ifLabel;
//                    }
                }else{
//                    if($ifLabel == "aBDVw"){
//                        echo $ifLabel;
//                    }
//                    echo $ifLabel."重复=".$this->allFindLabelStr.";<br>";
                }
                if(!empty($value->name->isWhile)){
                    //条件跳转跟下一句的nextgoto跳转相同
                    //条件反向的处理,并把if改为while
                    $oldName = $value->name;
                    $attributes = $value->cond->getAttributes();
                    $whileObj = new \PhpParser\Node\Stmt\While_(  $value->cond,$value->stmts,$attributes);
                    $value = $whileObj;
                    $value->name = $oldName;
                    $res[$key] = $value;
                    if( !empty($res[$key] ->stmts)){
                        $this->restoreWhile($res[$key] ->stmts);
                    }
                }elseif(!empty($res[$key] ->stmts)){
                        $this->restoreWhile($res[$key] ->stmts);
                        if(!empty($res[$key] ->else->stmts)){
                            $this->restoreWhile($res[$key] ->else->stmts);
                        }
                }
            }
        }
    }

    public function getPrettyCode($prettyPrinter, $res){
        $res_code = "";
        if(!empty($res)){
            $arrayLength = count($res);
            $tempArray = array();
            $find = array("?>\n","?>","<?php","<?php");
            for($i = 0;$i < $arrayLength;$i++){
                if (get_class($res[$i]) == &#39;PhpParser\Node\Stmt\Switch_&#39;&& !empty($res[$i]->cases) && count($res[$i]->cases)>0) {
                    foreach ($res[$i]->cases as $key2 => $value2) {
                        if (!empty($value2->stmts) && count($value2->stmts)>0) {
                            echo date(&#39;h:i:s&#39;, time())."         YY/";
                            $if_code = $this->getPrettyCode($prettyPrinter, $value2->stmts);
                            if(!empty($this->parserObj)){
                                $if_code = str_ireplace( $find,"",$if_code,$count);
                                $this->replaceTip = $this->parserObj->parse($if_code);
                            }
                            $value2->stmts = $this->replaceTip;
                            $tempArray[0] = $value2;
                            $old_code = $prettyPrinter->prettyPrint($tempArray);
                            $one_code = str_ireplace( $find,"",$old_code,$count);
                            echo date(&#39;h:i:s&#39;, time())."         YY/";
                            $memoryValue = number_format(memory_get_usage());
                            echo $memoryValue . "      /";
                            echo date(&#39;h:i:s&#39;, time())."         /";
                        }
                    }
                    $tempArray[0] = $res[$i];
                    $old_code = $prettyPrinter->prettyPrint($tempArray);
                    $one_code = str_ireplace( $find,"",$old_code,$count);
                }else if(get_class($res[$i]) == &#39;PhpParser\Node\Stmt\If_&#39; && !empty($res[$i]->stmts) && count($res[$i]->stmts)>0){
                        $if_code = $this->getPrettyCode($prettyPrinter, $res[$i]->stmts);
                        if(!empty($this->parserObj)){

                            $if_code = str_ireplace( $find,"",$if_code,$count);
                            $this->replaceTip = $this->parserObj->parse($if_code);
                        }
                        $res[$i]->stmts = $this->replaceTip;
                        $tempArray[0] = $res[$i];
                        $old_code = $prettyPrinter->prettyPrint($tempArray);
//                        $one_code = str_ireplace( $this->replaceTipStr,$if_code,$old_code,$count);
                        $one_code = str_ireplace( $find,"",$old_code,$count);
                        $this->printCount = $this->printCount +1;

                }else if(get_class($res[$i]) == &#39;PhpParser\Node\Stmt\Foreach_&#39; && !empty($res[$i]->stmts) && count($res[$i]->stmts)>0){
                    $if_code = $this->getPrettyCode($prettyPrinter, $res[$i]->stmts);
                    if(!empty($this->parserObj)){
                        $if_code = str_ireplace( $find,"",$if_code,$count);
                        $this->replaceTip = $this->parserObj->parse($if_code);
                    }
                    $res[$i]->stmts = $this->replaceTip;
                    $tempArray[0] = $res[$i];
                    $old_code = $prettyPrinter->prettyPrint($tempArray);
//                        $one_code = str_ireplace( $this->replaceTipStr,$if_code,$old_code,$count);
                    $one_code = str_ireplace( $find,"",$old_code,$count);

                     $this->printCount2 = $this->printCount2 +1;
                }
                else{
                    $tempArray[0] = $res[$i];
                    $one_code = $prettyPrinter->prettyPrint($tempArray);
                    $this->printCount1 = $this->printCount1 +1;
                }
                $res_code = $res_code.$one_code;
            }
        }
        return $res_code;
    }


    public function prettyWriteCode($fileName,$prettyPrinter, $res){
        if(!empty($res)){
            $arrayLength = count($res);
            $myfile = fopen($fileName, "a+") or die("Unable to open file!");
            $tempArray = array();
            for($i = 0;$i < $arrayLength;$i++){
                $tempArray[0] = $res[$i];
                $res_code = $prettyPrinter->prettyPrint($tempArray);
                if($i == 0){
                    $res_code = "<?php" . "\n" . $res_code;
                }
                echo "i=".$i."\n";
                fwrite($myfile, $res_code);
            }
            fclose($myfile);
        }
    }
    public function writeFile($fileName, $content)
    {
        $myfile = fopen($fileName, "w") or die("Unable to open file!");
        fwrite($myfile, $content);
        fclose($myfile);
    }
}

推荐学习:php视频教程

以上是來咯,你想要的goto解密腳本它真的來咯!的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除