1
0
mirror of https://github.com/php/doc-zh.git synced 2026-03-23 22:52:08 +01:00
Files
archived-doc-zh/security/hiding.xml
魔王卷子 f33cef6bd5 更新枚举到最新 (#158)
* 更新

* fixed typo

* 翻译隐藏 PHP

* fixed typo

* 更新

* 更新

* Update enumerations.xml

* Update current.xml

* 更新

* Update hiding.xml

Co-authored-by: DAI JIE <daijie@php.net>
2022-01-02 20:41:32 +08:00

75 lines
2.6 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- $Author$ -->
<!-- EN-Revision: ab6785b01ce1006e3a9761988575289f40c9b678 Maintainer: lm92 Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<chapter xml:id="security.hiding" xmlns="http://docbook.org/ns/docbook">
<title>隐藏 PHP</title>
<para>
一般而言,通过隐藏来实现安全是最脆弱的安全方式之一。但在某些情况下,每一点额外的安全都是值得的。
</para>
<para>
一些简单的方法可以帮助隐藏 <acronym>PHP</acronym>,这可能会减慢攻击者试图找到系统弱点的速度。
通过在 &php.ini; 文件中设置 expose_php 为 <literal>off</literal>
可以减少能获得的有用信息。
</para>
<para>
另一个策略是配置 web 服务器(例如 apache通过 <acronym>PHP</acronym> 解析不同的文件类型,
无论是通过 &htaccess; 文件还是 apache 的配置文件,都可以设置能误导攻击者的文件扩展名:
<example>
<title>把 PHP 隐藏为另一种语言</title>
<programlisting role="apache-conf">
<![CDATA[
# 使 PHP 代码看起来像其他代码类型
AddType application/x-httpd-php .asp .py .pl
]]>
</programlisting>
</example>
或者干脆彻底隐藏它:
<example>
<title>使用未知的扩展名作为 PHP 的扩展名</title>
<programlisting role="apache-conf">
<![CDATA[
# 使 PHP 代码看起来像未知的类型
AddType application/x-httpd-php .bop .foo .133t
]]>
</programlisting>
</example>
或者隐藏它为 <acronym>HTML</acronym> 代码,这样会有轻微的性能影响,因为所有的
<acronym>HTML</acronym> 都将通过 <acronym>PHP</acronym> 引擎进行解析:
<example>
<title>使用 <acronym>HTML</acronym> 作为 PHP 扩展名</title>
<programlisting role="apache-conf">
<![CDATA[
# 使所有的 PHP 代码看起来像 HTML
AddType application/x-httpd-php .htm .html
]]>
</programlisting>
</example>
要让此方法生效,必须把 <acronym>PHP</acronym>
文件的扩展名改为以上的扩展名。这样就通过隐藏来提高了安全性,这是一个小的预防措施,几乎没有缺点。
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->