metasploit连接postgresql数据库

打开postgresql服务

root@wu:~# service postgresql start

进入postgresql

root@wu:~# sudo -u postgres psql

信息查看

postgres=# \du
                             角色列表
 角色名称 |                    属性                    | 成员属于 
----------+--------------------------------------------+----------
 postgres | 超级用户, 建立角色, 建立 DB, 复制, 绕过RLS | {}

更改密码

postgres=# \password
输入新的密码:
再次输入:

postgres权限太高,新建一个用户和数据库来连接metasploit

CREATE USER 用户名 WITH PASSWORD 密码 NOCREATEDB;

postgres=# CREATE USER msfdb1 WITH PASSWORD '000000' NOCREATEDB;
CREATE ROLE

给新建的用户新建一个数据库

CREATE DATABASE 数据库名 OWNER 用户名;

postgres=# CREATE DATABASE msf_db OWNER msfdb1;
CREATE DATABASE

查看数据库

postgres=# \l
                                  数据库列表
   名称    |  拥有者  | 字元编码 | 校对规则 |  Ctype  |       存取权限        
-----------+----------+----------+----------+---------+-----------------------
 msf_db    | msfdb1   | UTF8     | C.UTF-8  | C.UTF-8 | 
 postgres  | postgres | UTF8     | C.UTF-8  | C.UTF-8 | 
 template0 | postgres | UTF8     | C.UTF-8  | C.UTF-8 | =c/postgres          +
           |          |          |          |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C.UTF-8  | C.UTF-8 | =c/postgres          +
           |          |          |          |         | postgres=CTc/postgres
(4 行记录)

打开msfconsole

root@wu:~# msfconsole

查看数据库连接情况

msf > db_status
[*] postgresql selected, no connection

连接刚刚新建的数据库

db_connect 用户名:密码@127.0.0.1/数据库

msf > db_connect msfdb1:000000@127.0.0.1/msf_db
[*] Rebuilding the module cache in the background...
msf > db_status
[*] postgresql connected to msf_db
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值