ATT&CK-CN V1.01 Last Update: 2019-11 [返回索引页]

译者: 林妙倩、戴亦仑 原创翻译作品,如果需要转载请取得翻译作者同意。

数据来源:ATT&CK Matrices

原文: https://attack.mitre.org/techniques/T1504

术语表: /attack/glossary

PowerShell配置文件

在某些情况下,攻击者可以通过滥用PowerShell(T1086)配置文件来获得持久性和提升特权。PowerShell配置文件(profile.ps1)是一个在PowerShell启动时运行的脚本,可以用作登录脚本来自定义用户环境。PowerShell根据用户或主机程序支持多个配置文件。例如,PowerShell主机程序(例如PowerShell控制台,PowerShell ISE或Visual Studio Code)可以有不同的配置文件。管理员还可以配置一个配置文件,该配置文件适用于本地计算机上的所有用户和主机程序。

攻击者可能会修改这些配置文件,以包括任意命令,功能,模块和/或PowerShell驱动器来获得持久性。每次用户打开PowerShell会话时,除非启动该-NoProfile标志,否则将执行修改后的脚本。

如果PowerShell概要文件中的脚本由具有较高特权的帐户(例如域管理员)加载并执行,则对手也可能能够提升特权。

标签

ID编号: T1504

策略: 持久性,特权升级

平台: Windows

所需权限: user,administrator

数据源: 进程监视,文件监视,PowerShell日志

程序示例

名称 描述
Turla(G0010 Turla(G0010)使用PowerShell配置文件来维护受感染计算机的持久性。
Name Description
Turla(G0010 Turla(G0010) has used PowerShell profiles to maintain persistence on an infected machine.[2]

缓解措施

缓解 描述
代码签名(M1045) 强制执行仅签名的PowerShell脚本。对配置文件进行签名,以免对其进行修改。
限制文件和目录权限(M1022) 使PowerShell配置文件不可变且只能由某些管理员更改将限制对手轻松创建用户级持久性的能力。
软件配置(M1054) 如果不需要,请避免使用PowerShell配置文件。-No Profile远程执行PowerShell脚本时,请使用带有标志,以防止执行本地配置文件和脚本。
Mitigation Description
Code Signing (M1045) Enforce execution of only signed PowerShell scripts. Sign profiles to avoid them from being modified.
Restrict File and Directory Permissions (M1022) Making PowerShell profiles immutable and only changeable by certain administrators will limit the ability for adversaries to easily create user level persistence.
Software Configuration (M1054) Avoid PowerShell profiles if not needed. Use the -No Profile flag with when executing PowerShell scripts remotely to prevent local profiles and scripts from being executed.

检测

profile.ps1应该监视可以存储的位置是否有新的配置文件或修改。配置文件位置示例包括:

  • $PsHome\Profile.ps1
  • $PsHome\Microsoft._profile.ps1
  • $Home\My Documents\PowerShell\Profile.ps1
  • $Home\My Documents\PowerShell\Microsoft._profile.ps1

监视异常的PowerShell命令,异常的PowerShell驱动器或模块加载和/或未知程序的执行。

Locations where profile.ps1 can be stored should be monitored for new profiles or modifications. Example profile locations include:

  • $PsHome\Profile.ps1
  • $PsHome\Microsoft._profile.ps1
  • $Home\My Documents\PowerShell\Profile.ps1
  • $Home\My Documents\PowerShell\Microsoft._profile.ps1

Monitor abnormal PowerShell commands, unusual loading of PowerShell drives or modules, and/or execution of unknown programs.