在TB上使用系统自带的msfconsole,给出以下错误

[-] Failed to connect to the database: could not connect to server: Connection refused

Is the server running on host "127.0.0.1" and accepting

TCP/IP connections on port 7175?

 {"adapter"=>"postgresql", "database"=>"msf3", "username"=>"msf3", "password"=>"6c7159f1", "host"=>"127.0.0.1", "port"=>7175, "pool"=>75, "timeout"=>5} 

我们可以分析msfconsole需要连接一个数据库,并且需要用7175端口连接数据库。

Metasploit默认使用的数据库是postgresql ,可是TB5没有安装,所以我们需要安装

执行命令

aptitude install postgresql

安装完成后系统会自动启动postgresql数据库,

root@bt:~# netstat -atpn
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      818/sshd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      3299/postgres
tcp        0      0 0.0.0.0:38158           0.0.0.0:*               LISTEN      676/rpc.statd
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      627/portmap
tcp        0      0 172.20.5.191:22         172.20.5.62:2149        ESTABLISHED 3800/3
tcp6       0      0 :::22                   :::*                    LISTEN      818/sshd
tcp6       0      0 ::1:5432                :::*                    LISTEN      3299/postgres
我们可以看到postgresql默认使用的端口是5432,那么我们需要修改Metasploit连接数据库的端口,

查看文件 /opt/framework3/config/database.yml

production:
  adapter: postgresql
  database: msf3
  username: postgres  
  password: postgres
  host: 127.0.0.1
  port: 5432
  pool: 75
  timeout: 5

我现在修改这个文件为

production:
  adapter: postgresql
  database: msf3
  username: testuser
  password: 123
  host: 127.0.0.1
  port: 5432
  pool: 75
  timeout: 5

端口我使用了系统postgresql数据库自带的端口

现在我们为postgresql创建用户testuser

以下红色命令用postgress用户执行

root@bt:~# su - postgres
没有目录,将以 HOME=/ 登录
postgres@bt:/$ createdb msfs
postgres@bt:/$ createuser  -P  -d  -a -e testuser
为新角色输入的口令:123
再输入一遍:123
CREATE ROLE testuser PASSWORD 'md5947984a8e0740c3a51289292f6fa1c15' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;

好的用户创建完成,现在可以启动msfconsole

root@bt:~# msfconsole
注意:  CREATE TABLE 将为 serial 字段 "hosts.id" 创建隐含序列 "hosts_id_seq"
注意:  CREATE TABLE / PRIMARY KEY 将要为表 "hosts" 创建隐含索引 "hosts_pkey"
注意:  CREATE TABLE 将为 serial 字段 "clients.id" 创建隐含序列 "clients_id_seq"
注意:  CREATE TABLE / PRIMARY KEY 将要为表 "clients" 创建隐含索引 "clients_pkey"

.....................

=[ metasploit v3.7.0-release [core:3.7 api:1.0]
+ -- --=[ 684 exploits - 355 auxiliary
+ -- --=[ 217 payloads - 27 encoders - 8 nops
       =[ svn r12536 updated 176 days ago (2011.05.04)

Warning: This copy of the Metasploit Framework was last updated 176 days ago.
         We recommend that you update the framework at least every other day.
         For information on updating your copy of Metasploit, please see:
             http://www.metasploit.com/redmine/projects/framework/wiki/Updating

msf >

成功进入

msf > db_driver
[*]    Active Driver: postgresql
[*]        Available: postgresql, mysql

当前数据库postgresql可以使用。
msf > quit
root@bt:~#

退出,拜拜

最新文章

  1. Android和Linux应用综合对比分析
  2. 用户管理 之 Linux 用户(User)查询篇
  3. Smart210---学习记录 竞态与并发
  4. 【jmeter】参数化User Defined Variables与User Parameters
  5. 用R语言对NIPS会议文档进行聚类分析
  6. 《通过脚本查看哪些ip被占用》shell笔记
  7. X86架构与ARM架构比较
  8. C#泛型详解
  9. python3字符串
  10. RabbitMQ教程
  11. MyBatis动态SQL(认真看看, 以后写SQL就爽多了)
  12. poj1185 状态压缩经典题
  13. python list中append()方法和extend()方法区别
  14. Jenkins 主备master-slave模式搭建
  15. Does Deep Learning Come from the Devil?
  16. Ogre 渲染目标解析与多文本合并渲染
  17. pthon获取word内容之获取表单
  18. Linux Reboot And Poweroff Command
  19. Maven父级pom.xml配置文件
  20. 看jquery3.3.1学js类型判断的技巧

热门文章

  1. cesium运行环境搭建
  2. 查找CPU使用率过高的线程
  3. c#中的程序集
  4. PowerShell 惠普打印机双面驱动自动设置已安装
  5. Kettle系列文章二(安装配置Kettle+SqlServer+简单的输入输出作业)
  6. django常用封装
  7. redis的安全问题
  8. C Primer Plus note6
  9. 怎样关闭占用80端口的pid为4的进程
  10. JavaScript实现邮箱后缀提示功能