# RogueOne

{% embed url="<https://app.hackthebox.com/sherlocks/RogueOne>" %}

```
Your SIEM system generated multiple alerts in less than a minute, indicating potential C2 communication from Simon Stark's workstation.
Despite Simon not noticing anything unusual, the IT team had him share screenshots of his task manager to check for any unusual processes.
No suspicious processes were found, yet alerts about C2 communications persisted. The SOC manager then directed the immediate containment of the workstation and a memory dump for analysis.
As a memory forensics expert, you are tasked with assisting the SOC team at Forela to investigate and resolve this urgent incident.
```

### <mark style="color:red;">**Identifying the Malicious Process**</mark>

#### <mark style="color:blue;">Initial Analysis Using Imageinfo</mark>

first thing let's find the profile using imageinfo plugin to start our invistigation

```bash
remnux@remnux:~/malware$ vol.py -f 20230810.mem imageinfo > imageinfo.txt
Volatility Foundation Volatility Framework 2.6.1

INFO    : volatility.debug    : Determining profile based on KDBG search...
remnux@remnux:~/malware$ cat imageinfo.txt 
          Suggested Profile(s) : Win10x64_19041
                     AS Layer1 : SkipDuplicatesAMD64PagedMemory (Kernel AS)
                     AS Layer2 : FileAddressSpace (/home/remnux/malware/20230810.mem)
                      PAE type : No PAE
                           DTB : 0x1ad000L
                          KDBG : 0xf80179000b20L
          Number of Processors : 8
     Image Type (Service Pack) : 0
                KPCR for CPU 0 : 0xfffff80175b3a000L
                KPCR for CPU 1 : 0xffffc78138867000L
                KPCR for CPU 2 : 0xffffc7813892a000L
                KPCR for CPU 3 : 0xffffc781389ad000L
                KPCR for CPU 4 : 0xffffc78138aa3000L
                KPCR for CPU 5 : 0xffffc78138b26000L
                KPCR for CPU 6 : 0xffffc78138be9000L
                KPCR for CPU 7 : 0xffffc78138cec000L
             KUSER_SHARED_DATA : 0xfffff78000000000L
           Image date and time : 2023-08-10 11:32:00 UTC+0000
     Image local date and time : 2023-08-10 16:32:00 +0500
```

The output suggests the following profile:

```
Suggested Profile(s) : Win10x64_19041
```

With this profile, we can proceed to analyze the memory dump using volatility2.

#### <mark style="color:blue;">Process Listing</mark>

listing the processes and checking if there is any malicious process

```bash
vol.py -f 20230810.mem --profile=Win10x64_19041 pslist
```

but all the processes seem ligitamate since all of them are normal windows processes

#### <mark style="color:blue;">Network Connection Analysis</mark>

Investigating the TCP connections with the `netscan` plugin may reveal suspicious activities:

```bash
vol.py -f 20230810.mem --profile=Win10x64_19041 netscan
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FmcTs1g93DVJsFmuxDObV%2Fimage.png?alt=media&#x26;token=4564d1e2-4821-4d84-a4bf-3cafda02c662" alt=""><figcaption></figcaption></figure></div>

An unusual connection is discovered on port 8888, indicating a possible malicious connection. but we don't have infos about the process id (PID) that launches this connection (reverse tcp connection to an attacker listening on port 8888)

For more precise information about network activities, we use the `netstat` plugin from Volatility 3:

```bash
vol3 -f 20230810.mem windows.netstat.NetStat
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FK9XWUjh49iJXnh3x0vUY%2Fimage.png?alt=media&#x26;token=5d07276b-d3bc-4b09-858f-9c5a3380e567" alt=""><figcaption></figcaption></figure></div>

Further analysis of the network connections revealed a suspicious activity associated with a process:

* **Process Name**: svchost.exe
* **Process ID (PID)**: 6812
* **Connection**: The connection was established on TCP port 8888, which is not commonly used by standard Windows services.

Given that `svchost.exe` is a legitimate Windows process that hosts services, the presence of a `svchost.exe` process is not suspicious on its own. However, the unusual network activity associated with PID 6812 raises concerns that this instance of `svchost.exe` may have been compromised or is masquerading as a legitimate process to hide the Command and Control (C2) communication.

We will need to investigate process 6812 further to determine if it's indeed the source of the malicious traffic and take appropriate action to mitigate the threat.

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FGJ7JNzHr2hOHwiAkDg96%2Fimage.png?alt=media&#x26;token=a5571c9c-8786-4578-9043-76a0c055a80d" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">**Identifying the ChildProcess spawned by the Malicious Process svchost.exe**</mark>

To investigate the child processes spawned by the potentially compromised svchost.exe process, we will use the `pstree` plugin, which visualizes parent-child relationships between processes:

```bash
vol.py -f 20230810.mem --profile=Win10x64_19041 pstree | grep 6812
Volatility Foundation Volatility Framework 2.6.1

*** 6812	7436	svchost.exe	0x9e8b87762080	3	-	1	False	2023-08-10 11:30:03.000000 	N/A
**** 4364	6812	cmd.exe	0x9e8b8b6ef080	1	-	1	False	2023-08-10 11:30:57.000000 	N/A
```

The child process analysis using `pstree` indicates that the `svchost.exe` process with PID 6812 spawned a `cmd.exe` process with PID 4364.&#x20;

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2F6MiFq1pWGrpnbChhXA95%2Fimage.png?alt=media&#x26;token=ceddc8f2-cd20-4fa2-aa19-6a1e491f1fd6" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">Hunting for malicious file sample</mark>&#x20;

#### <mark style="color:blue;">Further Investigation of the Malicious "</mark><mark style="color:blue;">`svchost.exe`</mark><mark style="color:blue;">" Process</mark>

we know that the malicious process is svchost.exe so let's search for the parent process that spawned this malicious process using pstree again and grepping the by the parent PID `7436` (PPID is next to PID)

```bash
vol.py -f 20230810.mem --profile=Win10x64_19041 pstree | grep 7436
Volatility Foundation Volatility Framework 2.6.1

** 7436	7400	explorer.exe	0x9e8b8c4d2080	75	-	1	False	2023-08-10 11:14:07.000000 	N/A
*** 5864	7436	WinRAR.exe	0x9e8b92bdb0c0	5	-	1	False	2023-08-10 11:20:21.000000 	N/A
*** 936	7436	svchost.exe	0x9e8b8cd89080	0	-	1	False	2023-08-10 11:22:31.000000 	2023-08-10 11:27:51.000000 
*** 9580	7436	SecurityHealth	0x9e8b90135340	1	-	1	False	2023-08-10 11:14:25.000000 	N/A
*** 9712	7436	vmtoolsd.exe	0x9e8b8cbd5080	9	-	1	False	2023-08-10 11:14:26.000000 	N/A
*** 2776	7436	RamCapture64.e	0x9e8b8aa66080	5	-	1	False	2023-08-10 11:31:52.000000 	N/A
*** 6812	7436	svchost.exe	0x9e8b87762080	3	-	1	False	2023-08-10 11:30:03.000000 	N/A
```

The fact that `svchost.exe` was started by `explorer.exe` is particularly alarming as `explorer.exe` is the Windows program responsible for the desktop and file management. It typically does not spawn `svchost.exe` processes. This indicates that the user might have accidentally executed malicious code leading to the spawning of a fake or compromised `svchost.exe`.

#### <mark style="color:blue;">CMD History</mark>

let's search in the cmd history to see if the fake svchost.exe is executed there, let's use the `cmdline` plugin

```bash
vol.py -f 20230810.mem --profile=Win10x64_19041 cmdline | grep svchost.exe
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FBrbFnLpLI1r3qWZnYuT0%2Fimage.png?alt=media&#x26;token=929f75fa-b096-4131-a02e-a28ab4c86937" alt=""><figcaption></figcaption></figure></div>

we can notice that all the svchost.exe processes are spawned from system32 directory but the last which has the process id 6812 is executed from the simon's user downloads directory

so let's dump the svchost.exe file located at the downloads directory to do that we will dump all the files related to the malicious process id 6818 i am using volatility 3 for this

<pre class="language-bash"><code class="lang-bash">vol3 -f ../20230810.mem windows.dumpfiles.DumpFiles --pid 6812
<strong>
</strong><strong>...
</strong>...
...
file.0x9e8b8a4e4270.0x9e8b8a656d00.ImageSectionObject.mpr.dll.img
file.0x9e8b8ae25140.0x9e8b8a7e5a20.ImageSectionObject.cscapi.dll.img
file.0x9e8b8b0708b0.0x9e8b8a2a3d20.ImageSectionObject.wininet.dll.img
file.0x9e8b91ec0140.0x9e8b90819750.DataSectionObject.svchost.exe.dat
file.0x9e8b91ec0140.0x9e8b957f24c0.ImageSectionObject.svchost.exe.img
</code></pre>

we got a lot of but the last one is the one we want `file.0x9e8b91ec0140.0x9e8b957f24c0.ImageSectionObject.svchost.exe.img`&#x20;

let's calculate the md5 hash using `md5sum`

```
md5sum file.0x9e8b91ec0140.0x9e8b957f24c0.ImageSectionObject.svchost.exe.img
5bd547c6f5bfc4858fe62c8867acfbb5  file.0x9e8b91ec0140.0x9e8b957f24c0.ImageSectionObject.svchost.exe.img
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FDj6JT3TCV0UkXymFTCiS%2Fimage.png?alt=media&#x26;token=2e03d396-92c2-42d2-a0d0-853780e1d1b6" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">Identify C2 IP address and ports</mark>

By using the `windows.netstat.NetStat` plugin in Volatility 3, we can view all active connections and their corresponding IP addresses and ports. This allows us to identify any suspicious connections that the malware could be using to communicate with an external C2 server.

```bash
vol3 -f 20230810.mem windows.netstat.NetStat
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FK9XWUjh49iJXnh3x0vUY%2Fimage.png?alt=media&#x26;token=5d07276b-d3bc-4b09-858f-9c5a3380e567" alt=""><figcaption></figcaption></figure></div>

the results shows an active connection to an external IP address `13.127.155.166` on port `8888`

we can also identify the C2 ip and port by searching for the sample in virustotal using the md5 hash obtained in the previous question

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2F2W09pyLJajwzlwvZr3Mw%2Fimage.png?alt=media&#x26;token=44ab0653-464a-4de6-8eef-c2cd8fb51979" alt=""><figcaption></figcaption></figure></div>

in the behavior section

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FFN0P29qM2yBIbTRMFSzz%2Fimage.png?alt=media&#x26;token=cf0f4968-5d45-4fb4-b98e-2ea8e5703b4b" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FFbjysqye0aniJlYwJbmh%2Fimage.png?alt=media&#x26;token=c827560d-ec50-4144-b5dc-9013402e1d35" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">Timeline Analysis of Malicious Process Activity</mark>

this information can be obtained By using the `windows.netstat.NetStat` plugin in Volatility 3&#x20;

```bash
vol3 -f 20230810.mem windows.netstat.NetStat
```

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FK9XWUjh49iJXnh3x0vUY%2Fimage.png?alt=media&#x26;token=5d07276b-d3bc-4b09-858f-9c5a3380e567" alt=""><figcaption></figcaption></figure></div>

the results shows an active connection to an external IP address `13.127.155.166` on port `8888` at `2023-08-10 11:30:03`&#x20;

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FQyIAa17PUq03UeIfFF0J%2Fimage.png?alt=media&#x26;token=a2cd0192-f52f-4506-8ec6-f5718bf00f18" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">memory offset of the malicious process</mark>

using any process listing plugin we can find the offset of processes

```bash
remnux@remnux:~/malware$ vol.py --profile=Win10x64_19041 -f 20230810.mem pslist | grep 6812
Volatility Foundation Volatility Framework 2.6.1

0xffff9e8b87762080 svchost.exe            6812   7436      3        0      1      0 2023-08-10 11:30:03 UTC+0000                                 
0xffff9e8b8b6ef080 cmd.exe                4364   6812      1        0      1      0 2023-08-10 11:30:57 UTC+0000 
```

the offset is the part changing in the address so the offset of the malicious process `svchost.exe` with PID `6812` is `0x9e8b87762080`&#x20;

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FWzRg7J5cEgi7H2tLISt4%2Fimage.png?alt=media&#x26;token=c1035e95-4b61-4053-a520-b3d3a344c90e" alt=""><figcaption></figcaption></figure></div>

### <mark style="color:red;">First Submission to VirusTotal</mark>&#x20;

first we have to search for the sample in virustotal using the md5 hash and then go to details tab

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2Fr9Pzh6V2471AE2pogZJV%2Fimage.png?alt=media&#x26;token=10444d76-5e44-472c-90d8-5001296538de" alt=""><figcaption></figcaption></figure></div>

scrolling down we will find the first submission date

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FBPIfxs9VfYEZSEAQ32T3%2Fimage.png?alt=media&#x26;token=2e7be680-6c40-4fa7-a18b-a5030c7d98c0" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2Fgqu6m3frwYyddSwWb6SL%2Fimage.png?alt=media&#x26;token=622479a9-8a80-47ba-85b7-ba125c8bce94" alt=""><figcaption></figcaption></figure></div>

and we have completed all the questions.&#x20;

hope you found this walkthrough easy to understand and follow

Greeting From [<mark style="color:red;">**Sayonara**</mark>](https://github.com/ismail-arame)

<div align="left"><figure><img src="https://1410593648-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYI2noEqPw69jd0hR7Prp%2Fuploads%2FBrZLeAMW9rxJHXVHgPt0%2Fimage.png?alt=media&#x26;token=fab2a822-84be-48b6-a7e8-19a4e4e40334" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sayonara.gitbook.io/writeups/dfir/htb-forensics-challenges/rogueone.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
