程序没有有效过滤用户的输入,使攻击者成功的向服务器提交恶意的SQL脚本,程序在接收后错误的将攻击者的输入作为SQL语句的一部分执行,导致原始的查询逻辑被改变,执行了攻击者精心构造的恶意SQL语句。
![图片[1]-怎么防止sql注入-编程社](https://cos.bianchengshe.com/wp-content/uploads/2024/03/u28499896881591929237fm253fmtautoapp120fJPEG.webp?imageMogr2/format/webp/interlace/1/quality/100)
如从用户表根据用户名bianchengshe和密码123查用户信息
select * from user where username = 'bianchengshe' and password = '123'
恶意修改用户名参数 bianchengshe -> bianchengshe’ or 1=1 —
select * from user where username = 'bianchengshe' or 1=1 --' and password = '123'
SQL 中 — 是注释标记,如果上面这个 SQL 被执行,就可以让攻击者在不知道任何用户名和密码的情况下成功登录。
预防措施:
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容