Título: Saber si mi script es vulnerable
Publicado por: Rudy21 en 23 Abril 2007, 01:08 am
Hola aunke aprezca un intento de hacking o algo parecido no lo es asi
yo hice un SCRIPT de sistema de noticias
y no c que hicieron una inyeccion o que que me pusiern 900 noticias en unos instantes!!!! y yo tengo en el menú una tabla con un link a la derecha asi
borrar.php?id=id_noticia y los 900 no salia eso y es muy raro!!! ya que nadie conoce mi codigo :S
y queria ver si hay algún programa que verifique si se peude hacer inyecicon o algo :S
Salu2
Título: Re: Saber si mi script es vulnerable
Publicado por: alone-in-the-chat en 23 Abril 2007, 03:42 am
no entendi bien la pregunta si posteas tu codigo podemos ayudarte mejor y tb explika un poco mejor como haces para subir las noticias a tu base de datos si es un simple formulario se pueden hacer scripts que te envien esa cantidad de noticias en un instante pero antes publica tu codigo y explikare un poco mas Saludos
Título: Re: Saber si mi script es vulnerable
Publicado por: [ Alberto] en 23 Abril 2007, 04:13 am
si como dice el colega Richard pon tu codigo para ayudartelo a blindar, por lo que veo una falta de seguridad y desempeño es pasar variables por get...
Título: Re: Saber si mi script es vulnerable
Publicado por: дٳŦ٭ en 23 Abril 2007, 05:45 am
Señor Rudy, busca acerca del captcha. Otra, mete una regla para medir voto por ip mediante alguna base de datos.
Saludos
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 24 Abril 2007, 00:26 am
Hola es que siento que si publico el code quedaria aun mas vulnerable jejeje 1.- votos por IP?? eske mi sistema no tiene votos ni nada :S 2.- ok posteare el codigo pero es algo largo ya que son varios files :S 3.- No Paso las variables por $_GET todo es por $_POST y todo esta bajo contraseña por session if ($_POST['user'] == $usuario && $_POST['pass'] == $pass) mete en una variable de Session a el user bueno en unos momenos mas posteo el code salu2
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 24 Abril 2007, 00:49 am
entrar.php (verifica el USER y PASS) <?php require_once('Connections/Dominican.php'); if (!isset($_SESSION)) { session_start(); } $user = $_POST['User']; $pass = $_POST['Pass']; if($user == $Usuario1 && $pass == $Password1) { $_SESSION['Username'] = $user; header ("Location: ../main.php"); } elseif($user == $Usuario2 && $pass == $Password2) { $_SESSION['Username'] = $user; header ("Location: ../main.php"); }else{ echo "Usuario Y/O Password Incorrectos<br><strong>Favor de Verificarlos, (SOLO PARA ADMINISTRADORES DE LA WEB)</strong>"; }
?><style type="text/css"> <!-- body { background-color: #CCCCCC; } --> </style> <div align="center"> <p><br> <img src="http://www.dominican.com/iconos_web/1.jpg" width="9" height="9"> <a href="http://www.dominican.com/main.php"><< Atras</a> <img src="http://www.dominican.com/iconos_web/1.jpg" width="9" height="9"></p> <p> </p> </div> login.php (formulario del login, user pass) <?php if ($_SESSION['Username'] == '') { echo '<FORM action="sistema_noticia/entrar.php"
method=post> <INPUT type=hidden value=login
name=op><INPUT type=hidden name=t><INPUT type=hidden
name=f><INPUT type=hidden name=mode><INPUT type=hidden
name=redirect><FONT face=Arial
size=1> Usuario:<INPUT
name=User id="User" size=10 maxLength=25> Contraseña:<INPUT name=Pass type=password id="Pass" size=10 maxLength=20> <INPUT type=submit value=Entrar> </FONT> </FORM>'; } else { echo "<strong>Bienvenido <u>". $_SESSION['Username'] ."</u> </strong><a href=\"http://www.dominican.com/sistema_noticia/salir.php?doLogout=true\"> |Cerrar Sesion</a>|<a href=\"http://www.dominican.com/sistema_noticia/menu.php\">Menu de Noticias|</a>"; } ?> menu.php (el menu de el sistema) <?php require_once('Connections/Dominican.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } if ($_SESSION['Username'] == "") { header ("Location: http://www.dominican.com/main.php"); } mysql_select_db($database_Dominican, $Dominican); $query_Recordset1 = "SELECT ID, Titulo FROM noticias ORDER By ID DESC"; $Recordset1 = mysql_query($query_Recordset1, $Dominican) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>.::|Menu-SIstema de Noticias|::.</title> <style type="text/css"> <!-- a:link { color: #0000FF; text-decoration: none; } a:visited { text-decoration: none; color: #0000FF; } a:hover { text-decoration: underline; color: #FF0000; } a:active { text-decoration: none; color: #0000FF; } .Estilo1 { color: #FF0000; font-weight: bold; } --> </style> <link href="../iconos_web/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .Estilo2 { font-size: 16px; font-weight: bold; } .Estilo3 {font-size: 14px} .Estilo4 {color: #CCCCCC} .Estilo5 {font-size: 14px; font-weight: bold; } --> </style> </head>
<body> <p class="Estilo1"><?php $status = $_GET['status']; if($status == 1){ echo "Insertado Con Exito";} if($status == 2){ echo "Borrado Con Exito";} if($status == 3){ echo "Modificado Con Exito";} ?></p> <table width="311" border="0" align="center" bgcolor="#333333"> <tr> <td width="305" bgcolor="#666666"><div align="center" class="Estilo2 Estilo4"><strong>Menu De Noticias </strong></div></td> </tr> </table> <br /> <div align="center"></div> <table width="281" border="0" bgcolor="#333333"> <tr> <td width="141" height="15" bgcolor="#333333"><a href="../main.php"><strong>» Regresar atras</strong></a></td> <td width="130" bgcolor="#333333" class="Estilo3"><a href="noticia_nueva.php"><strong>» Crear Nueva Noticia </strong></a></td> </tr> </table> <br /> <br /> <br /> <hr> <table width="741" border="0" align="center"> <tr> <td width="731" height="160" valign="top" bgcolor="#333333"><table width="200" border="0" align="center" bgcolor="#333333"> <tr> <td bgcolor="#666666"><div align="center"><span class="Estilo5">Menu Noticias</span></div></td> </tr> </table> <table width="69%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#0000FF"> <tr> <td><div align="center"><strong>ID</strong></div></td> <td><div align="center"><strong>Titulo</strong></div></td> <td><div align="center"><strong>Borrar</strong></div></td> <td><div align="center"><strong>Modificar</strong></div></td> </tr> <?php do { ?> <tr> <td><div align="center"><?php echo $row_Recordset1['ID']; ?></div></td> <td><div align="center"><?php echo $row_Recordset1['Titulo']; ?></div></td> <td><div align="center"><a href="noticia_borrar.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="borrar.png" width="16" height="16" border="0" /></a></div></td> <td><div align="center"><a href="noticia_modificar.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="editar.png" width="16" height="16" border="0" /></a></div></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table></td> </tr> </table> <br /> </body> </html> <?php mysql_free_result($Recordset1); ?> noticia_modificar.php (modifica noticia existente) ?php require_once('Connections/Dominican.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } if ($_SESSION['Username'] == "") { header ("Location: http://www.dominican.com/main.php"); } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }
$editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET Titulo=%s, Texto1=%s, Imagen=%s WHERE ID=%s", GetSQLValueString($_POST['Titulo'], "text"), GetSQLValueString($_POST['Texto1'], "text"), GetSQLValueString($_POST['Imagen'], "text"), GetSQLValueString($_POST['ID'], "int"));
mysql_select_db($database_Dominican, $Dominican); $Result1 = mysql_query($updateSQL, $Dominican) or die(mysql_error());
$updateGoTo = "menu.php?status=3"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
$colname_Recordset1 = "-1"; if (isset($_GET['id'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']); } mysql_select_db($database_Dominican, $Dominican); $query_Recordset1 = sprintf("SELECT * FROM noticias WHERE ID = %s", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $Dominican) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>.::|Modificar Noticia|::.</title> <style type="text/css"> <!-- .Estilo2 {font-weight: bold} --> </style> <script type="text/javascript"> function codigo(a,b) { if(navigator.appName == 'Microsoft Internet Explorer') { if(seleccionado = document.selection.createRange().text) { document.selection.createRange().text = a + seleccionado + b ; document.m_formulario.Texto1.focus() ; } else { document.m_formulario.Texto1.focus() ; document.selection.createRange().text = a + b ; } } else { document.m_formulario.Texto1.value += a + b ; document.m_formulario.Texto1.focus() ; } } </script> <link href="../iconos_web/style.css" rel="stylesheet" type="text/css" /> </head>
<body> <form action="<?php echo $editFormAction; ?>" method="post" name="m_formulario" id="m_formulario"> <table align="center"> <tr valign="baseline"> <td align="right" valign="top" nowrap>Titulo:</td> <td valign="top"><input type="text" name="Titulo" value="<?php echo $row_Recordset1['Titulo']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>BBCode</td> <td valign="top"><input type="button" onclick="codigo('[b]','[/b]')" value="[b]" onmouseover="ayuda1('Texto en negrita')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[i]','[/i]')" value="[i]" onmouseover="ayuda1('Texto en cursiva')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[u]','[/u]')" value="[u]" onmouseover="ayuda1('Texto subrayado')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[img]','[/img]')" value="[img]" onmouseover="ayuda1('Poner una imagen')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[url][/url]','[texto][/texto]')" value="[url]" onmouseover="ayuda1('Crear un enlace')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[hr]','')" value="[hr]" onmouseover="ayuda1('Colorear código (HTML, PHP, étc.)')" onmouseout="ayuda2()" class="eforo_formulario"><br /> <input type="button" class="" onclick="codigo('[centrar]','[/centrar]')" value="[centrar]"/> <input name="button2" type="button" class="eforo_formulario" onclick="codigo('[izquierda]','[/izquierda]')" onmouseover="ayuda1('Texto en negrita')" onmouseout="ayuda2()" value="[izquierda]" /> <input name="button" type="button" class="" onclick="codigo('[derecha]','[/derecha]')" value="[derecha]"/> <input name="button3" type="button" class="" onclick="codigo('[azul]','[/azul]')" value="[azul]"/> <br /> <input name="button4" type="button" class="" onclick="codigo('[rojo]','[/rojo]')" value="[rojo]"/> <input name="button5" type="button" class="" onclick="codigo('[verde]','[/verde]')" value="[verde]"/> <input name="button6" type="button" class="" onclick="codigo('[amarillo]','[/amarillo]')" value="[amarillo]"/> <input name="button7" type="button" class="" onclick="codigo('[negro]','[/negro]')" value="[negro]"/> <input name="button8" type="button" class="" onclick="codigo('[blanco]','[/blanco]')" value="[blanco]"/></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Texto1:</td> <td valign="top"><textarea name="Texto1" cols="50" rows="15"><?php echo $row_Recordset1['Texto1']; ?></textarea></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Imagen:</td> <td valign="top"><input type="text" name="Imagen" value="<?php echo $row_Recordset1['Imagen']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap> </td> <td valign="top"><input type="submit" value="Actualizar registro"></td> </tr> </table> <p align="center">Los Comandos Son Los Siguientes:<br /> <strong>[b] </strong>Texto En Negritas <span class="Estilo2"><em><strong>[/b]</strong></em></span><em><strong><br /> [i] </strong></em>Texto en Cursiva <em><strong>[/i]<br /> [u] </strong></em>Texto Subrayado <em><strong>[/u]<br /> [img] </strong></em>Poner Imagen <em><strong>[/img]<br /> [url]http://www.dominican.com[/url][texto]Visitar Dominican[/texto]</strong></em> Poner Un Enlace<br /> <span class="Estilo2">[hr]</span> Poner Una Linea<br /> <span class="Estilo2">[centrar] </span>Centrar el texto<span class="Estilo2">[/centrar]<br /> </span><strong>[izquierda]</strong> Direccionar el texto<strong>[/izquierda]</strong><br /> <strong>[derecha]</strong> Direccionar el texto<strong>[/derecha]</strong><span class="Estilo2"><br /> [azul] </span>Texto de Color <span class="Estilo2">[/azul] </span><br /> <span class="Estilo2">[rojo] </span>Texto de Color <span class="Estilo2">[/rojo]</span><br /> <span class="Estilo2">[verde] </span>Texto de Color <span class="Estilo2">[/verde]</span><br /> <span class="Estilo2">[amarillo] </span>Text de Color <span class="Estilo2">[/amarillo]</span><br /> <span class="Estilo2">[negro] </span>Texto de Color <span class="Estilo2">[/negro]</span><br /> <span class="Estilo2">[blanco] </span>Texto de Color <span class="Estilo2">[/blanco]</span><br /> <br /> <input type="hidden" name="MM_insert" value="form1"> </p> <p> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="ID" value="<?php echo $row_Recordset1['ID']; ?>"> </p> </form> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); ?> noticia_nueva.php (Meter nueva noticia) <?php require_once('Connections/Dominican.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } if ($_SESSION['Username'] == "") { header ("Location: http://www.dominican.com/main.php"); }
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }
$editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ($_POST['Submit'] != "") { $nombre_archivo = $_FILES['archivo_1']['name']; $Local_Resource = $_FILES['archivo_1']['tmp_name']; //script de prueba move_uploaded_file($Local_Resource, "../iconos_web/fotos_noticias/$nombre_archivo"); //fin prueba } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO noticias (Titulo, Texto1, Imagen) VALUES (%s, %s, %s)", GetSQLValueString($_POST['Titulo'], "text"), GetSQLValueString($_POST['Texto1'], "text"), GetSQLValueString("../iconos_web/fotos_noticias/".$nombre_archivo, "text"));
mysql_select_db($database_Dominican, $Dominican); $Result1 = mysql_query($insertSQL, $Dominican) or die(mysql_error());
$insertGoTo = "menu.php?status=1"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> function codigo(a,b) { if(navigator.appName == 'Microsoft Internet Explorer') { if(seleccionado = document.selection.createRange().text) { document.selection.createRange().text = a + seleccionado + b ; document.m_formulario.Texto1.focus() ; } else { document.m_formulario.Texto1.focus() ; document.selection.createRange().text = a + b ; } } else { document.m_formulario.Texto1.value += a + b ; document.m_formulario.Texto1.focus() ; } } </script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>.::|Noticia Nueva|::.</title> <link href="main_files/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .Estilo1 {font-size: 14px} .Estilo2 { color: #00FF00; font-style: italic; font-weight: bold; } .Estilo4 {color: #00FF00} .Estilo5 {font-weight: bold} --> </style> <link href="../iconos_web/style.css" rel="stylesheet" type="text/css" /> </head>
<body> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="m_formulario" id="m_formulario"> <table align="center"> <tr valign="baseline"> <td colspan="2" align="right" valign="top" nowrap><div align="center" class="Estilo1">NuEvA NoTiCiA</div></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Titulo:</td> <td valign="top"><input type="text" name="Titulo" value="" size="32"></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>BBCode:</td> <td valign="top"><input type="button" onclick="codigo('[b]','[/b]')" value="[b]" onmouseover="ayuda1('Texto en negrita')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[i]','[/i]')" value="[i]" onmouseover="ayuda1('Texto en cursiva')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[u]','[/u]')" value="[u]" onmouseover="ayuda1('Texto subrayado')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[img]','[/img]')" value="[img]" onmouseover="ayuda1('Poner una imagen')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[url][/url]','[texto][/texto]')" value="[url]" onmouseover="ayuda1('Crear un enlace')" onmouseout="ayuda2()" class="eforo_formulario"> <input type="button" onclick="codigo('[hr]','')" value="[hr]" onmouseover="ayuda1('Colorear código (HTML, PHP, étc.)')" onmouseout="ayuda2()" class="eforo_formulario"><br /> <input type="button" class="" onclick="codigo('[centrar]','[/centrar]')" value="[centrar]"/> <input name="button2" type="button" class="eforo_formulario" onclick="codigo('[izquierda]','[/izquierda]')" onmouseover="ayuda1('Texto en negrita')" onmouseout="ayuda2()" value="[izquierda]" /> <input name="button" type="button" class="" onclick="codigo('[derecha]','[/derecha]')" value="[derecha]"/> <input name="button3" type="button" class="" onclick="codigo('[azul]','[/azul]')" value="[azul]"/> <br /> <input name="button4" type="button" class="" onclick="codigo('[rojo]','[/rojo]')" value="[rojo]"/> <input name="button5" type="button" class="" onclick="codigo('[verde]','[/verde]')" value="[verde]"/> <input name="button6" type="button" class="" onclick="codigo('[amarillo]','[/amarillo]')" value="[amarillo]"/> <input name="button7" type="button" class="" onclick="codigo('[negro]','[/negro]')" value="[negro]"/> <input name="button8" type="button" class="" onclick="codigo('[blanco]','[/blanco]')" value="[blanco]"/></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Texto1:</td> <td valign="top"><textarea name="Texto1" cols="50" rows="15" wrap="virtual"></textarea></td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap>Imagen:</td> <td> <p align="center"><input name="archivo_1" type="file" id="archivo_1"> </p> </td> </tr> <tr valign="baseline"> <td align="right" valign="top" nowrap> </td> <td valign="top"><input name="Submit" type="submit" id="boton" value="Insertar registro"></td> </tr> </table> <p align="center">Los Comandos Son Los Siguientes:<br /> <span class="Estilo2">[b] </span>Texto En Negritas <span class="Estilo2"><em><strong>[/b]</strong></em></span><em><strong><br /> <span class="Estilo4">[i]</span> </strong></em>Texto en Cursiva <span class="Estilo2"><em><strong>[/i]</strong></em></span><em><strong><br /> <span class="Estilo4">[u]</span> </strong></em>Texto Subrayado <span class="Estilo2"><em><strong>[/u]</strong></em></span><br /> <em><strong><span class="Estilo4">[img]</span> </strong></em>Poner Imagen <span class="Estilo2"><em><strong>[/img]</strong></em></span><em><strong><br /> <span class="Estilo4">[url]</span>http://www.dominican.com<span class="Estilo4">[/url][texto]</span>Visitar Dominican <span class="Estilo4">[/texto]</span></strong></em> Poner Un Enlace<br /> <span class="Estilo2">[hr]</span> Poner Una Linea<br /> <span class="Estilo2">[centrar] </span>Centrar el texto<span class="Estilo2">[/centrar]</span><br /> <span class="Estilo2">[izquierda] </span>Direccionar el texto<span class="Estilo2">[/izquierda]</span><br /> <span class="Estilo2">[derecha] </span>Direccionar el texto<span class="Estilo2">[/derecha]</span><br /> <span class="Estilo2">[azul] </span>Texto de Color <span class="Estilo2">[/azul] </span><br /> <span class="Estilo2">[rojo] </span>Texto de Color <span class="Estilo2">[/rojo]</span><br /> <span class="Estilo2">[verde] </span>Texto de Color <span class="Estilo2">[/verde]</span><br /> <span class="Estilo2">[amarillo] </span>Text de Color <span class="Estilo2">[/amarillo]</span><br /> <span class="Estilo2">[negro] </span>Texto de Color <span class="Estilo2">[/negro]</span><br /> <span class="Estilo2">[blanco] </span>Texto de Color <span class="Estilo2">[/blanco]</span><br /> <br /> <input type="hidden" name="MM_insert" value="form1"> </p> </form> <p> </p> </body>
</html>
noticia_borrar.php (borra la noticia, es muy sencillo) <?php require_once('Connections/Dominican.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } if ($_SESSION['Username'] == "") { header ("Location: http://www.dominican.com/main.php"); } function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }
if ((isset($_GET['id'])) && ($_GET['id'] != "")) { $deleteSQL = sprintf("DELETE FROM noticias WHERE ID=%s", GetSQLValueString($_GET['id'], "int"));
mysql_select_db($database_Dominican, $Dominican); $Result1 = mysql_query($deleteSQL, $Dominican) or die(mysql_error());
$deleteGoTo = "menu.php?status=2"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head>
<body> </body> </html>
salir.php (hacer logout, cerrar sesion) <?php if (!isset($_SESSION)) { session_start(); } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['Username'] = NULL; unset($_SESSION['Username']);
$logoutGoTo = "http://www.dominican.com/main.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; } } ?> Connections/Dominican.php (El Archivo de config.php) <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" //>>>>>>|Datos Para el Admin de Las News|<<<<<<<<<<
//--------Usuario/Moderador [1]--------// $Usuario1 = "USER1"; $Password1 = "PASS1";
//--------Usuario/Moderador [2]--------// $Usuario2 = "USER2"; $Password2 = "PASS2";
//---------Numero de Noticias a Mostrar Por Paginas----------// $registros = 4;
//---------- Paginas de Numeracion Para Dar Salto de Linea < Anterior [1][2][3][4][5] etc.. ----------------// $abajo=17;
//-------Titulo De La Pagina antes de (|-| "Cargando...") ------// $titulo_cargando = "--> Dominican Está...";
//------- Titulo Antes Del "titulo" de la Primera noticia de cada pagina -----// $titulo_antes_titulo = "...::: Dominican :::...";
//>>>>>>>|Datos de la Conexion a la BD|<<<<<<<<<<<<< $hostname_Dominican = "localhost"; $database_Dominican = "noticias"; $username_Dominican = "noticias_user"; $password_Dominican = "noticias_pass";
//------------------------->> No Tocar de aki Para ABAJO, SOlo Modificar de aquí para arriba |^_^| $Dominican = mysql_pconnect($hostname_Dominican, $username_Dominican, $password_Dominican) or trigger_error(mysql_error(),E_USER_ERROR);
//Funcion BBCode function BBCode($palabra) { $palabra = htmlentities($palabra); $palabra = str_replace("[url]","<a href=\"", $palabra);
$palabra = str_replace("[/url]","\" target=\"_blank\">", $palabra); $palabra = str_replace("[img]","<img src=\"", $palabra);
$palabra = str_replace("[/img]","\">", $palabra); $palabra = str_replace("[texto]"," ", $palabra); $palabra = str_replace("[/texto]"," </a>", $palabra);
$palabra = str_replace("[hr]","<hr color='#FFFFFF' size='1'>", $palabra);
$palabra = str_replace("[b]","<b>", $palabra);
$palabra = str_replace("[/b]","</b>", $palabra); $palabra = str_replace("[centrar]","<center>", $palabra);
$palabra = str_replace("[/centrar]","</center>", $palabra);
$palabra = str_replace("[derecha]","<p align=\"right\">", $palabra); $palabra = str_replace("[/derecha]","</p>", $palabra); $palabra = str_replace("[izquierda]","<p align=\"left\">", $palabra); $palabra = str_replace("[/izquierda]","</p>", $palabra); $palabra = str_replace("[u]","<u>", $palabra);
$palabra = str_replace("[/u]","</u>", $palabra);
$palabra = str_replace("[i]","<i>", $palabra);
$palabra = str_replace("[/i]","</i>", $palabra);
$palabra = str_replace("[azul]","<font color='#0000FF'>", $palabra);
$palabra = str_replace("[rojo]","<font color='#FF0000'>", $palabra);
$palabra = str_replace("[verde]","<font color='#009D00'>", $palabra);
$palabra = str_replace("[amarillo]","<font color='#EEDC02'>", $palabra); $palabra = str_replace("[negro]","<font color='#000000'>", $palabra);
$palabra = str_replace("[/negro]","</font>", $palabra);
$palabra = str_replace("[blanco]","<font color='#FFFFFF'>", $palabra);
$palabra = str_replace("[/blanco]","</font>", $palabra);
$palabra = str_replace("[/amarillo]","</font>", $palabra); $palabra = str_replace("[/verde]","</font>", $palabra);
$palabra = str_replace("[/rojo]","</font>", $palabra);
$palabra = str_replace("[/azul]","</font>", $palabra); $palabra = nl2br($palabra); return $palabra;
} ?>
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 24 Abril 2007, 00:58 am
Si Pueden copiar el CoDE y pegarle en dreamweaver para analizarlo, peus mejor
pero es urgente que medigan que está mal en mic ode, lo del a funcion de GetsqlValue lo mete el Dreamweaver
Salu2
Título: Re: Saber si mi script es vulnerable
Publicado por: [ Alberto] en 27 Abril 2007, 04:41 am
ese script es vulnerable a una inyeccion sql mira esto: http://php.mirrors.ilisys.com.au/manual/es/security.database.sql-injection.php http://foro.elhacker.net/index.php/topic,98448.0.html
Título: Re: Saber si mi script es vulnerable
Publicado por: Ertai en 27 Abril 2007, 09:49 am
ese script es vulnerable a una inyeccion sql mira esto: http://php.mirrors.ilisys.com.au/manual/es/security.database.sql-injection.php http://foro.elhacker.net/index.php/topic,98448.0.html
Di donde, sinó no sirve de nada.
Título: Re: Saber si mi script es vulnerable
Publicado por: Ertai en 27 Abril 2007, 09:53 am
Me he leído el código muy por encima, y no le veo nada malo (aparentemente). Pero no haces ningún tipo de comprobación para las peticiones.
Lo que creo que ha pasado es que alguien ha usado un programa para hacer muchas peticiones POST y tu programa no filtra nada, las acepta todas.
Por otra parte, me extraña lo del mismo id. Acaso no tienes este campo en la BDD como auto_increment?
Saludos.
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 27 Abril 2007, 21:32 pm
el ID es autoincrement y no entiendo en donde pueden meter la Inyeccíon SQL
si no tiene acceso masque al LOGIN!!!!
y el login no necesita Base de datos
entonces????
me podrian indicar donde???
gracias
Título: Re: Saber si mi script es vulnerable
Publicado por: [ Alberto] en 27 Abril 2007, 22:40 pm
Hola la verdad es que le heche solo una ojeada y como vi que no tratabas los campos user y pass tambien supuse que las variables usuario1... los sacabas de una base de datos pero si son valores constates no ay problema por eso coincido tambien en lo que dice Ertai, con algun programa te an spameado saludos
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 27 Abril 2007, 23:57 pm
jajajaj mano em tienes como loko intentanto hacer eso y no funcionaba xD xD
pero haber no entendi eso que me dijeron de la SPAMEADA
como filtro los POST o como hicieron para hacer el post si el que hace el POST está protejido bajo $_SESSION ??
Título: Re: Saber si mi script es vulnerable
Publicado por: [ Alberto] en 28 Abril 2007, 01:56 am
ah tio disculpa las molestias, por spameada keria decir que te llenen de mensajes de noticias indeseados para eso una buena solucion es usar CAPTCHA (un detecta humanos) como este ejemplo http://www.contactify.com/1 Saludos
Título: Re: Saber si mi script es vulnerable
Publicado por: SeniorX en 28 Abril 2007, 04:07 am
Yo uso sleep(), para dormirlo un segundo, evitando asi un colapso probocado por bots, etc... Usar captcha es una buenisima medida. Lo otro, es que a parte de filtrar las variables, es bueno que el usuario que se conecta y lee los datos de la base de dato tenga permisos para lo que va a hacer y nada mas. Por ejemplo, si solo lee la base y los pasa a tu web, entonces quitale los permisos de borrar, escribir, etc etc... Esa practica no es muy usada pero muy eficiente.
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 28 Abril 2007, 18:34 pm
Si se lo que es el SPAM pero lo k no entiendoe s como dicen que lo pudieron hacer si se fijan el noticia_nueva.php verifica si está iniciada la sesion y si no hay USERNAME lo redirecciona al header osea como pudieron meter las noticias <?php if (!isset($_SESSION)) { session_start(); } if ($_SESSION['Username'] == "") { header ("Location: http://www.dominican.com/main.php"); } Se me hace buena idea eso de utilizar el sleep() pero solo encuentran esa posibilidad de hackeo porke lo que se me hace AUN mas raro es que en la BD no tenian ni texto ni imagen NI ID!!!!! y todo es esta en NOT NULL y eso es lok se hme hace mas extraño, yo supongo que han d ehaber hackeado el HOST mas que mi SCRIPT PERO NO LO c :S Salu2
Título: Re: Saber si mi script es vulnerable
Publicado por: Hans el Topo en 28 Abril 2007, 23:35 pm
las sesiones se pueden manipular también desde el usuario y tal... no hace falta ni logearse para hacerte una inyección ya que solo compruebas si existe la sesión, no si la sesión es correcta y contiene datos verdaderos yo podría entrar simplemente editando una sessión que pusiese algo diferente de vacio como usuario. eso es lo primero que he visto al ojear las primeras líneas de tu código... voy a mirar un poco más y te sigo diciendo xD En serio te funciona esto¿? estas metiendo datos de texto sin meter comillas, ¿se las añade la función no, y supongo que también comprobará que no te meten lameradas xD? $insertSQL = sprintf("INSERT INTO noticias (Titulo, Texto1, Imagen) VALUES (%s, %s, %s)", GetSQLValueString($_POST['Titulo'], "text"), GetSQLValueString($_POST['Texto1'], "text"), <?php $insertSQL = sprintf("INSERT INTO noticias (Titulo, Texto1, Imagen) VALUES (%s, %s, %s)", GetSQLValueString($_POST['Titulo'], "text"), GetSQLValueString($_POST['Texto1'], "text"), GetSQLValueString("../iconos_web/fotos_noticias/".$nombre_archivo, "text"));
mysql_select_db($database_Dominican, $Dominican); $Result1 = mysql_query($insertSQL, $Dominican) or die(mysql_error()); ?>
si el id es autoincremental y usas mysql...(si se supone que es clave primaria, cosa que me temo que no) no dejaría enviar 500 en un segundo, al no ser clave primaria, envia los 500 inserts a la vez y al colapsarse la base de datos no aumenta el autoincremental (por el commit y tal xD) lo que utilizarón es un script que lanza simultáneamente esas 500 peticiones sin más, pon como clave primaria al identificador de la noticia y añade un contador que no permita enviar noticias hasta pasado 1 minuto después de su última (vía mysql o po sesion) y la otra opción es utilizar captcha
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 29 Abril 2007, 00:55 am
si me funciona eso así sin comillas no veo lo raro ya que como dices la funcion las mete!!!
y eso de lammeradas no me preocupó ya que solo el Admin tiene acceso no cualquier usuario
solo hay2
el admin y el moderador!!!!
lo que no eh probado es eso que me dices de clave principal el ID
ahora se lo pongo
y creo qeu si necesitare USAR CAPTCHA
Título: Re: Saber si mi script es vulnerable
Publicado por: SeniorX en 29 Abril 2007, 01:49 am
y eso de lammeradas no me preocupó ya que solo el Admin tiene acceso no cualquier usuario
Ojo: Mala politica de seguridad. Asi piensan todos los que hacen sistemas vulnerables. Piensa como hacker, estas facilitando las cosas para hacer inyecciones, independientemente de si hay que ser admin o no.
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 29 Abril 2007, 03:13 am
si y c tmbq ue esstóy facilitando mucho eso (despeus comento porké)
a loq ue voy es que se refierencon LAMMERADAS???
y por lo k mi SCRIPTS ES MUY VULNERABLE
si se fijan el UPLOAD de la imagenes
es para archivo CUALKIERA SUBE CAULKIER archivo ya sea una SHELL o un viruz etc...
pero no le eh peuso qeu revise si lo que se sube sea gif o jpg o pong ya que no eh tenido tiempo
me peudend ecira que se refieren con LAMMERADAS entiendo que es lok hace un lammer y se que es un lammer pero no entiendo como se aplica aqui Salu2
P.D estóy ciendo como implementar el CAPTCHA() gracias
Título: Re: Saber si mi script es vulnerable
Publicado por: Hans el Topo en 29 Abril 2007, 13:15 pm
como te he dicho no hace falta ni logearse para entrar a tu zona restringida xD
y una vez ahi se puede inyectar código al insertar noticias y tal, por no mencionar que se puede como has dicho borrar todas las noticias de la base de datos xD
eso es una lamerada ... xD
recomendación, comprobar los datos de la sessión antes de utilizarlos, y hacer la comprobación doble que el user y el pass sean buenos (en todas las zonas en las que quieras meter seguridad) te haces una función que haga todo eso y listo
lo de seguridad y tal en las consultas y subidas de archivos... yo creo que te pueden hacer de todo, por ejemplo: si alguien logra entrar, sube un achivo y le mete una url en la noticia todo el que entre y la clique mismamente, quedaría infectado... y eso es lo primero que se me ha ocurrido
asi que filtra las subidas (k son un par de ifs)
a mi por de pronto no se me ocurre nada más que comentarte
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 29 Abril 2007, 20:02 pm
Me podrias dar un EJEMPLO de como entrar?? creas una session falso desde tu host oq eu haces??
lo que haré es meter en el CONFIG.php que verifique el USER y El PASS
y en entrar.php tmb meteré el pass en una variabeld e session
Salu2
Ya estóy metiendo el CAPTCHA
Título: Re: Saber si mi script es vulnerable
Publicado por: Hans el Topo en 29 Abril 2007, 23:45 pm
busca por el foro k hay manuales para hacer inyección sql y otro tipo de ataques, para editar las sesiones y tal depende del navegador...
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 30 Abril 2007, 00:15 am
jajaj okas
y :-X :o :¬¬
no me gustó nada tu firma xD
salu2
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 1 Mayo 2007, 00:57 am
Ya está puesto el verifica.php en vez de uqe verifique si el user no es '' kite eso code e hice incldue a verifica.php y hasta ahora está funcionando bien <?php //Usuario 1 $us = $_SESSION['Username']; $ps = $_SESSION['Password']; if($us !== $Usuario1 && $ps !== $Password1) { echo '<meta http-equiv="refresh" content="0;URL=http://www.dominicanhack.net/sistema_noticia/salir.php?doLogout=true" /> '; } elseif($us == $Usuario1 && $ps !== $Password1) { echo '<meta http-equiv="refresh" content="0;URL=http://www.dominican.com/sistema_noticia/salir.php?doLogout=true" /> '; } ?> <?php //Usuario 2 // lo mismo pero es para no metér tanto code xD ?>
Título: Re: Saber si mi script es vulnerable
Publicado por: Hans el Topo en 1 Mayo 2007, 14:53 pm
Ya está puesto el verifica.php
en vez de uqe verifique si el user no es ''
kite eso code e hice incldue a verifica.php
y hasta ahora está funcionando bien
no entiendo lo que haces en el code <?php //Usuario 1 $us = $_SESSION['Username']; $ps = $_SESSION['Password']; if($us !== $Usuario1 || $ps !== $Password1) { echo '<meta http-equiv="refresh" content="0;URL=http://www.dominicanhack.net/sistema_noticia/salir.php?doLogout=true" /> '; } ?> <?php //Usuario 2 // lo mismo pero es para no metér tanto code xD ?> yo creo que sería de ese modo... con un or, si la pass o el usuario no son iguales pafuera
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 2 Mayo 2007, 00:53 am
jejej ok explico al entra.php hice que tmb metiera el PASS en uan variable de session (que no se llama PASSWORD porke si no darian un echo $_SESSION['PASSWORD'] y se harian del PASS se llama SECRETITOSCOM(PUSE PASSWORD en el code para que entiendan) pongo el include a verifica debajo del include del config.php donde está el USER y PASS del sistema entonces en cada pagina antes de cargar verifica si el password y usuario que está en la variable de sesion es el mismo que en el config.php asi ya no me hacen inyeccion con una session falsa ya que ya no verifica si el usuario no es = a "" como me mencionaban en POST anteriores el primero if if($us !== $Usuario1 && $ps !== $Password1) verifica que el USER y el PASS corresponda SI NO actualiza la pagina que hace LOGOUT y destruye las sesiones el segundo if elseif($us == $Usuario1 && $ps !== $Password1) verifica si el USUARIO que hay en la session corresponde al PASS de ese usuario (por si le atinaron al USER, pero no saben el pass xD) y sino = les hace LOGOUT tmb se podria hacer como tu dices en vez de AND un OR si no dime que parte del code no entiendes
Título: Re: Saber si mi script es vulnerable
Publicado por: Tasc0 en 2 Mayo 2007, 01:39 am
Off topic: Rudy21, chequea tus mensajes privados (http://foro.elhacker.net/index.php?action=pm).
Título: Re: Saber si mi script es vulnerable
Publicado por: Hans el Topo en 2 Mayo 2007, 20:06 pm
no entendía para que ponías el and teniendo el or xD
nada más xD
Título: Re: Saber si mi script es vulnerable
Publicado por: Rudy21 en 3 Mayo 2007, 01:02 am
SIp ya lo kambie jejeje
Tasc0
ya lo lei jiji sorry haber si te encuentro por messenger :)
Salu2
|