【www.bbyears.com--ruby】
Metasploit一款基于ruby的渗透测试框架,官方只提供Windows和Linux的安装包,要在osx上安装需要手动准备运行环境,下面介绍安装过程。
安装要求:
技能:会使用Terminal,了解命令sudo的作用,帐号具备管理员权限。
操作系统:我使用的OS X Yosemite(10.10.3)。
网络:似乎rubygem和一些代码托管网站在大陆是被封锁的,所以你可能需要用到代理。
1.安装Xcode and Command Line Development Tools
打开AppStore搜索Xcode安装,快速链接(美国商店)https://itunes.apple.com/us/app/xcode/id497799835?mt=12
安装完成后在命令终端输入下面命令后会弹出一个新的安装窗口,根据提示进行安装。
xcode-select --install
2.安装JDK
提供下载链接:
http://download.oracle.com/otn-pub/java/jdk/8u40-b27/jdk-8u40-macosx-x64.dmg
3.安装Homebrew和运行环境
执行下面命令
#安装
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo PATH=/usr/local/bin:/usr/local/sbin:$PATH >> ~/.bash_profile
source ~/.bash_profile
#确保brew正常运行
brew doctor
brew tap homebrew/versions
brew tap homebrew/dupes
#通过brew安装nmap网络扫描软件
brew install nmap
#安装ruby2.1.5
brew install homebrew/versions/ruby21
#安装postgresql
brew install postgresql
4.下载metasploit安装相关ruby模块
请参照下面命令操作,注意执行bundle install前需cd到 /usr/local/share/metasploit-framework目录。
cd /usr/local/share/
git clone https://github.com/rapid7/metasploit-framework.git
cd metasploit-framework
for MSF in $(ls msf*); do ln -s /usr/local/share/metasploit-framework/$MSF /usr/local/bin/$MSF;done
sudo echo export MSF_DATABASE_CONFIG=/usr/local/share/metasploit-framework/config/database.yml >> /etc/profile
#产生vncviewer链接
echo "#!/usr/bin/env bash">> /usr/local/bin/vncviewer
echo open vnc://\$1 >> /usr/local/bin/vncviewer
chmod +x /usr/local/bin/vncviewer
#安装模块
gem install pg sqlite3 msgpack activerecord redcarpet rspec simplecov yard bundler
#重要步骤! 安装nokogiri模块
gem install nokogiri -v "1.6.6.2" -- \
--use-system-libraries -- \
--with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib \
--with-xslt-lib=/usr/local/lib \
--with-xslt-include=/usr/local/include
#安装其他模块
bundle install
5.配置Postgresql
#初始化数据库
initdb /usr/local/var/postgres
#创建“msf”用户和“msf”数据库,注意记下你设置的数据库密码
createuser msf -P -h localhost
createdb -O msf msf -h localhost
#配置postgresql随开机启动
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.4.1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
#配置metasploit的数据库连接
#编辑器创建一个配置
vi /usr/local/share/metasploit-framework/config/database.yml
#配置内容,注意保留跟在冒号后的空格
##########配置开始################
production:
adapter: postgresql
database: msf
username: msf
password: <数据库密码>
host: 127.0.0.1
port: 5432
pool: 75
timeout: 5
###########配置结束################
6.大功告成
输入msfconsole进入metasploit的shell,输入db_status确认数据库连接正常。