# Velociraptor P2

### 1. Introduction

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FYS8U9JTdEa2esfqPoW88%2Fsetup2.png?alt=media\&token=eaae1573-e9cf-4c99-9b14-301ce6299e7a)

In this exercise we will infect a windows client with a simple malware sample and investigate it with velocirpator.&#x20;

Prerequisite:

* Linux VM (<https://livecd.hacking-lab.com/>)
* Windows 10 VM (<https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/>)
* PUP Malware Sample (<https://samsclass.info/152/proj/pup4.zip>)
  * Password: malware

If you need instructions how to setup velociraptor please go back to [Part1](https://cas-cyber.gitbook.io/cas-cybersecurity/live-response/velociraptor-p1) of this series.

Mitre Attack techniques used in this exercise:

**T1204.002**: User Execution: Malicious File\
**T1547.001**: Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder\
**T1562.001**: Impair Defenses: Disable or Modify Tools

[Original Lab](https://samsclass.info/152/proj/IR372.htm) developed by SAM BOWNE:

{% embed url="<https://samsclass.info/>" %}

### 2. Infecting Windows Client

Note: Disable the Windows Defender

Download the PUP Malware Sample from above and extract it.

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FgYVkaGy6XdtQDD0bwi53%2Fpup01.png?alt=media&#x26;token=3f5e1a34-4797-4f06-bb8a-e4ba4a92f855" alt=""></div>

1\. Run `pup4.exe` as administrator\
2\. Move `pup4message.exe` to C:\\\
3\. Delete pup4.zip and the pup4 folder. Empty the Recycle Bin.\
4\. **Restart your machine**. If an "Open File - Security Warning" box pops up, uncheck the "Always ask before opening this file" box and click **Run**.&#x20;

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FtFOGE0tKGCHM7RQ0iY3U%2Flogin01.png?alt=media&#x26;token=91e2926d-5e96-4a9c-880b-ddbf4b00cfad" alt=""></div>

After Login to our Win10 box, we can see this nice popup:

YOUR MACHINE IS PWNED BY DOUBLEBAD!

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2F5q4YcS6YLzU1arcNysX5%2Flogin02.png?alt=media\&token=4b55332d-4d65-4f51-acdb-b33e286274e9)

### 3. Investigation with velociraptor

First made sure that the windows box is connected to the velociraptor server:

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FPAuVTQ4S09tVODuRCzut%2Fvelociraptor14.png?alt=media\&token=756afd30-87b0-4929-8feb-b3ea274f3c67)

From here we can access the client ID and click on the **Collected** button.&#x20;

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FUg0KpPLBYUuxfqPYc90z%2Fvelociraptor15.png?alt=media&#x26;token=4cf943f2-6f61-4394-b977-f476cf6ddafd" alt=""></div>

We can click then on the **plus-sign** to prepare and execute a specific artefact on the client.

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FwnihcDlzKLv4iqUKzhXb%2Fvelociraptor16.png?alt=media&#x26;token=b057a96c-3c82-4fab-889c-34ecc00f6649" alt=""></div>

### 3.1 Check Autorun paths

Use the search box to find this collector, as shown below.

> **Windows.Sysinternals.Autoruns**

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FHdTow5BVlB77RWt4ApHP%2Fvelociraptor17.png?alt=media&#x26;token=8ccdfd37-54ee-43fc-83ff-93923ef12dda" alt=""></div>

I'll launch the collector with its default values. After a while I get the results with 1453 rows back. For a better overview I'll download the results in a csv file.

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FjpV9Rhdj98p37YZM6ttA%2Fvelociraptor18.png?alt=media\&token=defd7c6c-a28a-4898-8627-2b637ec98fa1)

With help of the csv file I can work with filters to show me only rows where the Company field is empty. I could successfull Identify the **autorun path** of pup4message.exe:

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FWWCadIemfRy9j2Ve8Ndv%2Fautoruns01.png?alt=media\&token=3851465c-3e09-41ca-8e73-80f490ec9cd2)

### 3.2 Get MD5 Hash of binary

The MD5 hash of pup4message.exe could also be found in the csv file, but I'll use some other artifacts as well.&#x20;

> **Windows.System.Pslist**

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2Fy00NL542UwegKSSeAPPL%2Fvelociraptor19.png?alt=media&#x26;token=a373fc72-e032-44cb-b798-a34e6143a2b3" alt=""></div>

Configure the collector with regex pattern `pup.`

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FP2tYQc4FfM1uV1UjwYn1%2Fvelociraptor20.png?alt=media&#x26;token=50356c28-6354-4f94-9fc3-4296e229cc25" alt=""></div>

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FGeOQjowLmAXc4zZT8ztl%2Fpslist01.png?alt=media\&token=947825d9-f466-4ac6-adee-7b9cbf59c736)

### 3.3 Process Memory dump

The purpose of this step is to verify that the "**pup4message**" process is actually creating the pop-up message

For that we use the following artifact:

> **Windows.Triage.ProcessMemory**

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FkAA6wHyMXMfDj5WTzIgX%2Ftriage01.png?alt=media&#x26;token=5e836403-8055-4491-818f-e804d095b868" alt=""></div>

Again I'll use the regex pattern `pup*` and let it run

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FqWNxKjlROMBi9mlBPPX7%2Ftriage02.png?alt=media&#x26;token=5a759d3c-6fed-4187-ad48-cbeaf92a8362" alt=""></div>

After a while it's possibe to download the dump under uploaded files

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2F5JhdX8BDcZEab5JRyuGK%2Ftriage03.png?alt=media&#x26;token=30c53c3a-957e-4c93-96a5-bd0151c78cc2" alt=""></div>

We can now analyse the dump by using the command strings

```
strings -el dmp2505619614.dmp | grep BAD  
```

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FtQje6ePgHOlg3RCTD3Xt%2Ftriage04.png?alt=media\&token=691db11e-e3ae-4d6e-97a4-5c18b2f7721f)

### 3.4 YARA Hunt

The purpose of this step is to see if other EXE files on the target computer are also involved.

For that I use the the following artifact:

> **Windows.Detection.Yara.NTFS**

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FWvsAw80qwpVeyNKJNizD%2Fyara_detect01.png?alt=media&#x26;token=f68e97ef-4569-4594-b4e0-c7a9c144f4a2" alt=""></div>

I set the following options:

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FKCZxFjiZwb0T7jvI1BrC%2Fyara_detect02.png?alt=media&#x26;token=9edb02db-05aa-4c5f-bb6a-ad4276f62a65" alt=""></div>

<div align="left"><img src="https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FQQklZfUQQVsxUcQuLpE2%2Fyara_detect03.png?alt=media&#x26;token=dccd1259-5df8-466f-9439-7d712414b2fb" alt=""></div>

```
rule Hit {
   strings:
     $a = "PWNED" nocase wide ascii
    condition:
      any of them
}
```

I did expect a result, but for some reasons I got no results back. I did also miss the YARA shortener option which was not available in this artifact. Regarding the description it should be available. I have to let this stay for a moment and continue with the remediation!

### 4. Remediation

The purpose of this step is to remove the malware from the client.

Launch these commands, one at a time:

> **TASKKILL /FI "IMAGENAME eq pup4message.exe"**
>
> **reg delete HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run /v PUP4 /f**
>
> **del c:\pup4message.exe**

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfT0VPyK6X13Egd9pzy%2Fuploads%2FHI4ON3UzC1nkCQF1QTWl%2Fremediation01.png?alt=media\&token=65d5975a-19c5-47ba-b5d6-1827add3231d)
