最近购了台mac一直没有时间折腾,下面就把在mac上安装metasploit的步骤做一个简单的记录吧。
安装的几个步骤:
0×00-从github上克隆Metasploit项目到本地;
0×01-安装postgresql并进行配置;
0×02-安装特定版本的ruby,并解决依赖;
0×00 从github上克隆Metasploit项目到本地
话说github真是什么都有,很多好的项目在上面都能找到,首先打开终端并输入下列命令,因为10.9.3自带了git,所以就不需要另外安装了
git clone https://github.com/rapid7/metasploit-framework.git /usr/local/share/metasploit-framework
克隆到本地后,将metasploit-framework/config/目录下的配置文件:database.yml 添加到环境变量中(database.yml 也许不存在,直接复制database.yml.example)
在$HOME/.bash_profile或者其他配置文件中添加下面这条配置
export MSF_DATABASE_CONFIG=/usr/local/share/metasploit-framework/config/database.yml
0×01 安装postgresql并进行配置
metasploit下载完后,不急着去配置,因为metasploit的默认数据库postgresql还没有装上
你可以直接使用brew来下载并自动安装postgresql,可以运行如下命令
brew install postgresql --without-ossp-build
等待自动安装完毕,完成后,初始化postgresql(若出现错误删掉/usr/local/var/postgres,并重试)
initdb /usr/local/var/postgres
初始化完毕后,为metasploit添加数据库用户和创建相应DB
createuser msf -P -h localhost
createdb -O msf msf -h localhost
(上面参数不懂了,大家可以百度一下,这里就不做过多解释了)
上面的步骤完成后,需更改metasploit的数据库连接配置,也就是第一步中的database.yml文件
在database.yml中,将信息修改如下
production: adapter: postgresql database: msf username: msf password: <your password> host: 127.0.0.1 port: 5432 pool: 75 timeout: 5
完成后,进入第三步!
(可自行添加alisa来简便每一次postgresql的启动)
alias pg_start='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias pg_stop='pg_ctl -D /usr/local/var/postgres stop'
0×02 安装特定版本的ruby,并解决依赖
说到ruby的多版本管理,这里就要用最给力的工具了rbenv(可以在github上找到,也可以使用brew直接安装)
brew install rbenv ruby-build
rbenv安装完成后,在$HOST/.bash_profile或其他配置文件中添加如下设置
eval "$(rbenv init -)"
下面就可以通过rbenv来安装特定版本的ruby了,首先列出当前可用的ruby版本
rbenv install --list
可以看到几乎所有的ruby版本都有,这里我们选择安装ruby-1.9.3-p547(因为OS X 10.9.3 自带的ruby为2.0.0版本,在某些地方会产生问题)
rbenv install 1.9.3-p547
这里可能会等一会儿,rbenv会将各个版本的ruby安装在$HOST/.rbenv/versions/下,完成后,将下载的版本设置为系统默认
rbenv rehash
rbenv global 1.9.3-p547
完成后,重新打开终端,输入ruby –version就可以看到当前默认的ruby版本已经设置成为1.9.3-p547
下面安装bundle来解决依赖问题
gem install bundle
安装的时候,可能会出连接问题,多试几次即可
bundle安装完毕后,再次进入metasploit的主目录解决模块包的依赖
cd /usr/local/share/metasploit-framework
rbenv rehash
bundle install
(在bundle install的过程中,可能会出现某一个特定版本的模块安装失败的问题,解决方法:根据GemFiles里的版本限制,自行使用gem安装替代版本,完成后,删掉GemFiles.lock,重新运行bundle install)
依赖解决后,即可运行目录下的msfconsole启动metasploit终端控制器(已启动postgresql,不然会连不上数据库)
可以将msf命令批量ln到bin下
for MSF in $(ls msf*); do ln -s /usr/local/share/metasploit-framework/$MSF /usr/local/bin/$MSF;done
下面是完成后的截图
(由于是事后记录,可能过程没有截图,第一次投稿,勿喷,本渣渣的weibo:http://weibo.com/rickgray)
-
yyyy3333...不错 不过要先有个苹果 ……
-
楼主可否留下个QQ 有问题咨询
不容错过
- 经验分享:挖洞联盟第一季漏洞精选漏洞盒子2016-04-14
- 基于约束的SQL攻击鸢尾2017-01-06
- FireEye发布报告《风暴中心的APT28》:揭秘俄罗斯政府操控的黑客组织APT28cxt2017-01-15
- 【BlackHat专题】议题花絮一箩筐:Pwnie Awards、灯泡传播病毒、会场WiFi有人捣乱…欧阳洋葱2016-08-06
0daybank
已有 42 条评论
楼主可否留下个QQ 有问题咨询
ln -s $PATH/metasploit-framework/msf* usr/local/bin/
没有用shell的必要。
表示mac上的metasploit用了很久了,参照网上的文章安装的,虽然具体遇到很多问题,但是问题解决了就装上了
@╃本人出售╃ 你是怎么下载的? 我在github下载好慢,下不动
@gsky 网络环境问题吧,我这边下载还可以,或者直接访问https://github.com/rapid7/metasploit-framework.git 下载zip包
…不错 不过要先有个苹果 ……
不明觉厉
你是我的小丫小苹果
方法已经学会,就差一个苹果电脑了
前几天在youtube上面看见有相同的教程 没有苹果只能吃黑苹果啦 等会测试一下 ,
Receiving objects: 0% (1542/262166), 844.00 KiB | 9.00 KiB/s
速度太慢了
速度真的很慢,有什么方法可以下载快点吗?
@gsky github应该不慢吧,你可以网站上下好了cp过去,或者试试挂代理?
@RickGray
请教一下,运行完bundle install 后, 运行msfconsole报这个要怎么修复呢?
.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:298:in `to_specs’: Could not find ‘metasploit-framework’ (>= 0) among 81 total gem(s) (Gem::LoadError)
from /Users/gsky/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:309:in `to_spec’
在bundle install的过程中,可能会出现某一个特定版本的模块安装失败的问题,解决方法:根据GemFiles里的版本限制,自行使用gem安装替代版本,完成后,删掉GemFiles.lock,重新运行bundle install)
大牛 这步不明白啊 麻烦详细说下吧
@alchuan 因为由于网络原因(被墙?),特定版可能无法正常下载,此时可以更改GemFile里的版本限制,然后再bundle install进行依赖包的安装。
@RickGray 大牛 怎么更改GemFile里的版本限制呢
@ alchuan 在metasploit安装目录下 vi GemFile还有vi GemFile.lock,修改里面的源
.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/bundler-1.7.5/lib/bundler/resolver.rb:357:in `resolve’: Could not find gem ‘timecop (>= 0) ruby’ in the gems available on this machine. (Bundler::GemNotFound)
metasploit-framework at /usr/local/share/metasploit-framework did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["Gemfile.lock"] are not files
Using metasploit-framework 4.10.1.pre.dev from source at .
Errno::EACCES: Permission denied – metasploit-framework-db-4.10.1.pre.dev.gem
An error occurred while installing metasploit-framework-db (4.10.1.pre.dev), and Bundler cannot continue.
Make sure that `gem install metasploit-framework-db -v ’4.10.1.pre.dev’` succeeds before bundling.
0ks3iiodeMacBook-Pro:metasploit-framework 0ks3iio$ gem install metasploit-framework-db -v ’4.10.1.pre.dev’
ERROR: Could not find a valid gem ‘metasploit-framework-db’ (= 4.10.1.pre.dev) in any repository
gem install bundle
Successfully installed bundle-0.0.1
1 gem installed
Installing ri documentation for bundle-0.0.1…
file ‘lib’ not found
Installing RDoc documentation for bundle-0.0.1…
file ‘lib’ not found
@ river.nate 我也遇见同样的问题
装了一下午依赖包啥的,终于搞好了,哈哈哈
ln的话不是特别的好,最好能做个shell cd过去,因为metasploit现在要求ruby2.1.6
$HOST/.bash_profile和$HOME/.bash_profile有何区别?$HOST/.bash_profile这个文件没找到啊
user-20141223zj:metasploit-framework yangjunfeng$ msfconsole
[*] Metasploit requires the Bundler gem to be installed
$ gem install bundler
user-20141223zj:metasploit-framework yangjunfeng$ gem install bundle
ERROR: Could not find a valid gem ‘bundle’ (>= 0), here is why:
Unable to download data from https://rubygems.org/ – Errno::ECONNRESET: Connection reset by peer – SSL_connect (https://api.rubygems.org/latest_specs.4.8.gz)
找大虾指点啊!
rbenv: version `2.1.7′ is not installed报这个错
@ yiran4827 我也遇到相同报错,是在bundle install时遇到的。
Smith:metasploit-framework Hola$ msfconsole
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:377:in `parse’: (/usr/local/share/metasploit-framework/config/database.yml): could not find expected ‘:’ while scanning a simple key at line 9 column 1 (Psych::SyntaxError)
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:377:in `parse_stream’
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:325:in `parse’
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:252:in `load’
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:471:in `block in load_file’
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:471:in `open’
from /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/psych.rb:471:in `load_file’
from /usr/local/share/metasploit-framework/lib/msf/ui/console/driver.rb:172:in `initialize’
from /usr/local/share/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `new’
from /usr/local/share/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `driver’
from /usr/local/share/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start’
from /usr/local/share/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start’
from /usr/local/bin/msfconsole:48:in `<main>’
按步骤装完 执行msfconsole 报错 求大神解答?
请问大神如何升级呢
碰到一个问题,pg安装不上。最终解决方法:
env ARCHFLAGS="-arch x86_64" gem install pg
成功安装pg
rbenv安装后,我用的是zsh,所以必须在 ~/.zshrc下添加以下两行,否则rbenv rehash 和 rbenv global执行不了。
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
@ 小道儿 可怜的人,被2014年的文章坑了吧…… msf早有osx安装包了 –> http://osx.metasploit.com/ _(:зゝ∠)_
@ evil7 下载了之后怎么用啊
@ evil7 安装了后怎么启动啊(•͈˽•͈)
szc:~ apple$ 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" (fe80::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?
metasploit添加数据库用户和创建相应DB出错,提示链接server失败,metasploit-framework/config/目录下没有database.yml ,添加环境变量指向database.yml.example?? 更改metasploit的数据库连接配置,只能更改database.yml.example??
rbenv: version `2.3.1′ is not installed (set by /usr/local/share/metasploit-framework/.ruby-version)
Could not find gem ‘simplecov’ in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
brew install postgresql –without-ossp-uuid
Error: Unknown command: install
求解。。。
= =原谅我挖贴,我是10.11的,网络问题我用OS X终端使用配置socks5 代理,镜像用https://gems.ruby-china.org,现在的msg是需要2.3.1的,然后就这么= =慢慢的成功了
@ Mr_Null 挖坟了兄弟啊,直接msf官网有mac版的pkg下了。一键搭建,环境隔离,不用谢。
Index: http://osx.metasploit.com
Latest: http://osx.metasploit.com/metasploitframework-latest.pkg
用rvm解决ruby的安装问题很爽