{"componentChunkName":"component---src-templates-post-template-js","path":"/magical-windbg-vol1-50-en","result":{"data":{"markdownRemark":{"id":"efadd108-d9e5-534e-9ed9-9372f0f22734","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/magical-windbg-vol1-50\">original page</a>.</p>\n</blockquote>\n<p>In this appendix, I introduce several debugger techniques that could not be included in the main text.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of contents</h2>\n<ul>\n<li><a href=\"#output-command-window-results-to-a-file\">Output Command Window Results to a File</a></li>\n<li><a href=\"#script-and-execute-windbg-commands\">Script and Execute WinDbg Commands</a></li>\n<li><a href=\"#use-the-mex-extension\">Use the MEX Extension</a></li>\n<li><a href=\"#read-file-contents-from-a-full-memory-dump\">Read File Contents from a Full Memory Dump</a></li>\n<li><a href=\"#extract-executables-from-dump-files-with-windbg\">Extract Executables from Dump Files with WinDbg</a></li>\n<li><a href=\"#links-to-each-chapter\">Links to each chapter</a></li>\n</ul>\n<h2 id=\"output-command-window-results-to-a-file\" style=\"position:relative;\"><a href=\"#output-command-window-results-to-a-file\" aria-label=\"output command window results to a file permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Output Command Window Results to a File</h2>\n<p>You can configure the WinDbg Command window to write execution results to any file.</p>\n<p>This is useful when you want to save a history of your analysis with WinDbg, or when you want to analyze the results of commands that produce a huge amount of output using methods other than WinDbg.</p>\n<p>If you want to save WinDbg command output to a specified file, run the <code class=\"language-text\">.logopen &lt;full path to the destination file></code> command in the Command window.</p>\n<p>After running this command, the results of subsequent commands will be written to the specified path as ASCII text.</p>\n<p>To stop writing and close the file, run the <code class=\"language-text\">.logclose</code> command.</p>\n<p>By running the commands above, the output is saved to a log as shown in the image below.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b7fd878508bf57c5eaaa84bfbe78ce7c/0b533/appendix-logfile-01.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 63.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACH0lEQVQ4y6VT53LiQAzm/V+KACHH0AI4BGPcwQ3b2FRj2neSAgy5v7czmi32fkXSVrLNBofDAceiwH63w/l8xv+Mynq9RpZliOMYq9UKeZ7TnAmJEJUlCiLjOJ1OuN1uEtfr9RmPM47KcDiCZVoEmGC73WJDisMoQpLEiGheEZnvefAokiTB5XKRi4/xCiaAruPgeDxKlBQpXcpIJTOzopIU8o8MyGQZudhstgLM8QoslrvdLhzbgTIa4e3tDZ12B++NdywWC4yGQ1SrVQRBCFVVYVoW3PkcFs3adIoh3WE3ZXl6glYURYFNgLOZhl6vh/HXGP1+XxTpMx2fnwOxOtNmGBCB5/lI00RAHXIXBIG4ewIOBgPM3TkBKWg2m+B9u91GSKpYdaNel4JZpokuEXq+j3gZyTeVVPq057Q8AVmVoZv4IqV/Pj4EsNVqSRom39/odDqIlkuEYQDDMHCmvM1dF1MCM4jkFUxyOB6PqYo+1MkEnE+2zKBLAtGmmpwlSUppsaHrhrQP53eqTmmvY78//Kp2pUsKDMMUC7VaDbxvNBqicED5q9fqpC4kQAsKke2o+Vkh517TNCH4pXBCysJ7FX8KZFOBdORZDpcu8vmWQBiUi8OD7XPRbMemdfTomx+FbJEvsnXOSUxW83yNVZpKMRiI19zk0uj0irg/uQf5mb42ugCW96fFjfxY8/xo9qI43KMQu/yaXl/Kv439F/JazWlRGWzVAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b7fd878508bf57c5eaaa84bfbe78ce7c/8ac56/appendix-logfile-01.webp 240w,\n/static/b7fd878508bf57c5eaaa84bfbe78ce7c/d3be9/appendix-logfile-01.webp 480w,\n/static/b7fd878508bf57c5eaaa84bfbe78ce7c/b0a15/appendix-logfile-01.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b7fd878508bf57c5eaaa84bfbe78ce7c/8ff5a/appendix-logfile-01.png 240w,\n/static/b7fd878508bf57c5eaaa84bfbe78ce7c/e85cb/appendix-logfile-01.png 480w,\n/static/b7fd878508bf57c5eaaa84bfbe78ce7c/0b533/appendix-logfile-01.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b7fd878508bf57c5eaaa84bfbe78ce7c/0b533/appendix-logfile-01.png\"\n            alt=\"Command output written to a log file\"\n            title=\"Command output written to a log file\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Note that if you specify a log destination with <code class=\"language-text\">.logopen</code> and a file already exists at that path, the existing file data will be deleted and replaced with the new command output.</p>\n<p>If you want to save command output by appending to an existing file, use the <code class=\"language-text\">.logappend &lt;full path to the destination file></code> command instead of <code class=\"language-text\">.logopen</code>.</p>\n<p>Also, if you want to avoid accidentally overwriting a file that contains past analysis results, you can use the <code class=\"language-text\">/t</code> option with the <code class=\"language-text\">.logopen</code> command.</p>\n<p>When you use the <code class=\"language-text\">/t</code> option, timestamp information for the date and time when logging started is automatically added to the specified file path, as in the example below, which prevents existing files from being overwritten.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0:000> .logopen /t C:\\Users\\Public\\windbg.log\nClosing open log file C:\\Users\\Public\\windbg.log\nOpened log file 'C:\\Users\\Public\\windbg_1058_2023-09-24_08-36-13-088.log'</code></pre></div>\n<p>Whichever command you use, run <code class=\"language-text\">.logclose</code> to stop writing and close the file.</p>\n<p>For more detailed information about saving WinDbg output, please refer to the official documentation below.</p>\n<br>\n<p>Keeping a Log File in WinDbg:</p>\n<p><a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/keeping-a-log-file-in-windbg\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/keeping-a-log-file-in-windbg</a></p>\n<br>\n<h2 id=\"script-and-execute-windbg-commands\" style=\"position:relative;\"><a href=\"#script-and-execute-windbg-commands\" aria-label=\"script and execute windbg commands permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Script and Execute WinDbg Commands</h2>\n<p>WinDbg can execute complex scripted processing.</p>\n<p>In this book, when using commands for dump file analysis, I entered either a single command or multiple commands separated by semicolons (<code class=\"language-text\">;</code>) in the WinDbg Command window.</p>\n<p>However, to analyze more efficiently, there are cases where you may want to execute complex commands all at once or control which commands run by using conditional branches.</p>\n<p>For example, the following script enumerates EPROCESS structures in kernel memory and uses an If statement to print only the address when the D4C.exe process is found.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$$  Get process list LIST_ENTRY in $t0.\nr $t0 = nt!PsActiveProcessHead\n\n$$  Iterate over all processes in list.\n.for (r $t1 = poi(@$t0);\n      (@$t1 != 0) &amp; (@$t1 != @$t0);\n      r $t1 = poi(@$t1))\n{\n    r? $t2 = #CONTAINING_RECORD(@$t1, nt!_EPROCESS, ActiveProcessLinks);\n    as /x Procc @$t2\n\n    $$  Get image name into $ImageName.\n    as /ma $ImageName @@c++(&amp;@$t2->ImageFileName[0])\n\n    .block\n    {\n   .if ($scmp(\"D4C.exe\",\"${$ImageName}\")) { } .else {.echo ${$ImageName} at ${Procc}}\n    }\n\n    ad $ImageName\n    ad Procc\n}</code></pre></div>\n<p>You can save this script as <code class=\"language-text\">C:\\Users\\Win10\\Downloads\\windbg_script.txt</code> and execute it by invoking it in WinDbg as follows.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">6: kd> $$>a&lt;C:\\Users\\Win10\\Downloads\\windbg_script.txt\nD4C.exe at 0xffffc18f45284080</code></pre></div>\n<p>This book does not explain in detail the script invocation commands<sup id=\"fnref-1\"><a href=\"#fn-1\" class=\"footnote-ref\">1</a></sup>, the syntax for the conditional branches<sup id=\"fnref-2\"><a href=\"#fn-2\" class=\"footnote-ref\">2</a></sup> and loops<sup id=\"fnref-3\"><a href=\"#fn-3\" class=\"footnote-ref\">3</a></sup> used in this script, or how to use aliases<sup id=\"fnref-4\"><a href=\"#fn-4\" class=\"footnote-ref\">4</a></sup> and pseudo-registers<sup id=\"fnref-5\"><a href=\"#fn-5\" class=\"footnote-ref\">5</a></sup>.</p>\n<p>Please refer to the public documentation for details on each command.</p>\n<h2 id=\"use-the-mex-extension\" style=\"position:relative;\"><a href=\"#use-the-mex-extension\" aria-label=\"use the mex extension permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Use the MEX Extension</h2>\n<p>The MEX extension is an extension for WinDbg officially provided by Microsoft.</p>\n<p>Some commands in the MEX extension were used in Chapter 7.</p>\n<p>For the level of analysis covered in this book, you do not need to use the MEX extension, but I think it is convenient to know about it.</p>\n<p>To use the MEX extension, first run Mex.exe, which can be downloaded from the URL below, on a Windows system.</p>\n<br>\n<p>Download MEX Debugging Extension from Official Microsoft Download Center:</p>\n<p><a href=\"https://www.microsoft.com/en-us/download/details.aspx?id=53304\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://www.microsoft.com/en-us/download/details.aspx?id=53304</a></p>\n<br>\n<p>Next, in the window that appears after you agree to the license terms, specify any folder path where the MEX extension modules will be placed.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c75e8c47f84c63428c00b284e2b7ec7a/0b533/MEX-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 33.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABbklEQVQoz22R7WriQBiFc9NegJewa//4xwtoC34gmGDW0n8ioqDRNB8qJnFjKiaxpuJHu89OBrIg7MDDOcMMw5nzKr1eD1XtoHU1uoJOR0XVNHovL4xGozvG4zHD4ZDBYCB9of1+X56Xy2WUNE15370TbHx2u0iwI4oi4iTh9vXF7Xbjer1KLXyxP51OXITPNV+1Wg1ltVrhui6O4+B5HsvlUvpCTdNkPp9jWdY/tW0H17GxLVPwxtJ14M83lUoFJU8ThiG+77PZbAiCQCbcbrfs93uyLLvjeMz4zI54UcJ8FWI4HobrE8QnKg8PKLZtM51OJYZhMJlMmM1mUtfrNYfDgTiOJYmoIUlS0mQvH3sdL+j2DX4NTGbBBz9+ioT53y+Xy103hT+fz7KfPFmeeLFYSPKe0zThd7jlTXzfEuT3q9Uqiq7rYrIdMWn1v2hi4rk2m03q9bqk1WrRbrdpNBo8Pz/x9PiIrncplUr8BSyS7eMrbQRfAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/c75e8c47f84c63428c00b284e2b7ec7a/8ac56/MEX-001.webp 240w,\n/static/c75e8c47f84c63428c00b284e2b7ec7a/d3be9/MEX-001.webp 480w,\n/static/c75e8c47f84c63428c00b284e2b7ec7a/b0a15/MEX-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/c75e8c47f84c63428c00b284e2b7ec7a/8ff5a/MEX-001.png 240w,\n/static/c75e8c47f84c63428c00b284e2b7ec7a/e85cb/MEX-001.png 480w,\n/static/c75e8c47f84c63428c00b284e2b7ec7a/0b533/MEX-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/c75e8c47f84c63428c00b284e2b7ec7a/0b533/MEX-001.png\"\n            alt=\"Extracting the MEX modules\"\n            title=\"Extracting the MEX modules\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>If you open the path you specified above in Explorer, you can confirm that a file named <code class=\"language-text\">Mex.zip</code> has been placed there, so extract this ZIP file.</p>\n<p>By loading the <code class=\"language-text\">mex.dll</code> file contained in the extracted folder into WinDbg with the <code class=\"language-text\">.load &lt;full path to mex.dll></code> command, you will be able to use the MEX extension.</p>\n<p>This book does not explain the MEX extension in detail, but you can output help for each available feature by running the <code class=\"language-text\">!mex.help -all</code> command.</p>\n<h2 id=\"read-file-contents-from-a-full-memory-dump\" style=\"position:relative;\"><a href=\"#read-file-contents-from-a-full-memory-dump\" aria-label=\"read file contents from a full memory dump permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Read File Contents from a Full Memory Dump</h2>\n<p>In this section, I introduce a technique for retrieving file data from memory data collected in a full memory dump.</p>\n<p>On Windows systems, a mechanism called the cache manager caches file contents and file system metadata.<sup id=\"fnref-6\"><a href=\"#fn-6\" class=\"footnote-ref\">6</a></sup></p>\n<p>This cache manager tracks which parts of which files exist in the cache by using a mechanism called Virtual Block Caching.</p>\n<p>In this book, I attempt to extract file contents from the system by identifying the address of the structure called the virtual address control block (VACB), which is managed by the cache manager, from a memory-mapped file object.</p>\n<p>Note that this method assumes cached data exists in pages included in the full memory dump, so it is important to keep in mind that you cannot necessarily retrieve file contents from every full memory dump you collect.</p>\n<p>To extract file contents from a full memory dump, first load the collected full memory dump into WinDbg and run the <code class=\"language-text\">!memusage</code> command.</p>\n<p>Because the output of <code class=\"language-text\">!memusage</code> is enormous, I recommend enabling output to a file in advance with the <code class=\"language-text\">.logopen</code> command.</p>\n<p>As a result of running <code class=\"language-text\">!memusage</code> and analyzing the PFN database information, I confirmed the presence of no-cached-file.txt and Microsoft-Windows-Windows Defender%4Operational.evtx (the Microsoft Defender Antivirus event log file) as mapped files.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> !memusage\nloading PFN database\n{{ omitted }}\nUsage Summary (in Kb):\nControl       Valid Standby Dirty Shared Locked PageTables  name\n\nffffc40861b53750     0      4     0     0     0     0  mapped_file( no-cached-file.txt )\n\nffffc40861b5c350    68      0     0     0    68     0  mapped_file( Microsoft-Windows-Windows Defender%4Operational.evtx )</code></pre></div>\n<p>To inspect the Control information identified here, use the <code class=\"language-text\">!ca</code> extension.<sup id=\"fnref-7\"><a href=\"#fn-7\" class=\"footnote-ref\">7</a></sup></p>\n<p>When I ran the <code class=\"language-text\">!ca ffffc40861b53750</code> command using 0xffffc40861b53750, which is the address of the control area corresponding to <code class=\"language-text\">mapped_file( no-cached-file.txt )</code>, I obtained the following result.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ff05f77f98d57df8289c61e0929e0b30/0b533/windbg-read-file-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 43.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABRklEQVQoz3WSa8uCQBCF/f//y/wiEaZUlJVdtAuVUtndE8+AYry8C8NeZvfMOWfWWa1W2u/3ms1miqJIw+FQm81G7/db9Xi9Xno+nxbt83bu8Xjo8/nI8TxP2+1W5/NZSZJouVxqsVhYAH69XpXnuXa7nQ6HgxULgsDuQqQoip+c47quer2eTqeTxfF4tOR4PFan05Hv+7rdbg0jAMhNp1OlafrDluJOlmXNBapiAfLZMxPI+m9UVdUEw0Haer02+oDN53NjiEwqYgUMAeWMQMX9fv8BrNfmYRiGdglj60eXy8W8wVOK0QzOCGS3bajBjCFyYYhcmjAajcwCwGHFTBfbLIg6R2f/MKTLsAKIr9Ptds27wWBg+ziO7QGsJpOJ+v2+eUwTy7I0axpAvgBy8ASJsEUma74BfnJG89gTFGZmwBCmNeAXZluo2l5c/fcAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ff05f77f98d57df8289c61e0929e0b30/8ac56/windbg-read-file-001.webp 240w,\n/static/ff05f77f98d57df8289c61e0929e0b30/d3be9/windbg-read-file-001.webp 480w,\n/static/ff05f77f98d57df8289c61e0929e0b30/b0a15/windbg-read-file-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ff05f77f98d57df8289c61e0929e0b30/8ff5a/windbg-read-file-001.png 240w,\n/static/ff05f77f98d57df8289c61e0929e0b30/e85cb/windbg-read-file-001.png 480w,\n/static/ff05f77f98d57df8289c61e0929e0b30/0b533/windbg-read-file-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ff05f77f98d57df8289c61e0929e0b30/0b533/windbg-read-file-001.png\"\n            alt=\"Retrieve control area information for no-cached-file.txt with !ca\"\n            title=\"Retrieve control area information for no-cached-file.txt with !ca\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Likewise, when I ran the <code class=\"language-text\">!ca ffffc40861b5c350</code> command using 0xffffc40861b5c350, which is the address of the control area corresponding to <code class=\"language-text\">mapped_file( Microsoft-Windows-Windows Defender%4Operational.evtx )</code>, the result was as follows.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/9d4e16a72f9099898ae7d0f08c992c63/0b533/windbg-read-file-002.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 43.333333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABT0lEQVQoz22S646CUAyEef/nMjH4DyVGRBEv4BVEAe8ym68Jxt1sk5PTnKHTmRZntVrpcDhoOp1qOBxqNBpps9no/X6rjcfjofv9buf1euk7/mKO67rKskzn81nL5VI0iKJIi8XCGtR1rePxqP1+b43TNJXneZrNZtrtdjqdTobBwe10Oh0NBgMjzPPcigAp6PV6hqGijaqqDJvP51qv17/UotKh42QyMUWcOI6VJImKojBlNCGnEWrIy7K0HKzF+bZpGjlYZGbIJ4fwm4hCCC6Xi5Fy+BZHt9vNVOGAY4Tdble+71shRdiFjCWhnrlCwJKwy4Hser3qv3AoxCJzCcPQthwEgXVnayh4Pp/WnWhvMFSBtZs3hQweBViBaDwef2YKOeppRqAMjDeE4IQ3RvMh7Pf7ZoffA+Ltdmvr52aL5NhmzuTcNGUc3/9iS/gDMqynVyJaYIAAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/9d4e16a72f9099898ae7d0f08c992c63/8ac56/windbg-read-file-002.webp 240w,\n/static/9d4e16a72f9099898ae7d0f08c992c63/d3be9/windbg-read-file-002.webp 480w,\n/static/9d4e16a72f9099898ae7d0f08c992c63/b0a15/windbg-read-file-002.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/9d4e16a72f9099898ae7d0f08c992c63/8ff5a/windbg-read-file-002.png 240w,\n/static/9d4e16a72f9099898ae7d0f08c992c63/e85cb/windbg-read-file-002.png 480w,\n/static/9d4e16a72f9099898ae7d0f08c992c63/0b533/windbg-read-file-002.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/9d4e16a72f9099898ae7d0f08c992c63/0b533/windbg-read-file-002.png\"\n            alt=\"Retrieve control area information for the event log file with !ca\"\n            title=\"Retrieve control area information for the event log file with !ca\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>From this output, you can confirm the path of each file and the address of its file object.</p>\n<p>For example, because the output for no-cached-file.txt shows <code class=\"language-text\">File Object  ffffc40861f5f720</code>, you can determine that this file’s file object exists at 0xffffc40861f5f720.</p>\n<p>You can also confirm that the output for the event log file shows <code class=\"language-text\">File Object  ffffc40861920440</code>.</p>\n<p>To verify this, let’s use these addresses to run the <code class=\"language-text\">!fileobj</code> extension and confirm that we can inspect the detailed information for the file objects.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Inspect the file object for no-cached-file.txt\n0: kd> !fileobj ffffc40861f5f720\n\n\\Users\\Vuln\\Desktop\\no-cached-file.txt\n\nDevice Object: 0xffffc4085b32ec00   \\Driver\\volmgr\nVpb: 0xffffc4085b3c69c0\nAccess: Read SharedRead SharedWrite \n\nFlags:  0x44042\nSynchronous IO\nCache Supported\nCleanup Complete\nHandle Created\n\nFinal Status: 80000005\nFsContext: 0xffff83807b62d700FsContext2: 0xffff83807ceb2580\nCurrentByteOffset: 0\nCache Data:\n  Section Object Pointers: ffffc40861f22a98\n  Shared Cache Map: 00000000\n\n\n# Inspect the file object for the event log file\n0: kd> !fileobj ffffc40861920440\n\n\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-Windows Defender%4Operational.evtx\n\nDevice Object: 0xffffc4085b32ec00   \\Driver\\volmgr\nVpb: 0xffffc4085b3c69c0\nEvent signalled\nAccess: Read Write SharedRead \n\nFlags:  0x41042\nSynchronous IO\nCache Supported\nModified\nHandle Created\n\nFsContext: 0xffff83807a55f700FsContext2: 0xffff83807a55f970\nPrivate Cache Map: 0xffffc40861582b98\nCurrentByteOffset: 36a0\nCache Data:\n  Section Object Pointers: ffffc40861981b38\n  Shared Cache Map: ffffc40861582a20         File Offset: 36a0 in VACB number 0\n  Vacb: ffffc4085abd5ea0\n  Your data is at: ffff9688ea9436a0</code></pre></div>\n<p>Now that we have identified the address of each file object, we can next obtain the address of the <code class=\"language-text\">nt!_SECTION_OBJECT_POINTERS</code> structure from information in the <code class=\"language-text\">nt!_FILE_OBJECT</code> structure.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Inspect the file object for no-cached-file.txt\n0: kd> dt nt!_FILE_OBJECT ffffc40861f5f720 SectionObjectPointer\n   +0x028 SectionObjectPointer : 0xffffc408`61f22a98 _SECTION_OBJECT_POINTERS\n\n# Inspect the file object for the event log file\n0: kd> dt nt!_FILE_OBJECT ffffc40861920440 SectionObjectPointer\n   +0x028 SectionObjectPointer : 0xffffc408`61981b38 _SECTION_OBJECT_POINTERS</code></pre></div>\n<p>Next, dump the information in the <code class=\"language-text\">nt!_SECTION_OBJECT_POINTERS</code> structure pointed to by those addresses.</p>\n<p>If we first dump the information for no-cached-file.txt, we can see that SharedCacheMap is empty as shown below.</p>\n<p>In this case, no-cached-file.txt is not cached by the cache manager, so its contents cannot be referenced from the cache.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> dt nt!_SECTION_OBJECT_POINTERS ffffc408`61f22a98 \n   +0x000 DataSectionObject : 0xffffc408`61b53750 Void\n   +0x008 SharedCacheMap   : (null) \n   +0x010 ImageSectionObject : (null)</code></pre></div>\n<p>Next, let’s dump the structure information for the event log file.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> dt nt!_SECTION_OBJECT_POINTERS ffffc40861981b38\n   +0x000 DataSectionObject : 0xffffc408`61b5c350 Void\n   +0x008 SharedCacheMap   : 0xffffc408`61582a20 Void\n   +0x010 ImageSectionObject : (null) </code></pre></div>\n<p>Here, we can see that the address 0xffffc40861582a20 is stored in SharedCacheMap.</p>\n<p>The SharedCacheMap structure includes the address of a VACB.</p>\n<p>Therefore, by running the <code class=\"language-text\">dt nt!_SHARED_CACHE_MAP ffffc40861582a20 Vacbs</code> command using the identified SharedCacheMap address, we can identify the VACB address needed to refer to the cache that contains the target file’s contents.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> dt nt!_SHARED_CACHE_MAP ffffc40861582a20 Vacbs\n   +0x058 Vacbs : 0xffffc408`61582a58  -> 0xffffc408`5abd5ea0 _VACB</code></pre></div>\n<p>By dumping the information in the <code class=\"language-text\">nt!_VACB</code> structure using the VACB address 0xffffc4085abd5ea0 identified by the command above, I was able to obtain the following information.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">0: kd> dt nt!_VACB ffffc4085abd5ea0\n   +0x000 BaseAddress      : 0xffff9688`ea940000 Void\n   +0x008 SharedCacheMap   : 0xffffc408`61582a20 _SHARED_CACHE_MAP\n   +0x010 Overlay          : &lt;anonymous-tag>\n   +0x020 ArrayHead        : 0xffffc408`5abce000 _VACB_ARRAY_HEADER</code></pre></div>\n<p>The VACB structure is managed by the system’s VACB array, and each VACB entry describes the address of a 256 KB slot allocated for the system cache.<sup id=\"fnref-8\"><a href=\"#fn-8\" class=\"footnote-ref\">8</a></sup></p>\n<p>In other words, the contents of the Microsoft Defender Antivirus event log file are cached at the address 0xffff9688ea940000 shown in BaseAddress.</p>\n<p>If you actually dump 60 bytes of memory from BaseAddress with the <code class=\"language-text\">db 0xffff9688ea940000 L60</code> command, you can see that the data begins with <code class=\"language-text\">ElfFile\\x00</code>, which is the signature of the Windows Event Log (EVTX) format.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7eaa5672a14e677b12c278b63f52b5e2/0b533/windbg-read-file-003.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 14.166666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAADCAYAAACTWi8uAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAmUlEQVQI1z2OSQqFMBBEc/9juRBRNMEhDmQhunEgbiVKKOmC/xePSjXhdaumaaC1Rp7nsNaiLEv2YRiwbRuO48C+78zzPDn7pfce13WR930RY4QqigJJkpB1XVHXNcVd15GqqmCM+c/l3bYtlzrnEELAfd9MkSr5kGUZ0jTFsiyQi/u+J+M4sotIJNJlyTRN7PM88yoRPc9DPgkq17+R/b8eAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/7eaa5672a14e677b12c278b63f52b5e2/8ac56/windbg-read-file-003.webp 240w,\n/static/7eaa5672a14e677b12c278b63f52b5e2/d3be9/windbg-read-file-003.webp 480w,\n/static/7eaa5672a14e677b12c278b63f52b5e2/b0a15/windbg-read-file-003.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/7eaa5672a14e677b12c278b63f52b5e2/8ff5a/windbg-read-file-003.png 240w,\n/static/7eaa5672a14e677b12c278b63f52b5e2/e85cb/windbg-read-file-003.png 480w,\n/static/7eaa5672a14e677b12c278b63f52b5e2/0b533/windbg-read-file-003.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/7eaa5672a14e677b12c278b63f52b5e2/0b533/windbg-read-file-003.png\"\n            alt=\"Dump of cached memory for the event log file\"\n            title=\"Dump of cached memory for the event log file\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Although the detailed specification of the Windows Event Log (EVTX) format is not public, you can get information about the file header and chunk header from the public information in the <a href=\"https://github.com/libyal/libevtx/blob/main/documentation/Windows%20XML%20Event%20Log%20(EVTX).asciidoc#windows-xml-event-log-evtx-format\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">libyal/libevtx</a> repository on GitHub.</p>\n<p>To further check whether event log file data is written to the memory region beginning at this BaseAddress, dump an arbitrary 10000 bytes into windefend-event.txt with the <code class=\"language-text\">.writemem C:\\windefend-event.txt ffff9688ea940000 L10000</code> command.</p>\n<p>Because the text inside the event log file is written as a wide string, when I extracted text from the file with a command such as <code class=\"language-text\">strings -e l windefend-event.txt</code>, I found that I could obtain data written in the event log file as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$ strings -e l windefend-event.txt\n\nMicrosoft Defender Antivirus\n4.18.23080.2006\n1.397.865.0\n1.1.23080.2005\nSecurity intelligence update\nC:\\ProgramData\\Microsoft\\Windows Defender\\Scans\\RtSigs\\data\\884898236a1fb17353dac39aea1e06cfeadc24e4\n0.0.0.0\n10/20/2023 11:36:23 AM\nDuration\n2592000000\nMicrosoft-Windows-Windows Defender\nMicrosoft-Windows-Windows Defender/Operational</code></pre></div>\n<p>By the way, this time I followed the structure information step by step from the file object address to reach the VACB address, but if you use the <code class=\"language-text\">!finddata</code> extension<sup id=\"fnref-9\"><a href=\"#fn-9\" class=\"footnote-ref\">9</a></sup>, you can identify the address where the contents are cached much more easily.</p>\n<p>When I ran the <code class=\"language-text\">!finddata</code> command using the addresses of the file objects for no-cached-file.txt and the event log file that I investigated above, I obtained the following results.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\"># Inspect the file object for no-cached-file.txt\n0: kd> !finddata ffffc40861f5f720\n\nFindData for FileObject ffffc40861f5f720   Section Object Pointers: ffffc40861f22a98\nShared Cache Map: 00000000Unable to read nt!_SHARED_CACHE_MAP at 0000000000000000\n\n\n# Inspect the file object for the event log file\n0: kd> !finddata ffffc40861920440\n\nFindData for FileObject ffffc40861920440   Section Object Pointers: ffffc40861981b38\nShared Cache Map: ffffc40861582a20         File Offset: 0 in VACB number 0\nVacb: ffffc4085abd5ea0\nYour data is at: ffff9688ea940000</code></pre></div>\n<p>In the case of no-cached-file.txt, which had no cache present in memory, text was output indicating that the address of the <code class=\"language-text\">nt!_SHARED_CACHE_MAP</code> structure could not be referenced.</p>\n<p>On the other hand, for the event log file, <code class=\"language-text\">Your data is at: ffff9688ea940000</code> was output, which is the cached address of the contents identified from the VACB structure information.</p>\n<p>With that, I was able to extract data for files cached in the system from the full memory dump.</p>\n<p>This method makes it difficult to retrieve a specifically targeted file or the original complete file, but I think it is an interesting technique to know when analyzing full memory dumps.</p>\n<h2 id=\"extract-executables-from-dump-files-with-windbg\" style=\"position:relative;\"><a href=\"#extract-executables-from-dump-files-with-windbg\" aria-label=\"extract executables from dump files with windbg permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Extract Executables from Dump Files with WinDbg</h2>\n<p>You are unlikely to need this in actual troubleshooting, but for example, when analyzing a dump file from a malware-infected system, there are cases where you may want to retrieve the original executable from the memory dump.</p>\n<p>In such cases, you can obtain an executable (a PE file) by extracting the data expanded in a process’s memory with WinDbg and exporting it as a file.</p>\n<p>However, note that an executable extracted from process memory with this method is not completely identical to the original executable.<sup id=\"fnref-10\"><a href=\"#fn-10\" class=\"footnote-ref\">10</a></sup></p>\n<p>There are several reasons for this, but one is that some sections of the PE file are not expanded into process memory.</p>\n<p>Also, if values such as global variables or executable code expanded in memory have been modified by the program, it is no longer possible to extract the original executable file.</p>\n<p>There are other reasons why it is difficult to extract a file from process memory that is completely identical to the original executable, but this book omits a detailed explanation.</p>\n<p>For executable extraction from process memory, the reference listed in this book, <em>The Art of Memory Forensics</em>, explains the topic in detail.</p>\n<p>In this book, I will recover the D4C.exe executable from a full process memory dump using WinDbg.</p>\n<p>Basically, recovery is possible by performing the reverse of the PE file loader: extracting the PE headers and each section’s information as expanded in process memory and merging them into a single file.</p>\n<p>As introduced in Chapters 5 and 6, it is technically possible to recover the executable by using the <code class=\"language-text\">!dh -f</code> and <code class=\"language-text\">!dh -s</code> commands to obtain information about the IAT and section headers, then using the <code class=\"language-text\">.writemem</code> command to write each memory region to a file.</p>\n<p>This time, however, I will extract the executable by using an open-source extension published on GitHub (<a href=\"https://github.com/HongThatCong/dumpext\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">HongThatCong/dumpext</a>).</p>\n<p>This book only introduces the fact that executables can be extracted from process dumps, so it does not explain the details of the extension.</p>\n<p>To extract the executable, I use the D4C.exe process dump obtained in Chapter 6.</p>\n<p>After loading the D4C.exe process dump into WinDbg, load the extension downloaded from the <a href=\"https://github.com/HongThatCong/dumpext\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">HongThatCong/dumpext</a> repository with the <code class=\"language-text\">.load C:\\Users\\Public\\Downloads\\dumpext.dll</code> command.</p>\n<p>After loading the extension, run the <code class=\"language-text\">!dumpext.dump_pe !D4C</code> command to dump the executable from the process.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ef34154aad3352406c6345fc16287d37/0b533/windbg-recover-file-001.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 20.833333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAs0lEQVQY031PSQqEQBDr//9MEfetXUHFBUFFvQhqhsphbjMFoUJ1k0X5vo+iKOC6LoQnSYIoitB1Hfq+xziO5G3bYlkWHMeBf6M8z6OIbdsIggBZlsFxHN7iOEZVVUjTFGEY8q2ua27BMAxomgbTNNFs33coy7L42TAMJhRh4aZp8q61ppEYSOJ1XSmwbRvTyr6ui+ne94XK85yVyrL8QlIJpO48zzjPE/d943men1VFTOYDlwcm7ogkQKcAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ef34154aad3352406c6345fc16287d37/8ac56/windbg-recover-file-001.webp 240w,\n/static/ef34154aad3352406c6345fc16287d37/d3be9/windbg-recover-file-001.webp 480w,\n/static/ef34154aad3352406c6345fc16287d37/b0a15/windbg-recover-file-001.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ef34154aad3352406c6345fc16287d37/8ff5a/windbg-recover-file-001.png 240w,\n/static/ef34154aad3352406c6345fc16287d37/e85cb/windbg-recover-file-001.png 480w,\n/static/ef34154aad3352406c6345fc16287d37/0b533/windbg-recover-file-001.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ef34154aad3352406c6345fc16287d37/0b533/windbg-recover-file-001.png\"\n            alt=\"Dumping an executable with !dumpext.dump_pe !D4C\"\n            title=\"Dumping an executable with !dumpext.dump_pe !D4C\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>The binary output by the extension is saved as dump.out in WinDbg’s execution folder (<code class=\"language-text\">C:\\Program Files (x86)\\Windows Kits\\10\\Debuggers\\x64</code>), so rename it to something like dump.exe.</p>\n<p>When I ran dump.exe, it started just like the original D4C.exe and I was able to use its various functions.</p>\n<p>However, when I compared the file hashes of dump.exe obtained here and the original D4C.exe, I found that the file recovered from the dump file did not match the original file.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 500px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ee1759107617605fb2474109be3a1476/0b533/windbg-recover-file-003.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 35.833333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABPUlEQVQoz22R6U4CQRCER25EIaCCoAgKiCzxAAXF4xEMKIu7S0RBFtH3f4CyeoJ4ZH9UZiZdfX2j4scjxE9ekDx7xeb5BJmWi1RT3j1sNB+QbXcRq5tYqw8RM2wkTsU/QrIxRro11Tnpizd6x4jWhlA7VzOI1llYFfsMTCBN1L4JdTD4UWmh33cvSbHAoQVfxWKRvu5cvPtE9nKmlaPy13Nst6fI0bt3M0eoarOw6d1Egn4WDPIMHTmIcOxwzeHdRMQwEaUC1YFuGqTEI95vv0j88l4pP0ElhAf5pTiZrJtpk2FjRFZdTtvjZPdYNfqUQ0YW0TxrPJoh2W0t+Em+NFUFrrBkWHjUBgmqkgV/xYavzA0q1h8t1/RiLGxkVJ+My4B03u3wo6jC7Qe5uWTpan5y5jvvCHNNSZa8//oCAgPazg3wKOcAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/ee1759107617605fb2474109be3a1476/8ac56/windbg-recover-file-003.webp 240w,\n/static/ee1759107617605fb2474109be3a1476/d3be9/windbg-recover-file-003.webp 480w,\n/static/ee1759107617605fb2474109be3a1476/b0a15/windbg-recover-file-003.webp 500w\"\n              sizes=\"(max-width: 500px) 100vw, 500px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/ee1759107617605fb2474109be3a1476/8ff5a/windbg-recover-file-003.png 240w,\n/static/ee1759107617605fb2474109be3a1476/e85cb/windbg-recover-file-003.png 480w,\n/static/ee1759107617605fb2474109be3a1476/0b533/windbg-recover-file-003.png 500w\"\n            sizes=\"(max-width: 500px) 100vw, 500px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/ee1759107617605fb2474109be3a1476/0b533/windbg-recover-file-003.png\"\n            alt=\"Comparing file hashes\"\n            title=\"Comparing file hashes\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>As shown above, I confirmed that even though it does not completely match the original file, it is possible to extract an executable EXE file from a process dump.</p>\n<h2 id=\"links-to-each-chapter\" style=\"position:relative;\"><a href=\"#links-to-each-chapter\" aria-label=\"links to each chapter permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Links to each chapter</h2>\n<ul>\n<li><a href=\"/magical-windbg-vol1-00-en\">Preface</a></li>\n<li><a href=\"/magical-windbg-vol1-01-en\">Chapter 1: Environment Setup</a></li>\n<li><a href=\"/magical-windbg-vol1-02-en\">Chapter 2: Basic WinDbg Operations</a></li>\n<li><a href=\"/magical-windbg-vol1-03-en\">Chapter 3: Prerequisites for Analysis</a></li>\n<li><a href=\"/magical-windbg-vol1-04-en\">Chapter 4: Analyzing an Application Crash Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-05-en\">Chapter 5: Analyzing a Full Memory Dump from a System Crash</a></li>\n<li><a href=\"/magical-windbg-vol1-06-en\">Chapter 6: Investigating a User-Mode Application Memory Leak from a Process Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-07-en\">Chapter 7: Investigating a User-Mode Memory Leak from a Full Memory Dump</a></li>\n<li><a href=\"/magical-windbg-vol1-50-en\">Appendix A: WinDbg Tips</a></li>\n<li><a href=\"/magical-windbg-vol1-51-en\">Appendix B: Analyzing Crash Dumps with Volatility 3</a></li>\n</ul>\n<div class=\"footnotes\">\n<hr>\n<ol>\n<li id=\"fn-1\">\n<p><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mo>&lt;</mo><mo separator=\"true\">,</mo></mrow><annotation encoding=\"application/x-tex\">&lt;,</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.5782em;vertical-align:-0.0391em;\"></span><span class=\"mrel\">&lt;</span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.3em;vertical-align:-0.1944em;\"></span><span class=\"mpunct\">,</span></span></span></span>>&#x3C;, <span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mo>&lt;</mo><mo separator=\"true\">,</mo></mrow><annotation encoding=\"application/x-tex\">&lt;,</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.5782em;vertical-align:-0.0391em;\"></span><span class=\"mrel\">&lt;</span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.3em;vertical-align:-0.1944em;\"></span><span class=\"mpunct\">,</span></span></span></span>>&#x3C;, $$ >a&#x3C; Run Script File: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-----------------------a---run-script-file-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-----------------------a---run-script-file-</a></p>\n<a href=\"#fnref-1\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-2\">\n<p>.if: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-if\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-if</a></p>\n<a href=\"#fnref-2\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-3\">\n<p>.for: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-for\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-for</a></p>\n<a href=\"#fnref-3\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-4\">\n<p>as, aS Set Alias: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/as--as--set-alias-\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/as—as—set-alias-</a></p>\n<a href=\"#fnref-4\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-5\">\n<p>Pseudo-register syntax: <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/pseudo-register-syntax\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/pseudo-register-syntax</a></p>\n<a href=\"#fnref-5\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-6\">\n<p>インサイド Windows 第 7 版 下 P.595 (Andrea Allievi, Mark E.Russinovich, Alex Ionescu, David A.Solomon 著 / 山内和朗 訳 / 日系 BP 社 / 2022 年)</p>\n<a href=\"#fnref-6\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-7\">\n<p><code class=\"language-text\">!ca</code> extension <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-ca\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-ca</a></p>\n<a href=\"#fnref-7\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-8\">\n<p>インサイド Windows 第 7 版 下 P.606 (Andrea Allievi, Mark E.Russinovich, Alex Ionescu, David A.Solomon 著 / 山内和朗 訳 / 日系 BP 社 / 2022 年)</p>\n<a href=\"#fnref-8\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-9\">\n<p><code class=\"language-text\">!finddata</code> extension <a href=\"https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-finddata\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://learn.microsoft.com/ja-jp/windows-hardware/drivers/debugger/-finddata</a></p>\n<a href=\"#fnref-9\" class=\"footnote-backref\">↩</a>\n</li>\n<li id=\"fn-10\">\n<p>The Art of Memory Forensics: Detecting Malware and Threats in Windows, Linux, and Mac Memory 1st Edition P.239 (Michael Hale Ligh, Andrew Case, Jamie Levy, AAron Walters 著 / Wiley / 2014 年 )</p>\n<a href=\"#fnref-10\" class=\"footnote-backref\">↩</a>\n</li>\n</ol>\n</div>","fields":{"slug":"/magical-windbg-vol1-50-en","tagSlugs":["/tag/magical-win-dbg/","/tag/windows/","/tag/win-dbg/","/tag/english/"]},"frontmatter":{"date":"2023-11-15","description":"This is the web edition of Magical WinDbg - Enjoying Windows Dump Analysis and Troubleshooting by Feel - VOL.1, distributed at Tech Book Fest 15.","tags":["Magical WinDbg","Windows","WinDbg","English"],"title":"Magical WinDbg VOL.1 [Appendix A: WinDbg Tips]","socialImage":{"publicURL":"/static/2dbf3e09d59db889dc9dc41adcc8e827/magical-windbg-vol1.png"}}}},"pageContext":{"slug":"/magical-windbg-vol1-50-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}