{"componentChunkName":"component---src-templates-post-template-js","path":"/ctf-escapectf-2023-en","result":{"data":{"markdownRemark":{"id":"92346633-98a2-5c66-98a8-a6ff0e6bafc8","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/ctf-escapectf-2023\">original page</a>.</p>\n</blockquote>\n<p>I participated in ESCAPE CTF, which was held on 8/5, as part of 0nePadding.</p>\n<p>It was a pretty rough CTF where the challenge pages were inaccessible for most of the contest period, but for now I’ll at least leave a quick writeup of the problems I solved.</p>\n<p>I’m skipping the problems I couldn’t solve for now, since I haven’t been able to find a single writeup for them.</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=\"#ransom-systemrev\">ransom system(Rev)</a></li>\n<li><a href=\"#hiddenforensic\">Hidden(Forensic)</a></li>\n</ul>\n<h2 id=\"ransom-systemrev\" style=\"position:relative;\"><a href=\"#ransom-systemrev\" aria-label=\"ransom systemrev 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>ransom system(Rev)</h2>\n<blockquote>\n<p>The enemy has spread ransomware on important systems of the country. Please analyze the ransomware and recover the files!</p>\n</blockquote>\n<p>When I decompiled the EXE provided for the challenge in Ghidra, I found that it performs the following operations.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">int</span> __cdecl <span class=\"token function\">_main</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">int</span> _Argc<span class=\"token punctuation\">,</span><span class=\"token keyword\">char</span> <span class=\"token operator\">*</span><span class=\"token operator\">*</span>_Argv<span class=\"token punctuation\">,</span><span class=\"token keyword\">char</span> <span class=\"token operator\">*</span><span class=\"token operator\">*</span>_Env<span class=\"token punctuation\">)</span>\n\n<span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">char</span> data<span class=\"token punctuation\">;</span>\n  FILE <span class=\"token operator\">*</span>_File<span class=\"token punctuation\">;</span>\n  FILE <span class=\"token operator\">*</span>_File_00<span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">int</span> iVar1<span class=\"token punctuation\">;</span>\n  \n  <span class=\"token function\">__main</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  _File <span class=\"token operator\">=</span> <span class=\"token function\">_file_open</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"flag.exe\"</span><span class=\"token punctuation\">,</span><span class=\"token string\">\"rb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  _File_00 <span class=\"token operator\">=</span> <span class=\"token function\">_file_open</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"flag.exe.enc\"</span><span class=\"token punctuation\">,</span><span class=\"token string\">\"wb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">while</span><span class=\"token punctuation\">(</span> true <span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    iVar1 <span class=\"token operator\">=</span> <span class=\"token function\">_feof</span><span class=\"token punctuation\">(</span>_File<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>iVar1 <span class=\"token operator\">!=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">)</span> <span class=\"token keyword\">break</span><span class=\"token punctuation\">;</span>\n    data <span class=\"token operator\">=</span> <span class=\"token function\">_read_data</span><span class=\"token punctuation\">(</span>_File<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    data <span class=\"token operator\">=</span> <span class=\"token function\">_encrypt</span><span class=\"token punctuation\">(</span>data<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token function\">_write_data</span><span class=\"token punctuation\">(</span>_File_00<span class=\"token punctuation\">,</span>data<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span>\n  <span class=\"token function\">_fclose</span><span class=\"token punctuation\">(</span>_File<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token function\">_fclose</span><span class=\"token punctuation\">(</span>_File_00<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">return</span> <span class=\"token number\">0</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Apparently, it reads a file named <code class=\"language-text\">flag.exe</code> one byte at a time, encrypts each byte with the <code class=\"language-text\">_encrypt</code> function, and writes the result to <code class=\"language-text\">flag.exe.enc</code>.</p>\n<p>The decompiled <code class=\"language-text\">_encrypt</code> function looked like this.</p>\n<div class=\"gatsby-highlight\" data-language=\"c\"><pre class=\"language-c\"><code class=\"language-c\"><span class=\"token keyword\">char</span> __cdecl <span class=\"token function\">_encrypt</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span> param_1<span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">{</span>\n  byte bVar1<span class=\"token punctuation\">;</span>\n  \n  bVar1 <span class=\"token operator\">=</span> param_1 <span class=\"token operator\">+</span> <span class=\"token number\">5U</span> <span class=\"token operator\">^</span> <span class=\"token number\">6</span><span class=\"token punctuation\">;</span>\n  <span class=\"token keyword\">return</span> bVar1 <span class=\"token operator\">+</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">int</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">char</span><span class=\"token punctuation\">)</span>bVar1 <span class=\"token operator\">/</span> <span class=\"token number\">0xff</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>Since the logic was simple, I decrypted the encrypted file provided with the challenge using the following script.</p>\n<div class=\"gatsby-highlight\" data-language=\"python\"><pre class=\"language-python\"><code class=\"language-python\"><span class=\"token keyword\">with</span> <span class=\"token builtin\">open</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"enc\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"rb\"</span><span class=\"token punctuation\">)</span> <span class=\"token keyword\">as</span> f<span class=\"token punctuation\">:</span>\n    data <span class=\"token operator\">=</span> f<span class=\"token punctuation\">.</span>read<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\">\"flag.exe\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"wb\"</span><span class=\"token punctuation\">)</span> <span class=\"token keyword\">as</span> f<span class=\"token punctuation\">:</span>\n    <span class=\"token keyword\">for</span> d <span class=\"token keyword\">in</span> data<span class=\"token punctuation\">:</span>\n        b <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>d<span class=\"token operator\">^</span><span class=\"token number\">6</span><span class=\"token punctuation\">)</span><span class=\"token operator\">-</span><span class=\"token number\">5</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">&amp;</span> <span class=\"token number\">0xff</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>to_bytes<span class=\"token punctuation\">(</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span> byteorder<span class=\"token operator\">=</span><span class=\"token string\">\"big\"</span><span class=\"token punctuation\">)</span>\n        f<span class=\"token punctuation\">.</span>write<span class=\"token punctuation\">(</span>b<span class=\"token punctuation\">)</span>\n\n<span class=\"token comment\"># ESCAPE{ransomeware_decrypt_key_get!}</span></code></pre></div>\n<p>Running the decrypted <code class=\"language-text\">flag.exe</code> gave me the flag.</p>\n<!-- ## Smartest captive(Rev)\n\n> You are captured as a prisoner. Unlock the password and let's escape from here quickly.\n\n![image-20230805110532020](../../static/media/2023-08-05-ctf-escapectf-2023/image-20230805110532020.png) -->\n<h2 id=\"hiddenforensic\" style=\"position:relative;\"><a href=\"#hiddenforensic\" aria-label=\"hiddenforensic 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>Hidden(Forensic)</h2>\n<blockquote>\n<p>Find the flag hidden in the picture</p>\n</blockquote>\n<p>The JPG file provided for the challenge was actually a pcap file.</p>\n<p>So I changed the extension and analyzed it with Wireshark.</p>\n<p>From the pcap file, I could see that image files were being exchanged, so I exported the image and performed steganography analysis on it to obtain the flag.</p>\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/26c408b3dcb357509e13e709b5ccd64e/f53a0/image-20230805163104222.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: 89.16666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsTAAALEwEAmpwYAAAD4klEQVQ4y2VS90ukVxT9/ixF/cGKoChYsCN2rNgL9l7BGjuKrgU7RJ3VGQ3RLK67OpvVYFjd6U5vOvbZQE6+ezcrhPxwuO9933vnnnPuE/RGG+5dN3DeOGB3uuBy3eJWhM15D5vNCafzBg8PT/jm/ga3iJcXN9fvcP8PwpXqK7Q6JXR6FTTXGphtRpiseii0anFtht6og9GsZ1hsJtzeOWF1WGBzWOFw2kQR/4VweXuIU/0uzi2/4LNZBvXze+j++oATnQSqpyNo3ce4dB3g6v4Qhr9PYIYcisd3kBt2+fxnk4zvfzJK8ckghXDh2Md7zSZODRLIjW+heDqE6vk3HKl/xh92GVQv7/Dl7leR8AAGfIARH/nbqeEtfjfv8h1an+gl+Hi9LSpU/gm9SQudQQ2DWYdro0a0roBSc8X7R/cdHl5cePwX9lsLLHYD7DcWWJ0m2G7MYt5mMQaTCCMEpUIFq8UGi8UKg8EIrVYk1elhNltgtzlw57oTcQ/XrQtPj8/Qaa/F/9dQfFXi8sslV7VKLUIDo8EEYWFhAcPDP2F8fAyjo6PoH+jH0NAQZmdnsbC4wPU7ZjA/P4fl5WVsbW9BKpXi5PQEa2tr2JWK1uWneDP3BsLIyAgSEhIY+fn5KC0tRWVlJZqamtDZ2YnGxkbU1NSgra0N3d3djI6ODszMzGB6eloUMo7FxUXs7e0xuUAXs7KyUFtby5doX1dXh+bmZv5GldDe3o6xsTHG3Nwck1CdmJjA9vY2zs7OGEJiYiLKyspYWXl5OYqLi1FVVYXq6mreV1RUoLW1lUENKZbNzU3IZDIcHBywMiLu7+/H6uoqhLi4OLZYVFT0SkbK6uvrGQ0NDa+2SenAwICY+TAmJydZ3crKCiQSCaampjgOISoqCunp6SgoKEBeXh4KCwuZkJT19fWBMu7t7cXg4OBrXkSyvr7+WpVKJds9Pj6GEBMTg9TUVM4tMzOTQYRklxT29PSgq6uLB/HDNqmcn59nlTs7Ozg/P8fFxQUUCgUEyi8+Ph5JSUlIS0vjPEtKSpCbm8tkZJXyIZXUmOwTOT03Uru0tISNjQ22rVarIVD32NhYJqRpp6SkcIPQ0FB+ShRDTk4OryMjI3lPEyeVNF0azNHREUMul0OgzHx9fUFZBgYGws/PD/7+/ggJCWEQSVhYGIKDg/lMdnY250sDamlp4cnS+9va2sL+/j4EesweHh5M6u3tzYR02cfHB+Hh4fx8oqOjOQLKmeKIiIhAQEAAvLy8+Jynpye7ILcCHaILZDEoKAg/hpScnMwxEBFFQfnSkyJkZGRwBNSYFFMDckP//gEMjRdLNEtVcwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/26c408b3dcb357509e13e709b5ccd64e/8ac56/image-20230805163104222.webp 240w,\n/static/26c408b3dcb357509e13e709b5ccd64e/d3be9/image-20230805163104222.webp 480w,\n/static/26c408b3dcb357509e13e709b5ccd64e/e46b2/image-20230805163104222.webp 960w,\n/static/26c408b3dcb357509e13e709b5ccd64e/dac18/image-20230805163104222.webp 1062w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/26c408b3dcb357509e13e709b5ccd64e/8ff5a/image-20230805163104222.png 240w,\n/static/26c408b3dcb357509e13e709b5ccd64e/e85cb/image-20230805163104222.png 480w,\n/static/26c408b3dcb357509e13e709b5ccd64e/d9199/image-20230805163104222.png 960w,\n/static/26c408b3dcb357509e13e709b5ccd64e/f53a0/image-20230805163104222.png 1062w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/26c408b3dcb357509e13e709b5ccd64e/d9199/image-20230805163104222.png\"\n            alt=\"image-20230805163104222\"\n            title=\"image-20230805163104222\"\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=\"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>That’s all.</p>","fields":{"slug":"/ctf-escapectf-2023-en","tagSlugs":["/tag/ctf-en/","/tag/rev-en/","/tag/forensic-en/","/tag/english/"]},"frontmatter":{"date":"2023-08-06","description":"This is a writeup for ESCAPE CTF 2023.","tags":["CTF (en)","Rev (en)","Forensic (en)","English"],"title":"ESCAPE CTF 2023 Writeup","socialImage":{"publicURL":"/static/c6bf6e3d351797edafd3f95ff64fbabc/ctf-escapectf-2023.png"}}}},"pageContext":{"slug":"/ctf-escapectf-2023-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}