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 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错