<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Thcon on Anthrace | CTF Writeups</title><link>https://anthr4ce.github.io/tags/thcon/</link><description>Recent content in Thcon on Anthrace | CTF Writeups</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 08 Apr 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://anthr4ce.github.io/tags/thcon/index.xml" rel="self" type="application/rss+xml"/><item><title>THCon - Crypto</title><link>https://anthr4ce.github.io/ctf-writeups/thcon/crypto/</link><pubDate>Tue, 08 Apr 2025 00:00:00 +0000</pubDate><guid>https://anthr4ce.github.io/ctf-writeups/thcon/crypto/</guid><description>&lt;p&gt;&lt;img src="images/image1.png" alt="Screenshot"&gt;&lt;/p&gt;&#10;&lt;h1 id="overview-of-the-challenge"&gt;&#10; Overview of the Challenge&#10; &lt;a class="heading-link" href="#overview-of-the-challenge"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h1&gt;&#10;&lt;p&gt;In this challenge we are given a Python script that performs a one-time pad (OTP) encryption on a file and a crypted file.&lt;/p&gt;&#10;&lt;p&gt;Here’s what happens:&lt;/p&gt;&#10;&lt;h3 id="1otp-generation"&gt;&#10; 1.OTP Generation:&#10; &lt;a class="heading-link" href="#1otp-generation"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h3&gt;&#10;&lt;p&gt;A 10-byte pad is generated using random bytes.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;generate_OTP&lt;/span&gt;():&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; OTP &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;b&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; _ &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;):&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Generates a random byte (0–255) and appends it to the OTP.&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; OTP &lt;span style="color:#f92672"&gt;+=&lt;/span&gt; int&lt;span style="color:#f92672"&gt;.&lt;/span&gt;to_bytes(randint(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;255&lt;/span&gt;), &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;big&amp;#39;&lt;/span&gt;)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; OTP&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="2file-encryption"&gt;&#10; 2.File Encryption:&#10; &lt;a class="heading-link" href="#2file-encryption"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h3&gt;&#10;&lt;p&gt;The script reads the input file in binary mode and encrypts it by XORing each byte with a corresponding byte from the OTP (repeating the OTP cyclically).&lt;/p&gt;</description></item></channel></rss>