可以覆盖 Windows 加载时动态链接吗?

Can Windows Load-Time Dynamic Linking be overrided?

我是一名研究生,正在研究 Windows API 挂钩。 我知道用修改后的 DLL 替换 System32 文件夹中受保护的 DLL 并不容易。 但我正在寻找是否有一种方法,这样我就可以 change/override Windows 动态 DLL 链接器,我可以在全局范围内挂钩 Windows API,而无需使用任何其他系统 APIs?

我的目的是在全球范围内分析 Powershell 脚本,以便监控拜占庭行为。挂钩是我第一个想到的。

我在Windows内书(第6版)中寻找答案,但找不到任何基于此的理论。也将不胜感激。

谢谢。

可以使用称为绕行的旧功能。有一个名为 AppInit_DLLs 的注册表项,其中包含在启动时加载到每个进程中的库列表。例如,它被 Sophos Anti-Virus 使用。它是真正的全球性的,AFAIK。每个进程都会在创建进程时进行检查。但是,此处可能存在相关讨论:Preventing a DLL file from loading into my process via MS Detours

但是,如果您要监控的具体是 Powershell,并且您可以依靠 PSv5 及更高版本,Powershell 会为您提供一些非常强大的本机功能来监控和约束。你可能会更好地使用它。

绝对 ne plus ultra 白皮书的标题是 在企​​业中保护 PowerShell,由澳大利亚网络安全中心发布 here.我想他们会把它放在那里很长时间,作为一个政府 body,但即使它变黑了,你也应该能够用你选择的搜索引擎找到一份副本。它会定期更新;在撰写本文时,它显示 "March 2019" 并包含这个有用的骑手:

Organisations or individuals with questions regarding this advice can contact the ACSC by emailing asd.assist at defence.gov.au or calling 1300 CYBER1 (1300 292 371).

澳大利亚信号局,谢谢。由于这是澳大利亚号码,请不要忘记握住您的电话upside-down。

本着 SO 的精神,我给你一个概要。该文档列出了从低安全性到高安全性的一系列可实现步骤。阶段是:

  • 默认配置
  • 脚本白名单
  • 脚本代码签名
  • PSv5
  • 中央记录和转录
  • Role-based 白名单
  • WinRM 强化
  • 约束端点

整个文档有 20 页,因此花费的时间并不多。但是由于您的问题似乎与 中央日志记录和转录 部分有关,因此这里是显示功能的相关摘录:

  • Engine Lifecycle Logging: PowerShell logs the start-up and termination of PowerShell hosts. PowerShell version 5.0 has the ability to log the command-line arguments passed to the PowerShell host, including PowerShell code passed to powershell.exe via the command line. Engine lifecycle logging is enabled by default and can be found in the Applications and Services Logs\Microsoft\Windows\PowerShell\Operational log.
  • Module/Pipeline Logging: PowerShell version 3.0 and later can log pipeline events to Windows Event Logs on a per-module basis or on a global basis. This can be set via Group Policy.
  • Script Block Tracing: PowerShell version 5.0 can log detailed information including what code was run and is output to the Windows Operational Event Log.
  • Transcripting: PowerShell version 5.0 allows for the transcription of code in all PowerShell hosts and can be controlled by Group Policy. While very powerful, transcripts do not integrate into Windows Event Logs and will need to be managed as on disk files.

以下是与该部分相关的附录摘录:

我不确定您的具体目标是什么,但在我看来这篇论文可能对您有用。