The two primary components of Kape are target collection and module execution:
Figure 2 – Gkape Target Options
Figure 3 – Gkape Module Options
Gkape contains a section that shows the current command line usage based on the target and module options selected. Please see Figure 4.
Figure 4 – Gkape current command line
Several of the collection options offered by Kape contain groups of other collections. Collection groups minimize the options that need to be selected for the incident responder to achieve their desired configuration. The collection of Kape scripts that would run can be viewed by double-clicking on the collection. Please see Figures 5 and 6. (Zimmerman, 2020)
Figure 5 – Gkape View Collection Scripts
Figure 6 – Gkape Script Details
Before using Kape, a user must download external modules. Downloading external modules is performed by running the included Get-KAPEUpdate.ps1 PowerShell script. Some modules may need to be downloaded from an external source. Kape will notify the User of any of these external dependencies. Kape will provide instructions on how to download and install the dependency. Kape intentionally does not bundle in all of the binaries needed because Kape leverages programs from many different authors. You can always find the URL of the binary dependency required by using the below command and adjusting the directory as required for each category.
Since Kape is a command-line application, it can easily be scripted to perform forensics on remote computers. Kape can be run remotely using either psexec.exe or by leveraging the enterprise’s software deployment tool. Kape requires administrative permissions on the endpoint to retrieve forensic artifacts correctly. Kape is such a lightweight forensics tool that it is perfect for pulling triage information over a slower network before pulling the computer for full forensics imaging. Accessing the triage information earlier enables the incident responder to start their investigation sooner.
It is important to note that Kape is only available on Microsoft Windows. GRR Rapid Response is a similar live-forensic tool that is available for Linux and OS X.
Memory captures should be gathered first for nearly all incidents. Memory captures are critical to the forensic methodology because of how computer processes behave. Memory images preserve the following information lost on reboot:
The incident responder performs memory captures with Kape by selecting the WinPmem module or using this command:
kape.exe –msource C: –mdest %1\%computername%\ –module WinPmem
The incident responder needs to set %1 to the drive letter of the drive where the memory image is copied. Depending on the type of security incident, a full forensic disk image may still be necessary, but Kape generally makes traditional forensic techniques seem archaic. (DeGrazia, 2019)
The easiest option for speeding up incident response times is to use Kape for live-forensics before capturing a full hard drive image. Capturing a full hard drive image allows the incident responder to start their investigation sooner and minimize downtime while also allowing the incident responder to use traditional forensics techniques. Kape has thirty-four specifically designed modules for live response. We used Kape (Version 9.3.0; Zimmerman, 2020) to complete the table in Figure 7.
Figure 7 – Kape Live Response Options
One way to leverage Kape in conjunction with traditional forensics tools is to have Kape collect the KapeTriage collection. The KapeTriage collection includes file system ($MFT, $LogFile, $Boot, $J, $SDS), Registry Hives, Scheduled Tasks, Web Browser, Link files, jump lists, and remote access information. Once this is collected, these files can be manually loaded into Axiom, FTK, or Encase. Manually loading these files provides a way to quickly collect forensic artifacts and analyze them in traditional robust forensics tools. The concept of Kape as a forensics triage tool is expanded later in this paper. (Thinkdfir, 2019)
The final option for using Kape to speed up incident response analysis time is to use Kape excusively. Kape is robust enough to compete with full forensics suites directly. One of the drawbacks of this approach is that Kape’s output is several unrelated files. It can be challenging to keep the files organized and to track artifact comments. Kape provides a timeline feature that is generally only found in commercial forensic programs. The Kape “mini_timeline” module parses the MFT, event logs, and registry hives to create a CSV file with the combined timeline. For the computer name to be included in the timeline correctly, a variable with the Key computerName must exist. The value for the variable should be the name of the computer. If the computer has been in use for more than a year, then the CSV timeline generated is most likely too large to open in excel. The incident responder uses The Mini_Timeline_Slice_by_Daterange module to narrow down the information in the timeline. The Mini_Timeline_Slice_by_Daterange module requires a Kape variable named dateRange to function correctly. The value for the dateRange key should be in the following format: mm/dd/yyyy-mm/dd/yyyy.
The following scripts are recommended for use as appropriate, depending on the forensic engagement:
The following scripts are recommended for use as appropriate, depending on the forensic engagement:The recommended usage for most security incidents is to run the Kape_Default script and then copy the results from this script to the incident responder’s computer for analysis. Once the incident responder copies the results to their computer, the next recommended step is to run the Kape_HD script to gather a full hard disk image if required. Running the Kape_HD script allows the incident responder to investigate the Kape triage while the entire hard drive image is being captured and processed by the traditional forensics tool of choice.
Kape allows the incident responder to get granular with what information is collected and how it is processed. Granularity is helpful when the person who wrote the Kape script is not the person performing the evidence collection. An incident responder can tailor Kape to upload the collection artifacts to SFTP, Azure, or AWS. Uploading artifacts in this way is a crucial element of performing remote evidence collection. Figure 8 demonstrates the upload options in Kape.
Figure 8 – Gkape Upload Options
During the early stages of an investigation involving malicious software, the best two modules to review are autoruns and PWSH-Get-ProcessList.
Autoruns is a Kape module that runs the Sysinternals Autoruns program. Autoruns has the most comprehensive knowledge of auto-starting locations of any startup monitor. It shows the incident responder the programs configured to run during system bootup or login. Additionally, Autoruns shows the start for various built-in Windows applications like Internet Explorer, Explorer, and media players. (Markruss, 2020)
See Figure 9 for an abbreviated output from the Autoruns command. It is often helpful to filter the autoruns output to narrow down the search focus. The incident responder narrows the search focus by filtering for only enabled entries and entries with a signer that is “Not verified.” The incident responder can also group the Autoruns output by category to help filter out information that is not relevant to the investigation. Grouping allows the incident responder to narrow their search for how the malware is maintaining persistence. Unfortunately, the time column does not always show helpful information, so it can be challenging to track down the newest installed persistence mechanisms.
Figure 9 – Autoruns Output
PWSH-Get-ProcessList is a Kape module that runs a PowerShell script that calls the WMI object Win32_Process to list all currently running processes. This allows the incident responder to quickly track down suspicious running applications based on launch location, launch time, process owner, and process name. There is an issue with the creationdate field in the PWSH-Get-ProcessList Kape module. The creationdate is in a format not recognizable to Excel. The Kape module can easily be updated with the below code to convert this field to a better date format. The incident responder updates the following file KAPE\Modules\LiveResponse\PWSH-Get-ProcessList.mkape with the second part of the below code.
Original:
Executable:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
CommandLine: -Command “Get-WMIObject Win32_Process | Select-Object Name,ProcessID,Path,commandline,@{Label=’Owner’; Expression={(Get-Process -PID $_.ProcessID -IncludeUserName).UserName}},CreationDate,ThreadCount,HandleCount,VirtualSize,Priority,@{Label=’PriorityClass’; Expression={(Get-Process -PID $_.ProcessID).PriorityClass}},@{Label=’Security ID’;
Expression={$_.getownersid().SID}},@{Label=’TotalProcessorTime’; Expression={(Get-Process -PID $_.ProcessID).TotalProcessorTime}},@{Label=’Parent Path’; Expression={(Get-Process -PID $_.ParentProcessId).Path}},ParentProcessId,@{Label=’Company’; Expression={(Get-Process -PID $_.ProcessID).Company}},@{Label=’ProductVersion’; Expression={(Get-Process -PID $_.ProcessID).ProductVersion}},@{Label=’Description’; Expression={(Get-Process -PID $_.ProcessID).Description}},@{Label=’Product’; Expression={(Get-Process -PID $_.ProcessID).Product}},@{Label=’FileVersion’; Expression={(Get-Process -PID $_.ProcessID).FileVersion}},@{Label=’File Path SHA-256′; Expression={[System.BitConverter]::ToString( (New-Object System.Security.Cryptography.SHA256CryptoServiceProvider).ComputeHash([System.IO.File]::ReadAllBytes($_.Path))) -replace ‘-‘}} | Export-Csv -NoTypeInformation -Path %destinationDirectory%\PWSH-Get-ProcessList.csv “
ExportFormat: csv
Change to:
Executable:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
CommandLine: -Command “Get-WMIObject Win32_Process | Select-Object Name,ProcessID,Path,commandline,@{Label=’Owner’; Expression={(Get-Process -PID $_.ProcessID -IncludeUserName).UserName}},@{n=’StartTime’;e={$_.ConvertToDateTime($_.CreationDate)}},ThreadCount,HandleCount,VirtualSize,Priority,@{Label=’PriorityClass’; Expression={(Get-Process -PID $_.ProcessID).PriorityClass}},@{Label=’Security ID’; Expression={$_.getownersid().SID}},@{Label=’TotalProcessorTime’; Expression={(Get-Process -PID $_.ProcessID).TotalProcessorTime}},@{Label=’Parent Path’; Expression={(Get-Process -PID $_.ParentProcessId).Path}},ParentProcessId,@{Label=’Company’; Expression={(Get-Process -PID $_.ProcessID).Company}},@{Label=’ProductVersion’; Expression={(Get-Process -PID $_.ProcessID).ProductVersion}},@{Label=’Description’; Expression={(Get-Process -PID $_.ProcessID).Description}},@{Label=’Product’; Expression={(Get-Process -PID $_.ProcessID).Product}},@{Label=’FileVersion’; Expression={(Get-Process -PID $_.ProcessID).FileVersion}},@{Label=’File Path SHA-256′; Expression={(Get-FileHash -Algorithm SHA256 -LiteralPath $_.Path).Hash}} | Export-Csv -NoTypeInformation -Path %destinationDirectory%\PWSH-Get-ProcessList.csv “
ExportFormat: csv
Several columns can be used as a filter to help the incident responder when they are reviewing the output from PWSH-Get-ProcessList. It is helpful to narrow down the results by looking at process start time. If the incident responder expects the malicious process to run during boot up, then look for similar process times. The incident responder should investigate the Path and Commandline fields because they would show when a commonly named process runs from a non-standard location. It is also helpful to review the parent process ID and parent process path. These fields can help track down suspicious executables that need further investigation. Review the owner field to ensure that processes are running under the correct context.
Once the autoruns and PWSH-Get-ProcessList modules have been analyzed, and the malicious software identified, the next step of the incident response process can begin. At this point, the incident responder should start tracking down how the computer was infected. The incident responder uses the remoteaccess, programexecution, systemactivity, and timelining features in Kape. These modules should show the User who ran the malicious process, remote network connections, remote desktop connections, scheduled tasks, and GPO changes. The incident responder retraces the virtual footsteps and performs forensics on the computer that initiated the malicious activity. The incident responder continues until he or she identifies the initial infected computer. Once the malicious activity has been traced back to the initial infection, the incident responder uses the browsing history module to find what websites were visited that triggered the infection. The OutlookPSTOST Kape target gathers .ost and .pst files to allow the incident responder to search for any malicious emails that may have triggered the infection.
Kape has permanently changed forensics investigations by cutting out an entire business day of image processing time when Kape performs incident triage. Kape also returns live forensics results within minutes. Returning live forensics results within minutes allows Incident Responders to quickly analyze forensically significant information. Incident responders have the flexibility to augment any incident response process with Kape.
GIAC (GCIH) Gold Certification
Author: John Davis
Advisor: Chris Walker
Accepted: August XXth 2020
© SANS Institute
Author Retains Full Rights