dongnei3634 2011-04-05 04:15
浏览 112
已采纳

如何测试我的简单mysql登录表单进行sql注入?

I have created a simple login form for a project in PHP and mySQL. I read about security and info about SQL Injections and XSS. How can I test my form with these stuff ? I mean where I put it? I found something like this ' or 1=1– and SQL queries like

SELECT fieldlist
  FROM table
 WHERE field = '$EMAIL';

I know it's a silly question, but I don't know the answer!

  • 写回答

3条回答 默认 最新

  • dongzhiyan5693 2011-04-05 04:20
    关注

    for input input = $EMAIL the value asdf' or '1'='1 in the input and submit and see if you get true result or not.

    So the query generated is

    SELECT fieldlist
      FROM table
     WHERE field = 'asdf' or '1'='1';
    

    To check if password is not empty or not.

    if(!isset($_POST['password'])) 
    

    Also doing this would be more better if

    $username = trim($_POST['username']); //also turn magic quotes
                //or add slashes to prevent sql injection
    
    $password = md5(trim($_POST['username'])); //encrypt the password
    
    
    SELECT *
    FROM user
    WHERE username = `$username` AND
    password = `$password` LIMIT 1;
    
    if(mysql_num_rows($result)) //if the count is 1, then, the the user exists
    //do the login
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制