1

centos7安装Metasploit框架

 2 years ago
source link: https://www.hi-roy.com/posts/centos7%E5%AE%89%E8%A3%85metasploit%E6%A1%86%E6%9E%B6/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

centos7安装Metasploit框架

2015-12-28

Metasploit应该不用多说了吧?Kali自带、Win和Mac都提供了现成的安装包,不过我莫名的对apt系不感冒,这里记录一下在centos7上安装metasploit框架的步骤,理论上yum系的都应该通用。 首先执行

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
chmod 755 msfinstall
./msfinstall

然后安装postgresql:

yum install postgresql
yum install postgresql-server

安装完成后先别启动服务,这里有个 关键的步骤 就是修改验证方式,编辑/var/lib/pgsql/data/pg_hba.conf文件,添加一行

host    "msf_database"	"msf_user"      127.0.0.1/32          md5
host     all             all            127.0.0.1/32          ident

保存后初始化数据库并启动服务,这里我直接就是root权限:

postgresql-setup initdb
systemctl start postgresql.service
su postgres
createuser msf_user -P
Enter password for new role: yourmsfpassword
Enter it again: yourmsfpassword
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
createdb --owner=msf_user msf_database

然后切换回root用户,执行msfconsole:

msf> db_status
[*] postgresql selected, no connection
msf> db_connect msf_user:[email protected]:5432/msf_database
NOTICE:  CREATE TABLE will create implicit sequence "hosts_id_seq" for serial column "hosts.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "hosts_pkey" for table "hosts"
[..]
NOTICE:  CREATE TABLE will create implicit sequence "mod_refs_id_seq" for serial column "mod_refs.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "mod_refs_pkey" for table "mod_refs"
msf > db_status
[*] postgresql connected to msf_database

然后就可以愉快的玩耍了。这里还有个地方需要注意的就是如果用上面的办法安装后执行了msfupdate,更新完成后再执行msfconsole会提示找不到命令,不知为什么/usr/bin目录下的链接被删除了,上面的安装方法将程序安装到了/opt/metasploit-framework/,所有的命令都在/opt/metasploit-framework/bin目录,可以自己重建链接。

另外,如果觉得每次进入msfconsole都要重新链接一次数据库麻烦的话,可以使用alias命令:

alias msfconsole='msfconsole -d db_connect -y /opt/framework/config/database.yml'

自己修改对应路径即可。

或者把database.yml放到~/.msf4目录中。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK