<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Notes on HackOlympus</title><link>https://hackolympus.com/notes/</link><description>Recent content in Notes on HackOlympus</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 15 Jun 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://hackolympus.com/notes/index.xml" rel="self" type="application/rss+xml"/><item><title>Software Hardening</title><link>https://hackolympus.com/notes/software-hardening/</link><pubDate>Mon, 15 Jun 2026 00:00:00 +0000</pubDate><guid>https://hackolympus.com/notes/software-hardening/</guid><description>&lt;h1 id="memory-tagging"&gt;Memory Tagging&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;tag memory with unique &amp;ldquo;color&amp;rdquo; everytime &lt;code&gt;malloc()&lt;/code&gt; or &lt;code&gt;free()&lt;/code&gt; is called.&lt;/li&gt;
&lt;li&gt;encode tag inside ptrs (returned by malloc) :&lt;/li&gt;
&lt;li&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;if pointer_tag != memory_tag:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; crash()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://hackolympus.com/images/oob-mte-demo.png" alt="OOB detection"&gt;
&lt;img src="https://hackolympus.com/images/oob-mte-demo.png" alt="UAF detection"&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;2 problems: performance (due to repeated checking). User inconvinience (buggy apps will straight up crash).&lt;/li&gt;
&lt;li&gt;check if chip supports ADB &lt;code&gt;adb shell grep mte /proc/cpuinfo&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;vulnerable to side-channel attacks&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;64 bit ARM pointer layout:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Bit: 63 60 59 56 55 0
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; +--------------+--------------+---------------------------+
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Pointer: | upper nibble | logical tag | actual virtual address |
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; +--------------+--------------+---------------------------+
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 4 bits&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;uint8_t logical_tag = (pointer &amp;gt;&amp;gt; 56) &amp;amp; 0xF;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;we can allocate MTE memory/page by using &lt;code&gt;PROT_MTE&lt;/code&gt; allocation tag in MTE supported hardware.&lt;/li&gt;
&lt;li&gt;multiple behaviors possible in case of tag mismatch:&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;ignore - default mode.&lt;/li&gt;
&lt;li&gt;synchronous - SIGSESV called right there and then when the mismatch happens and process halts.&lt;/li&gt;
&lt;li&gt;asynchronous - SIGSEV is recorded and raised after process has ended. Memory access doesn&amp;rsquo;t occur. Not good for debugging, will not return fault address.&lt;/li&gt;
&lt;li&gt;asymmetric mode :
&lt;ul&gt;
&lt;li&gt;read with mismatched tag - handled synchronously&lt;/li&gt;
&lt;li&gt;write with mismatched tag - handled asynchronously&lt;/li&gt;
&lt;li&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; if (pointer_tag != memory_tag) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; if (operation == READ) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; raise_precise_SIGSEGV_now();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } else if (operation == WRITE) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; record_pending_fault();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; continue_execution();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>CP notes</title><link>https://hackolympus.com/notes/cp/</link><pubDate>Mon, 19 Jan 2026 18:28:12 -0700</pubDate><guid>https://hackolympus.com/notes/cp/</guid><description>&lt;h3 id="template"&gt;&lt;a href="https://github.com/h4ck0lympus/CP/blob/main/template.cpp"&gt;Template&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A common rule of thumb:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;About &lt;strong&gt;$10^8$ operations per second&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Rough feasibility guide ($n$ = input size):&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;$n$ upper bound&lt;/th&gt;
 &lt;th&gt;Possible complexities&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;$10$&lt;/td&gt;
 &lt;td&gt;$O(n!)$, $O(n^7)$, $O(n^6)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$20$&lt;/td&gt;
 &lt;td&gt;$O(2^n \cdot n)$, $O(n^5)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$80$&lt;/td&gt;
 &lt;td&gt;$O(n^4)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$400$&lt;/td&gt;
 &lt;td&gt;$O(n^3)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$7{,}500$&lt;/td&gt;
 &lt;td&gt;$O(n^2)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$7 \cdot 10^4$&lt;/td&gt;
 &lt;td&gt;$O(n \sqrt{n})$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$5 \cdot 10^5$&lt;/td&gt;
 &lt;td&gt;$O(n \log n)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$5 \cdot 10^6$&lt;/td&gt;
 &lt;td&gt;$O(n)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$10^{18}$&lt;/td&gt;
 &lt;td&gt;$O(\log^2 n)$, $O(\log n)$, $O(1)$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="fundamental-data-structures"&gt;Fundamental data structures&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;vector&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;multiset&lt;/code&gt; stores elements in sorted order and allows duplicates.&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Key properties:&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Logarithmic insertion and deletion&lt;/li&gt;
&lt;li&gt;Efficient access to smallest or largest elements&lt;/li&gt;
&lt;li&gt;Supports queries such as “largest value $\leq X$”&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use a multiset when:&lt;/p&gt;</description></item><item><title>Pwning</title><link>https://hackolympus.com/notes/pwning/</link><pubDate>Mon, 19 Jan 2026 17:57:48 -0700</pubDate><guid>https://hackolympus.com/notes/pwning/</guid><description>&lt;h1 id="rop"&gt;ROP&lt;/h1&gt;
&lt;h2 id="stack-pivoting"&gt;Stack pivoting&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Commonly used in places where you can only execute 1 or 2 gadgets (basically limited gadget execution) mainly because there is some metadata on stack you can&amp;rsquo;t corrupt (in cases like FSOP) or stack size is small.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="one-gadget"&gt;One gadget&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;one_gadget&lt;/code&gt; to pop shell
&lt;a href="https://github.com/david942j/one_gadget"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="angrop"&gt;angrop&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;easilly find rop chain&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="https://github.com/angr/angrop"&gt;GitHub&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h1 id="heap"&gt;Heap&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;malloc&lt;/code&gt; never clears the user data &lt;strong&gt;unless calloc is used&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;glibc-2.32 onwards have safe-linking.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="safe-linking"&gt;safe-linking&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;fd&lt;/code&gt; pointers in tcache and fastbins are mangled to make exploitation harder.&lt;/li&gt;
&lt;li&gt;straight-forward principle: use randomness from ASLR to mangle ptrs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;heap leak is needed&lt;/strong&gt; to break safe-linking.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;target address should be 0x10 byte aligned&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#000080;font-weight:bold"&gt;def&lt;/span&gt; mangle(pos, ptr):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#00f"&gt;&amp;#34;&amp;#34;&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#00f"&gt; pos: int = position of heap chunk
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#00f"&gt; ptr: int = ptr we need. This should be 0x10 byte aligned
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#00f"&gt; &amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#000080;font-weight:bold"&gt;return&lt;/span&gt; (pos &amp;gt;&amp;gt; &lt;span style="color:#00f"&gt;12&lt;/span&gt;) ^ ptr&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="tcache"&gt;tcache&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The free bin is a single linked list (LIFO based).&lt;/li&gt;
&lt;li&gt;Used to store &lt;strong&gt;small&lt;/strong&gt; freed allocations .&lt;/li&gt;
&lt;li&gt;7 allocations per bin.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ptr = malloc(size); free(ptr)&lt;/code&gt; with size &amp;lt;= 0x408 will go in tcache.&lt;/li&gt;
&lt;li&gt;&amp;ldquo;thread&amp;rdquo; cache. So one tcache per thread.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE-1:&lt;/em&gt;&lt;/strong&gt; &amp;gt;= glibc-2.32 requires heap leak for breaking safe-linking.&lt;/p&gt;</description></item><item><title/><link>https://hackolympus.com/notes/firefox/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://hackolympus.com/notes/firefox/</guid><description>&lt;h1 id="firefox-notes"&gt;Firefox notes&lt;/h1&gt;
&lt;h2 id="mozilla-graphics-architecture"&gt;Mozilla graphics architecture&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html"&gt;https://firefox-source-docs.mozilla.org/gfx/RenderingOverview.html&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>