duangan7834 2011-06-15 09:14
浏览 76
已采纳

为什么我不能使用mysql和php进行sql注入测试

i was trying to check a web site for an sql injection attack and amazed to see it not very very simple to prevent because below is the simple code .

$sql="select * from user_acount where login_id='".$username."' and password='".$password."' and status='1' ";

i can not do any sql injection to test it. i wrote the following

1st Attempt to check sql injection

Login:  admin'--
Password:'i typed nothing here '

Result Wrong password you cannot login.

2nd:

Login:  admin or 1=1 --' 
Password:''

Result Wrong password you cannot login.

3rd:

Login:  admin' or 1=1 
Password:''

4th: Login: admin or 1=1'-- Password:''

Result Wrong password you cannot login.

Can anyone please explain what is stopping me ? i am not using prepared statements nor i am using any filter class neither i have real_escape_string ?

  • 写回答

5条回答 默认 最新

  • doupu1727 2011-06-15 09:19
    关注

    Two possibilities:

    1. There is no login_id with admin, therefore the query looks like:

      select * from user_acount where login_id='admin'
      
    2. magic_quotes have been enabled, resulting in queries like:

      select * from user_acount where login_id='admin\'--' and password='' and status='1'
      select * from user_acount where login_id='admin or 1=1 --\'' and password='' and status='1'
      

      The last query will always fail, even if magic quotes was turned off:

      select * from user_acount where login_id='admin or 1=1 --'' and password='' and status='1'
      

      Because -- comments within strings do not work, the query is interpreted like:

      select * from user_acount where login_id='STRING'' and password='' and status='1'
      

      As you can see, this will result in a syntax error after 'STRING'

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python