PowerShell

From ATT&CK
Jump to: navigation, search
PowerShell
Technique
ID T1086
Tactic Execution
Platform Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows XP, Windows 7, Windows 8, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012 R2, Windows Vista, Windows 8.1
Permissions Required User, Administrator
Data Sources Windows Registry, File monitoring, Process command-line parameters, Process monitoring
Supports Remote Yes

PowerShell is a powerful interactive command-line interface and scripting environment included in the Windows operating system.1 Adversaries can use PowerShell to perform a number of actions, including discovery of information and execution of code. Examples include the Start-Process cmdlet which can be used to run an executable and the Invoke-Command cmdlet which runs a command locally or on a remote computer.

PowerShell may also be used to download and run executables from the Internet, which can be executed from disk or in memory without touching disk.

Administrator permissions are required to use PowerShell to connect to remote systems.

A number of PowerShell-based offensive testing tools are available, including Empire,2 PowerSploit,3 and PSAttack.4

Examples

  • Deep Panda has used PowerShell scripts to download and execute programs in memory, without writing to disk.5
  • APT29 has used encoded PowerShell scripts uploaded to CozyCar installations to download and install SeaDuke.6 APT29 also used PowerShell scripts to evade defenses.7
  • APT3 has used PowerShell on victim systems to download and run payloads after exploitation.8
  • The Poseidon Group's Information Gathering Tool (IGT) includes PowerShell components.9
  • FIN6 has used a Metasploit PowerShell module to download and execute shellcode and to set up a local listener.10
  • Stealth Falcon malware uses PowerShell commands to perform various functions, including gathering system information via WMI and executing commands from its C2 server.11
  • Patchwork used PowerSploit to download and run a reverse shell.12
  • HAMMERTOSS is known to use PowerShell.13
  • SeaDuke uses a module to execute Mimikatz with PowerShell to perform Pass the Ticket.6
  • AutoIt downloads a PowerShell script that decodes to a typical shellcode loader.14

Mitigation

It may be possible to remove PowerShell from systems when not needed, but a review should be performed to assess the impact to an environment, since it could be in use for many legitimate purposes and administrative functions. When PowerShell is necessary, restrict PowerShell execution policy to administrators and to only execute signed scripts. Be aware that there are methods of bypassing the PowerShell execution policy, depending on environment configuration.15 Disable/restrict the WinRM Service to help prevent uses of PowerShell for remote execution.

Detection

If proper execution policy is set, adversaries will likely be able to define their own execution policy if they obtain administrator or system access, either through the Registry or at the command line. This change in policy on a system may be a way to detect malicious use of PowerShell. If PowerShell is not used in an environment, then simply looking for PowerShell execution may detect malicious activity.

It is also beneficial to turn on PowerShell logging to gain increased fidelity in what occurs during execution.16 PowerShell 5.0 introduced enhanced logging capabilities, and some of those features have since been added to PowerShell 4.0. Earlier versions of PowerShell do not have many logging features.17 An organization can gather PowerShell execution details in a data analytic platform to supplement it with other data.

References