Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 登錄密碼攔截原理深度解析:lsass 進程 Hook 技術

編輯:Windows XP 系統介紹

本文從底層原理剖析 Windows 密碼攔截/破解機制,涉及核心認證架構與 Hook 技術,僅供安全研究參考。

核心認證流程

  • 所有交互式登錄 (本地、RDP、RunAs、IPC$) 最終均進入 lsass.exe 進程。
  • 默認認證包 msv1_0.dll 導出關鍵函數 LsaApLogonUserEx2。
  • 該函數接收認證信息 (用戶名、明文密碼、域等) 並進行驗證。

攔截技術實現

  1. DLL 注入 lsass.exe。
  2. Hook LsaApLogonUserEx2 (或 LsaApLogonUserEx)。
  3. 在 Hook 處理函數中讀取參數結構體中的明文密碼字段 (UNICODE_STRING)。
  4. 不同系統版本解碼方式不同:
    • 2000/XP/2003:密碼可能經 RtlRunDecodeUnicodeString 編碼,需通過 UNICODE_STRING.Length 高 8 位獲取 XOR Key 解碼。
    • Vista/7/8/10:調用 AdvApi32.CredIsProtectedW 判斷,CredUnprotectW 解密。
  5. 將獲取的明文密碼通過管道、郵槽、文件等 IPC 機制傳出。

接口規範 (示例 DLL 導出)

HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine);
  • pszCmdLine 指定輸出目標 (文件路徑、管道名 \\.\pipe\xxx、郵槽 \\.\mailslot\xxx)。
  • 數據格式:ANSI 字符串 username:password。

測試驗證

regsvr32 /n /i:c:\xxx.log c:\plugin\WinPswLogger.dll

成功後鎖定/切換用戶重新登錄,c:\xxx.log 將記錄攔截到的密碼。

防禦對策

  • 啟用 Windows Defender Credential Guard (虛擬化隔離 LSASS)。
  • 部署 LSA 保護 (RunAsPPL) 防止非簽名代碼注入。
  • 監控 lsass.exe 異常模塊加載 (Sysmon Event ID 7)。
  • 限制調試權限 (SeDebugPrivilege)。

聲明: 技術原理公開旨在促進防禦建設,嚴禁用於非授權滲透測試或惡意竊取憑證。

Copyright © Windows教程網 All Rights Reserved