beef在ubuntu上怎么安装

Python012

beef在ubuntu上怎么安装,第1张

在终端中执行以下命令:

sudo apt-get update

sudo apt-get install curl git

curl -sSL https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable source ~/.rvm/scripts/rvm

sudo rvm install 2.1.5

sudo rvm use 2.1.5 -- default

sudo gem install bundler

执行完rvm use 2.1.5 -- default后需要 更换Ruby的源;否则在国内会因未知原因导致

“gem install bundler” 执行失败。

Ruby源:https://gems.ruby-china.org/

克隆BeEF源码到本地

git clone git://github.com/beefproject/beef.git

然后执行命令

cd beef

sudo bundle install

ruby beef

安装完成。

先删除BT5上面自带的版本稍旧的BeEF

rm -rf /pentest/web/beef-ng

然后通过Git clone最新的BeEF代码

这样beef的代码已经拷贝到 /pentest/web/beef 下

然后就开始安装

cd /pentest/web/beef

gedit INSTALL.txt

查看安装文档,只看第一步和第三步

1. Prerequisites (platform independent)

BeEF requires ruby 1.9 and the “bundler” gem. Bundler can be installed by:

gem install bundler

3. Prerequisites (Linux)

!!! This must be done PRIOR to running the bundle install command !!!

On linux you will need to find the packages specific to your distribution for sqlite. An example for Ubuntu systems is:

3.0. sudo apt-get install libsqlite3-dev sqlite3 sqlite3-doc

3.1. install rvm from rvm.beginrescueend.com, this takes care of the various incompatable and conflicting ruby packages that are required

3.2. rvm install 1.9.2

3.3. rvm use 1.9.2

BT5自带的Ruby,所以我们只需要下面几步

apt-get install libsqlite3-dev sqlite3 sqlite3-doc

gem install bundler

bundle install

然后尝试运行beef

./beef

发现报如下错误

/root/beef/core/loader.rb:18:in `require': no such file to load -- bundler/setup (LoadError)

from /root/beef/core/loader.rb:18:in `<top (required)>'

from ./beef:42:in `require'

from ./beef:42:in `<main>'

上网找了一下,发现是环境变量的原因。

用如下方法再次安装bundler

gem install -–user-install bundler

然后成功运行beef

./beef

三、BeEF与metasploit的配合使用

这时候你会发现,启动过程没有出现metasploit加载的信息。于是需要先关闭BeEF,进去metasploit主目录。

cd /opt/framework/msf3/

生成一个beef.rc的文件,内容是

load msgrpc ServerHost=127.0.0.1 Pass=abc123

(这个密码牵扯众多地方,貌似改了影响太大,所以还是用默认的)

注:这里需要msf里面装好msgrpc这个插件,在msf里面运行 gem install --user-install msgpack

IP是你metasploit所在主机的IP,密码是两个软件之间的设定好的。之后到beef的主目录去修改主机的配置,这里重点配置的是metasploit攻击后,回连主机的IP,这个很重要。配置上述信息的文件如下:

/pentest/web/beef/extensions/metasploit/config.yaml

由于实验主机这两个软件都有,所以我的IP设置就是本机IP。很明显,两个软件不在同一台主机上工作也是没问题的。最后还要配置beef主目录下的文件:

/pentest/web/beef/config.yaml

将里面的metasploit一项设置为true

之后启动metasploit并加载beef模块

./msfconsole -r beef.rc

可以看到成功加载上面的beef模块

[*] MSGRPC Service: 127.0.0.1:55552

[*] MSGRPC Username: msf

[*] MSGRPC Password: abc123

[*] Successfully loaded plugin: msgrpc

这时候去运行beef ,就能够看到metasploit的攻击加载过程。

[*] MSGRPC Service: 127.0.0.1:55552

[*] MSGRPC Username: msf

[*] MSGRPC Password: abc123