|
71 | 71 | "metadata": {}, |
72 | 72 | "outputs": [], |
73 | 73 | "source": [ |
74 | | - "conn = inventory.connector(\"kvm\", \":win11:\")\n" |
| 74 | + "connector = inventory.create_connector(name=\"kvm\", args=\":win11:\")" |
| 75 | + ] |
| 76 | + }, |
| 77 | + { |
| 78 | + "attachments": {}, |
| 79 | + "cell_type": "markdown", |
| 80 | + "id": "bb246aa8", |
| 81 | + "metadata": {}, |
| 82 | + "source": [ |
| 83 | + "Without the `target` argument the kvm connector will just pick the first virtual machine it finds. It is also possible on some connectors to retrieve a list of all available targets (whereas the resulting `name` is the name of the target):" |
| 84 | + ] |
| 85 | + }, |
| 86 | + { |
| 87 | + "cell_type": "code", |
| 88 | + "execution_count": null, |
| 89 | + "id": "760b6687", |
| 90 | + "metadata": {}, |
| 91 | + "outputs": [], |
| 92 | + "source": [ |
| 93 | + "inventory.connector_target_list(\"qemu\")" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "attachments": {}, |
| 98 | + "cell_type": "markdown", |
| 99 | + "id": "150e13f0", |
| 100 | + "metadata": {}, |
| 101 | + "source": [ |
| 102 | + "It is also possible to retrieve a Help-Text for Plugins, this is especially useful when writing CLI applications:" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "code", |
| 107 | + "execution_count": 19, |
| 108 | + "id": "7c2d9f98", |
| 109 | + "metadata": {}, |
| 110 | + "outputs": [ |
| 111 | + { |
| 112 | + "data": { |
| 113 | + "text/plain": [ |
| 114 | + "'The `qemu` connector implements a memflow plugin interface\\nfor QEMU on top of the Process Filesystem on Linux.\\n\\nThis connector requires access to the qemu process via the linux procfs.\\nThis means any process which loads this connector requires\\nto have at least ptrace permissions set.\\n\\nThe `target` argument specifies the target qemu virtual machine.\\nThe qemu virtual machine name can be specified when starting qemu with the -name flag.\\n\\nAvailable arguments are:\\nmap_base: override of VM memory base\\nmap_size: override of VM memory size'" |
| 115 | + ] |
| 116 | + }, |
| 117 | + "execution_count": 19, |
| 118 | + "metadata": {}, |
| 119 | + "output_type": "execute_result" |
| 120 | + } |
| 121 | + ], |
| 122 | + "source": [ |
| 123 | + "inventory.connector_help(\"qemu\")" |
| 124 | + ] |
| 125 | + }, |
| 126 | + { |
| 127 | + "cell_type": "code", |
| 128 | + "execution_count": 20, |
| 129 | + "id": "e7f09308", |
| 130 | + "metadata": {}, |
| 131 | + "outputs": [ |
| 132 | + { |
| 133 | + "name": "stderr", |
| 134 | + "output_type": "stream", |
| 135 | + "text": [ |
| 136 | + "ERROR memflow.error 2022-12-18 21:00:09,824 error.rs:31 connector: not supported (Os-Plugin `win32` does not support help text.)\n" |
| 137 | + ] |
| 138 | + }, |
| 139 | + { |
| 140 | + "ename": "Exception", |
| 141 | + "evalue": "connector: not supported", |
| 142 | + "output_type": "error", |
| 143 | + "traceback": [ |
| 144 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 145 | + "\u001b[0;31mException\u001b[0m Traceback (most recent call last)", |
| 146 | + "Cell \u001b[0;32mIn[20], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m inventory\u001b[39m.\u001b[39;49mos_help(\u001b[39m\"\u001b[39;49m\u001b[39mwin32\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n", |
| 147 | + "\u001b[0;31mException\u001b[0m: connector: not supported" |
| 148 | + ] |
| 149 | + } |
| 150 | + ], |
| 151 | + "source": [ |
| 152 | + "inventory.os_help(\"win32\")" |
75 | 153 | ] |
76 | 154 | }, |
77 | 155 | { |
|
80 | 158 | "id": "2c510e26", |
81 | 159 | "metadata": {}, |
82 | 160 | "source": [ |
83 | | - "The next step is to utilize the previously created connector to initialize an OS. In the given example we try to find Windows running in memory. " |
| 161 | + "The previously created connector can now be utilized to initialize an Os. In the given example we try to find Windows running in memory in the KVM Virtual Machine." |
84 | 162 | ] |
85 | 163 | }, |
86 | 164 | { |
|
90 | 168 | "metadata": {}, |
91 | 169 | "outputs": [], |
92 | 170 | "source": [ |
93 | | - "os = inventory.os(\"win32\", conn)" |
| 171 | + "os = inventory.create_os(name=\"win32\", input=connector)" |
94 | 172 | ] |
95 | 173 | }, |
96 | 174 | { |
|
112 | 190 | "from pprint import pprint\n", |
113 | 191 | "\n", |
114 | 192 | "drivers = os.module_info_list()\n", |
115 | | - "for driver in drivers: # TODO: implement str for module list\n", |
116 | | - " pprint(driver.name)" |
| 193 | + "pprint(drivers)" |
| 194 | + ] |
| 195 | + }, |
| 196 | + { |
| 197 | + "cell_type": "code", |
| 198 | + "execution_count": null, |
| 199 | + "id": "88aa478d-d24c-46d0-b419-3310663834fd", |
| 200 | + "metadata": {}, |
| 201 | + "outputs": [], |
| 202 | + "source": [ |
| 203 | + "kernel = os # TODO:" |
117 | 204 | ] |
118 | 205 | }, |
119 | 206 | { |
|
128 | 215 | { |
129 | 216 | "cell_type": "code", |
130 | 217 | "execution_count": null, |
131 | | - "id": "88aa478d-d24c-46d0-b419-3310663834fd", |
| 218 | + "id": "0dc364fa", |
132 | 219 | "metadata": {}, |
133 | 220 | "outputs": [], |
134 | 221 | "source": [ |
135 | | - "kernel = os # TODO:\n", |
136 | 222 | "process = os.process_from_name(\"explorer.exe\")" |
137 | 223 | ] |
138 | 224 | }, |
| 225 | + { |
| 226 | + "attachments": {}, |
| 227 | + "cell_type": "markdown", |
| 228 | + "id": "d0ef57bf", |
| 229 | + "metadata": {}, |
| 230 | + "source": [ |
| 231 | + "A Process also features the same functions for retrieving modules:" |
| 232 | + ] |
| 233 | + }, |
139 | 234 | { |
140 | 235 | "cell_type": "code", |
141 | 236 | "execution_count": null, |
|
145 | 240 | "source": [ |
146 | 241 | "from pprint import pprint\n", |
147 | 242 | "\n", |
148 | | - "# List all modules in the process:\n", |
149 | 243 | "modules = process.module_info_list()\n", |
150 | | - "for mod in modules: # TODO: implement str for module list\n", |
151 | | - " pprint(mod.name)" |
| 244 | + "pprint(modules)" |
| 245 | + ] |
| 246 | + }, |
| 247 | + { |
| 248 | + "attachments": {}, |
| 249 | + "cell_type": "markdown", |
| 250 | + "id": "9194330f", |
| 251 | + "metadata": {}, |
| 252 | + "source": [ |
| 253 | + "It is also possible to get a module by it's name:" |
152 | 254 | ] |
153 | 255 | }, |
154 | 256 | { |
|
158 | 260 | "metadata": {}, |
159 | 261 | "outputs": [], |
160 | 262 | "source": [ |
161 | | - "# Load module 'Explorer.EXE':\n", |
162 | 263 | "module = process.module_from_name(\"Explorer.EXE\")" |
163 | 264 | ] |
164 | 265 | }, |
| 266 | + { |
| 267 | + "attachments": {}, |
| 268 | + "cell_type": "markdown", |
| 269 | + "id": "b612a8d1", |
| 270 | + "metadata": {}, |
| 271 | + "source": [ |
| 272 | + "Finally we are able to read Data from the process/module. In the following example we read parts of the COFF Header from the PE Header of the primary module:" |
| 273 | + ] |
| 274 | + }, |
165 | 275 | { |
166 | 276 | "cell_type": "code", |
167 | 277 | "execution_count": null, |
|
187 | 297 | ], |
188 | 298 | "metadata": { |
189 | 299 | "kernelspec": { |
190 | | - "display_name": "Python 3", |
| 300 | + "display_name": "Python 3 (ipykernel)", |
191 | 301 | "language": "python", |
192 | 302 | "name": "python3" |
193 | 303 | }, |
|
0 commit comments