Investigating Windows 2.0 - TryHackMe
Tags: tryhackme, writeup
Published: 2021-03-10 13:26:29

Here is the writeup for the room [Investigating Windows 2.0](https://tryhackme.com/room/investigatingwindows2).

This room is the continuation of [Investigating Windows](https://tryhackme.com/room/investigatingwindows).



### What registry key contains the same command that is executed within a scheduled task? 

Open the task scheduler:

![task scheduler](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j86da9nr9r88pewvzq3r.PNG)

From Regedit, search for the task (e.g. `sekurlsa` or `LogonPasswords`). You'll end up there:

```
\HKCU\Environment\UserInitMprLogonScript
```

### What analysis tool will immediately close if/when you attempt to launch it?

To get a good overview of the running maching, The SysInternals tools are the way to go. However, the famous process explorer refuses to start :

```
procexp64.exe
```

## What is the full WQL Query associated with this script?

For this one, start Loki, the IOC scanner. It can take a while to run but it is super useful. It detected some suspicious/malicious files and gives us the culprit playing with `procexp64` through WQL queries:

![LOKI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdqmyq1np555zwxqv8xg.PNG)

Query is:

```
SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName = 'procexp64.exe'
```

### What is the script language?

Open the file `\TMP\WMIBackdoor.ps1`:

```
vbscript
```

### What is the name of the other script?

We'll have to read/understand the script to find this one. Loki also found it:

![LaunchBeaconingBackdoor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apqxi9r7xqumsca73k2h.PNG)

```
LaunchBeaconingBackdoor
```

### What is the name of the software company visible within the script?

![Motobit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8norvx2nqgqhtjzubxs.PNG)

We can read it within comments:

```
Motobit Software
```

### What 2 websites are associated with this software company?

We can also read the two URLS within the script comments:

- `http://www.motobit.com`
- `http://Motobit.cz`

### Search online for the name of the script from Q5 and one of the websites from the previous answer. What attack script comes up in your search?

```
WMIBackdoor.ps1
```

### What is the location of this file within the local machine?

```
C:\TMP
```

### Which 2 processes open and close very quickly every few minutes?

By looking at the window titles:

1. `mim.exe`
2. `powershell.exe`

### What is the parent process for these 2 processes?

We can start the SysInternals Process monitor `procmon64.exe`. The we can add filter on "Process Name" to `mim.exe` so we capture the process creation. In the properties of that event, we have the parent PID which is `916`. In task manager, we can get the name for the pid `916` which is:

```
svchost.exe
```

### What is the first operation for the first of the 2 processes?

Again in the process monitor, we can capture the first opertion made which is:

```
Process Start
```

### Inspect the properties for the 1st occurrence of this process. In the Event tab what are the 4 pieces of information displayed?

Go back to the event properties:

- `Parent PID`
- `Command line`
- `Current directory`
- `Environment`

or 

```
Parent PID, Command line, Current directory, Environment
```

### Inspect the disk operations, what is the name of the unusual process?

The hint tells us to use Process Hacker.

![No Process](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8z4psaz2v993whh5bip3.PNG)

```
No Process
```

### Run Loki. Inspect the output. What is the name of the module after `Init`?

From 'loki-output.txt' MODULE section:

```
WMIScan
```

### Regarding the 2nd warning, what is the name of the eventFilter?

From 'loki-output.txt' NAME section:

```
ProcessStartTrigger
```

### For the 4th warning, what is the class name?

From 'loki-output.txt' CLASS section:

```
__FilterToConsumerBinding
```

### What binary alert has the following 4d5a90000300000004000000ffff0000b8000000 as FIRST_BYTES?

From 'loki-output.txt' FIRST_BYTES section:

```
nbtscan.exe
```

### According to the results, what is the description listed for reason 1?

From 'loki-output.txt' DESC section:

```
Known Bad / Dual use classics
```

### Which binary alert is marked as APT Cloaked?

From 'loki-output.txt' FILE section

```
C:\TMP\p.exe
```

or 

```
p.exe
```

### What are the matches?

From 'loki-output.txt' MATCHES section

- `psexesvc.exe`
- `Sysinternals PsExec`

or

```
psexesvc.exe, Sysinternals PsExec
```

### Which binary alert is associated with somethingwindows.dmp found in C:\TMP?

From 'loki-output.txt' FILE/INFO:

```
C:\TMP\schtasks-backdoor.ps1
```

or simply

```
schtasks-backdoor.ps1
```

### Which binary is encrypted that is similar to a trojan?

Loki found a xor-encrypted binary ("Derusbi trojan") under `C:\TMP\xCmd.exe`

```
xCmd.exe
```

### There is a binary that can masquerade itself as a legitimate core Windows process/image. What is the full path of this binary?

Remember pid `916` under name `svchost`? Loki raised an alert for a `svchost` located at:

```
C:\Users\Public\svchost.exe
```

### What is the full path location for the legitimate version?

Svchost is a system process that can host one or many Windows services. It is lcoated at

- `%SystemRoot%\System32\Svchost.exe`
- `%SystemRoot%\SysWOW64\Svchost.exe`

and on the THM maching:

```
C:\Windows\System32
```

### What is the description listed for reason 1?

Look at the corresponding DESC section:

```
Stuff running where it normally shouldn't
```

### There is a file in the same folder location that is labeled as a hacktool. What is the name of the file?

Next to the malicious `svchost.exe`, there is a strange javascript file:

```
en-US.js
```

### What is the name of the Yara Rule MATCH?

Loki raised a warning for that file, with the rule:

```
CACTUSTORCH
```

It looks like a javascript shellcode injector.

### Which binary didn't show in the Loki results?

```
mim.exe
```

### Complete the yar rule file located within the Tools folder on the Desktop. What are 3 strings to complete the rule in order to detect the binary Loki didn't hit on?

We'll have to complete the strings (regular expressions) of the provided yara rule. We can help ourselves with `strings64.exe` from SysInternals suite to test our regexps through `findstr` :

```
strings64.exe \tmp\mim.exe | findstr "??.?x?"
strings64.exe \tmp\mim.exe | findstr "...exe"
strings64.exe \tmp\mim.exe | findstr "mk.exe"
```

Finally,

```
mk.ps1, mk.exe, v2.0.50727
```

Alright, you're done!

This room was fun, I hope there's a 3.0 at some point! Congrats to heavenraiza, the creator of that one.