Commandline Activity Use Cases
Grouped by Detection Method
MITRE ATT&CK Framework: Command-Line Interface (T1059), PowerShell (T1086), Inhibit System Recovery
- Execution of malicious commands AND scripts from command-line interfaces.
Aggregate Count
- Process file names (without path)
- Process file names (with path)
- rundll32.exe DLL Paths
- regsvr32.exe DLL Paths
Question the use of these, as they are infrequently used legitimately
- at.exe
- aspnet_compiler.exe
- CustomShellHost.exe to execute an explorer.exe child process
- DeviceCredentialDeployment.exe to hide a process (T1564)
- makecab.exe (T1105, T1564.004, T1036)
- pktmon.exe to capture packets (T1040)
- rpcping.exe to exploit RPC (T1003, T1187)
!!!! IMPORTANT NOTES !!!!
- MANY commandlines can use - OR / interchangeably. Account for this!
- Commandlines can have junk characters like ^ to obfuscate detections, where the command is ran as if those characters didn’t exist.
- Any inclusion of “http” can be supplemented by a pattern to match IP addresses for web communication.
- Commandline Obfuscation
- Commandline containing
- a caret (^) (T1027)
- /c echo
- two double quotes (“”)
- a comma immediately followed by a (,;)
- a semicolon immediately followed by a comma (;,)
- consecutive commas
- consecutive semicolons
- COMSPEC (part of %COMSPEC%)
- /\ OR \/ OR \.\ OR /./ or\./ OR ..
-
- final
Whitelist Alert
Levenshtein Score Alert
Rolling Whitelist Alert
Shannon Entropy Score Alert
Threshold Alert
Log Source Examples
- Windows Security Event ID 4104 (Enable ScriptBlock Logging)
- Windows Security Event ID 4103 (Enable Module Logging)
- Windows PowerShell Transcription Log (File)
- Create the key path: HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\Transcription\
- Create new DWORD EnableInvocationHeader = 1
- Create new DWORD EnableTranscripting = 1
- Create new STRING VALUE OutputDirectory =
- Logs will be stored in .txt files in teh specified directory, using the format
..\YYYYMMDD\PowerShell_transcript.PCNAME.RANDOM.YYYYMMDDHHMMSS.txt
)
- Endpoint Detection AND Response product
Possible False Positives
- Many commandline activities performed by authorized privileged users may false-positive on this content.
References
- https://lolbas-project.github.io/
- https://github.com/3CORESec/MAL-CL