Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 2.3 KB

T1504.md

File metadata and controls

51 lines (33 loc) · 2.3 KB

T1504 - PowerShell Profile

Adversaries may gain persistence and elevate privileges in certain situations by abusing [PowerShell](https://attack.mitre.org/techniques/T1086) profiles. A PowerShell profile (profile.ps1) is a script that runs when PowerShell starts and can be used as a logon script to customize user environments. PowerShell supports several profiles depending on the user or host program. For example, there can be different profiles for PowerShell host programs such as the PowerShell console, PowerShell ISE or Visual Studio Code. An administrator can also configure a profile that applies to all users and host programs on the local computer. (Citation: Microsoft About Profiles)

Adversaries may modify these profiles to include arbitrary commands, functions, modules, and/or PowerShell drives to gain persistence. Every time a user opens a PowerShell session the modified script will be executed unless the -NoProfile flag is used when it is launched. (Citation: ESET Turla PowerShell May 2019)

An adversary may also be able to escalate privileges if a script in a PowerShell profile is loaded and executed by an account with higher privileges, such as a domain administrator. (Citation: Wits End and Shady PowerShell Profiles)

Atomic Tests


Atomic Test #1 - Append malicious start-process cmdlet

Appends a start process cmdlet to the current user's powershell profile pofile that points to a malicious executable

Supported Platforms: Windows

Inputs:

Name Description Type Default Value
exe_path Path the malicious executable Path calc.exe
ps_profile Powershell profile to use String $profile

Attack Commands: Run with powershell!

if(Test-Path #{ps_profile}){
}
else{
  New-Item -Path #{ps_profile} -Type File -Force
}
$malicious = "Start-Process #{exe_path}"
Add-Content #{ps_profile} -Value $malicious
powershell -command exit

Cleanup Commands:

$oldprofile = cat $profile | Select-Object -skiplast 1
Set-Content $profile -Value $oldprofile