欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 前些日子一个朋友丢了个shell给我,让我帮忙解密,打开源码看了下写着是 "神盾加密" , 其实网上早就有人分析过这个了,而且写成了工具、但是我测试了很多个,没一个能用,所以决定自己从头分析一遍。
欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入
前些日子一个朋友丢了个shell给我,让我帮忙解密,打开源码看了下写着是 "神盾加密" , 其实网上早就有人分析过这个了,而且写成了工具、但是我测试了很多个,没一个能用,所以决定自己从头分析一遍。
我们来做第一步解密处理吧。
PS: 这只是我的解密思路,与大家分享一下,也许你有更好的方法还望分享
$str = file_get_contents("1.php");
// 第一步 替换所有变量
// 正则 \$[a-zA-Z_\x7f-\xff][\w\x7f-\xff]*
preg_match_all('|\$[a-zA-Z_\x7f-\xff][\w\x7f-\xff]*|', $str, $params) or die('err 0.');
$params = array_unique($params[0]); // 去重复
$replace = array();
$i = 1;
foreach ($params as $v) {
$replace[] = '$p' . $i;
tolog($v . ' => $p' . $i); // 记录到日志
$i++;
}
$str = str_replace($params, $replace, $str);
// 第二步 替换所有函数名
// 正则 function ([a-zA-Z_\x7f-\xff][\w\x7f-\xff]*)
preg_match_all('|function ([a-zA-Z_\x7f-\xff][\w\x7f-\xff]*)|', $str, $params) or die('err 0.');
$params = array_unique($params[1]); // 去重复
$replace = array();
$i = 1;
foreach ($params as $v) {
$replace[] = 'fun' . $i;
tolog($v . ' => fun' . $i); // 记录到日志
$i++;
}
$str = str_replace($params, $replace, $str);
// 第三步 替换所有不可显示字符
function tohex($m) {
$p = urlencode($m[0]); // 把所有不可见字符都转换为16进制、
$p = str_replace('%', '\x', $p);
$p = str_replace('+', ' ', $p); // urlencode 会吧 空格转换为 +
return $p;
}
$str = preg_replace_callback('|[\x00-\x08\x0e-\x1f\x7f-\xff]|s', "tohex", $str);
// 写到文件
file_put_contents("1_t1.php", $str);
function tolog($str) {
file_put_contents("replace_log.txt", $str . "\n", FILE_APPEND);
}
?>
(其中有一个记录到日志的代码,这个在之后的二次解密时有用。)
执行之后就会得到一个 1_t1.php 文件,打开文件看到类似这样的代码
找个工具格式化一下,我用的 phpstorm 自带了格式化功能,然后代码就清晰很多了。
进一步整理后得到如下代码:
//Start code decryption《===
if (!defined('IN_DECODE_82d1b9a966825e3524eb0ab6e9f21aa7')) {
define('\xA130\x8C', true);
function fun1($str, $flg="") {
if(!$flg) return(base64_decode($str));
$ret = '?';
for($i=0; $i $c = ord($str[$i]); $ret .= $c136 ? chr($c/2) : $str[$i] ) : ""; } return base64_decode($ret); } [1] [2]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor