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,通過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

centos7 安裝msf5 - 左小龍 - 博客園 (cnblogs.com)
Centos安裝msf與配置 - 莫契 - 博客園 (cnblogs.com)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM