一、启动PostgreSQL服务
######################################################################
?root@root:~# service postgresql start    ###启动PostgreSQL服务
?root@root:~# service postgresql status    ###查看状态
?root@root:~# ss -ant    ###执行成功后,可以通过ss -ant命令查看端口5432是否在侦听,去验证PostgreSQL服务是否成功开启。
######################################################################


二、msfconsole连接PostgreSQL数据库
######################################################################
连接方式1:
    root@root:~# msfdb init    ###初始化数据库
    root@root:~# msfconsole    ###打开msf
    msf > db_status    ###查看连接状态
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    [*] postgresql connected to msf    ###连接成功
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    msf > update-rc.d postgresql enable    ###设置PostgreSQL服务开机自启
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    [*] exec: update-rc.d postgresql enable    ###使用命令update-rc.d postgresql enable将PostgreSQL服务添加至开机启动项中
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

######################################################################
注意:
!!!
msf > search ms08-067
[!] Module database cache not built yet, using slow search

? 提示这个信息,其实Metasploit已经连接上数据库,但是没有建立数据库缓存。

!!!
重新构建数据库缓存

? 这时,需要重新构建数据库缓存,在msf提示符下执行以下命令:

msf > db_rebuild_cache
[*] Purging and rebuilding the module cache In the background..

?#######################################################################    

参考:https://www.jianshu.com/p/9c82ccb2aaf7

########################################################################

三、msfconsole手动连接PostgreSQL数据库
########################################################################
root@root:~# su postgres    ###切换postgres账号
########################################################################
postgres@root:/root$ createuser test -P    ###创建test账号,密码为test。
########################################################################
postgres@root:/root$ createdb --owner=test test    ###owner参数指定数据库的所有者,赋予数据库的所有者为test,创建数据库为test。
########################################################################
msf > db_connect test:test@localhost/test    ###进入msf,连接数据库。
########################################################################

分类:

技术点:

相关文章: