Centos7下msf的安装与Postgresql数据库的配置

故事的起因是这样的,之前做的渗透测试都是在虚拟机中通过kali中的msf来做测试,但是这样其实是处于内网当中的,很多操作必须要内网转发出去才能使用,所以就买了一台公网的服务器来安装下msf,然后就是一路踩坑啊……
网上很多文章在不同的环境里面,其实配置是有点一样,还有很多失效的,这里就记录下我在Centos7中的安装metasploit的方法和过程。

msf的安装

使用脚本进行安装,命令如下:

curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall:下载安装包
chmod 755 msfinstall:设置权限
./msfinstall:执行在线安装(如果你的网络环境对于raw.githubusercontent.com不友好的话,能慢死……)

下载好了以后,路径是在/opt/metasploit-framework/目录下,到这里其实msf就已经安装好了,但是我们直接通过msfconsole启动的时候会提示

No database support: No database YAML file

但是还是可以使用msf的,其实这个时候由于没有配置postgresql数据库导致的。

Postgresql数据库的安装

ps:安装postgresql数据库到时候真是踩到了各种坑……
配置Postgresql 数据库,下载并安装yum源:

> wget https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-redhat11-11-2.noarch.rpm
rpm -ivh pgdg-redhat11-11-2.noarch.rpm

安装数据库以及相关服务:

yum install postgresql11 postgresql11-server postgresql11-devel

初始化数据库:

/usr/pgsql-11/bin/postgresql-11-setup initdb

启动数据库并配置为开机自启:

systemctl start postgresql-11:启动数据库
systemctl enable postgresql-11:配置开启启动
systemctl status postgresql-11.service:查看数据库状态

切换到postgres用户配置数据库:

sudo -u postgres psql

创建用户和数据库并授权:

create user msf_user with password 'jimolang' nocreatedb;
create database msf5 with owner ='msf_user ';
\q

修改数据库配置:

vim /var/lib/pgsql/11/data/pg_hba.conf

重启数据库:

systemctl restart postgresql-11

新建metasploit数据配置信息:

vim /opt/metasploit-framework/database.yml

database.yml的内容为:

production:
 adapter: postgresql
 database: msf5
 username: msf_user
 password: jimolang
 host: 127.0.0.1
 port: 5432
 pool: 75
 timeout: 5

使配置生效:

echo export MSF_DATABASE_CONFIG=/opt/metasploit-framework/database.yml >> /etc/bashrc
source ~/.bashrc

最后启动msf:

msfconsole

大功告成~~~~~~

发布了23 篇原创文章 · 获赞 30 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/cj_Allen/article/details/104132949