search
Homephp教程php手册如何禁用php eval

如何禁用php eval

Jun 06, 2016 pm 08:09 PM
devalphpphp.inihowDisableset 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

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

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

最后重启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
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

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor