mac os 安装metasploit v5.0.23(msf)

安装metasploit

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

执行上面的命令时,报如下错误,需要对bundler进行更新。

[*] Bundler failed to load and returned this error:

   'cannot load such file -- bundler/setup'

[*] You may need to uninstall or upgrade bundler

bundler是一个很好的管理ruby项目gems的工具。使用bundler可以为你的ruby project提供统一的构建环境(无论是production, development, 还是staging),因为bunder可以很好的跟踪和安装指定的和预期的gem。

gem install bundler  //需要在root用户下运行

安装postgresql

在msf中使用数据库之后搜索msf中模块的速度可以大大提高;使用msf的痕迹会被保存下来,方便之后导出编写测试报告。

brew install postgresql
brew services start postgresql //启动postgresql 服务

初始化数据库

initdb /usr/local/var/postgres

在创建数据库中,如果报如下错误:

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".

删除该目录,然后执行创建数据库命令:

rm -r /usr/local/var/postgres

为msf创建一个用户和数据库:

createuser msf -P -h localhost  //设置密码
createdb -O msf msf -h localhost  // 使用msf用户创建msf数据库

配置metasploit中的postgresql

cd metasploit-framework/config
cp database.yml.example database.yml

development: &pgsql
  adapter: postgresql
  database: msf
  username: msf
  password: 
  host: localhost
  port: 5432
  pool: 200
  timeout: 5

安装指定的和预期的gem

刚刚已经安装了bundler,接下来使用它安装msf依赖的所有gem包。RubyGems是Ruby的一个包管理器,提供了分发Ruby程序和库的标准格式“gem”,旨在方便地管理gem安装的工具,以及用于分发gem的服务器。这类似于Python的pip。

bundle install  //此命令会尝试更新系统中已存在的gem包

安装过程中出现如下错误:

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.

执行这条命令即可,可能需要安装一会,耐心等待。。。

bundle install --path vendor/bundle

运行msf

一定要按照以上顺序进行安装
全都安装完成后,就可以运行msf了:

cd metasploit-framework
./msfconsole

mac os 安装metasploit v5.0.23(msf)_第1张图片

如果想方便运行,也可以设置下env(环境变量):

echo 'alias msfconsole="path/metasploit-framework && ./msfconsole && cd -"' >> ~/.zshrc
echo 'alias msfbinscan="path/metasploit-framework && ./msfbinscan && cd -"' >> ~/.zshrc
echo 'alias msfd="path/metasploit-framework && ./msfd && cd -"' >> ~/.zshrc
echo 'alias msfelfscan="path/metasploit-framework && ./msfelfscan && cd -"' >> ~/.zshrc
echo 'alias msfmachscan="path/metasploit-framework && ./msfmachscan && cd -"' >> ~/.zshrc
echo 'alias msfpescan="path/metasploit-framework && ./msfpescan && cd -"' >> ~/.zshrc
echo 'alias msfrop="path/metasploit-framework && ./msfrop && cd -"' >> ~/.zshrc
echo 'alias msfrpc="path/metasploit-framework && ./msfrpc && cd -"' >> ~/.zshrc
echo 'alias msfrpcd="path/metasploit-framework && ./msfrpcd && cd -"' >> ~/.zshrc
echo 'alias msfupdate="path/metasploit-framework && ./msfupdate && cd -"' >> ~/.zshrc
echo 'alias msfvenom="path/metasploit-framework && ./msfvenom && cd -"' >> ~/.zshrc
sudo chmod go+w /etc/profile
sudo echo export MSF_DATABASE_CONFIG=path/metasploit-framework/config/database.yml >> /etc/profile

升级msf

可以通过设置github用户信息,然后执行./msfupdate进行升级:

git config --global user.name "NAME HERE" 
git config --global user.email "[email protected]"

欢迎关注wx公号:StriveBen;看左侧联系我加群交流哦!

你可能感兴趣的:(MAC)