{"componentChunkName":"component---src-templates-post-template-js","path":"/ctf-tfcctf-2023-en","result":{"data":{"markdownRemark":{"id":"0170bc53-75c9-5f25-a478-f1f76764e90e","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/ctf-tfcctf-2023\">original page</a>.</p>\n</blockquote>\n<p>We participated in TFCCTF, which started on July 28, as 0nePadding and placed 35th out of 1,429 teams.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 818px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/52958a944465d24b2fe9aaa75fd89d55/64d87/image-20230801221548741.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: 42.5%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAABjElEQVQoz12SO2/bQBCE+f+bAK5i65F/ECAQmTSp0gQIEDt6UVIkkUfyXqRow4XTBAbGs3eUIbsYCJrbvf1mj4lxJ4ic73Esa8yXOe7mK6zyHbTtYL2c93Ctw3rzGV9mKdKvKWZZhkI19O9Z02O3L9jfILGOTZTzHRptUZRVUKlq+i2LKQ70bYOcF6bZN8zSDBkvlRrfnkKdNg7GeiRCYXiheaXpUDWWk/voD9K2he+e0Xa/+PsTD4//WR996RPCQ1EjEbJLmWHaez/qxBRbnufDmtrok7JuTEiYXFKI8s0Ot3dz7I8qXBD9PkT+ffsBH28muB6NMBpfY38o6d8HQqkvKx13eCaQXchejoVibBO9Qc57qGqBxXKJ5Uq0fpMkEPJ/ILQBX+I4NuRB290xvLw9E3aa5Fck+4TxdILJdEQqEnaR8CCESr/bIXchU1XV4JLcDYTWCeWajSsO9yHR+bzRhr3DK2t7Ct+cIdHfg8KfRc7IPiw+np9f8x/9H1D1d9j2KXjxW+1DInnlFwGPis5nvwNAAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/52958a944465d24b2fe9aaa75fd89d55/8ac56/image-20230801221548741.webp 240w,\n/static/52958a944465d24b2fe9aaa75fd89d55/d3be9/image-20230801221548741.webp 480w,\n/static/52958a944465d24b2fe9aaa75fd89d55/3a941/image-20230801221548741.webp 818w\"\n              sizes=\"(max-width: 818px) 100vw, 818px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/52958a944465d24b2fe9aaa75fd89d55/8ff5a/image-20230801221548741.png 240w,\n/static/52958a944465d24b2fe9aaa75fd89d55/e85cb/image-20230801221548741.png 480w,\n/static/52958a944465d24b2fe9aaa75fd89d55/64d87/image-20230801221548741.png 818w\"\n            sizes=\"(max-width: 818px) 100vw, 818px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/52958a944465d24b2fe9aaa75fd89d55/64d87/image-20230801221548741.png\"\n            alt=\"image-20230801221548741\"\n            title=\"image-20230801221548741\"\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>Personally, I found the Rev challenges so difficult that I could barely solve any of them, so it was a pretty hard CTF for me. Still, my teammates solved a lot of challenges, which helped us end up with a respectable rank despite the large number of participating teams.</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=\"#passrev\">PASS(Rev)</a></li>\n<li><a href=\"#process-monitorrev\">PROCESS-MONITOR(Rev)</a></li>\n<li><a href=\"#down-badforensic\">DOWN BAD(Forensic)</a></li>\n<li><a href=\"#mcteenxforensic\">MCTEENX(Forensic)</a></li>\n<li><a href=\"#summary\">Summary</a></li>\n</ul>\n<h2 id=\"passrev\" style=\"position:relative;\"><a href=\"#passrev\" aria-label=\"passrev 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>PASS(Rev)</h2>\n<blockquote>\n<p>Can you get the right password?</p>\n</blockquote>\n<p>When I decompiled the challenge binary with Ghidra, it turned out to be a program that checks whether the password is correct by evaluating the input one character at a time.</p>\n<p>This is exactly the kind of problem angr is good at, so I used the following solver to obtain the flag.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">import</span> angr\n\nproj <span class=\"token operator\">=</span> angr<span class=\"token punctuation\">.</span>Project<span class=\"token punctuation\">(</span><span class=\"token string\">\"pass\"</span><span class=\"token punctuation\">,</span> auto_load_libs<span class=\"token operator\">=</span><span class=\"token boolean\">False</span><span class=\"token punctuation\">)</span>\nobj <span class=\"token operator\">=</span> proj<span class=\"token punctuation\">.</span>loader<span class=\"token punctuation\">.</span>main_object\n<span class=\"token keyword\">print</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Entry\"</span><span class=\"token punctuation\">,</span> <span class=\"token builtin\">hex</span><span class=\"token punctuation\">(</span>obj<span class=\"token punctuation\">.</span>entry<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n\nfind <span class=\"token operator\">=</span> <span class=\"token number\">0x4019b0</span>\navoids <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token number\">0x401981</span><span class=\"token punctuation\">]</span>\n\ninit_state <span class=\"token operator\">=</span> proj<span class=\"token punctuation\">.</span>factory<span class=\"token punctuation\">.</span>entry_state<span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\nsimgr <span class=\"token operator\">=</span> proj<span class=\"token punctuation\">.</span>factory<span class=\"token punctuation\">.</span>simgr<span class=\"token punctuation\">(</span>init_state<span class=\"token punctuation\">)</span>\nsimgr<span class=\"token punctuation\">.</span>explore<span class=\"token punctuation\">(</span>find<span class=\"token operator\">=</span>find<span class=\"token punctuation\">,</span> avoid<span class=\"token operator\">=</span>avoids<span class=\"token punctuation\">)</span>\n\n<span class=\"token comment\"># Output</span>\nsimgr<span class=\"token punctuation\">.</span>found<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>posix<span class=\"token punctuation\">.</span>dumps<span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\n\n<span class=\"token comment\"># TFCCTF{f0und_th3_p44sv0rd}</span></code></pre></div>\n<h2 id=\"process-monitorrev\" style=\"position:relative;\"><a href=\"#process-monitorrev\" aria-label=\"process monitorrev 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>PROCESS-MONITOR(Rev)</h2>\n<blockquote>\n<p>Just a simple process monitor. Or is it?</p>\n</blockquote>\n<p>The challenge binary consisted of the usual three-piece kernel-driver set: a <code class=\"language-text\">.sys</code>, <code class=\"language-text\">.inf</code>, and <code class=\"language-text\">.cat</code> file.</p>\n<p>For now, I right-clicked the INF file to install the driver into a Windows VM, and at the same time continued analyzing it with Ghidra.</p>\n<p>After working through the analysis, I found that the challenge binary hooks process activity and runs its own callback function.</p>\n<p>Following the callback processing further, I found that it collects multiple pieces of information such as the hooked process’s executable name and path, checks whether they satisfy certain conditions, and, if all of the conditions are met, writes some string to <code class=\"language-text\">C:\\flag.txt</code>.</p>\n<p>By the time I got this far, the logic that writes the string to <code class=\"language-text\">C:\\flag.txt</code> was a bit too complicated to pin down statically, so I decided to set up kernel debugging.</p>\n<p>While attaching a kernel debugger to a VM running in test mode, I ran the following commands.</p>\n<blockquote>\n<p>bp ProcessMonitor+0x1410\nbp ProcessMonitor+0x1426\nbp ProcessMonitor+0x1435\nbp ProcessMonitor+0x1446</p>\n<p>.while(1){g;r zf=1;g;r zf=1;g;? poi(rcx);g;? poi(rcx)}</p>\n</blockquote>\n<p>Reference: <a href=\"/windows-windriver-001-tutorial-en\">Building a Windows Kernel Driver and Analyzing It with WinDbg - Frog’s Secret Base</a></p>\n<p>This caused the string <code class=\"language-text\">0967ce7f7c9e7e2e28bcab79c921398ba92dd3d9fc6045a546f4c4130252bf9</code> to be written to <code class=\"language-text\">C:\\flag.txt</code>, so by submitting <code class=\"language-text\">TFCCTF{0967ce7f7c9e7e2e28bcab79c921398ba92dd3d9fc6045a546f4c4130252bf9}</code> I was able to obtain the flag.</p>\n<h2 id=\"down-badforensic\" style=\"position:relative;\"><a href=\"#down-badforensic\" aria-label=\"down badforensic 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>DOWN BAD(Forensic)</h2>\n<blockquote>\n<p>The flag is right there!</p>\n</blockquote>\n<p>The file <code class=\"language-text\">down_bad.png</code> provided as the challenge binary could not be opened normally.</p>\n<p>Running <code class=\"language-text\">pngcheck</code> on it showed that there was a CRC mismatch.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">pngcheck down_bad.png\n<span class=\"token operator\">></span>\ndown_bad.png  CRC error <span class=\"token keyword\">in</span> chunk IHDR <span class=\"token punctuation\">(</span>computed 1d9c52c0, expected a9d5455b<span class=\"token punctuation\">)</span>\nERROR: down_bad.png</code></pre></div>\n<p>Because of that, I used the following solver to brute-force the correct CRC value.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">from</span> binascii <span class=\"token keyword\">import</span> crc32\ncorrect_crc <span class=\"token operator\">=</span> <span class=\"token builtin\">int</span><span class=\"token punctuation\">.</span>from_bytes<span class=\"token punctuation\">(</span><span class=\"token string\">b'\\xa9\\xd5\\x45\\x5b'</span><span class=\"token punctuation\">,</span>byteorder<span class=\"token operator\">=</span><span class=\"token string\">'big'</span><span class=\"token punctuation\">)</span>\n<span class=\"token keyword\">for</span> h <span class=\"token keyword\">in</span> <span class=\"token builtin\">range</span><span class=\"token punctuation\">(</span><span class=\"token number\">2000</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">:</span>\n    <span class=\"token keyword\">for</span> w <span class=\"token keyword\">in</span> <span class=\"token builtin\">range</span><span class=\"token punctuation\">(</span><span class=\"token number\">2000</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">:</span>\n        crc<span class=\"token operator\">=</span><span class=\"token string\">b\"\\x49\\x48\\x44\\x52\"</span><span class=\"token operator\">+</span>w<span class=\"token punctuation\">.</span>to_bytes<span class=\"token punctuation\">(</span><span class=\"token number\">4</span><span class=\"token punctuation\">,</span>byteorder<span class=\"token operator\">=</span><span class=\"token string\">'big'</span><span class=\"token punctuation\">)</span><span class=\"token operator\">+</span>h<span class=\"token punctuation\">.</span>to_bytes<span class=\"token punctuation\">(</span><span class=\"token number\">4</span><span class=\"token punctuation\">,</span>byteorder<span class=\"token operator\">=</span><span class=\"token string\">'big'</span><span class=\"token punctuation\">)</span><span class=\"token operator\">+</span><span class=\"token string\">b\"\\x08\\x06\\x00\\x00\\x00\"</span>\n        <span class=\"token keyword\">if</span> crc32<span class=\"token punctuation\">(</span>crc<span class=\"token punctuation\">)</span> <span class=\"token operator\">%</span> <span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token operator\">&lt;&lt;</span><span class=\"token number\">32</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">==</span> correct_crc<span class=\"token punctuation\">:</span>\n            <span class=\"token keyword\">print</span> <span class=\"token punctuation\">(</span><span class=\"token string\">'FOUND!'</span><span class=\"token punctuation\">)</span>\n            <span class=\"token keyword\">print</span> <span class=\"token punctuation\">(</span><span class=\"token string\">'Width: '</span><span class=\"token punctuation\">,</span>end<span class=\"token operator\">=</span><span class=\"token string\">\"\"</span><span class=\"token punctuation\">)</span>\n            <span class=\"token keyword\">print</span> <span class=\"token punctuation\">(</span><span class=\"token builtin\">hex</span><span class=\"token punctuation\">(</span>w<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n            <span class=\"token keyword\">print</span> <span class=\"token punctuation\">(</span><span class=\"token string\">'Height :'</span><span class=\"token punctuation\">,</span>end<span class=\"token operator\">=</span><span class=\"token string\">\"\"</span><span class=\"token punctuation\">)</span>\n            <span class=\"token keyword\">print</span> <span class=\"token punctuation\">(</span><span class=\"token builtin\">hex</span><span class=\"token punctuation\">(</span>h<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\n            exit<span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span></code></pre></div>\n<p>By rewriting the image binary with the Height and Width identified here, I was able to recover an image that included the previously cropped-out flag portion.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">from</span> zlib <span class=\"token keyword\">import</span> crc32\n<span class=\"token keyword\">import</span> argparse\n<span class=\"token keyword\">import</span> struct\n\npng <span class=\"token operator\">=</span> <span class=\"token builtin\">bytearray</span><span class=\"token punctuation\">(</span><span class=\"token builtin\">open</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"down_bad.png\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'rb'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>read<span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\nwidth <span class=\"token operator\">=</span> <span class=\"token number\">0x780</span>\nheight <span class=\"token operator\">=</span> <span class=\"token number\">0x540</span>\npng<span class=\"token punctuation\">[</span><span class=\"token number\">0x10</span><span class=\"token punctuation\">:</span><span class=\"token number\">0x14</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> struct<span class=\"token punctuation\">.</span>pack<span class=\"token punctuation\">(</span><span class=\"token string\">\">I\"</span><span class=\"token punctuation\">,</span>width<span class=\"token punctuation\">)</span>\npng<span class=\"token punctuation\">[</span><span class=\"token number\">0x14</span><span class=\"token punctuation\">:</span><span class=\"token number\">0x18</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> struct<span class=\"token punctuation\">.</span>pack<span class=\"token punctuation\">(</span><span class=\"token string\">\">I\"</span><span class=\"token punctuation\">,</span>height<span class=\"token punctuation\">)</span>\ncalculatedCrc <span class=\"token operator\">=</span> crc32<span class=\"token punctuation\">(</span>png<span class=\"token punctuation\">[</span><span class=\"token number\">12</span><span class=\"token punctuation\">:</span><span class=\"token number\">29</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span>\n\n<span class=\"token keyword\">with</span> <span class=\"token builtin\">open</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"solve.png\"</span><span class=\"token punctuation\">,</span><span class=\"token string\">'wb'</span><span class=\"token punctuation\">)</span> <span class=\"token keyword\">as</span> <span class=\"token builtin\">file</span><span class=\"token punctuation\">:</span>\n    <span class=\"token builtin\">file</span><span class=\"token punctuation\">.</span>write<span class=\"token punctuation\">(</span>png<span class=\"token punctuation\">)</span></code></pre></div>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/63041bf9804054b30da2f0f50d19fa5c/0940f/image-20230801200251868.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: 69.58333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAACzUlEQVQ4y32TS0+TURCG+zv8FW5NXJm4c6MbjC6M18QQFyw0mphWrgEKtNhS7lCgFLBQbq2AlYulqMRaKEpMVT5LAi0VKBTohd4ev7ZUwKqTvIs55z3vzJyZkSSTSXKQSJAQkTKP8IUhzTPMzcXsb3nSZ6n7v74TITl2RFKKfISUhff89Jfl05B/kaGyPASbPiP4D7FjwaNsErEYfvsUAWE57fs9qyw2FeE1algZquTreA2hXd9/s5RkS4vHogRddnYnDezYzCRF/zAaZaFbg7u3jhVtOW81t/n59W1GMIs/BVOXh8E9DpZnCSxNE/y2RHzdTdZ8VjNbWgXLdQ+ZqrqGZ9HM4f4e2/MTHHrdOdlKQqEwlpEB3DNGkpGDNCHm8xA82CcqJu9+N8JqqxSnpoBX8qvsrMwRW/tOZG6YyGcbkc21U/8qcdg/UK9WoVEpMA30YjEP8kLXil7bhF4lQ33/HI7aO6x3FmKrvU53xV0sfZ2szc+wJzhJfJsj5BV+VyQJ7AaYtVrRd7WjbXxOa101bfUKGjVKWqR5lFw+w/viGyzU5DNRfomqBxdoLn1ChfQxFaVFOMYNJJYn8X2xExM/VZJVDgaDuN0/+PzJKQaYoVPbQpfsCiU3z6Msfkz5o1uo7p1lUH5NrKgSlVJOmewJsocFzI/2MNLTxuLCx8zYZDt90lYFF6b6AnTNCjRqJWq5NB3A0iXF8fE9LpeLmanXGA19NDY2oevqYMlhPznYGeF4PJ4W3N7eZqhfz6CxD2N/L6ZhA5OmTmxvxomfSCAqjlYoFBKbmGnoKcGTtrm5iba9DUOfThTsYXS4H52uHat1+oiR++bU6mWjBQIBwuEwS04nqtoamhvUtLc2oOtoob5OwfSUhUgkgt/vT/PSG3a0+zmCKcKG15sud2xsjJJCGYrqCp4rq0TIKSp8ykuziY0NH4IgiKI7Obv9C9olz6R1KPs6AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/63041bf9804054b30da2f0f50d19fa5c/8ac56/image-20230801200251868.webp 240w,\n/static/63041bf9804054b30da2f0f50d19fa5c/d3be9/image-20230801200251868.webp 480w,\n/static/63041bf9804054b30da2f0f50d19fa5c/e46b2/image-20230801200251868.webp 960w,\n/static/63041bf9804054b30da2f0f50d19fa5c/e3efe/image-20230801200251868.webp 1154w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/63041bf9804054b30da2f0f50d19fa5c/8ff5a/image-20230801200251868.png 240w,\n/static/63041bf9804054b30da2f0f50d19fa5c/e85cb/image-20230801200251868.png 480w,\n/static/63041bf9804054b30da2f0f50d19fa5c/d9199/image-20230801200251868.png 960w,\n/static/63041bf9804054b30da2f0f50d19fa5c/0940f/image-20230801200251868.png 1154w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/63041bf9804054b30da2f0f50d19fa5c/d9199/image-20230801200251868.png\"\n            alt=\"image-20230801200251868\"\n            title=\"image-20230801200251868\"\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<h2 id=\"mcteenxforensic\" style=\"position:relative;\"><a href=\"#mcteenxforensic\" aria-label=\"mcteenxforensic 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>MCTEENX(Forensic)</h2>\n<blockquote>\n<p>I fly in the sky, I got wings on my feet.</p>\n</blockquote>\n<p>The encrypted ZIP file given as the challenge binary seemed to contain a file called <code class=\"language-text\">script.sh</code>, but I could not obtain the password.</p>\n<p>One of my teammates had already solved it, and apparently even without knowing the entire script, you can guess the shebang (<code class=\"language-text\">#!/bin/bash\\n</code>) and use a known-plaintext attack to break the ZIP password.</p>\n<p>In practice, the attack goes like this.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># Write #!/bin/bash\\n into partial_script.sh</span>\n<span class=\"token comment\"># Generate the three keys with bkcrack</span>\n./bkcrack -C red.zip -c script.sh -p partial_script.sh\n\n<span class=\"token comment\"># Decrypt the file using the three keys</span>\nbkcrack -C red.zip  -c script.sh -k c0b1bc78 c3206dfc e7e5bae1 -d decipheredfile.sh</code></pre></div>\n<p>Reference: <a href=\"https://github.com/kimci86/bkcrack\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">kimci86/bkcrack: Crack legacy zip encryption with Biham and Kocher’s known plaintext attack.</a></p>\n<p>Running the decrypted script produces the following image.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 300px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/2f1e6b1d047067e8b1abb28b0a7896d4/5a46d/red.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: 100%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC80lEQVQ4y51VXUiTURiebrpNcWnzP8VJYHnVRYrQpJvhNpG5+bPAGXRjGnRltGAiGpiKf5tzuB+dGBh6M8Ggug5vJBDxp9vCupBAL7toqHt6z5nfacO+og683/nO+z3n2XPe9z3vFIlEAmycn5/jn0Yi5TXxa6Fgj7OzM77Y2tpCS0sLnE4n2trb4bDbYXc48KC1FX1tbbCRWWw2jHV2osdsxl2TCWurq0IQI1awx+npKXdGIhEoFAphN8msWVl4qtHizoWvluxGZqbA9Pf3QxJ1iTAajSaBRHKLLFpTg/uVlXhUXY0nFdfwuKwMnpISVOmuoLSggGM9Hs8fFIbDHHRdo8HLoiKMVlSgTqeDvbgYH0bH8H55GWvuZ6irrRUKBwcH5RWGg6HksXJyYMrPR31uLopJqbmqCvj0GfgRB46P8XFvH1qtlmOnp6f5XsZxiXB+fp6DdESSRyqvErGe1iWlZfh+cpJM45evePP2nVA4MzMjTzg3NyeABopbd5cL+aRUrdbgdn09NjZe49vREZqbmwXO6/XJE87OznJQRkYGdHl5cLlceEGxW4+tw2KxYGXlFdo7Ojgmi07BZr/fL0/o8/k4SKVU8VmtVqOwsBCHh4eicBm2i5RLCtmpZAm9Xi8HKZVKPmde1JudCnyPEjEwMIDFxUWUl5cLwkAgIE/IApxKmPre29sHN5WM5JeOzBIpS8hKQNrgdrsxNTUl1nq9Hg0NDTwMybAkfygYDMoTTk5OCgKLxcp9fn+AJ4n5XK5uGAyGNIVhugyyhBMTExyUnZ3N56GhYe7f3t5GLBbD7u4+cqjYOaEqmbiFhYW/E6ouwMyGh5+LDPf0PBRxlWLL7n8aIbvU8Xj8kkJGKm0yGo0YHx/nWWfGvkmxXFpaSidM7ZkjIyNp7SvVjI2Nv/WHw5F0woODA+zs7HDn5uYmmpqaYKLGya5XJzVSBzVYq9UKM/lZPbLme895j4q7CzZqtmxPWrcJhUKi2v93SH8BbP4JiQ0I23F0yA0AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/2f1e6b1d047067e8b1abb28b0a7896d4/8ac56/red.webp 240w,\n/static/2f1e6b1d047067e8b1abb28b0a7896d4/c85cb/red.webp 300w\"\n              sizes=\"(max-width: 300px) 100vw, 300px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/2f1e6b1d047067e8b1abb28b0a7896d4/8ff5a/red.png 240w,\n/static/2f1e6b1d047067e8b1abb28b0a7896d4/5a46d/red.png 300w\"\n            sizes=\"(max-width: 300px) 100vw, 300px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/2f1e6b1d047067e8b1abb28b0a7896d4/5a46d/red.png\"\n            alt=\"img\"\n            title=\"img\"\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>Extracting the RGB LSBs from this image gives the string <code class=\"language-text\">030a111418142c783b39380d397c0d25293324231c66220d367d3c23133c6713343e343b3931</code>.</p>\n<p>This hexadecimal string turned out to be the flag XORed with the key <code class=\"language-text\">\"WLR\"</code>, so decrypting it gives the flag.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary 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>Summary</h2>\n<p>I couldn’t solve much this time, so I need to keep improving.</p>","fields":{"slug":"/ctf-tfcctf-2023-en","tagSlugs":["/tag/ctf-en/","/tag/rev-en/","/tag/forensic-en/","/tag/english/"]},"frontmatter":{"date":"2023-07-31","description":"This is a writeup for TFCCTF 2023.","tags":["CTF (en)","Rev (en)","Forensic (en)","English"],"title":"TFCCTF 2023 Writeup","socialImage":{"publicURL":"/static/f3d954591958035df718d6532da3bb85/ctf-tfcctf-2023.png"}}}},"pageContext":{"slug":"/ctf-tfcctf-2023-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}