標題:域滲透之Windows Access Token 攻擊

taibeihacker

Moderator

域渗透之 Windows Access Token 攻击​

Windows Access Token 简介​

Windows Access Token 概念​

微軟官方的定義如下:
An access token is an object that describes the security context of a process or thread.The information in token includes the identity and privileges of the user account associatedwith the process or thread.
Windows Access Token(訪問令牌),它是一個描述進程或者線程安全上下文的一個對象。不同的用戶登錄計算機後,都會生成一個Access Token,這個Token 在用戶創建進程或者線程時會被使用,不斷的拷貝,這也就解釋了A 用戶創建一個進程而該進程沒有B 用戶的權限。當用戶註銷後,系統將會使主令牌切換為模擬令牌,不會將令牌清除,只有在重啟機器後才會清除。
Access Token 分為兩種(主令牌、模擬令牌)

Windows Access Token 分类​

1、primary token 這種令牌通常用於本地及遠程RDP 登錄
2、impersonation token 這種則通常用於各種非交互式的登錄,比如,netuse,wmi,winrm等等

登录方式​

交互式登錄
console login (type 2)
rdp login (type 10)
psexec (type 2)
網絡登錄
wmi (type 3)
winrm (type 3)

Windows Access Token 组成​

用戶帳戶的安全標識符(SID)
用戶所屬的組的SID
用於標識當前登錄會話的登錄SID
用戶或用戶組所擁有的權限列表
所有者SID
主要組的SID
訪問控制列表
訪問令牌的來源
令牌是主要令牌還是模擬令牌
限制SID 的可選列表
目前的模擬等級
其他統計數據

关于 SID​

安全標識符(Security identifiers),簡稱為SID,分別是OwnerSid 和GroupSid。所謂SID 就是每次當我們創建一個用戶或一個組的時候,系統會分配給該用戶或組一個唯一SID,當你重新安裝系統後,也會得到一個唯一的SID。 SID 是唯一的,不隨用戶的刪除而分配到另外的用戶使用。請記住,SID 永遠都是唯一的。 SIF 是由計算機名、當前時間、當前用戶態線程的CPU 耗費時間的總和三個參數決定以保證它的唯一性。
例:S-1-5-21-1763234323-321265751-1234321321-500(whoami/user)

Windows Access Token 产生过程​

用戶使用憑據(用戶密碼)進行認證– 登錄session 創建– windows 返回用戶的sid 和用戶所在組的sid – LSA 創建一個Access token — 使用憑據成功認證– 登錄session — token — 進程、線程
20200511155641.png-water_print

后渗透中的令牌模拟​

cobalt strike 模拟令牌​

使用steal_token 模擬令牌,rev2self 恢復令牌
20200511155846.png-water_print

metasploit 模拟令牌​

incognito 模塊,同樣rev2self 恢復令牌
20200511160407.png-water_print

获取任意进程的令牌权限​

手动令牌模拟​

模擬過程:
openprocess() – openprocesstoken() – impersonateloggedonuser() – duplicatetokenex() – createprocesswithtokenw()

openprocess​

20200511161046.png-water_print

openprocesstoken​

20200511161136.png-water_print

impersonateloggedonuser​

20200511161220.png-water_print

duplicatetokenex​

20200511161255.png-water_print

createprocesswithtokenw​

20200511161349.png-water_print

Bypass Protect Process​

並不是所有的進程都是可以被操作的
20200511161605.png-water_print

只獲取system 權限的進程:
1
get-token where-object {$_.username-eq 'NT AUTHORITY\SYSTEM' -and $_ownername -ne 'NT AUTHORITY\SYSTEM'} | select-object processname, processsid | format-table
然後經過測試發現像csrss、 service、 wininit、smss 等token 獲取失敗。
20200511162053.png-water_print

使用 Access Token 进行 BypassUAC​

Fuzzy Security 利用Windows 令牌實現UAC 繞過
20200511162556.png-water_print
 
返回
上方