Centos安装msf与配置

首先查看linux版本信息,

cat /proc/version cat /etc/issue cat /etc/redhat-release uname -a

对于不同的centos版本可能略有不同, 本实例是采用centos7测试可行
通过msf的安装脚本,

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

可以方便的安装msf测试版本,之后我们需要对centos下的数据库进行配置。
查看Postgresql 当前版本

psql -V

没装的话需要使用安装postgresql
尝试自带的postgresql出现问题,导入官方源安装新版本

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

这样会安装源文件到/etc/yum.repos.d,不需要的话可以自行清理

rpm -qa | grep Name rpm -e Name
sudo yum install -y postgresql10-server postgresql10 sudo /usr/pgsql-10/bin/postgresql-10-setup initdb sudo systemctl enable postgresql-10.service sudo systemctl start postgresql-10.service #开启服务之前一定要初始化
sudo yum install -y postgresql-server postgresql postgresql-setup initdb sudo systemctl start postgresql sudo systemctl enable postgresql

不论什么postgresql版本,只要安装好一个版本就可以
对数据库进行设置

su #切换到root用户 su postgres #切换到数据库用户 createuser msf -P -S -R -D #创建用户 会提示输入密码 createdb -O msf msf #创建数据库 createdb -O msf msftest

这个sql的程序名为psql,默认用户为postgres,通过susu postgres进入数据库后台管理,获取管理员权限可以通过psql -U postgres获取su,更改密码可以使用ALTER USER postgres WITH PASSWORD 'xxxxxx';或者password postgres
删除数据库drop database msf;,删除用户drop role msf;查看数据库列表\l,查看用户列表\du,切换数据库\c DatabaseName查看表\d
新建数据库配置文件database.yml,一般我们将它放在.msf/database.yml

production: adapter: postgresql database: msf username: msf password: msf #上一步创建用户的时候 设置的密码 host: 127.0.0.1 port: 5432 pool: 75 timeout: 5

由于centos默认无法localhost登录,可以使用psql msf -U msf -d msf -h localhost -W登录测试,可能由于防火墙等配置无法访问iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

find / | grep "pg_hba.conf" vim /var/lib/pgsql/data/pg_hba.conf host all all 127.0.0.1/32 md5 host all all ::1/128 md5

卸载msf

yum remove metasploit-framework
cd /opt sudo git clone https://github.com/rapid7/metasploit-framework.git sudo chown -R `whoami` /opt/metasploit-framework cd metasploit-framework yum install postgresql-devel libpcap-devel cd metasploit-framework # If using RVM set the default gem set that is create when you navigate in to the folder rvm --default use ruby-${RUBYVERSION}@metasploit-framework gem install bundler bundle install cd metasploit-framework sudo bash -c 'for MSF in $(ls msf*); do ln -s /opt/metasploit-framework/$MSF /usr/local/bin/$MSF;done' sudo nano /opt/metasploit-framework/config/database.yml production: adapter: postgresql database: msf_dev_db username: msfdev password: (your password as same as config file) host: 127.0.0.1 port: 5432 pool: 75 timeout: 5 sudo sh -c "echo export MSF_DATABASE_CONFIG=/opt/metasploit-framework/config/database.yml >> /etc/profile" source /etc/profile

参考文献:
postgresql数据库基本用法
PostgreSQL新手入门
Deepin Linux下的Metasploit安装及优化
Centos下安装msf


__EOF__

本文作者t0m1tu
本文链接https://www.cnblogs.com/t0m1tu/p/14734420.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   莫契  阅读(3926)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示