iZ Le²
Digital Forensic Examiner at Singapore Police Force
To enhance incident response capabilities, it is essential to understand and analyze PowerShell related Event IDs.
For PowerShell-related activities, monitoring specific Event IDs can provide valuable information for incident responders. Here are some key Event IDs associated with PowerShell:
Event ID 400: Engine Lifecycle State Change:
· Indicates a change in the PowerShell engine’s lifecycle state.
Event ID 600: Module Logging:
· Captures information about the loading and unloading of PowerShell modules.
Event ID 4100: Engine Error:
· Logs an error related to the PowerShell engine.
Event ID 4103: Module Logging:
· Captures information about the loading and unloading of PowerShell modules.
Event ID 40961 and 40962: PowerShell Console is starting
· Records the start time of the PowerShell console session
Event ID 800: Remote PowerShell Session Establishment:
· Indicates the establishment of a remote PowerShell session.
Understanding PowerShell-related Event IDs and analyzing the corresponding event log files is pivotal for effective incident response.
Help improve contributions
Contribution hidden for you
Explore topics
Approach
The aim here is to provide basic information on the kinds of logs and other artefacts that could be generated from Cobalt Strike on a default Windows 10 host. To get a better context and understanding, we enabled Sysmon on the victim workstation, in order to get a baseline to compare with.
Each command was executed twice to avoid false positives, and the investigations were conducted on one of these two executions. This short analysis can be later on used as a reference to build rules to detect Cobalt Strike movements during a forensics incident response (without Sysmon or Audit Policies).
- Windows 10 workstations with Sysmon installed,
- Windows Server 2016 Domain Controller.
The different steps and tools used to extract and analyze the artefacts post compromise are:
- Run DFIR-Orc to extract artefacts on the Windows 10 machine;
- Run log2timeline/plaso on the extracted data to build a clear timeline;
- Analyze data using Splunk or Kibana (ELK fullstack with custom Logstash configuration).
By using DFIR-Orc and Plaso, we were able to process the most important artefacts:
- Event logs (
*.evtx
), including PowerShell command history; - Prefetch files among other execution evidence;
- NTFS artefacts, such as USNjrnl and MFT;
- User and System hives (userassist, appcompatcache, etc.).
Findings Summary
Cobalt Strike Commands | Time | Description |
---|---|---|
jump psexec64 | 13:33:05.767 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_FILE_CREATE |
jump psexec64 | 13:33:05.769 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x000000000051bce7) with ‘-‘ |
jump psexec64 | 13:33:05.803 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x000000000051bd0a) with ‘-‘ |
jump psexec64 | 13:33:05.829 | [evtx/sys/scm/7045] Service ‘4542843’ (\\DESKTOP-RI5FIO5\ADMIN$\4542843.exe ) was installed by user ‘LocalSystem’ (type: user mode service, start: demand start) |
jump psexec64 | 13:33:05.877 | [prefetch] Prefetch [4542843.EXE] was executed – run count 1 path hints: [] hash: 0xB39DA9E6 volume: 1 [serial number: 0x228095FD device path: \VOLUME{01d80e8a80662822-228095fd}] |
jump psexec64 | 13:33:06.954 | [prefetch] Prefetch [RUNDLL32.EXE] was executed – run count 2 path hints: \WINDOWS\SYSTEM32\RUNDLL32.EXE hash: 0x64292FC9 volume: 1 [serial number: 0x228095FD device path: \VOLUME{01d80e8a80662822-228095fd}] |
jump psexec64 | 13:33:07.000 | [evtx/sys/scm/7034] Service ‘4542843’ terminated unexpectedly (1 times) |
jump psexec64 | 13:33:07.000 | [fs/mft][macb] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf ($FILE_NAME), MFT:98397-10, PARENT: 93711-2 |
jump psexec64 | 13:33:07.000 | [fs/usnjrnl] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf USN_REASON_FILE_CREATE |
jump psexec64 | 13:33:07.939 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_CLOSE USN_REASON_FILE_DELETE |
jump psexec64 | 13:33:17.063 | [fs/mft][macb] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf ($FILE_NAME), MFT:98393-10, PARENT: 93711-2 |
jump psexec64 | 13:33:17.063 | [fs/usnjrnl] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf USN_REASON_FILE_CREATE |
… | … | … |
jump winrm64 | 13:38:10.193 | [prefetch] Prefetch [WSMPROVHOST.EXE] was executed – run count 2 path hints: \WINDOWS\SYSTEM32\WSMPROVHOST.EXE hash: 0xEF06207C volume: 1 [serial number: 0x228095FD device path: \VOLUME{01d80e8a80662822-228095fd} ] |
jump winrm64 | 13:38:10.650 | [evtx/winrm/91] Creating WSMan shell on server with ResourceURI: ‘http://schemas.microsoft.com/powershell/Microsoft.PowerShell‘ |
jump winrm64 | 13:38:11.036 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘-‘ (‘-‘) (logon_id=0x00000000005eb099) with ‘-‘ |
jump winrm64 | 13:38:11.614 | [fs/usnjrnl] File ¨C10C USN_REASON_FILE_CREATE |
jump winrm64 | 13:38:11.631 | [fs/usnjrnl] File ¨C11C USN_REASON_FILE_CREATE |
jump winrm64 | 13:38:11.964 | [evtx/powershell/53504] Windows PowerShell has started an IPC listening thread on process ‘9724’ in AppDomain ‘DefaultAppDomain’ |
jump winrm64 | 13:38:13.099 | [evtx/powershell/400] The PowerShell engine state hosted by application ¨C12C is changed from ‘None’ to ‘Available’. |
jump winrm64 | 13:38:13.705 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘-‘ (‘-‘) (logon_id=0x00000000005edc9b) with ‘-‘ |
jump winrm64 | 13:38:13.828 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘-‘ (‘-‘) (logon_id=0x00000000005edd18) with ‘-‘ |
jump winrm64 | 13:38:14.362 | [evtx/powershell/4104] The remote PowerShell scriptblock named ‘¨C13C’ is executed (29 blocks) |
jump winrm64 | 13:38:19.168 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x00000000005f30a3) with ‘-‘ |
jump winrm64 | 13:38:20.349 | [fs/mft][macb] File ‘\Windows\Prefetch\WSMPROVHOST.EXE-EF06207C.pf’ ($FILE_NAME), MFT:106956-3, PARENT: 93711-2 |
jump winrm64 | 13:38:20.349 | [fs/usnjrnl] File ¨C14C USN_REASON_FILE_CREATE |
… | … | … |
jump psexec_psh | 13:45:07.732 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x00000000008629e3) with ‘-‘ |
jump psexec_psh | 13:45:07.755 | [evtx/sys/scm/7045] Service ‘4b3d5bc’ (¨C15C) was installed by user ‘LocalSystem’ (type: user mode service, start: demand start) |
jump psexec_psh | 13:45:07.755 | [fs/mft][.a..] File ¨C16C ($STANDARD_INFORMATION), MFT:53610-1 |
jump psexec_psh | 13:45:07.771 | [prefetch] Prefetch [CMD.EXE] was executed – run count 2 path hints: ¨C17C hash: 0xAC113AA8 volume: 1 [serial number: 0x228095FD device path: ¨C18C] |
jump psexec_psh | 13:45:07.803 | [prefetch] Prefetch [POWERSHELL.EXE] was executed – run count 5 path hints: ¨C19C hash: 0x767FB1AE volume: 1 [serial number: 0x228095FD device path: ¨C20C] |
jump psexec_psh | 13:45:07.833 | [fs/mft][macb] File ¨C21C ($FILE_NAME), MFT:110491-2, PARENT: 93711-2 |
jump psexec_psh | 13:45:07.833 | [fs/usnjrnl] File ¨C22C USN_REASON_FILE_CREATE |
jump psexec_psh | 13:45:07.904 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x0000000000862fb5) with ‘-‘ |
jump psexec_psh | 13:45:08.192 | [fs/mft][..c.] File ¨C23C ($STANDARD_INFORMATION), MFT:56216-1 |
jump psexec_psh | 13:45:09.308 | [evtx/powershell/40961] A new PowerShell runspace have been created |
jump psexec_psh | 13:45:09.508 | [fs/usnjrnl] File ¨C24C USN_REASON_FILE_CREATE |
jump psexec_psh | 13:45:09.520 | [fs/usnjrnl] File ¨C25C USN_REASON_FILE_CREATE |
jump psexec_psh | 13:45:09.834 | [evtx/powershell/53504] Windows PowerShell has started an IPC listening thread on process ‘6920’ in AppDomain ‘DefaultAppDomain’ |
jump psexec_psh | 13:45:10.348 | [evtx/powershell/400] The PowerShell engine state hosted by application ¨C26C is changed from ‘None’ to ‘Available’. |
jump psexec_psh | 13:45:10.387 | [evtx/powershell/40962] A PowerShell runspace have been closed |
jump psexec_psh | 13:45:10.681 | [evtx/powershell/4104] The remote PowerShell scriptblock named ‘¨C27C’ is executed (1 block) |
jump psexec_psh | 13:45:11.213 | [evtx/powershell/4104] The remote PowerShell scriptblock named ‘¨C28C’ is executed (1 block) |
jump psexec_psh | 13:45:11.246 | [evtx/powershell/4104] The remote PowerShell scriptblock named ‘¨C29C’ is executed (1 block) |
jump psexec_psh | 13:45:17.990 | [fs/usnjrnl] File ¨C30C USN_REASON_DATA_TRUNCATION |
Cobalt Strike « jump psexec64 »
The Cobalt Strike jump psexec64
command allows the attacker to use the PsExec
utility to execute a command or payload on a remote Windows system. When the jump psexec64
command is executed, it will use the active beacon to establish a connection to the specified Windows system, and then use the PsExec
utility to run the malicious payload on the remote system. The command uses the psexec64 executable that is included in the Cobalt Strike package to run the command on x64 architectures. The Beacon type used for this test is smb
.
Microsoft-Windows-Sysmon
As explained earlier, System Monitor (Sysmon) was installed on the Windows 10 workstation to have reference events on which to base our analyses. We therefore first reviewed the events recorded by Sysmon to get a baseline to compare with the extracted artefacts. The Sysmon events below have been filtered to keep the most useful ones.
Event ID 1 – Process Create
The process creation event provides extended information about a newly created process. The full command line provides context on the process execution. The ProcessGUID field is a unique value for this process across a domain to make event correlation easier.
Time | Description |
---|---|
13:33:05.883 | [evtx/sysmon/1] Process created with command \\DESKTOP-RI5FIO5\ADMIN$\4542843.exe (pid: 9612) by user ‘NT AUTHORITY\SYSTEM’ via C:\Windows\System32\services.exe (pid: 596) |
13:33:06.960 | [evtx/sysmon/1] Process created with command C:\Windows\System32\rundll32.exe (pid: 4648) by user ‘NT AUTHORITY\SYSTEM’ via \\DESKTOP-RI5FIO5\ADMIN$\4542843.exe (pid: 9612) |
Event ID 3 – Network Connection Detected
The network connection event logs TCP/UDP connections on the machine. Each connection is linked to a process through the ProcessId and ProcessGUID fields. The event also contains the source and destination host names, IP addresses, port numbers and IPv6 status.
In both of our tests, 3 connections using IPv4 are made to the victim. The first one on port 445, the second one on port 135 and the last one to a random port. Then, two IPv6 connections are recorded to port 445.
Time | Description |
---|---|
13:33:06.881 | [evtx/sysmon/3] Tcp network connection from host – (192.168.56.119:54055) to host – (192.168.56.117:445) (pid=4) |
13:33:06.884 | [evtx/sysmon/3] Tcp network connection from host – (192.168.56.119:54056) to host – (192.168.56.117:135) (pid=832) |
13:33:06.885 | [evtx/sysmon/3] Tcp network connection from host – (192.168.56.119:54057) to host – (192.168.56.117:49692) (pid=596) |
13:33:06.885 | [evtx/sysmon/3] Tcp network connection from host – (fe80:0:0:0:d4bc:701f:e0a6:897d:49800) to host – (fe80:0:0:0:d4bc:701f:e0a6:897d:445) (pid=4) |
13:33:06.885 | [evtx/sysmon/3] Tcp network connection from host – (fe80:0:0:0:d4bc:701f:e0a6:897d:49800) to host – (fe80:0:0:0:d4bc:701f:e0a6:897d:445) (pid=4) |
Event ID 7 – Image Loaded
The image loaded event logs when a module is loaded in a specific process. It indicates the process in which the module is loaded, hashes and signature information.
The libraries loaded by the beacon are not very fancy. This information will not be useful without Sysmon installed on the victim workstation.
Time | Description |
---|---|
13:33:05.896 | [evtx/sysmon/7] Image C:\\Windows\\System32\\ntdll.dll loaded from process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.897 | [evtx/sysmon/7] Image C:\\Windows\\System32\\kernel32.dll loaded from process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.899 | [evtx/sysmon/7] Image C:\\Windows\\System32\\KernelBase.dll loaded from process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.902 | [evtx/sysmon/7] Image C:\\Windows\\System32\\apphelp.dll loaded from process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.915 | [evtx/sysmon/7] Image C:\\Windows\\System32\\advapi32.dll loaded from process ¨C53C (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.916 | [evtx/sysmon/7] Image ¨C54C loaded from process ¨C55C (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.917 | [evtx/sysmon/7] Image ¨C56C loaded from process ¨C57C (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.918 | [evtx/sysmon/7] Image ¨C58C loaded from process ¨C59C (pid=9612) with user NT AUTHORITY\SYSTEM |
13:33:05.929 | [evtx/sysmon/7] Image ¨C60C loaded from process ¨C61C (pid=9612) with user NT AUTHORITY\SYSTEM |
Event ID 11 – File Create
A randomly named Beacon1 was created on the file system to the C:\Windows
directory by the System
process. The two created Prefetch files related to rundll32.exe
and the Beacon will be useful to identify Cobalt Strike execution.
Time | Description |
---|---|
13:33:05.772 | [evtx/sysmon/11] Process System (pid=4) created file C:\\Windows\\4542843.exe with user NT AUTHORITY\SYSTEM |
13:33:07.009 | [evtx/sysmon/11] Process C:\\Windows\\system32\\svchost.exe (pid=1860) created file C:\\Windows\\Prefetch\\4542843.EXE-B39DA9E6.pf with user NT AUTHORITY\SYSTEM |
13:33:17.065 | [evtx/sysmon/11] Process C:\\Windows\\system32\\svchost.exe (pid=1860) created file C:\\Windows\\Prefetch\\RUNDLL32.EXE-64292FC9.pf with user NT AUTHORITY\SYSTEM |
Event ID 13 – Registry Value Set
Registry key and value create and delete operations map to this event type.
Cobalt Strike creates a service to run the Beacon as SYSTEM. So a registry key with a random name2 is created under HKLM\\System\\CurrentControlSet\\Services\\4542843
by the Services.exe
executable and the ImagePath
is set to the Beacon path.
Time | Description |
---|---|
13:33:05.866 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process C:\\Windows\\system32\\services.exe (pid 596) has SetValue HKLM\\System\\CurrentControlSet\\Services\\4542843\\ObjectName value to LocalSystem |
13:33:05.866 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process C:\\Windows\\system32\\services.exe (pid 596) has SetValue HKLM\\System\\CurrentControlSet\\Services\\4542843\\ImagePath value to \DESKTOP-RI5FIO5\ADMIN$\4542843.exe |
13:33:05.866 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process C:\\Windows\\system32\\services.exe (pid 596) has SetValue HKLM\\System\\CurrentControlSet\\Services\\4542843\\ErrorControl value to DWORD (0x00000000) |
13:33:05.866 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process C:\\Windows\\system32\\services.exe (pid 596) has SetValue HKLM\\System\\CurrentControlSet\\Services\\4542843\\Start value to DWORD (0x00000003) |
13:33:05.866 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process C:\\Windows\\system32\\services.exe (pid 596) has SetValue ¨C82C value to DWORD (0x00000010) |
13:33:07.941 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process ¨C83C (pid 596) has SetValue ¨C84C value to DWORD (0x00000004) |
13:33:07.941 | [evtx/sysmon/13] Registry event : user NT AUTHORITY\SYSTEM process ¨C85C (pid 596) has SetValue ¨C86C value to DWORD (0x00000001) |
Event ID 17 – Pipe Created
Pipe creation operations map to this event type.
Time | Description |
---|---|
13:33:05.926 | [evtx/sysmon/17] Process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) created pipe \\MSSE-2716-server with user NT AUTHORITY\SYSTEM |
13:33:06.988 | [evtx/sysmon/17] Process C:\\Windows\\System32\\rundll32.exe (pid=4648) created pipe \\msagent_bd with user NT AUTHORITY\SYSTEM |
13:33:06.955 | [evtx/sysmon/18] Process \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) connected pipe \\MSSE-2716-server |
13:33:08.961 | [evtx/sysmon/18] Process System (pid=4) connected pipe \\msagent_bd |
Event ID 25 – Process Tampering
Since Sysmon version 13, a new type of event is recorded, called process tampering. This event is generated when a process uses hiding techniques such as hollow or herpaderp. The injection of Cobalt Strike was successfully detected by Sysmon:
Time | Description |
---|---|
13:33:05.889 | [evtx/sysmon/25] Process tampering detected for images \\\\DESKTOP-RI5FIO5\\ADMIN$\\4542843.exe (pid=9612) with user ‘NT AUTHORITY\SYSTEM’ |
Findings
Now that we have seen the events and other artefacts generated by the execution of the jump psexec64
command, let us dwell on the evidence present natively on a Windows 10 system out of the box.
Winevtx – Microsoft-Windows-Security-Auditing
Without the audit policies enabled, not many events are generated. Only two successful logons (event ID 4624) are recorded, with the logon type ‘3’ (Network), from the compromised account « CORP\alice ». If correlated, this behavior may help during the investigation to support a hypothesis. The source hostnames are not always recorded, nor is the logon process name.
Time | Description |
---|---|
13:33:05.769 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x000000000051bce7) with ‘-‘ |
13:33:05.769 | [evtx/sec/4672] Special privileges assigned to ‘CORP\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) (logon_id=0x000000000051bce7): SeSecurityPrivilege SeBackupPrivilege SeRestorePrivilege SeTakeOwnershipPrivilege SeDebugPrivilege SeSystemEnvironmentPrivilege SeLoadDriverPrivilege SeImpersonatePrivilege SeDelegateSessionUserImpersonatePrivilege |
13:33:05.803 | [evtx/sec/4624] User ‘CORP.LOCAL\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) successfully logon (type=3) from ‘192.168.56.119’ (‘-‘) (logon_id=0x000000000051bd0a) with ‘-‘ |
13:33:05.802 | [evtx/sec/4672] Special privileges assigned to ‘CORP\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) (logon_id=0x000000000051bd0a): SeSecurityPrivilege SeBackupPrivilege SeRestorePrivilege SeTakeOwnershipPrivilege SeDebugPrivilege SeSystemEnvironmentPrivilege SeLoadDriverPrivilege SeImpersonatePrivilege SeDelegateSessionUserImpersonatePrivilege |
Time | Description |
---|---|
13:34:46.386 | [evtx/sec/4634] User logged off ‘CORP\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) (logon_id=0x000000000051bd0a) from logon type=3 |
13:35:06.877 | [evtx/sec/4634] User logged off ‘CORP\alice’ (S-1-5-21-1155457554-2149841727-2293290625-1108) (logon_id=0x000000000051bce7) from logon type=3 |
Winevtx – Service Control Manager
Time | Description |
---|---|
13:33:05.829 | [evtx/sys/scm/7045] Service ‘4542843’ (\\DESKTOP-RI5FIO5\ADMIN$\4542843.exe ) was installed by user ‘LocalSystem’ (type: user mode service, start: demand start) |
13:33:07.000 | [evtx/sys/scm/7034] Service ‘4542843’ terminated unexpectedly (1 times) |
Prefecth – Program execution
Time | Description |
---|---|
13:33:05.877 | [prefetch] Prefetch [4542843.EXE] was executed – run count 1 path hints: [] hash: 0xB39DA9E6 volume: 1 [serial number: 0x228095FD device path: \VOLUME{01d80e8a80662822-228095fd}] |
13:33:06.954 | [prefetch] Prefetch [RUNDLL32.EXE] was executed – run count 2 path hints: \WINDOWS\SYSTEM32\RUNDLL32.EXE hash: 0x64292FC9 volume: 1 [serial number: 0x228095FD device path: \VOLUME{01d80e8a80662822-228095fd}] |
File System – MFT
Time | Description |
---|---|
13:33:07.000 | [fs/mft][m.cb] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf ($STANDARD_INFORMATION), MFT:98397-10 |
13:33:07.000 | [fs/mft][macb] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf ($FILE_NAME), MFT:98397-10, PARENT: 93711-2 |
13:33:17.063 | [fs/mft][…b] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf ($STANDARD_INFORMATION), MFT:98393-10 |
13:33:17.063 | [fs/mft][macb] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf ($FILE_NAME), MFT:98393-10, PARENT: 93711-2 |
In our case, since the system has been freshly installed, rundll32.exe
has run for the first time and the birth of the Prefetch file can be observed in the MFT (here in both $FILE_NAME
and $STANDARD_INFORMATION
of the RUNDLL32.EXE-64292FC9.pf
file), otherwise only its modification would be visible.
File System – USN journal
Just like the MFT, and as observed in the SysMon logs (event ID 11), the USN journal can also detect the malicious executable and its Prefetch file. The location of the beacon in the C:\Windows
directory makes it easy to spot. The activity of the Prefetch file of rundll32.exe
is also recorded. The C:\Windows\4542843.exe
binary is deleted immediately after its execution.
Time | Description |
---|---|
13:33:05.767 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_FILE_CREATE |
13:33:05.767 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
13:33:05.767 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_CLOSE USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
13:33:07.000 | [fs/usnjrnl] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf USN_REASON_FILE_CREATE |
13:33:07.000 | [fs/usnjrnl] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
13:33:07.000 | [fs/usnjrnl] File \Windows\Prefetch\4542843.EXE-B39DA9E6.pf USN_REASON_CLOSE USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
13:33:07.939 | [fs/usnjrnl] File \Windows\4542843.exe USN_REASON_CLOSE USN_REASON_FILE_DELETE |
13:33:17.063 | [fs/usnjrnl] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf USN_REASON_FILE_CREATE |
13:33:17.063 | [fs/usnjrnl] File \Windows\Prefetch\RUNDLL32.EXE-64292FC9.pf USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
13:33:17.063 | [fs/usnjrnl] File ¨C129C USN_REASON_CLOSE USN_REASON_DATA_EXTEND USN_REASON_FILE_CREATE |
Conclusion
The default Cobal Strike jump psexec64
command is fairly easy to detect because it creates a service with a random name2 and uses the rundll32.exe
3 program without any arguments to host the payload. Even if the malicious binary is deleted immediately after its execution, the location of the beacon in the C:\Windows
directory makes it even easier to spot.
Detection Rule Example
The timeline is processed using plaso
(https://plaso.readthedocs.io/) on data collected with DFIR-Orc (https://dfir-orc.github.io/). The available fields and their names may vary depending on how you use log2timeline
and psort
.
Kibana
The various KQL queries correspond to each aspect of the conclusion stated above and can of course be grouped together. The most important is the SCM record (event ID 7045). Note that all these events occur in a short period of time. The name of the beacon can be spotted with the SCM record (event ID 7045) and then used to improve the queries on the MFT and USN journal events.
parser : "winevtx" and source_name : "Service Control Manager" and eid : 7045
parser : "winevtx" and source_name : "Microsoft-Windows-Security-Auditing" and eid : (4624 or 4672 or 4634)
parser : "usnjrnl" and message : \\Windows\\*.exe
parser : ( "prefetch" or "mft" ) and message : *RUNDLL32.EXE*
Splunk
host="*" index="*" parser=winevtx eid=7045 service_path="*ADMIN$*"
| table _time host message
| sort _time
Sigma
A Sigma rule already exists for this event (sigma/win_cobaltstrike_service_installs.yml at master · SigmaHQ/sigma).
sigma-cli >>> sigma convert -t splunk -p sysmon ../sigma/rules/windows/builtin/system/win_cobaltstrike_service_installs.yml
Parsing Sigma rules [####################################] 100%
Provider_Name="Service Control Manager" EventID=7045 (ImagePath="*ADMIN$*" ImagePath="*.exe*" OR ImagePath="*%COMSPEC%*" ImagePath="*start*" ImagePath="*powershell*" OR ImagePath="*powershell -nop -w hidden -encodedcommand*" OR ImagePath="*SUVYIChOZXctT2JqZWN0IE5ldC5XZWJjbGllbnQpLkRvd25sb2FkU3RyaW5nKCdodHRwOi8vMTI3LjAuMC4xO*" OR ImagePath="*lFWCAoTmV3LU9iamVjdCBOZXQuV2ViY2xpZW50KS5Eb3dubG9hZFN0cmluZygnaHR0cDovLzEyNy4wLjAuMT*" OR ImagePath="*JRVggKE5ldy1PYmplY3QgTmV0LldlYmNsaWVudCkuRG93bmxvYWRTdHJpbmcoJ2h0dHA6Ly8xMjcuMC4wLjE6*")
Cobalt Strike « jump winrm64 »
The Cobalt Strike jump winrm64
command allows using the Windows Remote Management (WinRM) service to execute a command or payload on a remote Windows system. When the jump winrm64 command is executed, it will use the active beacon to establish a connection to the specified Windows system and then use the WinRM service to run the malicious payload on the remote system. The Beacon type used for this test is smb
.
Microsoft-Windows-Sysmon
Event ID 1 – Process Create
The process creation event provides extended information about a newly created process. The full command line provides context on the process execution. The ProcessGUID field is a unique value for this process across a domain to make event correlation easier. The hash is a full hash of the file with the algorithms in the HashType field.
Over the period of time during which the jump winrm64
command is executed, one of the created processes is wsmprovhost.exe
by the svchost.exe
process. Indeed, since the jump winrm64
command uses the Windows Remote Management (WinRM) service, the wsmprovhost.exe
process is started to handle the incoming connection and execute the command or payload.
Time | Description |
---|---|
13:38:10.192 | [evtx/sysmon/1] Process created with command C:\Windows\system32\wsmprovhost.exe -Embedding (pid: 9724) by user ‘CORP\alice’ via C:\Windows\System32\svchost.exe -k DcomLaunch -p (pid: 728) |
Event ID 3 – Network Connection Detected
The network connection event logs TCP/UDP connections on the machine. Each connection is linked to a process through the ProcessId and ProcessGUID fields. The event also contains the source and destination host names, IP addresses, port numbers and IPv6 status.
Sysmon recorded 4 network connections to the victim workstation on port TCP\5985 (HTTP default WinRM port) and, since the beacon type used for this test is smb
, one more to TCP port TCP\445 (SMB).
Time | Description |
---|---|
13:38:12.005 | [evtx/sysmon/3] An unknown process (pid: 4) created a TCP network connection from ‘192.168.56.119:54176’ to ‘192.168.56.117:5985’ |
13:38:12.907 | [evtx/sysmon/3] An unknown process (pid: 4) created a TCP network connection from ‘192.168.56.119:54177’ to ‘192.168.56.117:5985’ |
13:38:15.662 | [evtx/sysmon/3] An unknown process (pid: 4) created a TCP network connection from ‘192.168.56.119:54179’ to ‘192.168.56.117:5985’ |
13:38:15.935 | [evtx/sysmon/3] An unknown process (pid: 4) created a TCP network connection from ‘192.168.56.119:54180’ to ‘192.168.56.117:5985’ |
13:38:20.995 | [evtx/sysmon/3] An unknown process (pid: 4) created a TCP network connection from ‘192.168.56.119:54181’ to ‘192.168.56.117:445’ |
Event ID 7 – Image Loaded
The image loaded event logs when a module is loaded in a specific process. It indicates the process in which the module is loaded, hashes and signature information.
This event records the libraries loaded by a process during its execution. Without Sysmon installed on the victim workstation, it is hard to get the same information from other artefacts. However, because in that particular case the MFT artefact was able to get close information, this event is displayed here. The wsmprovhost.exe
process (PID 9724) loads 88 DLL and we chose to list only two because of their records in the MFT (see below).
Time | Description |
---|---|
13:38:10.177 | [evtx/sysmon/7] Process C:\Windows\System32\wsmprovhost.exe (pid: 9724) executed by ‘CORP\alice’ loaded module C:\Windows\System32\wsmprovhost.exe |
13:38:10.333 | [evtx/sysmon/7] Process C:\Windows\System32\wsmprovhost.exe (pid: 9724) executed by ‘CORP\alice’ loaded module C:\Windows\System32\WsmSvc.dll |
13:38:10.523 | [evtx/sysmon/7] Process C:\Windows\System32\wsmprovhost.exe (pid: 9724) executed by ‘CORP\alice’ loaded module C:\Windows\System32\wsmplpxy.dll |
13:38:10.600 | [evtx/sysmon/7] Process C:\Windows\System32\wsmprovhost.exe (pid: 9724) executed by ‘CORP\alice’ loaded module C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\97c421700557a331a31041b81ac3b698\mscorlib.ni.dll |
13:38:10.600 | [evtx/sysmon/7] Process C:\Windows\System32\wsmprovhost.exe (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C159C |
13:38:10.600 | [evtx/sysmon/7] Process ¨C160C (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C161C |
13:38:10.600 | [evtx/sysmon/7] Process ¨C162C (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C163C |
13:38:10.618 | [evtx/sysmon/7] Process ¨C164C (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C165C |
13:38:10.662 | [evtx/sysmon/7] Process ¨C166C (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C167C |
13:38:10.662 | [evtx/sysmon/7] Process ¨C168C (pid: 9724) executed by ‘CORP\alice’ loaded module ¨C169C |
Event ID 11 – File Create
Our malicious wsmprovhost.exe
process has the PID 9724. The Cobalt Strike Beacon runs under the context of PowerShell, this is why two PowerShell script files are generated by Microsoft to test against Applocker. If the test file executes, then it assumed that Applocker is disabled.
Time | Description |
---|---|
13:38:11.653 | [evtx/sysmon/11] Process C:\Windows\system32\wsmprovhost.exe (pid=9724) created file C:\Users\alice\AppData\Local\Temp\__PSScriptPolicyTest_amxqtozh.ie2.psm1 run by user ‘CORP\alice’ |
13:38:11.653 | [evtx/sysmon/11] Process C:\Windows\system32\wsmprovhost.exe (pid=9724) created file C:\Users\alice\AppData\Local\Temp\__PSScriptPolicyTest_psmlbjet.gus.ps1 run by user ‘CORP\alice’ |
13:38:29.313 | [evtx/sysmon/11] Process C:\Windows\system32\wsmprovhost.exe (pid=9724) created file C:\Users\alice\AppData\Local\Microsoft\Windows\PowerShell\ModuleAnalysisCache run by user ‘CORP\alice’ |
13:38:29.313 | [evtx/sysmon/11] Process C:\Windows\system32\wsmprovhost.exe (pid=9724) created file C:\Users\alice\AppData\Local\Microsoft\Windows\PowerShell run by user ‘CORP\alice’ |
Event ID 17 / 18 – Pipe Created or Accessed
Pipe creation operations map to these event types when a named pipe is created (event ID 17) and when a named pipe is created or accessed (event ID 18).
The previous spotted processes with PID 4 and 9724 used several names pipes. The created pipe \\msagend_bd
is made by the SMB beacon (by default) for the communication with the C2.
Time | Description |
---|---|
13:38:11.959 | [evtx/sysmon/17] User ‘CORP\alice’ used the process C:\Windows\system32\wsmprovhost.exe (pid: 9724) to create named pipe \PSHost.132924298901870926.9724.DefaultAppDomain.wsmprovhost |
13:38:17.148 | [evtx/sysmon/17] User ‘CORP\alice’ used the process C:\Windows\system32\wsmprovhost.exe (pid: 9724) to create named pipe \msagent_bd |
13:38:10.558 | [evtx/sysmon/18] User ‘CORP\alice’ used the process C:\Windows\system32\wsmprovhost.exe (pid: 9724) to connect named pipe \lsass |
13:38:19.169 | [evtx/sysmon/18] User ‘NT AUTHORITY\SYSTEM’ used the process System (pid: 4) to connect named pipe \msagent_bd |