# File location of the hash

What is this task

Basically, the task is asking us to find the file that is being written to in the program for the hash. The one way we can find this is by inspecting the way the process interacts with the environment. We can do this using [Procmon64 ](https://learn.microsoft.com/en-us/sysinternals/downloads/procmon)from the Windows [sysinternals ](https://learn.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite)suite.&#x20;

## How to solve this task

As mentioned, to solve this task, run the application in the environment and make sure we can see it as a process that is active (sometimes, programs will often hide their threads or their processes making them not so visible.)

### Step 1 - Procmon filtering

The first thing we need to do is open up Procmon. When we do that, we should see a Window like this one.

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2F8QDAaxUiEFoHn8xholSe%2FProcMon.png?alt=media&#x26;token=4fa294dc-04af-4966-8ccf-fd9e6c5224c5" alt=""><figcaption></figcaption></figure>

Now click the funnel Icon in the top bar. This is our filtering system since by default procmon listens **system wide.**

This will bring us to the following window

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FFdGFijXjslGYRFap1YRp%2FFilterWindow.png?alt=media&#x26;token=3910ea10-64ff-4315-9342-148d4d43d4b4" alt=""><figcaption></figcaption></figure>

Hit ok when you are done and then watch the window and wait until the binary integrity system triggers.&#x20;

> **Note**: If you read the [methodology-theory](https://skypeguinsolutions.gitbook.io/replay-reverse-engineering-playground/replay/writeups/level-2-all-walkthroughs/section-1.0-binary-integrity-system/tips-for-this-section/methodology-theory "mention") for this level then you would recall us talking about something with exploring systems and how the binary integrity system we are going to be exploring throughout this section was a client^2 binary integrity system which means it was a client only integrity system (remotely pulling, storing, and matching the production hash).

### Step 2  - Analyzing Results

The results in ProcMon are HUGE! Look at this window!

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FqFWPyqnNLUO4l6TspWyJ%2FRWPROCMON.png?alt=media&#x26;token=9c2428c6-0459-4adf-a8d1-ae7f054f5be2" alt=""><figcaption></figcaption></figure>

Eventually, after filtering for calls such as `ReadFile` using `CTRL+F` you come across a few events similar to this one.

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FRUuVoINJUWYp60LIIB5F%2FEventLogged2.png?alt=media&#x26;token=7438f5b6-4d71-4851-b057-84fcfac3b6f6" alt=""><figcaption></figcaption></figure>

This event shows us that the program is writing to a file path or file caled `nrGJzewj` now there are some weird things we should consider about this before we ignore it.

* 1: The binary integrity system is client side. We analyzed that it was previously possibly running a curl command in the silent mode to fetch the hash (*as it was included in a subroutine that passed the file contents to another function*). So maybe this is the end of a URL, or a raw path?<br>
* 2: The ID looks similar to a ending URL filepath. Ideally, the reason this program is storing it in a file is most likely because the path is static- Isolating this program in different empty folders shows that the download of the filepath is the same every single time. However, searching this as a string pulls nothing up so maybe its encrypted.

To find this, maybe we can dynamically analyze the program in HxD to find the string of the file that was written to in order to verify this.&#x20;

> **Note**: We could also just open the file location but we will get to this later, this gives you practice in case the program auto deletes the file after. But if you want to test if the program deletes it, filter for DeleteFile API calls.

### Step 3 - Verifying With HxD

To do this, open up HxD and dump the process. Should be seeing the same window we saw the first time we used HxD in [find-the-ctf-information-block](https://skypeguinsolutions.gitbook.io/replay-reverse-engineering-playground/replay/writeups/level-1-all-walkthroughs/find-the-ctf-information-block "mention"). Then try to CTRL+F to find the string and make sure your search direction is made to search both up and down from your current location.

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FUlMc6xfAgVp61NOSfuHj%2FHxDlayout.png?alt=media&#x26;token=88f45010-e8c7-43c0-8d37-fcad5dc3595f" alt=""><figcaption><p>My current HxD layout and configuration</p></figcaption></figure>

When we look at the findings we get, we can see all this juicy information.

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FMcpfMesPKtJJXs7IJ4Cz%2FPath2.png?alt=media&#x26;token=b9a0d5c5-a63f-4f75-8cd0-186485386150" alt=""><figcaption></figcaption></figure>

* **Pastebin URL:** Notice how this file that is being written to is literally the same ending of the pastebin URL? That is pretty cool! Now we have confirmed that this program remotely fetches the hash *(especially when visiting the URL)* also due to the `raw` in the URL filepath.&#x20;

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FFGZISwsxOlICwsRjcf0I%2FCURL.png?alt=media&#x26;token=f2da9957-f276-4acc-b1b3-9bf9b57a6538" alt=""><figcaption></figcaption></figure>

* **File path endpoint**: When we search for this file on our system, we get the following which showcases the hash.

<figure><img src="https://3418290465-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHgURTVnJd6nEDgFOIjUt%2Fuploads%2FqHn4bkKquNu8udDfeQtj%2FnrGJzewj_NOTEPADOPEN.png?alt=media&#x26;token=97d5ea8d-82d7-4d8d-8813-4d4b4375a86e" alt=""><figcaption></figcaption></figure>

* **Static File path:** We also confirmed that this is a static file path which makes this a lot easier for us for easy modifications of the hash!

### Step 4 - Answers

So the file location is approximately always going to be one step below the current directory and will be  named as `nrGJzewj`.
