
楼主并没有学过编译原理、数据结构、汇编语言等等的课程,本文纯属自己想出来的东西,并不一定是最优的解决方案,欢迎大家回帖交流
上回书说道,我们已经分析出来了代码的一些功能了,也有部分化的反编译成果了。
总而言之,我们的目标是可行的,我们可以继续做下去。
首先我们根据上回的分析手动整理出了一套指令集,整理指令集这个过程谁也帮不了你。我用了 4 天时间破解了这个加密方式,想想编写这套加密方式的人说不定可能要花上一个多月呢,想想 4 天也不算太多哈。

看看左侧那一堆 .1 .2 .3 你就知道我尝试了多少种方法来编写这堆东西。
可以参考一下附件的文件,我这里只讲一部分,其他请自行分析。
这个函数是我统一用来记录反编译之后结果的。注意 $eip - 6,上回分析过,1 字节秘钥,4 字节指令,1 字节指令长度,指令长度都是 6,同时我们要以指令开始处作为引用的基准,所以统一减去 6。
protected function dasmLine($eip, $asm, $args = [])
{
$this->asm[$eip - 6] = [
'asm' => $asm,
'args' => $args,
];
}
由于这套指令集大部分都是无操作数的指令,部分是以下 1 字节为立即数的指令,部分是以下 2 字节为立即数的指令,另外还有少量其他类型立即数的指令,我这里使用了 php 的魔术方法 __call 就是对部分函数统一处理
public function __call($name, $arguments)
{
if (in_array($name, ['func7', 'func8', 'func10', 'func20', 'func33', 'func35', 'fun1', 'fun4', 'func56'])) {
// 1 字节立即数
$this->dasmLine($arguments[0], $this->asmMap[$name], [$this->getInt($arguments[0], 1)]);
return 1;
} elseif (in_array($name, ['func1', 'func16'])) {
// 2 字节立即数
$this->dasmLine($arguments[0], $this->asmMap[$name], [$this->getInt($arguments[0], 2)]);
return 2;
} elseif (method_exists($this, '_' . $name)) {
// 特殊指令
$result = $this->{'_' . $name}($arguments[0], $this->asmMap[$name]);
$this->dasmLine($arguments[0], $this->asmMap[$name], $result[1]);
return $result[0];
} elseif (isset($this->asmMap[$name])) {
// 无操作数指令
$this->dasmLine($arguments[0], $this->asmMap[$name]);
return 0;
} else {
throw new \Exception('Call undefined function ' . $name);
}
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-67089-1.html
不知道怎么火的
好你们继续掐再给中国十年发展时间
雷不丝