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 添加

php strtoup,PHP 7 的几处函数安全小变化相关推荐

  1. Matlab绘制小波尺度函数和小波函数

    %小波尺度函数和小波函数 clear,clc,close all; figure,[phi1,psi1,xval1] = wavefun('haar',8,'plot'); figure,[psi2, ...

  2. 【转】由滤波器系数绘制尺度函数和小波函数图像的Matlab程序

    原帖地址:http://blog.csdn.net/LiuHB1127/archive/2007/12/02/1912474.aspx function ScaleWaveFig(h) % -- 函数 ...

  3. 由滤波器系数绘制尺度函数和小波函数图像的Matlab程序

    function ScaleWaveFig(h) %   --  函数描述 : 由滤波器系数绘制尺度函数和小波函数图像 %     M : 标准化常数

  4. wpdec函数_MATLAB小波函数总结

    函数   含义                  *:小波通用函数 Allnodes   计算树结点 appcoef   提取一维小波变换低频系数 appcoef2   提取二维小波分解低频系数 be ...

  5. uni-app 结合云函数开发小程序博客(二):云函数实现登录注册

    我们研发开源了一款基于 Git 进行技术实战教程写作的工具,我们图雀社区的所有教程都是用这款工具写作而成,欢迎 Star 哦 如果你想快速了解如何使用,欢迎阅读我们的 教程文档哦 本文由图雀社区认证作 ...

  6. 小波变换的尺度函数和小波函数分析

    低频数据决定图像大致轮廓,而高频数据决定图像的清晰度 小波变换能实现傅立叶变换无法分析的非平稳信号的频谱分析.之前在对小波变换进行理解的时候,只知道是对信号进行分解.直到详细理解时,发现有尺度函数和小 ...

  7. 小程序HOOK 小程序code、小程序sessionid、小程序云函数、小程序支付二维码 支持抢购小程序模拟认证

    hook工具,支持威信3.6.0.18版本.当时小程序抢购工具开发,有小程序code功能,可实现多开,获取code.用code即可通过本地web模拟绕过服务器认证实现毫秒级抢购.还有云函数.小程序se ...

  8. excel的if函数中android,excel中if函数使用小技巧分享

    excel中if函数使用小技巧分享[案例实操] 今天有同事问到笔者一个问题:"在EXCEL中,如何使用函数实现如下功能:在A1单元格填写A,B1单元格自动填写100,当A1单元格的内容更改为 ...

  9. uni-app 结合云函数开发小程序博客(三):接入云函数,实现完善的列表刷新机制

    我们研发开源了一款基于 Git 进行技术实战教程写作的工具,我们图雀社区的所有教程都是用这款工具写作而成,欢迎 Star 哦 如果你想快速了解如何使用,欢迎阅读我们的 教程文档哦 本文由图雀社区认证作 ...

最新文章

  1. 报表需求源源不断?手把手教你提升报表通用性
  2. [CODEVS 1301] 任务分配
  3. sublime3在windows下面无法关联.py文件解决方案(转载)
  4. Linux系统下与终端相关的命令
  5. JavaScript:Browser 对象
  6. 关于××× 相关收集资料
  7. 超清晰 ,一文理解:深拷贝与浅拷贝(js)
  8. windows网络编程头文件注意事项
  9. DG半离散格式的转化---基于matlab编写
  10. 超快全球任播OCSP:白嫖谷歌云免费SSL证书!
  11. 英语句子摘抄——书虫系列
  12. r730 raid5 linux 驱动,DELL R720安装REDHAT5.1 RAID驱动问题
  13. java将时间撮转成日期,Java将时间戳转换为日期
  14. box2d的部分心得
  15. 2009 雷人记录汇总[转]
  16. Windows AD域功能介绍、Windows AD域方案介绍
  17. java面向对象实验结论及心得_20162305 实验二 Java面向对象程序设计 实验报告
  18. 如何学习一门计算机语言?
  19. LOSER_____________实现一到九的乘法表列
  20. 企业宣传720vr全景展示优化网上营销体验

热门文章

  1. 240多个jQuery常用到的插件
  2. Linux系统信息与系统资源
  3. linux板级初始化
  4. 可做fft分析吗_小吃店生意好做吗,小吃业行情分析
  5. Mybatis中的#号与$符号的区别
  6. Spring Cloud alibaba版本对应
  7. yy自动语音接待机器人_人脸签到、发言记录,会议机器人来啦
  8. 操作系统:UNIX、Linux、IOS、Android之间的渊源
  9. 服务器:Nginx - 最小配置说明
  10. h5 与原生 app 交互的原理