centos7 安装msf
方法一
安装依赖
yum install sqlite-devel libxslt-devel libxml2-devel java-1.7.0-openjdk libpcap-devel nano openssl-devel zlib-devel libffi-devel gdbm-devel readline-devel wget gcc-c++ patch readline zlib bzip2 autoconf automake libtool bison iconv-devel libyaml-devel make postgresql-devel
安装rvm
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L get.rvm.io | bash -s stable
#经常出现获取不到的情况,看他提示运行相关操作
source /etc/profile.d/rvm.sh
rvm reload
安装ruby-2.6
rvm install ruby-2.6.2
0x4 下载编译msf5
git clone https://github.com/rapid7/metasploit-framework.git
cd metasploit-framework
gem install bundle
bundle install
0x5 添加快捷启动
ln -s /root/metasploit-framework/msfconsole /usr/bin/msfconsole
方法二
上面方法比较满 下面相对较快
首先先查看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,通过su
和su 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
转 centos7 安装msf5 - 左小龙 - 博客园 (cnblogs.com)
转Centos安装msf与配置 - 莫契 - 博客园 (cnblogs.com)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步