MANUAL DE PHP

(y algo mas)windsurf pozo izquierdo
Google
search for in the  
ELMARRAJO.COM mysql bulma desarrollo web linux fedora html ayuda

windsurf mercedes camper

Capítulo 32. Ocultando PHP

En general, la seguridad por oscuridad es una de las formas más débiles de seguridad. Pero, en algunos casos, cada pequeño elemento extra de seguridad es deseable.

Unas cuantas técnicas simples pueden ayudarle a esconder PHP, posiblemente retrasando a un atacante que esté intentando descubrir debilidades en su sistema. Al establecer expose_php = off en su archivo php.ini, usted reduce la cantidad de información disponible a posibles atacantes.

Otra táctica consiste en configurar los servidores web como apache para que procesen diferentes tipos de archivos como scripts de PHP, ya sea con una directiva .htaccess, o en el archivo de configuración de apache mismo. En ese caso puede usar extensiones de archivo que produzcan confusión:

Ejemplo 32-1. Ocultando PHP como otro lenguaje

# Hacer que el codigo PHP parezca como otro tipo de codigo
AddType application/x-httpd-php .asp .py .pl
U ocultarlo completamente:

Ejemplo 32-2. Uso de tipos desconocidos como extensiones para PHP

# Hacer que el codigo PHP parezca como de tipos desconocidos
AddType application/x-httpd-php .bop .foo .133t
O escóndalo como código HTML, lo que tiene un pequeño impacto de rendimiento ya que todos los documentos HTML serán procesados por el motor de PHP:

Ejemplo 32-3. Uso de tipos HTML para extensiones PHP

# Hacer que todo el codigo PHP luzca como HTML
AddType application/x-httpd-php .htm .html
Para que esto funcione de manera efectiva, usted debe renombrar sus archivos PHP con las extensiones anteriores. Aunque es una forma de seguridad por oscuridad, representa una medida preventiva menor con pocos inconvenientes.



add a note add a note User Contributed Notes
Ocultando PHP
simon at carbontwelevedesign dot co dot uk
10-Aug-2006 05:31
I use the following in the .htaccess document

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /http://indices.com.es/index.html [L]
</IfModule>

then the following simple code

<?php

$permalinks
= explode("/",$_SERVER['REQUEST_URI']);

$varone = $permalinks[1];
$vartwo = $permalinks[2];

...

?>
marpetr at NOSPAM dot gmail dot com
11-Apr-2006 05:18
I think the best way to hide PHP on Apache and Apache itself is this:

httpd.conf
-------------
# ...
# Minimize 'Server' header information
ServerTokens Prod
# Disable server signature on server generated pages
ServerSignature Off
# ...
# Set default file type to PHP
DefaultType application/x-httpd-php
# ...

php.ini
------------
; ...
expose_php = Off
; ...

Now the URLs will look like this:
http://my.server.com/forums/post?forumid=15

Now hacker knows only that you are using Apache.
ahmad at unikomcenter dot com
05-Mar-2006 10:05
I am use this script to hidding PHP:

http://indices.com.es/index.html
--------------
<?php

// PARSING QUERY STRING
$QS=explode("&",$_SERVER['QUERY_STRING']);
$QS=explode('/',$QS[0]);

// IF Modul is Undefined set it to index
if (!$QS[0]) $MODUL='index';
else
$MODUL=strtolower($QS[0]);

// WE can make a Variable $_QUERY
// for alternative _GET
for ($i=1;$i<count($QS);$i+=2)
{
  
$_QUERY[$NVAR]=$NVAR=$QS[$i];
   $
$NVAR=$QS[$i+1];
}

// Check the Modul is exists?
if (!file_exists("modul_directory/{$MODUL}.php"))
  
$MODUL="index";

#### THIS IS EXAMPLE TO IMPLEMENTATION THE SCRIPT
// Load The Template
include("template.php");
// Load The Module
include("modul_directory/{$MODUL}.php");
// Load The Footer
include("footer.php");

?>

we can access the modul in URL like this:
=================================

www.example.com/?forum/topic/20
- it mean load the modul forum.php, and set the _QUERY['topic']=20

www.foo.com/?voting/id/54/type/piechart&choice=2
- it mean load the modul voting.php, and set the _QUERY['id']=54 and _QUERY['type']='piechart' and set _GET['choice']=2
eric at ericwing dot net
20-Jan-2006 09:20
Something that has not been mentioned here is also the PHPSESSION id that will be displayed in the URL when passing it from page to page using GET.  If users have cookies set to off, this will be visible. This can be reset before any session_start() call with ini_set(). Be aware however that this can't be changed in this way if you use autho session start.
dyer85 at gmail dot com
31-Dec-2005 12:55
Although it's probably obvious to most people, Yavuz Darendelioglu's post below utilizes a method that will only work on a *nix OS, not Windows, and probably not Mac.

Also, his regex uses some superfluous matching, instead, write the redirect like so: (you don't really need to use absolute path when redirecting to a resource on the same server, either):

RedirectMatch (?:awstats|xmlrpc) /deny.php
28-Dec-2005 07:29
Even you hide your PHP, requests for bugy scripts still come.
No matter whether you have the script on your server or not.

You can make an additional step for those requests. Since the host now trying that buggy script  then, in the future when a new bug arises it will be tried  by that host again with a high possibility. So banning that host completey at its first attempt may be a good idea. For  this,

1- Add Permanent links for those requests in your httpd.conf:
RedirectMatch permanent (.*)awstats(.*)$ http://your_server/your_script.html

RedirectMatch permanent (.*)xmlrpc(.*)$ http://your_server/your_script.html
and add whatever you want to ban.

2- Write following code in your_script.html
<?
$host
= $_SERVER['REMOTE_ADDR'];
$dropit = "iptables -A INPUT -i eth0 -p tcp -s $host -m multiport --destination-ports 80,25,22 -j DROP";
shell_exec($dropit);
exit
?>

Yavuz Darendelioglu
user at pampelhuber dot invalid
18-Dec-2005 04:32
It is unnecessary, to let every Pampelhuber inspect your 'php.ini' files.
Put the following into the .htaccess of your htdocuments' root:

#Obscure 'php.ini' files (where they exist)
RedirectMatch 404 .*php\.ini$
jtw90210
30-Jun-2005 01:19
In order to get the PATH_INFO to work in order to pass parameters using a hidden program/trailing slash/"pretty url" in more recent versions of PHP you MUST add "AcceptPathInfo On" to your httpd.conf.

AddType application/x-httpd-php .php .html
AcceptPathInfo On

Try it out with your phpinfo page and you'll be able to search for PATH_INFO.

http://yourserver.com/myphpinfo.php/showmetheway

If you want to drop the .php use one or both of these:
DefaultType application/x-httpd-php
ForceType application/x-httpd-php
25-May-2005 01:06
You could also do this in .htaccess when you use Apache and your configuration allows you to override :

<Files test>
   ForceType application/x-httpd-php
</Files>

That way, you can use the URL test?pop=true without having to fake it by using test/http://indices.com.es/index.html.

See the Apache manual for more info: http://httpd.apache.org/docs/mod/mod_mime#forcetype
benjamin at sonntag dot fr
24-May-2005 09:14
In response to the previous messages, for apache, there is a easier way to set files without "." to be executed by PHP, just put this in a ".htaccess" file :

DefaultType  application/x-httpd-php
dimitar at bastun dot net
17-Jan-2005 09:13
In case there are an Internal Server error(error 500) using the old code below in an .htaccess file, you can replace it with the code modification that must solve the problem.

Old code
-----------

<Files ~ "^[^\.]+$">
       ForceType application/x-httpd-php
</Files>

Replacement of the code above(code modification)
------------------------------------------------------------

AddHandler server-parsed .php
<Files ~ "^[^\.]+$">
SetHandler application/x-httpd-php
</Files>

Regards,
Dimitar Tanev
Nikolai-Zujev-(at)-Gmail-dot-Com
22-Sep-2004 12:22
Assign files w/o extension to php interpreter
without using ReWrite module

[clip httpd.conf]

<Files ~ "^[^\.]+$">
       ForceType application/x-httpd-php
</Files>

[/clip]
php at vfmedia dot de
15-Jun-2004 06:21
I´ve found an easy way to hide php code and the uri is searchable by google and others...(only for unix or linux)

At first I have some rules in my hide.conf (i made an extra .conf for it (apache 2.0))

For example when I want to mask the http://indices.com.es/index.html

<Files index>
 ForceType application/x-httpd-php
 </Files>

My problem is, that my code should be readable...

so I made an extra folder for example srv/www/htdocs/static_output

My phpcode is in the includefolder....(for ex. mnt/source/http://indices.com.es/index.html)

Then I made a link in the shell  > ln mnt/source/http://indices.com.es/index.html srv/www/htdocs/static_output/index

So the code is readable (with .php extension) in my includefolder and there is only the link in the srv folder without extension(which is called by the browser...).
12-May-2004 08:20
Keep in mind, if your really freaked out over hiding PHP, GD will expose you.

Go ahead - make an image with GD and open with a text editor.. Somewhere in there you'll see a comment with gd & php all over it.
php at user dot net
10-Apr-2004 06:36
What about this in a .htaccess file :

RewriteEngine on
RewriteRule    ^$    /http://indices.com.es/index.html    [L]
RewriteRule    ^([a-zA-Z0-9\-\_/]*)/$    /$1/http://indices.com.es/index.html    [L]
RewriteRule    ^([a-zA-Z0-9\-\_/]*)\.(html|htm)$    /$1.php    [L]
RewriteRule    ^([a-zA-Z0-9\-\_/]*)$    /$1.php    [L]

Typing "sub.domain.foo/anything" loads "/anything/http://indices.com.es/index.html" if 'anything' is a directory, else it loads "/anything.php".

I'm sure you can find mutch better, but it works great on my site :)
mmj
14-Mar-2004 05:58
You can see if somebody's using PHP just by adding the following to the end of the URL:
?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
If the page is using PHP, this will show the PHP credits.

Setting expose_php to Off in php.ini prevents this.
Elora at alexandria dot cc
13-Feb-2004 03:30
<bminton at efn dot org>'s suggestion won't work. All someone has to do is look at "foo.com/dir/" and try "foo.com/dir/index.html", "foo.com/dir/http://indices.com.es/index.html", "foo.com/dir/index.cgi", until no 403/404 is returned.
ldemailly at qualysNOSPAM dot com
27-Oct-2003 08:17
adding MultiViews to your apache Options config
lets you hide/omit .php in the url without any rewriting, etc...
l0rdphi1 at liquefyr dot com
21-Jul-2003 04:02
More fun includes files without file extensions.

Simply add that ForceType application/x-httpd-php bit to an Apache .htaccess and you're set.

Oh yea, it gets even better when you play with stuff like the following:

substr($_SERVER['PATH_INFO'],1);

e.g. www.yoursite.com/somepage/55

And:

foreach ( explode('/',$_SERVER['PATH_INFO']) as $pair ) {
   list($key,$value) = split('=',$pair,2);
   $param[$key] = stripslashes($value);
}

e.g. www.yoursite.com/somepage/param1=value1/param2=value2/etc=etc

Enjoy =)
Bryce Nesbitt at Obviously.COM
27-Mar-2003 08:24
Using the .php extension for all your scripts is not necessary, and in fact can be harmful (by exposing too much information about your server, and by limiting what you can do in the future without breaking links). There are several ways to hide your .php script extension:

(1) Don't hard code file types at all.  Don't specify any dots, and most web servers will automatically find your .php, .html, .pdf, .gif or other matching file. This is called canonical URL format:
     www.xxxxxx.com/page
   www.xxxxxx.com/directory/
This gives you great flexibility to change your mind in the future, and prevents Windows browsers from making improper assumptions about the file type.

(2) In an Apache .htaccess file use:
   RewriteEngine on
   RewriteRule page.html page.php

(3) Force the webserver to interpret ALL .html files as .php:
   AddType application/x-httpd-php .php3 .php .html
bminton at efn dot org
27-Feb-2003 12:05
Another technique is to have every file be named http://indices.com.es/index.html and be in it's own directory.  Then instead of using for instance http://my.site/foo.php you could use http://my.site/foo/ where foo is a directory with a file called http://indices.com.es/index.html in it.
29-Jan-2003 10:53
PS. If you want to use pretty URLs (i.e. hide your .php extensions) AND you have safe-mode=on, the previous example (ForceType) won't work for you.  The problem is that safe-mode forces Apache to honor trailing characters in a requested URL.  This means that:

http://www.foo.com/home

would still be processed by the home script in our doc root, but for:

http://www.foo.com/home/contact_us.html

apache would actually look for the /home/contact_us.html file in our doc root.

The best solution I've found is to set up a virtual host (which I do for everything, even the default doc root) and override the trailing characters handling within the virtual host.  So, for a virtual host listening on port 8080, the apache directives would look like this:

<VirtualHost *:8080>
   DocumentRoot /web/doc_root
   Alias /home "/web/doc_root/home.php"
   AcceptPathInfo On
</VirtualHost>

Some people might question why we are overriding the trailing characters handling (with the AcceptPathInfo directive) instead of just turning safe-mode=off.  The reason is that safe mode sets global limitations on the entire server, which can then be turned on or left off for each specific virtual host.  This is the equivilent of blocking all connections on a firewall, and then opening up only the ones you want, which is a lot safer than leaving everything open globally, and assuming your programmers will never overlook a possible security hole.
Azureash
27-Jan-2003 04:34
Another way to hide your .php extensions is to use the Apache ForceType directive (which is often referred to as pretty URLs.)  Basically you force Apache to parse a file as PHP that matches the trailing directory name in your URL.

For example, place this directive in your Apache httpd.conf file:
<Location /home>
     ForceType application/x-httpd-php
</Location>

and create a php file name "home" in your doc root.  This file should not have a .php extension, and can be a php template file.  Combined with a function to strip out URL parameters, this can create a new templating system, which can effectively hide your file extensions.

In this example,
http://www.foo.com/home/bar.html

would actually use the home script we created, and then the "bar.html" could be used to specify content to include.
Kevin Vincent
23-Jan-2003 05:43
Just a thought but if you have changed the extensions that php interprets I would assume you've also changed header.php and footer.php files to the new extension.

EG:

http://indices.com.es/index.html, somefile.php, header.php, footer.php...

Change the Apache directive so PHP interprets .kev files and rename your files:

index.kev, somefile.kev, header.kev, footer.kev

If you leave header and footer as PHP files then it won't understand how to interpret them.
sth at panix dot com
04-Aug-2002 12:45
The flipside to this is, if you're running a version of
PHP/Apache which is not known to have exploitable bugs (usually the latest stable version at the time), and an attacker sees this, they may give up before even trying. If they don't, they may continue to attempt their exploit(s).

It really depends on the type of attacker. The educated, security advisory reading attacker vs. script kiddie on the street.

If you're keeping up on patches, version exposition should not be a problem for you.
m1tk4 at hotmail dot com
22-Jul-2002 05:53
I usually do:

<code>
RewriteEngine on<br>
RewriteOptions inherit<br>
RewriteRule (.*)\.htm[l]?(.*) $1.php$2 [nocase]<br>
</code>

in .htaccess. You'll need mod_rewrite installed for this .
yasuo_ohgaki at yahoo dot com
26-Jan-2002 03:59
To hide PHP, you need following php.ini settings

expose_php=Off
display_errors=Off

and in httpd.conf

ServerSignature Off
(min works, but I prefer off)
istvan dot takacsNOSPAM at hungax dot com
30-Dec-2001 09:42
And use the
ServerTokens min
directive in your httpd.conf to hide installed PHP modules in apache.

Citas célebres

Nuestros espejos, con el paso del tiempo, se van poniendo impertinentes.

Chumy Chúmez
Humorista español
(n. 1927)
Citas en tu mail
©Contenidos Gratis

Ilusiones Opticas
ilusion_optica_021.jpg
Contenidos Web

Chiste de... Deportes
Cuestión de pelotas

Un señor entra en una tienda de deportes y dice:

- Por favor, ¿tiene pelotas para jugar al tenis?

- Sí.

- Pues te espero mañana a las ocho.
Chistes en tu mail
©ContenidosGratis

Humor Gráfico
humor_grafico_013.jpg
Contenidos Web

Inicio | Acción | Estrategia | Palabras | Puzzles | Solitarios | Foro Trucos
Cake ManiaCake Mania
Jugadores: 6835
Categoría del juego: Acción
Objetivo del juego: Ayuda a Jill a recuperar la pastelería de su abuela llevando su propia pastelería; consigue clientes y gana dinero.
Rainbow WebRainbow Web
Jugadores: 2199
Categoría del juego: Puzzles
Objetivo del juego: Rompe un pegajoso hechizo y salva un reino de fantasía en Rainbow Web. Tendrás toneladas de diversión mientras juegas a este mágico desafío para la mente.
Mahjongg FortunaMahjongg Fortuna
Jugadores: 12462
Categoría del juego: Solitarios
Objetivo del juego: Velocidad y habilidad mental son las armas más importantes en esta versión de un antiguo juego asiático. Despeja el tablero lo antes posible haciendo clic en las fichas iguales y gánate la fama eterna de la puntuación más alta.
Chainz 2Chainz 2
Jugadores: 6955
Categoría del juego: Puzzles
Objetivo del juego: Entra en el mundo de las combinaciones con Chainz 2: Relinked, emocionante secuela del exitazo del año pasado, Chainz. Gira eslabones y crea combinaciones de 3 ó más.
DeliciousDelicious
Jugadores: 4405
Categoría del juego: Acción
Objetivo del juego: ¿Eres un as de la multitarea? ¿Quieres que tus clientes estén contentos? ¡Pues Delicious es tu juego! Sacia el apetito de los clientes y tenlos contentos; ¡no te arriesgues!
BookwormBookworm
Jugadores: 4568
Categoría del juego: Palabras
Objetivo del juego: Junta las letras para formar palabras. ¡Las palabras más largas valen más puntos!
ZumaZuma
Jugadores: 4976
Categoría del juego: Acción
Objetivo del juego: Controla el ídolo de la rana de piedra de los antiguos Zuma en este intrigante enigma de acción. ¡Dispara bolas para formar conjuntos de tres, pero si dejas que lleguen a la calavera dorada morirás!
Jewel of AtlantisJewel of Atlantis
Jugadores: 3798
Categoría del juego: Puzzles
Objetivo del juego: Descubre la ciudad hundida de la Atlántida y busca valiosos tesoros. Viaja más allá de las profundidades del mar y vive trepidantes aventuras en Jewel of Atlantis.
Jewel QuestJewel Quest
Jugadores: 3727
Categoría del juego: Puzzles
Objetivo del juego: Convierte la arena de la antigua selva en oro tan rápido como puedas juntando grupos de 3 elementos. ¡Los grupos más grandes valen más puntos!
Bejeweled 2Bejeweled 2
Jugadores: 3659
Categoría del juego: Puzzles
Objetivo del juego: Con cuatro modos de juego únicos y fascinantes, nuevas piezas de juego explosivas e imponentes fondos planetarios, Bejeweled 2 es mucho más adictivo que nunca.
Contenidos gratis en tu webSiguiente >>

Fotos divertidas
fotos_increibles_0119.jpg
Contenidos Web
microrobots avion deportes riesgo recetas cocina canaria juegos online gratis moto motociclismo horoscopos naranjas valencianas surf canarias montañismo ciudades turismo postales gratis library Horoscopos Diarios Windsurf Canarias
fregadero microondas placa electrica bañopreparar camper pantalla plananevera compresor electricacamper fiat ducato camper baño quimicomampara enrollable bañocamper aire climatizadofurgoneta surf windsurffurgoneta surf windsurftelevisor furgonetas camperfurgonetas camper cama

Sudoku del día
Nivel de dificultad: Fácil



Cómo jugar:
El juego consiste en colocar los números del 1 al nueve de tal forma que no se repita el mismo número en la columna, fila y caja (bloques 3x3 enmarcados).

©Contenidos Gratis | Sudoku en tu mail
Sucedió el...

30 de agosto de 1617

Fallece Santa Rosa de Lima, por la que se celebra el "Día de la Patrona de América".
Efemérides en tu mail
©Contenidos Gratis
windsurf canarias youtube porno canarias baleares valencia madrid