26-小迪安全-模块引用,mvc框架,渲染,数据联动0-rce安全

先创建一个新闻需要的库

这样id值可以逐级递增

然后随便写个值,让他输出一下看看

模板引入

但是这样不够美观,这就涉及到了引入html模板

模板引入是html有一个的地方值可以通过php代码去传入过去,其他的html界面直接调用,这样页面美观,输出查询的结果也可以显示在上面

大括号括起来的就是

这样就把php的值传递到了前端代码中显示的更美观

模板调用会造成安全问题,例如标题改成

在访问新闻网站的时候就会执行php代码

成功输出了123,这是因为在模板调用中用到哦leval函数,标题传入到这个函数中并且执行

在调用的html模板写一个php代码

也会被执行代码

为了安全的考虑就有人开发出了第三方模板

mvc模型

这样就不安全了,怎么样才能安全

下载好模板第三方插件,smarty

放在网站同一个目录,以上代码调用即可

同样在调用文件写入一个phpinfo代码

这就不会允许

最新版本没有,但是之前版本有过安全问题

复现

php 复制代码
<?php
include '../liuyanban/config.php';
$template=file_get_contents('new.html');//读取文件内容

$id=$_GET['id'] ?? '1';
$sql="select * from new where id='$id'";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_row($result)){
    $news_title=$row[1];
    $news_content=$row[3];
    $news_image=$row[4];
}

$template=str_replace('{news_title}',$news_title,$template);
$template=str_replace('{news_content}',$news_content,$template);
$template=str_replace('{news_image}',$news_image,$template);//替换括号tetle,替换内容为第二个值,替换的对象是第三个值,就上面取得文件内容
eval('?>'.$template);
html 复制代码
<!-- news_template.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新闻节目</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
        }
        .news-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            max-width: 800px;
            margin: 0 auto;
        }
        .news-title {
            font-size: 24px;
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
        }
        .news-image {
            max-width: 100%;
            height: auto;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .news-content {
            font-size: 16px;
            color: #555;
            line-height: 1.6;
        }
    </style>
</head>
<body>
<div class="news-container">
    <h1 class="news-title">{news_title}</h1>
    <img class="news-image" src="{news_image}" alt="新闻图片">
    <p class="news-content">{news_content}</p>
</div>
</body>
</html>

jian

kang

相关推荐
guyuyiqi8 分钟前
多效唑农药残留检测卡快速检测果蔬中的多效唑农药残留
科技·安全
东方隐侠安全团队-千里2 小时前
币安Skills Hub:散户的“机构级超能力“来了
安全·ai·区块链·skills
m0_738120722 小时前
渗透测试基础——基于Docker的Rsync服务靶场搭建与原理讲解
运维·服务器·网络·安全·web安全·docker·容器
CoreTK芯通康EMC整改2 小时前
PCB 信号回流路径 EMC 失效深度解析:原理、误区与量产级整改方案
网络·经验分享·安全·emc整改案例·emc整改
Dola_Zou3 小时前
边缘智能的“黑暗森林”:工业 AI 模型下沉的资产防护与变现密码
人工智能·安全·自动化·软件工程·软件加密
阿部多瑞 ABU3 小时前
数据循环悖论:AI检测模型的技术局限与生态灾难
大数据·人工智能·安全·机器学习·ai·自然语言处理
xhtdj3 小时前
Uber 如何通过批处理实现单账户每秒30+次更新
大数据·数据库·人工智能·安全·动态规划
鸿翼Macrowing4 小时前
OpenContent™ AI InDrive 智能网盘:以安全外发方案,打通企业内外协作闭环
安全·企业网盘·ai ready data
IpdataCloud4 小时前
跨境支付如何识别高风险IP?用IP风险画像服务选型与集成指南
服务器·网络·数据库·tcp/ip·安全
rsuhbsrjms5 小时前
可视耳勺靠谱吗?无线可视挖耳勺安全吗?口碑好的可视耳勺
人工智能·安全