php strtoup,PHP 7 的几处函数安全小变化

To Begin With

最近在准备 LANCTF,想把环境迁移到 PHP 7,却想到一些 payload 失效了。想着什么时候总结成一个笔记,恰巧在 FB 发现有人写了一篇博文,拜读后结合 CTF 环境整理了一下,总体来说,弃用了较多不安全的使用方式,但运行环境未过多限制时仍可使用。

测试环境

docker pull php:7.3.3-apache

docker pull php:7.0-apache

函数变化

preg_replace

preg_replace() 不再支持 /e 修饰符,官方曾提到

如果设置了这个被弃用的修饰符, preg_replace() 在进行了对替换字符串的 后向引用替换之后, 将替换后的字符串作为php 代码评估执行(eval 函数方式),并使用执行结果 作为实际参与替换的字符串。单引号、双引号、反斜线(\)和 NULL 字符在后向引用替换时会被用反斜线转义。

Version

Description

7.0.0

Support for the /e modifier has been removed. Use preg_replace_callback() instead.

5.5.0

The /e modifier is deprecated. Use preg_replace_callback() instead. See the PREG_REPLACE_EVAL documentation for additional information about security risks.

但在 php 7.0 时,移除了(removed)该修饰符,不能再使用此方式的后门。

create_function

create_function 被废弃 php7.2

Warning

This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

但目前还是弃用状态,在简单环境下仍可以使用该函数,但在未来的版本中会被移除。后面出现的相似情况不再赘述。

mysql_*

需要使用 mysqli 或者 pdo

unserialize

unserialize 第二个参数( optional )添加了白名单。可以通过unserialize的过滤参数来设定是否过滤指定的类返回__PHP_Incomplete_Class_Name类的对象,__PHP_Incomplete_Class_Name是一个没有方法的类。具体的参数为allowed_classes,其指向需要过滤的类,默认是true,既可以对所有类都可以完全反序列化。

$data = unserialize($serializedObj1 , ["allowed_classes" => true]);

$data2 = unserialize($serializedObj2 , ["allowed_classes" => ["MyClass1", "MyClass2"]]);

assert

第一个参数为 string 断言的情况被废弃。

Warning: Cannot call assert() with string argument dynamically (after 7.0)[6]

Version

Description

7.2.0

Usage of a string as the assertion became deprecated. It now emits an E_DEPRECATED notice when both assert.active and zend.assertions are set to 1.

7.0.0

assert() is now a language construct and not a function. assertion can now be an expression. The second parameter is now interpreted either as an exception (if a Throwable object is given), or as the description supported from PHP 5.4.8 onwards.

目前尚可使用。

parse_str

Warning

Using this function without the result parameter is highly DISCOURAGED and DEPRECATED as of PHP 7.2.

Dynamically setting variables in function's scope suffers from exactly same problems as register_globals.

Read section on security of Using Register Globals explaining why it is dangerous.

没有第二个参数的使用方式被弃用,将来第二个参数会是必选。

Version

Description

7.2.0

Usage of parse_str() without a second parameter now emits an E_DEPRECATED notice.

session_start

BabyPHP

Please input your name:

highlight_file(__FILE__);

ob_start();

error_reporting(0);

ini_set('open_basedir', '/var/www/html:/tmp');

$file = 'function.php';

$func = isset($_GET['function'])?$_GET['function']:'filters';

call_user_func($func,$_GET);

include($file);

session_start();

$_SESSION['name'] = $_POST['name'];

if($_SESSION['name']=='admin'){

header('location:admin.php');

}

?>

dl

dl 函数由 enable_dl 影响。

This directive is really only useful in the Apache module version of PHP. You can turn dynamic loading of PHP extensions with dl() on and off per virtual server or per directory.

Version

Description

7.0.0

dl() is disabled in PHP-FPM.

5.3.9

dl() is enabled in PHP-FPM, albeit discouraged.

5.3.0

dl() is now disabled in some SAPIs due to stability issues. The only SAPIs that allow dl() are CLI and Embed. Use the Extension Loading Directives instead.

杂项

十六进制字符串

如:'0x0e12345' 不再是弱类型

移除了 ASP 和 script PHP 标签

即、不再支持,只能使用<?php ?>、= ?>。

此外 ?>需要看是否开启短标签。

无引号字符串

PHP 7.2 废弃

不带引号的字符串是不存在的全局常量,转化成他们自身的字符串。 在以前,该行为会产生 E_NOTICE,但现在会产生 E_WARNING。在下一个 PHP 主版本中,将抛出 Error 异常。

花括号偏移访问

PHP 7.4 废弃。Array and string offset access using curly braces

The array and string offset access syntax using curly braces is deprecated. Use $var[$idx] instead of $var{$idx}.

allow_url_include ini directive

PHP 7.4 废弃

Enabling it will generate a deprecation notice at startup.

FFI

PHP 7.4 添加

FFI is a new extension, which provides a simple way to call native functions, access native variables, and create/access data structures defined in C libraries.

OPcache preload

PHP 7.4 添加

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/275675.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Node.js 框架设计及企业 Node.js 基础建设相关讨论

大家好&#xff0c;我是若川。19年我写的 lodash源码 文章投稿到海镜大神知乎专栏竟然通过了&#xff0c;后来20年海镜大神还star了我的博客&#xff0c;同时还转发了我的微博。时间真快啊。今天分享这篇Node.js的讨论。2021 年上半年早已过去&#xff0c;回顾 Node.js 在国内的…

DAS、NAS、SAN、iSCSI 存储方案概述

目前服务器所使用的专业存储方案有DAS、NAS、SAN、iSCSI几种。存储根据服务器类型可以分为&#xff1a;封闭系统的存储和开放系统的存储&#xff1a; &#xff08;1&#xff09;封闭系统主要指大型机. &#xff08;2&#xff09;开放系统指基于包括Windows、UNIX、Linux等操作系…

同态加法_同态—当旧趋势突然变酷时

同态加法Designers get excited at every year’s end to see what next year’s trend is going to be. What the future of design is going to look like. What they can carry forward to the next year; And Neumorphism was one among the lists which gained great atte…

网页标题设置,为什么在SERP中,显示结果不一致?

在网站建设与运营的过程中&#xff0c;我们经常会遇到各种各样的问题&#xff0c;特别是关于网页标题设置的问题&#xff0c;如果一个页面标题出错&#xff0c;那么&#xff0c;你整个页面建设的过程&#xff0c;就完全是事倍功半&#xff0c;得不偿失。 那么&#xff0c;网页标…

阿里专有钉钉前端面试指南

大家好&#xff0c;我是若川。今天推荐这篇掘金高赞文章&#xff0c;欢迎留言交流。经作者子奕大佬授权转载&#xff0c;原文链接&#xff1a;https://juejin.cn/post/6986436944913924103作者介绍子弈[1]&#xff0c;专有钉钉前端团队成员&#xff0c;负责专有钉钉 PC 客户端的…

安全态势感知产品对比_设计中的对比和人的感知

安全态势感知产品对比In this article, we’re going to explore the concept of contrast and its fundamental role in UX and visual design.在本文中&#xff0c;我们将探讨对比度的概念及其在UX和视觉设计中的基本作用。 Let’s start by defining what contrast is.让我…

在字节做前端一年后,有啥收获~

大家好&#xff0c;我是若川。今天分享这篇&#xff0c;相信读完会有些收获。本文经作者授权转载&#xff0c;原文链接&#xff1a;https://juejin.cn/post/6980671091526074404个人简介19年底12月进入字节实习&#xff0c; 第二年7月毕业转正。到前几天正好全职一周年。进入公…

app用户隐私协议相关法律_隐私图标和法律设计

app用户隐私协议相关法律During its 2020 Worldwide Developers Conference, Apple spent time on one of today’s hottest topics — privacy. During the past couple of years, Apple has been rolling out various public campaigns aiming to position itself as a compa…

HTTP referer

简言之&#xff0c;HTTP Referer是header的一部分&#xff0c;当浏览器向web服务器发送请求的时候&#xff0c;一般会带上Referer&#xff0c;告诉服务器我是从哪个页面链接过来的&#xff0c;服务器籍此可以获得一些信息用于处理。比如从我主页上链接到一个朋友那里&#xff0…

ecshop模板支持php,[老杨原创]关于ECSHOP模板架设的服务器php版本过高报错的解决方法集合...

1、admin/index.phpadmin/sms_url.php报错&#xff1a;Strict Standards: mktime(): You should be using the time() function instead in /data/web/ledetaoadmin/sms_url.php on line 31$auth mktime();替换为&#xff1a;$auth time();报错&#xff1a;Strict Standards:…

35 点击全图后发现地图“不见了”

相信很多用ArcGIS软件作图的时候会习惯用全图按钮&#xff0c;但是有的时候工程文件是他人提供的&#xff0c;也不太清楚是怎么做的&#xff0c;一点全图&#xff0c;软件界面就一片空白&#xff0c;找数据找半天&#xff0c;很是苦恼啊 这虽然不是什么大问题&#xff0c;但还是…

成为优秀沟通者的要素_如果您想成为更好的设计师,请成为更好的沟通者

成为优秀沟通者的要素Little changes that go a long way.小变化大有帮助。 I started my career in motion design.我的职业生涯始于运动设计。 My focus was on the visual and technical skills required to make emotionally compelling work. I believed great design s…

我读源码的经历~

你好&#xff0c;我是若川。最近来了一些读者朋友&#xff0c;在这里简单介绍自己的经历&#xff0c;也许对你有些启发。可以点击 ruochuan12 加我微信进群交流。这是我的公众号卡片&#xff0c;可以加下星标。我是谁我是若川&#xff0c;毕业于江西高校&#xff0c;《面试官问…

DEDECMS 5.6整合Discuz_X1.5的方法

DEDECMS 5.6整合Discuz_X1.5的方法 听朋友的建议&#xff0c;为了网站继续发展&#xff0c;准备整合一个论坛。我准备将DEDECMS 5.6与Discuz_X1.5进行整合&#xff0c;我先是在网站查找了一些资料&#xff0c;可能是技术太菜&#xff0c;竟然没有成功。经过几个高手的指点现在终…

php建一个表按删除就删除,php怎样删除数据库表_后端开发

php删除数据库表的要领&#xff1a;起首建立一个PHP示例文件&#xff1b;然后衔接mysql数据库&#xff1b;末了经由过程“DROP TABLE runoob_tbl”语句删除MySQL数据表即可。引荐&#xff1a;《PHP视频教程》php MySQL 删除数据表MySQL中删除数据表是异常轻易操纵的&#xff0c…

Android 应用安全性改进: 全面助力打造 零漏洞 应用

作者 / Patrick Mutchler 和 Meghan Kelly, Android 安全和隐私团队 帮助 Android 应用开发者构建 "零漏洞" 的安全应用有助于推动整个生态系统的健康发展。所以&#xff0c;我们在 5 年前启动了应用安全改进计划&#xff0c;项目发展至今&#xff0c;收获了许多成功…

字节招人

大家好&#xff0c;我是若川。这应该是第五次发招聘了&#xff0c;友情帮一个朋友宣传。普通高校的很多大学生因为信息差导致慢一两年才醒悟过来&#xff0c;原来大三就有校招了。如果能早些知道早做准备&#xff0c;结果可能会更好。而知名高校&#xff0c;身边很大学长学姐进…

人工智能和Adobe Sensei

Adobe概述 (Adobe Overview) The design process changes from person to person, practice to practice, and profession to profession. As we advance further into the 21st century, the design process for many people leans heavily on technology. Adobe leads the ch…

php如何生成公钥私钥,php如何生成公钥私钥(代码)

本篇文章给大家带来的内容是关于php如何生成公钥私钥(代码)&#xff0c;有一定的参考价值&#xff0c;有需要的朋友可以参考一下&#xff0c;希望对你有所帮助。//http://www.lampol-blog.com/detail/aid/ZDk5MmFNZ2pJL1pROW5QZU9KZ2FWdVlFTDVHRnRmZm4rNDMzSFlHNg%3D%3D 各种秘…

表达能力VS只会敲代码(2018届毕业生web前端)

2018年3月份开始在杭州实习&#xff0c;七月毕业&#xff08;计算机科学与技术专业&#xff09;&#xff0c;从事 web前端开发 到现在工作也一年了&#xff01;实际经验最多也只有一年罢了&#xff01; 一年来技术栈经历了 reactreact-routerreduxreact-reduxvuevuexvue-router…