基本信息
源码名称:解密魔方二代加密的代码工具
源码大小:0.28M
文件格式:.zip
开发语言:PHP
更新时间:2019-12-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 5 元 
   源码介绍
魔方二代代码解密 代码类,用户需要composer安装 php composer.phar require nikic/php-parser 或者去github上下载 php-parse 地址https://github.com/nikic/PHP-Parser 引入成功后把需要解密的文件更名为rebuild.php文件   例如:php bin/rebuild.php tests/devpatrol.inc.php

<?php

use Ganlv\MfencDecompiler\Decompiler;
use Ganlv\MfencDecompiler\DfsDisassembler;
use Ganlv\MfencDecompiler\DirectedGraphStructureSimplifier;
use Ganlv\MfencDecompiler\Disassembler1;
use Ganlv\MfencDecompiler\Disassembler2;
use Ganlv\MfencDecompiler\GraphViewer;
use Ganlv\MfencDecompiler\Helper;
use Ganlv\MfencDecompiler\VmDecompiler;

require 'vendor/autoload.php';

ini_set('xdebug.max_nesting_level', 1000000);

$functionIndex = 10;
if (isset($_GET['flowchart'])) {
    $functionIndex = $_GET['flowchart'];
    $graph = getGraph($functionIndex);
    $simplifier = new DirectedGraphStructureSimplifier($graph);
    $graph = $simplifier->simplify();
    header('Content-Type: text/plain; charset=UTF-8');
    echo Helper::graphToFlowchart($graph);
    return;
}
if (isset($_GET['id'])) {
    $functionIndex = $_GET['id'];
}

$dissectInstructions = getStructuredInstructions($functionIndex);
$decompiler = new Decompiler($dissectInstructions);
try {
    $decompiler->decompile();
} catch (Exception $e) {
    echo $e->getMessage(), PHP_EOL, PHP_EOL;
    echo $e->getTraceAsString(), PHP_EOL, PHP_EOL;
}
$ast = $decompiler->ast;
echo Helper::prettyPrintFile($ast);

$nodeVisitor = new \Ganlv\MfencDecompiler\NodeVisitors\GetAllEipsNodeVisitor();
Helper::traverseAst($nodeVisitor, $ast);
$eips = $nodeVisitor->eips;
file_put_contents("runtime/$functionIndex.structure.summary.txt", Helper::printStructuredInstructionsIsUsed(getStructuredInstructions($functionIndex), $eips, true));
$stack = $decompiler->stack;
$ast = \Ganlv\MfencDecompiler\Beautifier::beautify($ast);
file_put_contents("runtime/$functionIndex.decompiled.1.php", Helper::prettyPrintFile($ast));

function getAst()
{
    if (!file_exists("runtime/ast.serialize.txt")) {
        $original = file_get_contents('tests/keke_xzhseo.class.php');
        $ast = Helper::parseCode($original);
        file_put_contents("runtime/ast.serialize.txt", serialize($ast));
    } else {
        $ast = unserialize(file_get_contents("runtime/ast.serialize.txt"));
    }
    return $ast;
}

function getInstructions($functionIndex)
{
    if (!file_exists("runtime/$functionIndex.instructions.serialize.txt")) {
        $ast = getAst();
        $ast = $ast[11]->stmts[$functionIndex]->stmts;
        $vmStart = VmDecompiler::findVmStart($ast);
        $vmVariables = VmDecompiler::findVmVariables($ast, $vmStart);
        $vmMemoryData = VmDecompiler::findVmMemoryData($ast, $vmStart);

        $disassembler = new Disassembler1($vmMemoryData['memory_data']);
        $disassembler2 = new Disassembler2($vmVariables);
        $dfsDisassembler = new DfsDisassembler($disassembler, $disassembler2);
        $dfsDisassembler->disassemble();
        $instructions = $dfsDisassembler->getInstructions();
        file_put_contents("runtime/$functionIndex.instructions.serialize.txt", serialize($instructions));
        file_put_contents("runtime/$functionIndex.instructions.txt", Helper::printInstructions($instructions, true, true));
    } else {
        $instructions = unserialize(file_get_contents("runtime/$functionIndex.instructions.serialize.txt"));
    }
    return $instructions;
}

function getGraph($functionIndex)
{
    if (!file_exists("runtime/$functionIndex.graph.serialize.txt")) {
        $instructions = getInstructions($functionIndex);
        $graph = GraphViewer::toDirectedGraph($instructions);
        $graph->simplify();
        file_put_contents("runtime/$functionIndex.graph.serialize.txt", serialize($graph));
        file_put_contents("runtime/$functionIndex.graph.txt", Helper::printDirectedGraph($graph, true));
    } else {
        $graph = unserialize(file_get_contents("runtime/$functionIndex.graph.serialize.txt"));
    }
    return $graph;
}

function getStructuredInstructions($functionIndex)
{
    if (!file_exists("runtime/$functionIndex.structure.serialize.txt")) {
        $graph = getGraph($functionIndex);
        $simplifier = new DirectedGraphStructureSimplifier($graph);
        $graph = $simplifier->simplify();
        assert(count($graph->getVerticesId()) === 1);
        $instructions = $graph->getVertex(0);
        file_put_contents("runtime/$functionIndex.structure.serialize.txt", serialize($instructions));
        file_put_contents("runtime/$functionIndex.structure.txt", Helper::printStructuredInstructions($instructions, true));
    } else {
        $instructions = unserialize(file_get_contents("runtime/$functionIndex.structure.serialize.txt"));
    }
    return $instructions;
}