Ocultando PHP
En un anterior post expliqué cómo ocultar los detalles de versión que suministraba Apache en las cabeceras de solicitud HTTP. Ahora si tenemos PHP instalado, hay información de éste dentro de la cabecera, que puede resultar de ayuda a un cracker.
Una cabecera sin la firma del servidor web pero con información de PHP luce así
HTTP/1.0 200 OK
Date: Fri, 04 Jan 2008 14:25:36 GMT
Server: Apache
X-Powered-By: PHP/5.2.1
X-Pingback: http://localhost
Connection: close
Content-Type: text/html; charset=UTF-8
Para deshabilitar esa información hay que ir a /etc/php5/apache2 y editamos el archivo php.ini
#nano php.ini
Ahora debemos cambiar el valor de la opción expose_php de On a Off
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
expose_php = Off
Guardamos la nueva configuración y reiniciamos el servidor
#etc/init.d/apache2 restart
Y listo, ahora podríamos hacer una prueba para ver si no es suministrada la información de PHP.
#telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.0 200 OK
Date: Fri, 04 Jan 2008 14:29:24 GMT
Server: Apache
X-Pingback: http://localhost
Connection: close
Content-Type: text/html; charset=UTF-8
A desaparecido el campo X-Powered-By, el cuál informaba sobre PHP.