macOS 安裝metasploit framework

1.拉取項目

git clone https://github.com/rapid7/metasploit-framework.git /usr/local/share/metasploit-framework

2.安裝brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.安裝postgresql(msf需要用到的數據庫),創建數據庫

brew install postgresql --without-ossp-build

initdb /usr/local/var/postgres

啓動postgres

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

爲本地創建了一個名爲msf的數據庫服務器主機並且創建的時候需要密碼

createuser msf -P -h localhost 

Enter password for new role: 

Enter it again: 

創建了一個數據庫, 該數據庫的擁有者爲msf.

createdb -O msf msf -h localhost

爲了方便啓動與停止PostgreSQL, 可以在你的配置文件添加別名:

alias start_pgsql='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'

alias stop_pgsql='pg_ctl -D /usr/local/var/postgres stop'

4.配置文件

檢查metasploit-framework/config目錄下的database.yml是否存在,不存的話複製database.yml.example並命名爲database.yml.

4.1在/.bash_profile中添加下面這條配置:

export MSF_DATABASE_CONFIG=/usr/local/share/metasploit-framework/config/database.yml

4.2metasploit-framework/config/目錄下, 打開database.yml, 作出如下修改:

production:

adapter: postgresql

database: msf

username: msf

password: <你的密碼>

host: 127.0.0.1

port: 5432

pool: 75

timeout: 5

注意是修改production下面的行, 不是development.

5.安裝bundle

gem install bundle

6.bundle完成安裝後, 進入到metasploit-framework目錄下, 解決模塊包的依賴:

bundle install

如果安裝中出現報錯,無法繼續安裝時,可嘗試使用下面命令

ARCHFLAGS="-arch x86_64" bundle install

https://stackoverflow.com/questions/6209797/cant-find-the-postgresql-client-library-libpq

7.進入/usr/local/share/metasploit-framework,執行./msfconsole

 

其他文章參考:

http://www.geeshell.com/hacks/installing-metasploit-on-osx-yosemite

https://www.jianshu.com/p/1077b96bec49

 

一些錯誤:

1.postgresql錯誤

createuser msf -P -h localhost 

Enter password for new role: 

Enter it again: 

createuser: could not connect to database postgres: could not connect to server: Connection refused

Is the server running on host "localhost" (::1) and accepting

TCP/IP connections on port 5432?

could not connect to server: Connection refused

Is the server running on host "localhost" (127.0.0.1) and accepting

TCP/IP connections on port 5432?

上面失敗說明postgres沒啓動,先啓動後創建用戶

2.bundle install錯誤:

Using metasploit-model 2.0.4

Fetching pg 0.20.0

Your user account isn't allowed to install to the system RubyGems.

  You can cancel this installation and run:

      bundle install --path vendor/bundle

  to install the gems into ./vendor/bundle/, or you can enter your password

  and install the bundled gems to RubyGems using sudo.

  Password:

Installing pg 0.20.0 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /private/var/folders/jf/yys8w7wx2c703hmzfy8kkn405vvv53/T/bundler20181224-53339-apsatypg-0.20.0/gems/pg-0.20.0/ext

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181224-53339-8klri0.rb extconf.rb

checking for pg_config... yes

Using config values from /usr/local/bin/pg_config

checking for libpq-fe.h... yes

checking for libpq/libpq-fs.h... yes

checking for pg_config_manual.h... yes

checking for PQconnectdb() in -lpq... no

checking for PQconnectdb() in -llibpq... no

checking for PQconnectdb() in -lms/libpq... no

Can't find the PostgreSQL client library (libpq)

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.

直接使用ARCHFLAGS="-arch x86_64" bundle install可以解決

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章