吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 619|回复: 7
收起左侧

[求助] 简单的php解密求解

[复制链接]
gqdsc 发表于 2024-12-16 11:21
40吾爱币
本帖最后由 gqdsc 于 2024-12-17 11:00 编辑

一简单的php混淆加密,参考大神@Ganlv @willydong,https://www.52pojie.cn/thread-794057-1-1.htmlhttps://www.52pojie.cn/thread-693941-1-1.html的帖子,用vscode调试,能清晰的看到一些关键字,比如base64、md5等,然后用F11调试,能看到揭密支后的代码,但我想做个自动解密的,尝试替换那些乱码,发现保存后运行报错,恳请大神指点下思路,非常感谢。(附件下载:https://sbys.lanzoub.com/iiLJY2i8gwmj
我的调试截图:
1.png
2.png
3.png



附件下载:
https://sbys.lanzoub.com/iiLJY2i8gwmj

最佳答案

查看完整内容

[md]划重点:**简单的php**。人生苦短,我用Python。 使用`conda`配置环境。 ```bash conda create -n venv python=3.10 conda-forge::php=7.3 conda activate venv ``` 编写代码。 ```py import os with open("db.php", "rb") as f: db = f.read() assert db.count(b"@eval(") == 1 assert db.count(b");unset(") == 1 s = db.index(b"@eval(") + 0 e = db.index(b");unset(") + 2 db_eval2fwri ...

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

周易 发表于 2024-12-16 11:21

划重点:简单的php。人生苦短,我用Python。

使用conda配置环境。

conda create -n venv python=3.10 conda-forge::php=7.3
conda activate venv

编写代码。

import os

with open("db.php", "rb") as f:
    db = f.read()

assert db.count(b"@eval(") == 1
assert db.count(b");unset(") == 1
s = db.index(b"@eval(") + 0
e = db.index(b");unset(") + 2

db_eval2fwrite_1 = db.replace(b"@eval(", b'fwrite(fopen("db_1.fwrite","wb"),')
with open("db_eval2fwrite_1.php", "wb") as f:
    f.write(db_eval2fwrite_1)

os.system("php db_eval2fwrite_1.php")

with open("db_1.fwrite", "rb") as f:
    db_1 = f.read()

assert db_1.count(b" eval(") == 1

db_1 = b'fwrite(fopen("db_2.fwrite","wb"),' + db_1[db_1.index(b" eval(") + 6 :]

db_eval2fwrite_2 = db[:s] + db_1 + db[e:]
with open("db_eval2fwrite_2.php", "wb") as f:
    f.write(db_eval2fwrite_2)
os.system("php db_eval2fwrite_2.php")

with open("db_2.fwrite", "rb") as f:
    db_2 = f.read()

with open("result.php", "wb") as f:
    f.write(b"<?php\n" + db_2)

运行结果。

<?php
require_once ("config.php");

   $dbConn = new mysqli(DB_HOST,DB_USER,DB_PASSWORD, DB_NAME, DB_PORT);

                if (mysqli_connect_errno($dbConn)) 
        { 
           echo "连接 MySQL 失败: " . mysqli_connect_error(); 
        }   

            if ($dbConn->connect_error) {  

                                throw new Exception($dbConn->connect_error, $dbConn->connect_errno);  

            }
netcsk 发表于 2024-12-16 13:58
 楼主| gqdsc 发表于 2024-12-16 16:18
netcsk 发表于 2024-12-16 13:58
eval 里面的打印成字符串不就行了吗

修改下保存就是乱码执行不了。还有我想要做个自动解密的,因为有好多文件~~
 楼主| gqdsc 发表于 2024-12-17 10:12
netcsk 发表于 2024-12-16 13:58
eval 里面的打印成字符串不就行了吗

我只要一修改文件,哪怕删掉下注释,文件就不执行了,应该有md5或者是保存的字符出现了问题,能指教下吗

点评

编码问题,可以使用二进制方式编辑。  发表于 2024-12-17 20:41
 楼主| gqdsc 发表于 2024-12-18 14:18
周易 发表于 2024-12-16 11:21
[md]划重点:**简单的php**。人生苦短,我用Python。

使用`conda`配置环境。

太感谢老大了,果然可以。顺便请教下,我用AI改成php代码,怎么就不行咧?之前我也尝试用php替换eval,但没有成功。
 楼主| gqdsc 发表于 2024-12-18 14:20
ai转换成的php代码:<?php

// 读取db.php文件内容
$db = file_get_contents("db.php");

// 检查@eval(" 和 ");unset(" 的数量
assert(substr_count($db, "@eval(") == 1);
assert(substr_count($db, ");unset(") == 1);

// 找到@eval(" 和 ");unset(" 的位置
$s = strpos($db, "@eval(");
$e = strpos($db, ");unset(");

// 替换@eval(" 为fwrite(fopen("db_1.fwrite","wb"),
$db_eval2fwrite_1 = str_replace("@eval(", 'fwrite(fopen("db_1.fwrite","wb"),', $db);

// 将修改后的内容写入db_eval2fwrite_1.php文件
file_put_contents("db_eval2fwrite_1.php", $db_eval2fwrite_1);

// 执行db_eval2fwrite_1.php
shell_exec("php db_eval2fwrite_1.php");

// 读取db_1.fwrite文件内容
$db_1 = file_get_contents("db_1.fwrite");

// 检查 eval(" 的数量
assert(substr_count($db_1, " eval(") == 1);

// 找到 eval(" 的位置并替换
$db_1_start_index = strpos($db_1, " eval(") + 6;
$db_1_new = 'fwrite(fopen("db_2.fwrite","wb"),' . substr($db_1, $db_1_start_index);

// 构建新的db_eval2fwrite_2内容
$db_eval2fwrite_2 = substr($db, 0, $s) . $db_1_new . substr($db, $e);

// 将新的内容写入db_eval2fwrite_2.php文件
file_put_contents("db_eval2fwrite_2.php", $db_eval2fwrite_2);

// 执行db_eval2fwrite_2.php
shell_exec("php db_eval2fwrite_2.php");

// 读取db_2.fwrite文件内容
$db_2 = file_get_contents("db_2.fwrite");

// 将最终内容写入result.php文件
file_put_contents("result.php", "<?php\n" . $db_2);

?>
执行之后是空的
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-25 11:28

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表