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
013231
V2EX  ›  Python

pickle 反序列化時是可以執行任意系統命令的

  •  
  •   013231 · 2016-09-22 23:09:36 +08:00 · 2710 次点击
    这是一个创建于 2744 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import pickle
    pickle.loads(b"cos\nsystem\n(S'ls'\ntR.")
    

    上面的代碼中, ls 被執行, 列出了當前目錄下的文件. 這裡可以替換成其他命令, 例如rm -rf *.

    Stackoverflow上的原理解釋.

    5 条回复    2016-09-23 10:05:58 +08:00
    binux
        1
    binux  
       2016-09-22 23:15:20 +08:00
    这不是很正常吗?
    phithon
        2
    phithon  
       2016-09-22 23:15:49 +08:00   ❤️ 2
    ryd994
        3
    ryd994  
       2016-09-23 06:53:49 +08:00   ❤️ 1
    qiukun
        4
    qiukun  
       2016-09-23 09:06:18 +08:00 via Android
    所以说无论如何都要读文档啊
    mulog
        5
    mulog  
       2016-09-23 10:05:58 +08:00
    @phithon 厉害
    iReader 起码也算有挺大体量的公司了 居然这么坑。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5075 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 09:35 · PVG 17:35 · LAX 02:35 · JFK 05:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.