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.pswp.cn/news/275675.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/275675.shtml
英文地址,請注明出處:http://en.pswp.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…