網上的文章都很老了,很多方法都失效了,這里記錄下我在Centos 7 下安裝metasploit的過程
安裝metasploit
使用腳本進行安裝,具體命令如下
curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall chmod 755 msfinstall ./msfinstall
網絡沒問題的話會自動安裝,會安裝在/opt/metasploit-framework/目錄下
配置Postgresql 數據庫
由於postgresql 12還在測試中,所以這里選擇了11的版本。
第一步:下載並安裝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
切換到postgres用戶做數據庫的配置
sudo -u postgres psql
創建用戶和數據庫並授權
create user msf_test with password 'youpass' nocreatedb; create database msf1 with owner ='msf_test'; \q
修改數據庫配置
vim /var/lib/pgsql/11/data/pg_hba.conf
修改源文件部分為
# "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5
重啟數據庫使配置生效
systemctl restart postgresql-11
創建metasploit數據配置信息
vim /opt/metasploit-framework/database.yml
寫入以下內容:
production: adapter: postgresql database: msf1 username: msf_test password: youpass 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
啟動控制台
親測有效,有問題可以評論下提問。
轉自:https://blog.njcit.me/index.php/archives/5/