CmdID / Techniques / T1059
T1059.001 Command and Scripting Interpreter: PowerShell
Adversaries may abuse PowerShell commands and scripts for execution. MITRE ATT&CK
4 programs on CmdID 103 Sigma rules T1059.001 on attack.mitre.org
Part of
Programs for it
Sigma rules tagged with it
Command lines CmdID reads as it
Download the contents of a URL to a file on the page for invoke-webrequest
Invoke-WebRequest http://example.com -OutFile path\to\fileIdentifyOnly return raw HTML data instead of parsing it under Internet Explorer (PowerShell 3.0-5.1 only) on the page for invoke-webrequest
Invoke-WebRequest http://example.com -UseBasicParsingIdentifySend form-encoded data (POST request of type application/x-www-form-urlencoded) on the page for invoke-webrequest
Invoke-WebRequest -Method Post -Body @{ name='bob' } http://example.com/formIdentifySend a request with an extra header, using a custom HTTP method on the page for invoke-webrequest
Invoke-WebRequest -Headers @{ X-My-Header = '123' } -Method PUT http://example.comIdentifySend data in JSON format, specifying the appropriate content-type header on the page for invoke-webrequest
Invoke-WebRequest -Body '{"name":"bob"}' -ContentType 'application/json' http://example.com/users/1234IdentifyPass a username and password for server authentication on the page for invoke-webrequest
Invoke-WebRequest -Headers @{ Authorization = "Basic "+ [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("myusername:mypassword")) } http://example.comIdentifyAdd a computer to a domain using predefined computer credentials on the page for Add-Computer
$newADComputerSplat = @{
Name = "Server02"
AccountPassword = (ConvertTo-SecureString -String 'TempJoinPA$$' -AsPlainText -Force)
}
New-ADComputer @newADComputerSplat
# Then this command is run from Server02 which is not yet domain-joined:
$joinCred = New-Object pscredential -ArgumentList ([pscustomobject]@{
UserName = $null
Password = (ConvertTo-SecureString -String 'TempJoinPA$$' -AsPlainText -Force)[0]
})
$addComputerSplat = @{
DomainName = "Domain03"
Options = 'UnsecuredJoin', 'PasswordPass'
Credential = $joinCred
}
Add-Computer @addComputerSplatIdentifyGet JSON strings from a web service and convert them to PowerShell objects on the page for ConvertFrom-Json
# Ensures that Invoke-WebRequest uses TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$j = Invoke-WebRequest 'https://api.github.com/repos/PowerShell/PowerShell/issues' |
ConvertFrom-JsonIdentifyConvert a secure string to an encrypted string on the page for ConvertTo-SecureString
PS C:> $Secure = Read-Host -AsSecureString
PS C:> $Secure
System.Security.SecureString
PS C:> $Encrypted = ConvertFrom-SecureString -SecureString $Secure
PS C:> $Encrypted
01000000d08c9ddf0115d1118c7a00c04fc297eb010000001a114d45b8dd3f4aa11ad7c0abdae98000000000
02000000000003660000a8000000100000005df63cea84bfb7d70bd6842e7efa79820000000004800000a000
000010000000f10cd0f4a99a8d5814d94e0687d7430b100000008bf11f1960158405b2779613e9352c6d1400
0000e6b7bf46a9d485ff211b9b2a2df3bd6eb67aae41
PS C:> $Secure2 = ConvertTo-SecureString -String $Encrypted
PS C:> $Secure2
System.Security.SecureStringIdentifyCreate a secure string from an encrypted string in a file on the page for ConvertTo-SecureString
$Secure = Read-Host -AsSecureString
$Encrypted = ConvertFrom-SecureString -SecureString $Secure -Key (1..16)
$Encrypted | Set-Content Encrypted.txt
$Secure2 = Get-Content Encrypted.txt | ConvertTo-SecureString -Key (1..16)IdentifyConvert a plain text string to a secure string on the page for ConvertTo-SecureString
$Secure_String_Pwd = ConvertTo-SecureString "P@ssW0rD!" -AsPlainText -ForceIdentifyEffects of disabling a session configuration on the page for Disable-PSSessionConfiguration
PS> Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Auto
Name Permission
---- ----------
MaintenanceShell BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
PS> Disable-PSSessionConfiguration -Name MaintenanceShell -Force
PS> Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Auto
Name Permission
---- ----------
MaintenanceShell Everyone AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
PS> New-PSSession -ComputerName localhost -ConfigurationName MaintenanceShell
[localhost] Connecting to remote server failed with the following error message : Access is denied.
For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailedIdentifyAnd 29 more examples on CmdID’s program pages.
An example is here when CmdID’s reading of it names T1059.001: a Sigma rule it trips is tagged with it, or its abuse is documented as it.