您好,欢迎访问一九零五行业门户网

来咯,你想要的goto解密脚本它真的来咯!

goto解密脚本,破解微擎模块必备的解密工具,玩微擎的都知道,基本上微擎大部分都是goto加密的,看到好的模块,想要去学习他的代码,加密是万万不行的,所以用这个脚本就能无限解密模块加密文件,你想怎么学习就怎么学习。
因站长有phpgoto解密并且做一些二开,找了5-6小时后,在某站花168元在买的,亲测后两个字“完美”。
其它很多php源码会进行goto加密,比如很多微擎应用。对于已加密的应用很多人是不敢直接使用的,因为不知道里面有些什么内容。 今天,分享源码网为您整理分享一套goto解密的源码 直接上传服务器就可以使用的。php7及以上。
将要解密的代码上传到decodefile文件夹,然后访问index.php文件即可
解压出来的文件在complete文件。 当然如果你有能力二开的话可以将这套封装成付费解压的小工具。这套我自己现在也在用。
代码如下:
<?phpnamespace 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__ . '/vendor/autoload.php', __dir__ . '/vendor/nikic/php-parser/vendor/autoload.php'] as $file) { if (file_exists($file)) { require $file; break; }}date_default_timezone_set('prc'); $decodeobj = new decode(); $decodeobj->batchdecode();// $decodepath = __dir__.'\\'.'decodefile';class decode{ //注意windos下和linux下路线格式不同 public $decodepath = __dir__ .directory_separator. 'decodefile'; public $completepath = __dir__ . directory_separator . 'complete'.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 . '/' . $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>"; // echo $dumper->dump($ast);die; $ast = $this->check_two_data($satrt_ast); $newdata = []; $alldata = $this->check_first_data($ast, $newdata); $newdata = $alldata['newdata']; if(!empty($alldata['startdata'])){ $startdata = $alldata['startdata']; $nextgoto_old = ''; 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['startdata'])) { // code... $startdata = $alldata['startdata']; // halt($newdata); $firset_data = []; $nextgoto_old = ''; foreach ($newdata as $key => $value) { if ($key == $startdata) { if(get_class($value) != 'phpparser\node\stmt\goto_'){ $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 . '\\' . $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]) == 'phpparser\node\stmt\if_' && !empty($value->stmts[0]) && get_class($value->stmts[0]) == 'phpparser\node\stmt\function_'){ $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]) == 'phpparser\node\stmt\trycatch') { if (!empty($value->stmts[0]->name->name)) { $startdata = $value->stmts[0]->name->name; // var_dump($startdata);die; $newdata_new = []; $firset_data = []; $nextgoto_old = ''; foreach ($value->stmts as $key99 => $value99) { if (get_class($value99) == 'phpparser\node\stmt\foreach_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\switch_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\function_') { $fore_arry[0] = $value99; $value->stmts[$key99] = $this->check_two_data($fore_arry); } if (get_class($value99) == 'phpparser\node\stmt\label') { // var_dump($value99);die; // $newdata[$value->name->name] = $ast[$key+1]; if (!empty($value->stmts[$key99 + 1])) { if (get_class($value->stmts[$key99 + 1]) != 'phpparser\node\stmt\goto_') { $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]) == 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' &&$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]) != 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' && get_class($value998) != 'phpparser\node\stmt\label'){ $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]) == 'phpparser\node\stmt\if_'){ $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]) == 'phpparser\node\stmt\function_') { // 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 = ''; foreach ($value->stmts as $key99 => $value99) { if (get_class($value99) == 'phpparser\node\stmt\foreach_') { $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) == 'phpparser\node\stmt\trycatch') { $fore_arry[0] = $value99; // halt($fore_arry); $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\switch_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\function_') { $fore_arry[0] = $value99; // halt($fore_arry); $value->stmts[$key99] = $this->check_two_data($fore_arry); } if (get_class($value99) == 'phpparser\node\stmt\label') { // var_dump($value99);die; // $newdata[$value->name->name] = $ast[$key+1]; if (!empty($value->stmts[$key99 + 1])) { if (get_class($value->stmts[$key99 + 1]) != 'phpparser\node\stmt\goto_') { $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]) == 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' &&$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]) != 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_'){ if($key99 == 0 || ($key99 > 0 && get_class($value->stmts[$key99 - 1]) != 'phpparser\node\stmt\label')){ $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]) == 'phpparser\node\stmt\goto_'){ 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) != 'phpparser\node\stmt\goto_' && get_class($value998) != 'phpparser\node\stmt\label'){ $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]) == 'phpparser\node\stmt\if_'){ $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]) == 'phpparser\node\stmt\trycatch'){ $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]) == 'phpparser\node\stmt\foreach_' || get_class($ast[$key]) == 'phpparser\node\stmt\while_') { // 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 = ''; foreach ($value->stmts as $key99 => $value99) { if (get_class($value99) == 'phpparser\node\stmt\foreach_') { $fore_arry[0] = $value99; // halt($fore_arry); $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\trycatch') { $fore_arry[0] = $value99; // halt($fore_arry); $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\switch_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } // $startdata = ''; if (get_class($value99) == 'phpparser\node\stmt\label') { // var_dump($value99);die; // $newdata[$value->name->name] = $ast[$key+1]; if (!empty($value->stmts[$key99 + 1])) { if (get_class($value->stmts[$key99 + 1]) != 'phpparser\node\stmt\goto_') { $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]) == 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' &&$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]) != 'phpparser\node\stmt\label' && get_class($value->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' && get_class($value998) != 'phpparser\node\stmt\label'){ $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]) == 'phpparser\node\stmt\if_'){ $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]) == 'phpparser\node\stmt\label') { unset($ast[$key]->stmts[$key9527]); } } } } } if (get_class($ast[$key]) == 'phpparser\node\stmt\switch_') { 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 = ''; foreach ($value2->stmts as $key99 => $value99) { if (get_class($value99) == 'phpparser\node\stmt\foreach_') { $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) == 'phpparser\node\stmt\switch_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value->stmts[$key99] = $foreachdata[0]; } // $startdata = ''; if (get_class($value99) == 'phpparser\node\stmt\label') { // var_dump($value99);die; // $newdata[$value->name->name] = $ast[$key+1]; if (!empty($value2->stmts[$key99 + 1])) { if (get_class($value2->stmts[$key99 + 1]) != 'phpparser\node\stmt\goto_') { $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]) == 'phpparser\node\stmt\label' && get_class($value2->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' &&$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]) != 'phpparser\node\stmt\label' && get_class($value2->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' && get_class($value998) != 'phpparser\node\stmt\label'){ $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]) == 'phpparser\node\stmt\if_'){ $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) == 'phpparser\node\stmt\label') { unset($value2->stmts[$key_remove]); } if(get_class($value_remove) == 'phpparser\node\stmt\goto_'){ $attributes = array(); $breakstd = new \phpparser\node\stmt\break_(null,$attributes); $value2->stmts[$key_remove] = $breakstd; } } } } } } if (get_class($ast[$key]) == 'phpparser\node\stmt\class_') { foreach ($ast[$key]->stmts as $key2 => $value2) { if (get_class($value2) == 'phpparser\node\stmt\classmethod') { if (!empty($value2->stmts[0]->name->name)) { $startdata = $value2->stmts[0]->name->name; // var_dump($startdata);die; $newdata_new = []; $firset_data = []; $nextgoto_old = ''; foreach ($value2->stmts as $key99 => $value99) { if (get_class($value99) == 'phpparser\node\stmt\foreach_') { $fore_arry[0] = $value99; // halt($fore_arry); $foreachdata = $this->check_two_data($fore_arry); $value2->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\trycatch') { $fore_arry[0] = $value99; // halt($fore_arry); $foreachdata = $this->check_two_data($fore_arry); $value2->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\function_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value2->stmts[$key99] = $foreachdata[0]; } if (get_class($value99) == 'phpparser\node\stmt\switch_') { $fore_arry[0] = $value99; $foreachdata = $this->check_two_data($fore_arry); $value2->stmts[$key99] = $foreachdata[0]; } // $startdata = ''; if (get_class($value99) == 'phpparser\node\stmt\label') { // var_dump($value99);die; // $newdata[$value->name->name] = $ast[$key+1]; if (!empty($value2->stmts[$key99 + 1])) { if (get_class($value2->stmts[$key99 + 1]) != 'phpparser\node\stmt\goto_') {// 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]) == 'phpparser\node\stmt\label' && get_class($value2->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' &&$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]) != 'phpparser\node\stmt\label' && get_class($value2->stmts[$key99 + 1]) == 'phpparser\node\stmt\goto_') { $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) != 'phpparser\node\stmt\goto_' && get_class($value998) != 'phpparser\node\stmt\label'){ $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]) == 'phpparser\node\stmt\if_'){ $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) == 'phpparser\node\stmt\trycatch' || get_class($value_search) == 'phpparser\node\stmt\foreach_') { $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) == 'phpparser\node\stmt\label' && ($key + 1 < $astlength) && get_class($ast[$key + 1]) == 'phpparser\node\stmt\class_') { $classlabel = $classlabel.$ast[$key]->name->name.","; } } foreach ($ast as $key => $value) { if (get_class($value) == 'phpparser\node\stmt\goto_' && empty($startdata)) { $startdata = $ast[$key]->name->name; $newdata['startgoto'] = $ast[$key]; $alldata['startdata'] = $startdata; } if (get_class($value) == 'phpparser\node\stmt\goto_') { } if (get_class($value) == 'phpparser\node\stmt\label') { if (!empty($ast[$key + 1]) && !empty($ast[$key + 2])) { if (get_class($ast[$key + 1]) != 'phpparser\node\stmt\goto_') { $newdata[$value->name->name] = $ast[$key + 1]; $ast[$key + 1]->name->nextgoto = &$ast[$key + 2]->name->name; } if (get_class($ast[$key - 1]) == 'phpparser\node\stmt\label' && get_class($ast[$key + 1]) == 'phpparser\node\stmt\goto_') { $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]) != 'phpparser\node\stmt\label' && get_class($ast[$key + 1]) == 'phpparser\node\stmt\goto_') { $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]) != 'phpparser\node\stmt\goto_') { $newdata[$value->name->name] = $ast[$key + 1]; } if (get_class($ast[$key + 1]) == 'phpparser\node\stmt\goto_') { $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]) == 'phpparser\node\stmt\label'){ $value->name->otherfinishlabel = &$ast[$key - 1]->name->name; } } }elseif (get_class($value) != 'phpparser\node\stmt\goto_'){ if($key == 0 || ($key > 0 && get_class($ast[$key - 1]) != 'phpparser\node\stmt\label')){ $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]) == 'phpparser\node\stmt\goto_'){ 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) != 'phpparser\node\stmt\goto_' && 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['newdata'] = $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) == 'phpparser\node\stmt\if_'){ if(!empty($value2->stmts[0]->name->name)){ $nextgoto_new = $value2->stmts[0]->name->name; goto mygod; } } goto mygod2; } if (get_class($value2) != 'phpparser\node\stmt\goto_' && get_class($value2) != 'phpparser\node\stmt\label') { $firset_data[$key2] = $value2; } if(get_class($value2) == 'phpparser\node\stmt\label' && !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) != 'phpparser\node\stmt\goto_' && get_class($value2) != 'phpparser\node\stmt\label') { $firset_data[] = &$value2; } if (get_class($value2) == 'phpparser\node\stmt\return_') { // code... goto mygod2; } if (!empty($value2->expr)) { if (get_class($value2->expr) == 'phpparser\node\expr\exit_') { // 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) == 'phpparser\node\stmt\if_') { 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) != 'phpparser\node\stmt\goto_' && get_class($value) != 'phpparser\node\stmt\label'){ $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) != 'phpparser\node\stmt\goto_' && get_class($value) != 'phpparser\node\stmt\label'){ $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) != 'phpparser\node\stmt\goto_' && get_class($value2) != 'phpparser\node\stmt\label') { $firset_data[] = $value2; } if (get_class($value2) == 'phpparser\node\stmt\return_') { // code... goto mygod2; } if (!empty($value2->expr)) { if (get_class($value2->expr) == 'phpparser\node\expr\exit_') { goto mygod2; } } //最后一个label if(!empty($value2->name->exitfinish) && $value2->name->exitfinish == 1 && get_class($value2) == 'phpparser\node\stmt\label'){ if(!empty($nowkey) && get_class($newdata[$nowkey]) == 'phpparser\node\stmt\if_'){ if($start_nextgot != $newdata[$nowkey]->name->nextgoto){ $attributes = array(); $attributes['kind'] = 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) == 'phpparser\node\stmt\if_' || get_class($value) == 'phpparser\node\stmt\foreach_') { // 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) == 'phpparser\node\stmt\if_' && !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) == 'phpparser\node\expr\booleannot'){ $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) == 'phpparser\node\stmt\if_' || get_class($value) == 'phpparser\node\stmt\foreach_') { // 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 = '<?php break;'; $code2 = $this->parserobj->parse($code2); }else { $code2 = '<?php return false;'; $code2 = $this->parserobj->parse($code2); }// if($key == "uzki3"){// echo "uzki3";// } if (get_class($value) == 'phpparser\node\stmt\if_' && !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) == 'phpparser\node\stmt\if_'){ $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) == 'phpparser\node\stmt\goto_'){ $tabelstr = $this->findiflabel($valuefind->name,$res); }elseif (get_class($valuefind) == 'phpparser\node\stmt\label' && !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) == 'phpparser\node\stmt\goto_'){ $tabelstr = $this->findfirstnextlabel($valuefind->name,$res,$rowcount); }elseif(get_class($valuefind) == 'phpparser\node\stmt\label' && 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) == 'phpparser\node\stmt\goto_'){// $tabelstr = $this->comparenextlabel2($valuefind->name->name,$res,$comparestr,$whilelabel); $findstr = $valuefind->name->name; goto startcompare; }elseif(get_class($valuefind) == 'phpparser\node\stmt\label' && 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(',', $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) == 'phpparser\node\stmt\if_'){ $tempnextgoto = $valuefind->stmts[0]->name->name; $ifnodestr = $keyfind; }else{ $alllabelary = explode(',', $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) == 'phpparser\node\stmt\goto_'){// $tabelstr = $this->comparenextlabel2($valuefind->name->name,$res,$comparestr,$whilelabel);// }elseif(get_class($valuefind) == 'phpparser\node\stmt\label' && 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(',', $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]) == 'phpparser\node\stmt\if_' && !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(',', $this->allfindlabelstr); if(count($alllabelary)>480){ return ""; } } //判断是否进入死循环 if(!strstr($this->allfindlabelstr, $keyfind)){ $this->allfindlabelstr = $this->allfindlabelstr.$keyfind.","; }else{ if(get_class($valuefind) == 'phpparser\node\stmt\if_'){ $tempnextgoto = $valuefind->stmts[0]->name->name; $ifnodestr = $keyfind; if($valuefind != $ifkey){ $tabelstr = $this->comparenextlabel($tempnextgoto,$res,$comparestr,$type,$ifkey); return $tabelstr; } }else{ $alllabelary = explode(',', $this->allfindlabelstr); $ifnodestr = $alllabelary[count($alllabelary)-2]; if(get_class( $res[$ifnodestr]) != 'phpparser\node\stmt\if_'){ 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) == 'phpparser\node\stmt\if_' && !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) == 'phpparser\node\stmt\goto_'){ 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) == 'phpparser\node\stmt\label' && 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]) == 'phpparser\node\stmt\if_'){ $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) == 'phpparser\node\stmt\goto_'){ $tabelstr = $this->setwhiledata($valuefind->name->name,$res,$comparestr,$stoplabel); }elseif(get_class($valuefind) == 'phpparser\node\stmt\label' && 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(',', $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(',', $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) == 'phpparser\node\stmt\if_' && empty($value->name->oldiflabel)){ if(!empty($value->stmts) && count($value->stmts)>0){ $this->checkwhile($whilekey,$value->stmts,$whilenext); } }elseif(get_class($value) == 'phpparser\node\stmt\while_'){ 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) == 'phpparser\node\stmt\if_'){ 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]) == 'phpparser\node\stmt\switch_'&& !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('h:i:s', 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('h:i:s', time())." yy/"; $memoryvalue = number_format(memory_get_usage()); echo $memoryvalue . " /"; echo date('h:i:s', time())." /"; } } $temparray[0] = $res[$i]; $old_code = $prettyprinter->prettyprint($temparray); $one_code = str_ireplace( $find,"",$old_code,$count); }else if(get_class($res[$i]) == 'phpparser\node\stmt\if_' && !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]) == 'phpparser\node\stmt\foreach_' && !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解密脚本它真的来咯!的详细内容。
其它类似信息

推荐信息