Home php教程 php手册 如何禁用php eval

如何禁用php eval

Jun 06, 2016 pm 08:09 PM
d eval php php.ini how Disable set up

在php.ini中这样设置disable_functions =eval是无法禁用eval的,根据php手册说明,eval是一个语言构造器而不是一个函数。 如果要禁用eval,则需要第三方扩展,使用Suhosin。 Suhosin是朝鲜语“守护神”的音译,是一个专门的安全小组开发的专门针对php进行安

在php.ini中这样设置disable_functions =eval是无法禁用eval的,根据php手册说明,eval是一个语言构造器而不是一个函数。

如果要禁用eval,则需要第三方扩展,使用Suhosin。

Suhosin是朝鲜语“守护神”的音译,是一个专门的安全小组开发的专门针对php进行安全加固的补丁程 序,已经进入freebsd gentoo的ports系统。效果很好的。

Suhosin是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。我个人强烈你建议静态联编。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展。

# cd /usr/local/src
# wget http://cn.php.net/get/php-5.2.5.tar.gz/from/this/mirror
wget http://www.hardened-php.net/suhosin/_media/suhosin-patch-5.2.5-0.9.6.2.patch.gz //从官方下载补丁
# tar zxvf php-5.2.5.tar.gz
# gunzip suhosin-patch-5.2.5-0.9.6.2.patch.gz // 解压补丁
# cd php-5.2.5
# patch -p 1 -i ../suhosin-patch-5.2.5-0.9.6.2.patch // 给php打上补丁
# ./buildconf --force //一定要执行这一步。
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-bz2 --with-tiff-dir --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2 --with-freetype-dir --with-jpeg-dir --with-png-dir --with-ttf --enable-mbstring --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/etc --with-iconv --disable-ipv6 --enable-static --enable-maintainer-zts --enable-memory-limit --enable-zend-multibyte --enable-sockets --enable-soap --enable-suhosin // 配置选项
# make
# make install
重启apachectl,查看phpinfo信息,会出现
This server is protected with the Suhosin Patch 0.9.6.2
Copyright (c) 2006 Hardened-PHP Project
等许多Suhosin信息那么你就成功了。呵呵。
在这里也顺便说一下将suhosin安装成为php的动态扩展的方法。
wget http://download.suhosin.org/suhosin-0.9.23.tgz
tar zxvfsuhosin-0.9.23.tgz
cd suhosin-0.9.23
/usr/local/php/bin/phpize //这一步不能省
./configure --with-php-config=/usr/local/php/bin/php-config //必须在这儿注明php-config所在的绝对路径。
make
make install
会提示编译的模块存在的目录,记住它。
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
然后在php.ini中增加一行下列语句。
extension=suhosin.so
suhosin.executor.disable_eval = on
Copy after login

如果对于部分业务需要运行eval咋办?如果是 PHP 5.3+ 且 CGI/FastCGI 方式运行,可以这么改 php.ini,则可以破例使用? eval
操作方法:

suhosin.executor.disable_eval = on
[PATH=/htdocs/www/ex1/]
suhosin.executor.disable_eval = off
Copy after login

最后重启php-fpm 即可!

如何禁用php eval 在php.ini中这样设置disable_functions =eval是无法禁用eval的,根据php手册说明,eval是一个语言构造器而不是一个函数。 如果要禁用eval,则需要第三方扩展,使用Suhosin。 Suhosin是朝鲜语“守护神”的音译,是一个专门的安全小组开发的专门针对php进行安全加固的补丁程 序,已经进入freebsd gentoo的ports系统。效果很好的。 Suhosin是php增强型安全补丁,可以编译到静态内核中,也可以编译成php动态扩展。我个人强烈你建议静态联编。下面的以下先说静态安装步骤。当然你也可以在安装php后将它编译成php的动态扩展。 如果对于部分业务需要运行eval咋办?如果是 PHP 5.3+ 且 CGI/FastCGI 方式运行,可以这么改 php.ini,则可以破例使用? eval 操作方法: 最后重启php-fpm 即可!如何禁用php eval
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles