一个恶臭的Webshell

项目地址:https://github.com/KawaiiSh1zuku/PHP114514Shell
为什么删了?因为我发现我 shell 里的密码不太好泄露

分析

php 中有一个小小的特性:利用 $$abc 对以 $abc 的值为名字的变量进行赋值,可以以此污染变量。

1
foreach($_POST as $key => $value) $$key = $value;

这段语句就会将 POST 的所有参数设置为变量。
以此为基础可以写出简单的分支对抗语句

1
2
3
4
5
6
7
8
9
10
11
12
foreach($_POST as $key => $value) $$key = $value;
if ($sqlcheck) {
$checker = new sql_security(); // 注意这个类名
if(!$checker -> check_sql($sql)) {
die("杂鱼~杂鱼");
} else {
die("SQL is safe");
}
} else {
$checker = new sql_checker(); // 注意这个类名 和上面是不是不太一样
$checker -> __init__($sql, $sha);
}

然后,可以利用 PHP 子类函数覆盖的特性,构造两个类。一个是正常代码一个是恶意代码。
sql_checker 类继承了 sql_security 类,拥有其中的成员函数,在这里构造恶意代码进行执行。
接下来论证了一段恶臭数字

1
2
3
private function randomInt(){
//此处随意论证数字,只要你能写函数把数字解密出来就ok
}

别以为这是真的 random 嗷,这是用来对付某些只有字符串特征的引擎的。
以生成的数字解密出 system 函数就可以调用了。

一个恶臭的Webshell

https://omn.cc/archives/59.html

作者

空指针

发布于

2024-02-01

更新于

2024-02-01

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×