MacOS 安装 metasploit

1,系统环境

2,MacOS安装rbenv

$ brew install rbenv
  • 查看 rbenv
y50M:~ y50$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: not found
  The directory `/Users/y50/.rbenv/shims' must be present in PATH for rbenv to work.
  Please run `rbenv init' and follow the instructions.

Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20180822)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/Users/y50/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 2.2.4
Checking RubyGems settings: OK
Auditing installed plugins: O

3,rbenv安装ruby

3.1 列出所有版本

$ rbenv install -l

3.2 安装指定版本ruby

$ rbenv install 2.4.2
$ rbenv rehash
$ rbenv global 2.4.2  #将2.4.2设置成全局

4,安装Metasploit

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

5,更换gem源 升级gem

5.1 更新源

$ gem sources -l
*** CURRENT SOURCES ***

https://rubygems.org/

$ gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources

$ gem sources -a https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources

$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

vim 安装目录metasploit-framework/Gemfile  修改source
#source 'https://rubygems.org'
source 'https://gems.ruby-china.com'

5.2 升级gem

$ sudo gem update --system

5.3 没有修改更新源,更新会报错

$ sudo gem update --system 没有修改更新源,直接更新会报错

Error fetching https://ruby.taobao.org:bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

5.4 安装ruby依赖

$ sudo gem install bundler
$ cd metasploit-framework/
$ rbenv rehash
$ bundle install

5.4.1 nokogiri 安装失败

An error occurred while installing nokogiri (1.8.4), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.4' --source 'https://gems.ruby-china.com/'` succeeds before bundling.

$ brew unlink xz
Unlinking /usr/local/Cellar/xz/5.2.4... 0 symlinks removed
$ sudo gem install nokogiri
Password:
Building native extensions. This could take a while...
Successfully installed nokogiri-1.8.4
Parsing documentation for nokogiri-1.8.4
Installing ri documentation for nokogiri-1.8.4
Done installing documentation for nokogiri after 13 seconds
1 gem installed
$ brew link xz
Linking /usr/local/Cellar/xz/5.2.4... 53 symlinks created

5.5 安装报错An error occurred while installing pg (0.20.0), and Bundler cannot continue.Make sure that gem install pg -v '0.20.0' --source 'https://gems.ruby-china.com/' succeeds before bundling.

$ brew install postgresql
$ sudo gem install pg

$ rbenv rehash
$ bundle install

5.6 pg 安装失败

$./msfconsole 
Could not find pg-0.20.0 in any of the sources
Run `bundle install` to install missing gems.

sudo gem install pg

Can't find the PostgreSQL client library (libpq)
$xcode-select --install
$sudo xcodebuild -license

$ARCHFLAGS="-arch x86_64" gem install pg

Building native extensions. This could take a while...
Successfully installed pg-1.1.3
Parsing documentation for pg-1.1.3
Installing ri documentation for pg-1.1.3
Done installing documentation for pg after 2 seconds
1 gem installed

最后执行安装

$bundle install

6,PostgreSQL 配置

6.1 初始化数据库

$initdb /usr/local/var/postgres -E utf8
# 启动数据库
$pg_ctl -D /usr/local/var/postgres/  -l logfile start
# 创建用户
$ createuser msf -P 
$ createdb msf -O msf -E UTF8 -e
$ psql -U msf -d msf -h 127.0.0.1 
msf=> GRANT ALL PRIVILEGES ON DATABASE msf to msf;
y50M:config y50$ pwd
/Users/y50/metasploit-framework/config
$ cp database.yml.example database.yml

$ vim  database.yml
adapter: postgresql
  #database: metasploit_framework_development
  database: msf
  #username: metasploit_framework_development
  username: msf
  password: msf
  host: localhost
  port: 5432
  pool: 200
  timeout: 5
$ rbenv rehash
$ bundle install

在这里插入图片描述

参考:

  1. MAC OSX (10.11.3)安装metasploit最佳实践
  2. 在MAC上安装MSF
  3. Metasploit 教程
  4. Homebrew安装rbenv
  5. Download RubyGems
  6. Error fetching https://gems.ruby-china.org/: bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
  7. 苹果mac OS X上安装metasploit
  8. PostgreSQL 9.4.4 中文手册
  9. ruby nokogiri gem install mac osx high sierra
  10. Can’t find the PostgreSQL client library (libpq)
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值