Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Alguem entende de php,html ??

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Alguem entende de php,html ??

    Olá, galera..

    eu estou com 2 problema simples..

    tenho um script de noticia, que quando a pessoa clica no nome da noticia para visualizar ela, abre uma janela popup, como posso fazer para quando clica em um noticia, ir com a mesma pagina???


    CODIGO

    [NOTICIA.PHP]

    <?php
    include "includes/config.php";

    $y = mysql_query("SELECT * FROM tabela Order By id DESC")or die(mysql_error());
    while($x = mysql_fetch_array($y))
    {
    echo'

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>'.$titulo.'</title>
    <style type="text/css">
    <!--
    @import url("estilos/estilos.css");
    -->
    </style>
    </head>

    <body>
    <table width="100%" border="0">
    <tr>
    <td width="1%">&nbsp;</td>
    <td width="99%"><b><span class="form_ver">'.$x['data'].'</span></b></td>
    </tr>
    <tr>
    <td><img src="imagens/setinha.jpg" width="8" height="8" /></td>
    <td><b><span class="form_ver"><a href="#" onClick=window.open("view.php?id='.$x[id].'","Janela","toolbar=no,location=no,directories=n o,status=no,menubar=no,scrollbars=yes,resizable=no ,width='.$width.',height='.$height.'"); return false;" style="color: #000000"><u>'.$x['titulo'].'</u></a></span></b></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td class="geral">'.$x['subtitulo'].'</td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td height="5" background="imagens/divide.jpg"></td>
    </tr>
    </table>
    </body>
    </html>
    ';
    }
    ?>


    E o segundo problema, é que esse escript ta vulnerável a sql injection, como posso se proteger disso?

    quando clico para ver a noticia, fica php?id= e ja testei no Havij, está vulneravel

    ae o codigo da pagina de [VIEW.PHP]



    <style type="text/css">
    <!--
    body {
    background-color: #CCCCCC;
    }
    -->
    </style><table width="879" height="388" border="1" align="center">
    <tr>
    <td colspan="2" bgcolor="#000000">&nbsp;</td>
    </tr>
    <tr>
    <td width="106" valign="top"><p>Home</p>
    <p>Fotos</p>
    <p>Videos</p></td>
    <td width="757" valign="top"><p><?php

    include "includes/config.php";
    if(!isset($_GET["id"])) {

    echo '<div align=\"center\"><font face=\"Arial\" size=\"2\">O registro nao pode ser vizualisado verifique as configuraçoes!<meta http-equiv=\"refresh\" content=\"2; URL=exibir.php\"></font></div>';

    } else {

    $y = mysql_query("select * from tabela where id='".$_GET["id"]."' order by id limit 1") or die(mysql_error());
    while ($x = mysql_fetch_array($y)) {

    echo'
    <title> '.$titulo.'</title>
    <style type="text/css">
    <!--
    @import url("estilos/estilos.css");
    -->
    </style>
    </head>

    <body>
    <table width="100%" border="0" cellspacing="3">
    <tr>
    <td class="ft10"><div align="center" class="titleview">'.$x['titulo'].'</div></td>
    </tr>
    <tr>
    <td class="geral">'.$x['noticia'].'</td>
    </tr>
    </table>
    <table width="100%" border="0">
    <tr>
    <td>&nbsp;</td>
    </tr>
    </table>
    <table width="100%" border="0">
    <tr>
    <td><div align="center" class="ft10"><a href="mailto:'.$autor.'" class="form">Desenvolvido por Diego Oliveira </a></div></td>
    </tr>
    </table>
    ';}

    }
    ?>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    </tr>
    <tr>
    <td colspan="2" bgcolor="#000000">&nbsp;</td>
    </tr>
    </table>
    Last edited by Nickguitar.dll; 21-10-2013, 17:16. Motivo: Adição da tag [QUOTE]
    Similar Threads

  • Font Size
    #2
    @Movido para a área de dúvidas, preste atenção onde você posta, postou na área errada.


    Bom, para resolver o primeiro 'erro' é simples, o que acontece é que você está chamando uma pop up com javascript, basta remover e colocar o link no href..

    Abra seu código, dê CTRL + F e procure por isso :
    <a href="#" onClick=window.open("view.php?id='.$x[id].'","Janela","toolbar=no,location=no,directories =n o,status=no,menubar=no,scrollbars=yes,resizable=no ,width='.$width.',height='.$height.'"); return false;" style="color: #000000"><u>'.$x['titulo'].'</u></a>

    Substitua por isso :


    <a href="SEULINK.COM/view.php?id='.$x[id].'" onClick=return false;" style="color: #000000"><u>'.$x['titulo'].'</u></a>
    (altere o "SEULINK.COM" pelo link do seu site)


    O que nós fizemos foi simplesmente abrir o link com o atributo "href" da tag, ou seja, assim que for clicado ele abrirá na mesma página..


    O segundo problema é muito comum, e bem fácil de resolver...

    O SQL Injection acontece por que alguns parâmetros não foram validados no envio do formulário, e podem ser manipulados.. Basta validá-los.

    No seu caso, o que não foi validado foi o ID que é passado via URL, então precisamos validá-lo..


    Abra seu protejo, aperte CTRL + F, procure por


    if(!isset($_GET["id"])) {
    Troque por

    if(!isset((int)$_GET["id"])) {



    Depois procure por

    $y = mysql_query("select * from tabela where id='".$_GET["id"]."' order by id limit 1") or die(mysql_error());
    Troque por

    $y = mysql_query("select * from tabela where id='".(int)$_GET["id"]."' order by id limit 1") or die(mysql_error());

    Veja que o que nós fizemos foi simplesmente adicionar um (int) antes do $_GET["id"].. Isso que dizer que o valor do GET id TEM que ser inteiro, ou seja, um número inteiro.. Caso contrário ele ignora ou converte a string para inteiro..

    Então se alguém passar algum parâmetro malicioso pela URL, ele será ignorado pelo interpretador...

    É isso, espero que tenha entendido, qualquer coisa só falar
    Last edited by Nickguitar.dll; 21-10-2013, 17:32.
    .

    - PHP & VB C0d3r.

    Nickguitar.dll@hotmail.com

    http://www.youtube.com/user/superskate56 <~ Hacking tuts =)

    Quando aprendemos a ouvir, também aprendemos a falar..
    Quando aprendemos a ler, também aprendemos a escrever.
    Então, quando aprendemos a usar um computador, por que não aprender a programa-lo ?


    I'm C0ding for $$$

    #~: Just $this :~#

    Comment

    X
    Working...
    X