V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
0xvincebye
V2EX  ›  Python

请问一下 Python 如何反序列化 Java 序列化后的代码?

  •  
  •   0xvincebye · 2020-04-28 17:22:01 +08:00 · 2612 次点击
    这是一个创建于 1455 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近在做一个东西,大概是接受其他人 Java 序列化后的数据进行一个数据处 请问一下有没有什么办法? 这边看 python 的序列化方法都是针对的 python 对象

    10 条回复    2020-04-28 20:10:22 +08:00
    yxcxx
        1
    yxcxx  
       2020-04-28 17:30:55 +08:00
    protobuf
    InkStone
        2
    InkStone  
       2020-04-28 17:31:50 +08:00
    用一个 Java 中间层再把序列化对象转换成 json,再从 Python 读
    GM
        3
    GM  
       2020-04-28 17:34:32 +08:00
    跨语言传数据要么 json 要么 protobuf 之类,哪有直接传原生序列化数。
    widewing
        4
    widewing  
       2020-04-28 17:38:38 +08:00 via Android
    @yxcxx 一直有个疑问借楼问下,protobuf 相对 json 有啥好处吗,还要引入学习一堆东西,性能显著提升?但是只是接口的话性能应该不是瓶颈呀
    0xvincebye
        5
    0xvincebye  
    OP
       2020-04-28 17:45:37 +08:00
    我觉得我还是没说清楚,实际就是做一个蜜罐,在测试反序列化漏洞,因为这个项目是用 python 写的,所以需要用 python 处理,也因为是蜜罐,我这边也无法控制他发什么,主要功能就是捕获他们的序列化数据
    hitmanx
        6
    hitmanx  
       2020-04-28 18:42:53 +08:00
    @widewing

    https://developers.google.com/protocol-buffers/docs/overview#whynotxml
    ```
    Protocol buffers have many advantages over XML for serializing structured data. Protocol buffers:

    are simpler
    are 3 to 10 times smaller
    are 20 to 100 times faster
    are less ambiguous
    generate data access classes that are easier to use programmatically
    ```
    virusdefender
        7
    virusdefender  
       2020-04-28 18:57:23 +08:00
    @0xvincebye 类似 pickle,实现下相关的协议就好吧,不知道网上有没有现成的

    https://docs.oracle.com/javase/8/docs/platform/serialization/spec/protocol.html
    CoderGeek
        8
    CoderGeek  
       2020-04-28 18:59:31 +08:00
    @widewing protobuf 虽然不是性能最高 优势在于鲁棒性好
    CoderGeek
        9
    CoderGeek  
       2020-04-28 19:00:36 +08:00
    @CoderGeek 说错了啊 不好意思 Hessian 的鲁棒性最好 protobuf 的性能已经很高了
    RIcter
        10
    RIcter  
       2020-04-28 20:10:22 +08:00 via Android
    蜜罐啊,那关键字+正则完事了。
    总共就那么几个 gadgets 可用,要么就是执行命令或者 EL,那么就是 JNDI
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5403 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 1083ms · UTC 07:47 · PVG 15:47 · LAX 00:47 · JFK 03:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.