1:安装ruby

yum -y install ruby

 

 

2:根据官方文档执行,安装支持包

 yum install xorg-x11-server-Xvfb -y

 

3:官网下载最新版的Metasploit。

    https://gist.github.com/appastair/3913714

    32位系统

wget http://downloads.metasploit.com/data/releases/metasploit-latest-linux-installer.run

    64位系统

wget http://downloads.metasploit.com/data/releases/metasploit-latest-linux-x64-installer.run

4:然后给文件X权限。

  32位系统

chmod +x metasploit-latest-linux-installer.run

  64位系统

chmod +x metasploit-latest-linux-x64-installer.run

5:开始安装

 

  32位系统

./metasploit-latest-linux-installer.run

  64位系统

./metasploit-latest-linux-x64-installer.run

 

这里几乎都是下一步下一步的,按回车或y回车继续就可以

至此 Metasploit 已经安装完成。

检查数据库连接状态db_status 返回如下结果表示数据库已经连接成功
msf > db_status
[*] postgresql connected to msf3

 

6:如果没有连接成功需要重新配置数据库连接

首先查看数据库服务是否开启,shell命令:

 

netstat -tnpl | grep postgres

 

上面提示已经开启,如果没有开启需要安装数据库 参考下面的安装数据库方法,先说下开启状态的数据库连接方式

首先去查看postgres数据库用户名和密码在database.yml这个配置文件中具体位置可能根据版本不同而不太一样建议搜索一下

使用如下命令:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. find / -name database.yml  


我的配置文件地址 /opt/metasploit/apps/pro/ui/config/database.yml 查看数据库配置信息

 

输入

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <span style="font-family:'Microsoft Yahei', 微软雅黑, arial, 宋体, sans-serif;"># </span>msfconsole  

进入metasploit命令行界面:使用命令db_connect 可连接数据库,具体命令:

 

db_connect username:password@localhost:端口号/数据库名 

 

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. msf> db_connect  msf3:3768f4b7@127.0.0.1:7337  

 

使用 db_status 命令查看是否连接成功!

 

7:如果postgres数据库没有安装请参照如下方法进行安装 

 

Centos安装,为yum。如果在是Ubuntu命令下请替换成apt-get

sudoyum install postgresql-8.4 postgresql-client-8.4

安装好了过后就创建用户密码和数据库:

su postgres       #进入数据库
createdb msf3    #创建数据库
createuser msf3     #创建用户

这儿要求你输入密码,我设置的是msf3。输入后确定就ok,然后输入exit退出

接着就是进入msfconsole设置MSF与postgresql数据库相关联

进入了msf shell之后,利用以下命令连接数据库:

db_connet msf3:msf3@127.0.0.1:7337

然后会看见msf的一些输出,这些是初始数据,第一次关联数据库会有,第二次就没了。

等待输出完成之后,我们再输入命令db_status测试下是否链接好了

如果看到以下的回显,证明数据库已经成功和MSF相关联:

postgresql conneted to msf3