|
3 | 3 | This repository aims to simplify the process of inspecting the |
4 | 4 | Registry for forensically relevant details. |
5 | 5 |
|
6 | | -This project is inspired by the RECmd Batch files project |
7 | | -(https://github.com/EricZimmerman/RECmd/tree/master/BatchExamples) |
| 6 | +This project is inspired by the following projects: |
| 7 | + |
| 8 | +1. [The RECmd Batch files project](https://github.com/EricZimmerman/RECmd/tree/master/BatchExamples) |
| 9 | +2. [RegRipper](https://github.com/keydet89/RegRipper4.0) |
| 10 | + |
| 11 | +The intention of this project is to produce a single artifact |
| 12 | +incorporating many analysis modules (called Rules). The user would |
| 13 | +simply need to collect a single artifact from the endpoint and receive |
| 14 | +a wide number of analysis output in machine readable format in |
| 15 | +minutes. |
| 16 | + |
| 17 | +This simplifies the process of collection and analysis as the user |
| 18 | +does not need to remember the hundreds of separate Velociraptor |
| 19 | +artifacts and collect many different artifacts. |
| 20 | + |
| 21 | +The artifact is also designed to simplify running in various |
| 22 | +situations: |
| 23 | + |
| 24 | +1. Live analysis: Running on a live endpoint |
| 25 | +2. Analysis of separate collected hive files (e.g. post processing a |
| 26 | + Triage). |
| 27 | +3. Running over a dead disk image. |
8 | 28 |
|
9 | 29 | ## How does it work? |
10 | 30 |
|
@@ -33,7 +53,117 @@ Rules: |
33 | 53 | output |
34 | 54 | * Comment: The comment will be shown in the generated artifact output |
35 | 55 | * Glob: The glob represents a search expression (See |
36 | | - https://docs.velociraptor.app/vql_reference/plugin/glob/ ) the will |
| 56 | + https://docs.velociraptor.app/vql_reference/plugin/glob/ ) this will |
37 | 57 | search the registry under the Root key. |
38 | 58 | * Root: The is a root registry path. This can only be one of the |
39 | 59 | following values as described below |
| 60 | + |
| 61 | +## What is a `Remapping Strategy`? |
| 62 | + |
| 63 | +The Windows registry consists of a number of hives "mounted" onto a |
| 64 | +single logical hierarchy. For example, the `HKEY_USERS` hive consists |
| 65 | +each currently logged in user's `NTUser.DAT` hive file mounted within |
| 66 | +it. |
| 67 | + |
| 68 | +If we just relied on the API to fetch keys from the `HKEY_USERS` hive, |
| 69 | +we would only be able to see currently logged in users. Users that are |
| 70 | +not currently logged in will not have their `NTUSER.DAT` file |
| 71 | +analysed. |
| 72 | + |
| 73 | +Similarly other parts of the registry are not accessible via the API - |
| 74 | +for example the `SAM` or `Amcache`. |
| 75 | + |
| 76 | +Therefore the registry hunter artifact constructs a virtual hierarchy |
| 77 | +and automatically mounts various hives on these mount points. This is |
| 78 | +necesary even when using the API. |
| 79 | + |
| 80 | +The different remapping strategies describe how the virtual hierarchy |
| 81 | +is constructed (Note that the system itself does not mount the |
| 82 | +registry hives! the hives are logically remapped for the purpose of |
| 83 | +Velociraptor's VQL engine): |
| 84 | + |
| 85 | +* The `API And NTUser.dat` strategy mounts all user's `NTUSER.DAT` |
| 86 | + over the `HKEY_USERS` key. This allows the rule to address all user |
| 87 | + hives without needing to worry about raw registry parsing of |
| 88 | + non-logged in users. |
| 89 | +* The `SAM` is mounted under `/SAM` |
| 90 | + |
| 91 | +### How to use on a dead disk image? |
| 92 | + |
| 93 | +The Registry Hunter can be used on a dead disk image by first creating |
| 94 | +a remapping file for the image. This is described in details in [Remapping Accessors](https://docs.velociraptor.app/docs/forensic/filesystem/remapping/) and [Dead Disk Analysis](https://docs.velociraptor.app/blog/2022/2022-03-22-deaddisk/). |
| 95 | + |
| 96 | +Briefly use the following procedure: |
| 97 | + |
| 98 | +1. Generate a remapping file for the disk image: |
| 99 | + |
| 100 | +``` |
| 101 | +$velociraptor-linux-amd64 -v deaddisk --add_windows_disk /path/to/image.vmdk /tmp/remapping.yaml |
| 102 | +``` |
| 103 | + |
| 104 | +After checking the remapping file, you can start a Velociraptor client |
| 105 | +with it - this creates a "Virtual Client" which can collect artifacts |
| 106 | +directly from the image. |
| 107 | + |
| 108 | +To start a client/server "instant Velociraptor": |
| 109 | + |
| 110 | +``` |
| 111 | +velociraptor-linux-amd64 --remap /tmp/remapping.yaml gui -v |
| 112 | +``` |
| 113 | + |
| 114 | +Alternatively to start a remapped client that connects to a remote server: |
| 115 | + |
| 116 | +``` |
| 117 | +velociraptor-linux-amd64 --remap /tmp/remapping.yaml client -v |
| 118 | +``` |
| 119 | + |
| 120 | +You can now collect the Registry Hunter artifact with the "None" |
| 121 | +Remapping Strategy. |
| 122 | + |
| 123 | + |
| 124 | +## How to easily develop new rules? |
| 125 | + |
| 126 | +The artifact generated contains a large number of rules and it is |
| 127 | +designed to collect them all at once. This makes it hard to develop as |
| 128 | +we need a quick development cycle (build -> test -> inspect cycle). |
| 129 | + |
| 130 | +I usually use a Windows test VM with a shared drive that I can used to |
| 131 | +exchange data with the development system. |
| 132 | + |
| 133 | +I run `velociraptor.exe gui` on the development VM to create an |
| 134 | +instant Velociraptor server and client. This way I can use the |
| 135 | +notebook directly on Windows and develop/test my artifacts. |
| 136 | + |
| 137 | +On the development system: |
| 138 | + |
| 139 | +``` |
| 140 | +$ make && cp output/Windows.Registry.Hunter.yaml /shared/reghunter/ |
| 141 | +``` |
| 142 | + |
| 143 | +This builds the artifacts and copies onto a shared directory which I |
| 144 | +can exchange with the Windows test VM. |
| 145 | + |
| 146 | +On the test VM I create a notebook and enter the following query. Here |
| 147 | +`F:` is the shared drive mount letter on the Windows system. |
| 148 | + |
| 149 | +```sql |
| 150 | +LET RuleName = "Active Setup Installed Components" |
| 151 | + |
| 152 | +LET _ <= SELECT artifact_set(definition=read_file(filename=OSPath)).name AS Name |
| 153 | +FROM glob(globs="F:/reghunter/*") |
| 154 | + |
| 155 | +-- SELECT * FROM Artifact.Windows.Registry.Hunter(DescriptionFilter=RuleName, source="Remapping", RemappingStrategy="API") |
| 156 | +-- SELECT * FROM Artifact.Windows.Registry.Hunter(DescriptionFilter=RuleName, source="Rules", RemappingStrategy="API") |
| 157 | +SELECT * FROM Artifact.Windows.Registry.Hunter(DescriptionFilter=RuleName, source="Results", RemappingStrategy="API") |
| 158 | +``` |
| 159 | + |
| 160 | +In the above example, I am working on a rule called `Active Setup |
| 161 | +Installed Components`. The above query: |
| 162 | + |
| 163 | +1. Imports the new artifact that was just built from the shared folder. |
| 164 | +2. Runs the artifact with the API remapping strategy and a description |
| 165 | + filter that should only select the rule I am working on right now. |
| 166 | +3. The results are shown from the Results source. |
| 167 | + |
| 168 | +Iterating is now very quick - I just rebuild the artifact in my dev |
| 169 | +system, and refresh the cell in the test system. |
0 commit comments