<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>路径穿越 on Jay's CTF life</title><link>https://asd12542.github.io/tags/%E8%B7%AF%E5%BE%84%E7%A9%BF%E8%B6%8A/</link><description>Recent content in 路径穿越 on Jay's CTF life</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Tue, 02 Jun 2026 21:41:59 +0800</lastBuildDate><atom:link href="https://asd12542.github.io/tags/%E8%B7%AF%E5%BE%84%E7%A9%BF%E8%B6%8A/index.xml" rel="self" type="application/rss+xml"/><item><title>ImaginaryCTF 2025 codenames-1</title><link>https://asd12542.github.io/p/imaginaryctf2025-codenames-1/</link><pubDate>Tue, 02 Jun 2026 21:40:00 +0800</pubDate><guid>https://asd12542.github.io/p/imaginaryctf2025-codenames-1/</guid><description>&lt;p&gt;题目提示：&lt;/p&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;author: Eth007&lt;/p&gt;&#10;&lt;p&gt;I hear that multilingual codenames is all the rage these days. Flag is in &lt;code&gt;/flag.txt&lt;/code&gt;.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h2 id="a-代码审计"&gt;a. 代码审计&lt;/h2&gt;&#10;&lt;h3 id="1-基于-create_game-上半部分的"&gt;1. 基于 /create_game 上半部分的&lt;/h3&gt;&#10;&lt;p&gt;打开附件发现有两个附件，app.py 和 bot.py，点开第一个 app.py 前面并没有发现什么异样，直到我们定位到 &lt;code&gt;/create_game&lt;/code&gt; 这个路径下，其中存在一个致命的漏洞 &amp;mdash;- &lt;code&gt;os.path.join()&lt;/code&gt;，当参数中存在绝对地址也就是 &lt;code&gt;/&lt;/code&gt; 会抛弃前面所有的路径。&lt;/p&gt;&#10;&lt;p&gt;举几个例子：&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;code&gt;os.path.join(&amp;quot;words&amp;quot;, &amp;quot;english.txt&amp;quot;)&lt;/code&gt;，这是正常拼接，结果为：&lt;code&gt;words/english.txt&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;os.path.join(&amp;quot;words&amp;quot;, &amp;quot;/flag.txt&amp;quot;)&lt;/code&gt;，由于出现 &lt;code&gt;/&lt;/code&gt;，要抛弃前面所有路径，结果为：&lt;code&gt;/flag.txt&lt;/code&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;os.path.join(&amp;quot;a/b/c/d&amp;quot;, &amp;quot;/etc/passwd&amp;quot;)&lt;/code&gt;，结果为：&lt;code&gt;/etc/passwd&lt;/code&gt;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;figure class="code-block" data-code-block data-language="python"&gt;&#10; &lt;figcaption class="code-block__toolbar"&gt;&#10; &lt;span class="code-block__language"&gt;python&lt;/span&gt;&#10; &lt;button class="code-block__copy" type="button" data-code-copy&gt;复制&lt;/button&gt;&#10; &lt;/figcaption&gt;&#10; &lt;div class="code-block__viewport"&gt;&#10; &lt;pre class="code-block__fallback" tabindex="0"&gt;&lt;code class="language-python"&gt;@app.route(&amp;#39;/create_game&amp;#39;, methods=[&amp;#39;POST&amp;#39;]) # 这里是上半部分&#10;def create_game():&#10; if &amp;#39;username&amp;#39; not in session:&#10; return redirect(url_for(&amp;#39;index&amp;#39;))&#10; # generate unique code&#10; while True:&#10; code = &amp;#39;&amp;#39;.join(random.choices(string.ascii_uppercase + string.digits, k=6))&#10; if code not in games:&#10; break&#10; # prepare game with selected language word list&#10; # determine language (default to first available)&#10; language = request.form.get(&amp;#39;language&amp;#39;, None)&#10; if not language or &amp;#39;.&amp;#39; in language:&#10; language = LANGUAGES[0] if LANGUAGES else None&#10; # load words for this language&#10; word_list = []&#10; if language:&#10; wl_path = os.path.join(WORDS_DIR, f&amp;#34;{language}.txt&amp;#34;)&#10; try:&#10; with open(wl_path) as wf:&#10; word_list = [line.strip() for line in wf if line.strip()]&#10; except IOError as e:&#10; print(e)&#10; word_list = []&lt;/code&gt;&lt;/pre&gt;&#10; &lt;/div&gt;&#10; &lt;button class="code-block__expand" type="button" data-code-expand hidden&gt;展开全部&lt;/button&gt;&#10;&lt;/figure&gt;&#10;&lt;p&gt;在得知了这个漏洞之后，继续审代码，发现在拼接之后，会尝试打开 &lt;code&gt;wl_path&lt;/code&gt;，之后把值赋给 &lt;code&gt;word_list&lt;/code&gt;。&lt;/p&gt;</description></item></channel></rss>