# Malware Investigations

How do you know if an unknown program is evil?

* Suspicious isn't necessarily malicious
* Oddly named executables aren't enough, might still be benign

How can you determine indicators?

* Someone might have reverse engineered it already
* But not always … and sometimes signatures change

We might see a running process that is suspicious, but whether it is malicious is unknown. For example, an oddly-named process that is not flagged by antivirus. Since suspicious isn't necessarily malicious, you would need to investigate the unknown process.

When investigating malware, two main methods are used:

* Behavioral analysis, which involves monitoring how the malware interacts with its environment using specialized tools
* Direct code examination with debuggers and disassemblers.

## Online Analysis Sites

Online analysis sites like VirusTotal can quickly check potentially suspicious software by scanning it with multiple antivirus tools.

Hybrid Analysis lets you upload a file and choose a virtual machine (e.g., Windows 10, Windows 11) to observe its behavior.

## Practicing Good Hygiene

When investigating malware, always adhere to strict security practices to prevent accidental spread or negative exposure for your organization.

Never investigate malware directly on your primary system due to the risk of it escaping. Ideally, use an air-gapped system and wipe it after each use, though this is often impractical during an incident.

For malware investigation, using a virtual machine with host-only networking is common. Despite this, maintain good security practices on the host, such as enabling firewalls and keeping the system updated. When transferring data, use USB drives for air-gapped systems or folder sharing features in virtualization tools, but only enable these temporarily to minimize risks.

## Basic Attributes

```powershell
PS C:\> Get-FileHash file           # Calculate the SHA256 hash of a file on Windows
PS C:\> strings file                # View ASCII and 16-bit little endian Unicode strings
```

```bash
$ strings file                      # View the ASCII strings on Linux
$ strings -e l file                 # View 16-bit little endian Unicode strings on Linux
```

One of the first things to do when investigating malware is to calculate a cryptographic hash sum. To calculate a SHA256 hash for a Windows file with PowerShell, you can use this command:

&#x20;`Get-FileHash file`

You can also add the argument `-Algorithm SHA1` to calculate a SHA1 hash instead. On Linux, the equivalent command is:

`sha256sum file`

## Monitoring the Environment

A common malware investigation strategy is monitoring its interactions with the environment, which is faster and partially automatable compared to code analysis, though it may miss certain details.

The basic strategy for monitoring malware is as follows:

1. Set up the environment, including configuring monitoring tools (temporarily disable them until ready).
2. Take a snapshot if using a virtual machine.
3. Enable monitoring tools and take the first snapshot (if applicable).
4. Run the malware.
5. Interact with the malware to understand its behavior.
6. Use commands like Stop-Process to terminate it if needed.
7. Disable monitoring tools and take the second snapshot (if using one).
8. Review the output and compare snapshots if applicable

## Snapshot vs. Continuous Recording

Some malware monitoring tools take snapshots of the environment at specific points, allowing comparison before and after the malware runs. Others continuously record the environment, logging activity from when the malware starts to when it's stopped for later analysis.

Continuous reporting tools provide more data than snapshot tools, capturing events like file creation and deletion that snapshots might miss. While they offer greater detail and insight, the large volume of data can also be overwhelming.

## Regshot

Regshot is a Windows tool that records snapshots of the registry and file system at two points, highlighting changes such as added, removed, or modified registry keys and files. It's simple to use and provides a clear summary of the differences.

* Run Regshot as an administrator, check the "Scan dir" box, and add directories to scan for file system changes.
* Prepare the malware to run, but don’t execute it yet. Set everything up, minimizing system changes to reduce irrelevant data in the comparison. If using a virtual machine, take a VM snapshot.
* Take the first Regshot snapshot by clicking "1st Shot | Shot."
* Run the malware and interact with it if needed, then terminate it.
* Take the second snapshot by clicking "2nd Shot | Shot."
* Click "Compare" to review the changes between snapshots.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FVXVfnW8rtL6iaUHDMXrT%2FScreenshot(8).png?alt=media&#x26;token=d51be715-0325-48c0-b959-cfe477966f03" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FRaLPa8zJiEHS9s698tvN%2FScreenshot(9).png?alt=media&#x26;token=712359c9-7442-49c1-bcb6-caa82a60e191" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FphM4akvdSzgOW7MsZe2Q%2FScreenshot.png?alt=media&#x26;token=1a663ed8-6a1a-4f66-9f53-d5aac3ac46ee" alt=""><figcaption></figcaption></figure>

### Regshot Output

```bash
----------------------------------
Files added: 16
----------------------------------
C:\Users\mike\AppData\Local\Temp\7ZipSfx.000\smss.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.000\otjguv.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.000\bytrea
C:\Users\mike\AppData\Local\Temp\7ZipSfx.001\vsmss.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.001\itjguv.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.001\ooytrea
C:\Users\mike\AppData\Local\Temp\7ZipSfx.002\umss.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.002\stjguv.com
C:\Users\mike\AppData\Local\Temp\7ZipSfx.002\ltrea
C:\Users\mike\AppData\Local\Temp\7ZipSfx.003\yotrol.dat
C:\Windows\Prefetch\B71C43A127DFC1F5906F7C6CA98FF-E6F4D17D.pf
C:\Windows\Prefetch\CERTUTIL.EXE-A864005A.pf
C:\Windows\Prefetch\CMD.EXE-2EB3E6E2.pf
C:\Windows\Prefetch\SMSS.COM-91BE788F.pf
C:\Windows\Prefetch\USMSS.COM-9FB7A7F2.pf
C:\Windows\Prefetch\SMSS.COM-ADB0D755.pf
```

Here's an example of Regshot output. It shows files created by the malware in C:\Users\mike\AppData\Local\Temp. The .pf files listed are Prefetch files, which weren't created by the malware but were generated as a result of it running. Prefetch files help Windows speed up program startup by tracking memory pages used during launch. From an investigative viewpoint, they reveal when and where a program was last run.

## Process Monitor

Process Monitor is a Microsoft tool for real-time monitoring of registry, file system, network, and process activities, including profiling events. You can filter information by toggling activity categories using the five buttons for registry, file system, network, process, and profiling.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F4a5abia0VP9TefuSy8I5%2FScreenshot(2).png?alt=media&#x26;token=2969dc0e-6662-4857-823f-4a92ce7a17b2" alt=""><figcaption></figcaption></figure>

When reading Process Monitor output, the Operation, Path, Result, and Detail columns are where information about what the process was doing is displayed.

Under the Tools menu, several options summarize activity categories. The `Process Activity Summary` provides a count of the registry, file, and network areas used by each process. `The Registry Summary` shows distinct registry keys accessed and how often. `The File Summary` does the same for files, and the `Network Summary` lists visited network addresses. `The Profiling Events` option summarizes process exits, including execution time, CPU, and memory usage.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fcy7ugtWOKu70WXDiYKYm%2FScreenshot(3).png?alt=media&#x26;token=a852e9b4-c23a-43f3-9096-402e9feed937" alt=""><figcaption></figcaption></figure>

One of Process Monitor's more useful summary tools is the Process Tree. You can activate it by clicking `Tools -> Process Tree` to see visually which processes spawned other processes. What makes this especially nice is that unlike Task Manager, this view will also show processes that are no longer running.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F6cbBz5mW3uFFwt2T0e3o%2FScreenshot(4).png?alt=media&#x26;token=be42080c-f4db-4748-bf7c-8ab970f36d8d" alt=""><figcaption></figcaption></figure>

## Analyzing Code

Another way to investigate malware is by analyzing its code. IDA Pro is a leading tool for code analysis and reverse engineering, featuring a disassembler, debugger, extensive plugin support, and compatibility with various CPU and memory architectures. It also includes the Hex-Rays Decompiler for converting binaries into readable C-like code.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FzmPoYxINWraCmBAHdZQV%2FScreenshot(9).png?alt=media&#x26;token=4ed013ae-5c23-4bc4-a8d6-9857ca062806" alt=""><figcaption></figcaption></figure>

## Lab 1.4: Malware Investigation

### Scenario

This lab assumes we're already familiar with the first two parts of the scenario ( Lab 1.2: Network Investigation and Lab 1.3: Memory Investigation) before continuing here.

We know from the previous two labs that a malware named `analytics.exe` was installed using `analyticsinstaller.exe`.

### Calculate Basic Properties

First let's open a PowerShell prompt with administrative privileges and calculate the MD5 and SHA256 hash sums of `AnalyticsInstaller.exe` file.

```powershell
PS C:\Tools\falsimentis> Get-FileHash -Algorithm MD5 AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F98DHMJz58kPJ9cAqNkY7%2FScreenshot(5).png?alt=media&#x26;token=8c094db3-fe9a-439b-8445-9ee3270a28df" alt=""><figcaption></figcaption></figure>

```powershell
PS C:\Tools\falsimentis> Get-FileHash -Algorithm SHA256 AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FMudDAVMEdxsntE43SAtM%2FScreenshot(6).png?alt=media&#x26;token=7db62da3-9d58-480f-9039-2c0cefe827ba" alt=""><figcaption></figcaption></figure>

### Examine Malware Strings

Let's use Sysinternals' `strings` utility to find ASCII and Unicode strings of 10+ characters.

```powershell
PS C:\tools\falsimentis> C:\tools\sysinternals\strings.exe -n 10 .\AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FgBvBSRBLMrzlkJQceEPO%2FScreenshot(7).png?alt=media&#x26;token=d897a8f2-ca13-4cd1-9a29-c3079654719e" alt=""><figcaption></figcaption></figure>

There are some strings worthy of note:

* First the URL `http://www1-google-analytics.com:8088/analytics.exe` . In the Network Investigation lab we discovered that the attackers used ports 8090 and 80. Port 8088 is an additional port that we can investigate.
* The registry key `Software\Microsoft\Windows\CurrentVersion\Run` is an AutoStart Extensibility Point (ASEP) and is a common method used by malware to persist following a reboot.
* The `cmd.exe /c rd c:\ /s /q` command is used to recursively delete files and folders starting at the root of the file system. Since the ransom note mentioned the loss of files, this could be a possible mechanism.
* The powershell.exe command line has a Base64 encoded command, which is suspicious, especially since this is malware.
* The `cmd.exe /c start /max http://www.midnitemeerkats.com/note` will display a copy of the ransom note, similar to what the CEO saw.

Malware authors can easily embed fake strings and hide real ones, so treat string outputs as suggestions.

### Examine Registry and File System Changes

Let's examine the changes made by the malware installer using Regshot. Regshot takes snapshots of the registry and file system at two different times and shows the differences between them.

```powershell
PS C:\tools\falsimentis> c:\tools\regshot\regshot_x64.exe
```

Regshot shows a configuration screen. It automatically scans the registry and optionally the file system for changes. Check the box labeled "Scan dir1\[;dir2;dir3...;dir nn]" and enter "C:" in the field below, and take the first snapshot.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FgOrOxNpT5E4HlrfqC7gN%2FScreenshot(8).png?alt=media&#x26;token=677d0a16-1361-4a86-a840-08a245b48fd0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FDJfyEZzb3CkDYg0xZUHU%2FScreenshot(9).png?alt=media&#x26;token=eedd97ca-60e6-4429-aeb2-20e4b98b3fab" alt=""><figcaption></figcaption></figure>

After the first snapshot has finished, let's run the malware file `AnalyticsInstaller.exe` .

```powershell
PS C:\tools\falsimentis> .\AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FRGg57V42021ejCZSVakj%2FScreenshot(10).png?alt=media&#x26;token=6307bdc3-75ed-498b-a611-5ea3eacab4a7" alt=""><figcaption></figcaption></figure>

After the malware installer finishes, we'll take the second snapshot.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FVJVtzvL0rBKLYysNIpfS%2FScreenshot(11).png?alt=media&#x26;token=0193298d-bca2-430c-9616-47cc75fee7f1" alt=""><figcaption></figcaption></figure>

Once the second snapshot has completed, let's click the Compare button to compare the two snapshots.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FuHH8vN7mSRPJGVC2HanN%2FScreenshot(12).png?alt=media&#x26;token=fbd9b752-5a7f-486f-b6a9-e9e27e8fa1ef" alt=""><figcaption></figcaption></figure>

After Regshot compares the snapshots, it will open a text file summarizing the changes.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FcxNDov6qvjhObz6hg0wU%2FScreenshot(13).png?alt=media&#x26;token=356d9606-79bc-463e-8293-df3330659a94" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FocEAzEAdrFoT7RySCEq1%2FScreenshot(14).png?alt=media&#x26;token=dc8af328-375d-405e-ab22-ac8fa8a55497" alt=""><figcaption></figcaption></figure>

The following entries are noteworthy:

* HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks{13C9BAD0-D2BE-47C5-98D6-855F5A2DE223}\URI: "\Analytics Backup"
* HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks{13C9BAD0-D2BE-47C5-98D6-855F5A2DE223}\Description: "Analytics Backup Service"
* HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\Analytics Client: "C:\Windows\System32\analytics.exe"
* HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\File Saver: "cmd.exe /c start /max <http://www.midnitemeerkats.com/note>"

The first two entries relate to scheduling a task. The third entry runs `C:\Windows\System32\analytics.exe` at user logon, while the fourth opens a browser window with the ransom note at user logon.

In the Files Added section, the following entries are notable:

* C:\Windows\Prefetch\ANALYTICSINSTALLER.EXE-E57CE4F0.pf
* C:\Windows\System32\Tasks\Analytics Backup
* C:\Windows\SysWOW64\AnalyticsBackup.bat

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fa5JHjqygPB9sYmkD5Txf%2FScreenshot(16).png?alt=media&#x26;token=66ff5e94-4f78-4789-bff7-2121ed91cb09" alt=""><figcaption></figcaption></figure>

The first entry is from Windows Prefetch, showing the last run time and directory of a program, useful for timeline correlation. The second entry indicates a new scheduled task, and the third shows a batch file addition, which we can view with the `Get-Content` cmdlet.

```powershell
PS C:\tools\falsimentis> Get-Content C:\Windows\SysWOW64\AnalyticsBackup.bat
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FliHVcWdoWl9crqr13yuJ%2FScreenshot(17).png?alt=media&#x26;token=cdb580f9-506a-4617-bcb9-6191aaa402c5" alt=""><figcaption></figcaption></figure>

This matches an earlier output from the strings command and likely indicates the recursive file deletion method used by the Midnite Meerkats.

## Examine Process Activity

Let's use `Procmon.exe` to get detailed insights into the malware installer's actions.

Open `Procmon` and click the capture button (or press Ctrl+E) to stop capturing.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FyF6TjQTKt305dvbLtR8x%2FScreenshot(1).png?alt=media&#x26;token=32ea7640-6739-4a24-a28a-edcbeccbca1b" alt=""><figcaption></figcaption></figure>

Next let's a filter for events related to `AnalyticsInstaller.exe` by clicking Filter -> Filter.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FCcYsKDcnLr0HOyKGuA4b%2FScreenshot(2).png?alt=media&#x26;token=961cd2e0-5018-4e7f-8508-f2b4ee4661e3" alt=""><figcaption></figcaption></figure>

In the Filter dialog, change Architecture to Process Name, enter "AnalyticsInstaller.exe" in the input box, click Add, then click OK.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FslA4bx0DDuzBpaN06hoj%2FScreenshot(3).png?alt=media&#x26;token=a29931cb-7ca2-4262-9ece-fe295132e5ad" alt=""><figcaption></figcaption></figure>

Now let's discard events that do not match the display.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FSuX5ANL3FQdTRI4J5Miy%2FScreenshot.png?alt=media&#x26;token=9935401a-895e-4cc3-b7c9-1aaf83d8a6bf" alt=""><figcaption></figcaption></figure>

Next before launching the malware installer, click the Capture icon to enable event capturing.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fl5MICnxNqJwMlTUbBCTz%2FScreenshot(1).png?alt=media&#x26;token=4c6a4177-5706-4ac7-b315-b62025dd239d" alt=""><figcaption></figcaption></figure>

Now let's run the malware installer.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fbx4xDgghOyMSKoo3z1Wn%2FScreenshot(2).png?alt=media&#x26;token=1b8e926d-0333-44c7-b981-0d62bd2f23c7" alt=""><figcaption></figcaption></figure>

The error occurs because the scheduled task already exists and can be ignored.

After the malware installer finishes, click the capture icon again to disable event capture.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fm1UGpXLKTgA8U6Ey0F1y%2FScreenshot(3).png?alt=media&#x26;token=dcc3232b-7d40-4626-a2c1-f9aac76e82da" alt=""><figcaption></figcaption></figure>

### Examine Process Activity

Use Procmon to examine process activity by clicking the registry, file system, and network filter buttons to disable them. This removes their light blue background, showing only process activity.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FWvzgeR9Lk3iezakfdMdU%2FScreenshot(4).png?alt=media&#x26;token=7c858c2e-71fb-4d9a-99d4-068786de3ea0" alt=""><figcaption></figcaption></figure>

Now let's look for process creation. To do this click Edit -> Find.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FEAdmMCo0rqU2kv3hwM1W%2FScreenshot(5).png?alt=media&#x26;token=6b164242-6bdd-4b9e-9fe5-a4cdf48f3ac9" alt=""><figcaption></figcaption></figure>

In the Find dialog, enter "Process Create" and click Find Next.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FvpMYyZM51JqwjpxrIvru%2FScreenshot(6).png?alt=media&#x26;token=22e195f2-26bb-4226-afbc-b15dc44de2dc" alt=""><figcaption></figcaption></figure>

The first result shows a Process Create event for `cmd.exe`. Double-click the entry for more details.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fdk0safMsUCg9zFcCHHyG%2FScreenshot(7).png?alt=media&#x26;token=222ab8ae-6132-4eba-bfc0-1f307faa209f" alt=""><figcaption></figcaption></figure>

The command line seems to launch a PowerShell process.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FGXhHyIIgZXnd9v6oFoKK%2F5972048692926071520.jpg?alt=media&#x26;token=2c0e43c6-23d5-45f0-b37d-5edf6be3fb23" alt=""><figcaption></figcaption></figure>

Even though we did not include cmd.exe in the lter, Procmon still captures process spawn activity in the Process Tree. To see this, close the Event Properties window, then click Tools | Process Tree.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FzGXpWE1FFoVL6qrMIBe2%2FScreenshot(8).png?alt=media&#x26;token=26447c69-6b53-4df4-a9f6-a7b684057fa5" alt=""><figcaption></figcaption></figure>

As we can see AnalyticsInstaller.exe launched cmd.exe, which then started powershell.exe.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F0tCKOOAcwj6CAP0dcfAs%2FScreenshot(9).png?alt=media&#x26;token=6d83499b-bf0d-4b78-b0e0-29e539bef1b6" alt=""><figcaption></figcaption></figure>

### Remove the Malware Artifacts

Now let's remove the malware artifacts.

```powershell
Unregister-ScheduledTask -TaskName "Analytics Backup"
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FsnTyLhUIteM0ImJJEizJ%2FScreenshot(10).png?alt=media&#x26;token=81e3a161-6a14-46fa-85ae-918eef20be91" alt=""><figcaption></figcaption></figure>

Next, remove the malware artifacts in C:\windows\SysWOW64\analytics\*

```powershell
del C:\windows\SysWOW64\analytics*
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FazNBS4YUI5cQBBuVPHvy%2FScreenshot(11).png?alt=media&#x26;token=95cf4789-9d15-4d82-af67-9afe7a3a1952" alt=""><figcaption></figcaption></figure>

Next remove the ASEP entries for the Analytics Client and File Saver properties.

```powershell
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\ | Remove-ItemProperty -Name "Analytics Client"
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\ | Remove-ItemProperty -Name "File Saver"
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fzf31mrTIpXQmaPQY50Tv%2FScreenshot(12).png?alt=media&#x26;token=24fcd15e-26f8-4a96-926f-4e890a599626" alt=""><figcaption></figcaption></figure>

## Bonus Lab

### Examine Network Traffic

Now let's start tcpdump to monitor for DNS requests.

```bash
sudo tcpdump -n -i eth0 udp port 53
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FjfvXAl3e1jgMgUhYt7uS%2FScreenshot.png?alt=media&#x26;token=a21a8f39-01e5-424f-a1d5-77f4013346a4" alt=""><figcaption></figcaption></figure>

The tcpdump command is explained as:

* -n -> don't resolve host name or port numbers
* -i eth0 -> monitor trac on the interface eth0
* udp port 53 -> only capture trac destined for UDP port 53

Let's return to our Windows VM, open PowerShell as an administrator, and use `Set-DnsClientServerAddress` to set the DNS server to 10.10.75.1.

```powershell
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses ("10.10.75.1")
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2F74XLAm419TPa0IRH8kFJ%2FScreenshot(13).png?alt=media&#x26;token=a594ac9c-ebb9-46b5-80ac-e461b991bf63" alt=""><figcaption></figcaption></figure>

This command sets the DNS server address for the network interface named "Ethernet" to `10.10.75.1`. When a device on this interface needs to resolve a domain name, it will send DNS queries to the server at `10.10.75.1`.

`10.10.75.1` is the IP address for the slingshot linux machine.

Next, let's launch the malware installer again.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fc1J9PnLCCJMaVz7GuAQL%2FScreenshot(1).png?alt=media&#x26;token=95927ea8-10af-487e-ae48-b44e95c4b6eb" alt=""><figcaption></figcaption></figure>

After the malware installer completes, let's return to our Linux VM and stop `tcpdump` by pressing CTRL+C.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FKdsGQcsxIn6mf1mIuz0i%2FScreenshot(2).png?alt=media&#x26;token=77d59356-feab-403d-ab11-e0218efad309" alt=""><figcaption></figcaption></figure>

The output shows a DNS request from our Windows VM to the Linux VM, querying the host www1-google-analytics.com.

Let's configure the environment for the malware by updating the Windows VM's hosts file to redirect www1-google-analytics.com to 10.10.75.1, so we can intercept the request.

```powershell
Add-Content C:\Windows\System32\drivers\etc\hosts -Value "10.10.75.1 www1-google-analytics.com"
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FGotvTHkWYT2SHw8xmE7Y%2FScreenshot(3).png?alt=media&#x26;token=cd41662e-9d5e-404b-a7ec-c0df5d34c3b9" alt=""><figcaption></figcaption></figure>

Since the malware's connection type to `www1-google-analytics.com` is unknown, we need to restart tcpdump to capture all traffic.

```bash
sudo tcpdump -n -i eth0
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FV0aRB1MChPTXb1Yo0VLa%2FScreenshot(5).png?alt=media&#x26;token=d019c34a-7b86-49d2-900f-0f6f5564bcfc" alt=""><figcaption></figcaption></figure>

Next let's return to the Windows VM and run the malware installer again.

```powershell
.\AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FTkC7Ug5d3qujwf1H2omr%2FScreenshot.png?alt=media&#x26;token=b2f92932-43a9-4de2-8781-b390982644d2" alt=""><figcaption></figcaption></figure>

Once the malware installer completes, let's return to our Linux VM and stop `tcpdump` by pressing CTRL+C.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2Fz3DMDypIWlfhDuUKK8Nq%2FScreenshot(1).png?alt=media&#x26;token=5134d1ca-3ff3-40d2-9e5d-9a5446e282d4" alt=""><figcaption></figcaption></figure>

A connection attempt to TCP port 8088 is made, but since no service is listening, a TCP reset is returned.

Let's set up a Netcat listener on TCP port 8088 with the `nc` command, as the malware installer is trying to connect to this port.

```bash
nc -nlvp 8088
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FmnTeXrdYBZm1ozdo4slT%2FScreenshot(2).png?alt=media&#x26;token=0d6e8dc2-e33c-435f-a94b-8614f659d588" alt=""><figcaption></figcaption></figure>

The `nc` command can be summarized as:

* -n -> don't resolve host names
* -v -> displays verbose output
* -l -> listen mode
* -p 8088 -> listen on port 8088

Next let's switch back to the Windows VM and run the malware installer again.

```powershell
.\AnalyticsInstaller.exe
```

Next let's return to the Linux VM and review the Netcat output.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FBJMBMNXM7ReioWMU0uPg%2FScreenshot(3).png?alt=media&#x26;token=81ff71ba-bf90-4255-9ffe-27084c694a10" alt=""><figcaption></figcaption></figure>

This is an HTTP GET request for /analytics.exe. Let's stop the Netcat listener with CTRL+C and set up an HTTP server for the malware.

We have a copy of `analytics.exe` file in the current directory, so let's start the HTTP server.

```bash
python3 -m http.server 8088
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FylWEPkdyuA8d17az0swF%2FScreenshot(4).png?alt=media&#x26;token=b7a8c282-24ca-49b9-93d8-0a54533dc2bc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FgLYCQNAElj9pq4PUcPjx%2FScreenshot(5).png?alt=media&#x26;token=a8a4a0ba-d707-4018-ba37-e813761755d4" alt=""><figcaption></figcaption></figure>

Next let's switch back to the Windows VM and run the malware installer again.

```powershell
.\AnalyticsInstaller.exe
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FWxZomfsGi60w0Yu2tgeI%2FScreenshot(6).png?alt=media&#x26;token=1bcc4326-784f-4090-bc17-f7b63af86a77" alt=""><figcaption></figcaption></figure>

Now let's go back to our Linux VM.

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FzrCB4e3K1bL7QwTW5Pc6%2FScreenshot(7).png?alt=media&#x26;token=0d14de49-cc7f-432f-a2b6-c9bd83938e3f" alt=""><figcaption></figcaption></figure>

This indicates that the malware installer is trying to download `analytics.exe`. To confirm, let's  check for `analytics.exe` in the `C:\Windows\SysWOW64` directory on the Windows VM.

```powershell
dir C:\Windows\SysWOW64\analytics*
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FYXtyIL0YhcB8sdOz3FkP%2FScreenshot(8).png?alt=media&#x26;token=52b725b1-c6b5-4a54-b37d-f2124deadb56" alt=""><figcaption></figcaption></figure>

When looking at evidence, consider how well it supports one theory and rules out others. Here, we see a normal HTTP GET request that seems to support the idea that malware downloaded the file. But this alone doesn't rule out other possibilities, like the malware using a request to mislead analysts. To be sure, you need more evidence, like network traffic and code analysis, before dismissing other theories.

Lastly, let's delete the DNS server settings for the Ethernet adapter.

```powershell
Get-NetAdapter Ethernet | Set-DnsClientServerAddress -ResetServerAddresses
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FGXSeJKPfEF0M47Xm4RPl%2FScreenshot(9).png?alt=media&#x26;token=e9fe14c9-8795-4e58-a488-abb6f3cf1901" alt=""><figcaption></figcaption></figure>

Next, let's clean the malware from the system.

```powershell
Unregister-ScheduledTask -Confirm -TaskName "Analytics Backup" -ea SilentlyContinue
del c:\windows\syswow64\analytics* -ea SilentlyContinue
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FHK0uyuulQ849fHbiQSkF%2FScreenshot(11).png?alt=media&#x26;token=6a0c35cd-cdc3-4f1e-82d4-8f9cdd4f0597" alt=""><figcaption></figcaption></figure>

```powershell
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\ | Remove-ItemProperty -Name "Analytics Client" -ea SilentlyContinue
Get-Item HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run\ | Remove-ItemProperty -Name "File Saver" -ea SilentlyContinue
```

<figure><img src="https://2537271824-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIswWWP3l0rGuQmG2WUcr%2Fuploads%2FA1X1pY2uXjU4wDv9WSVn%2FScreenshot(12).png?alt=media&#x26;token=41f367ac-e77a-44b4-8978-f1bbbe56c5c3" alt=""><figcaption></figcaption></figure>
