[英]Is there a way to execute vim commands that are within txt file along with text?
我在我的 CTF 最后階段,我有這個:
vim flag
iCourse{v3ry_g00d_fl4g}[ESC]13hs1[ESC]am_[ESC]9l2xli_[ESC]2li3[ESC]vypaks[ESC]:s/ry/15
:wq
我對 Vim 不是很熟悉,所以我不知道如何運行這個腳本。 我猜它必須做一些比用“15”替換“ry”更大的事情,因為我手動嘗試過並且標志不正確。 提前致謝!
對的,這是可能的。 當使用-s
命令行標志啟動時, vim
將從輸入文件中獲取命令:
從手冊頁:
-s {scriptin} The script file {scriptin} is read. The characters in the file are interpreted as if you had typed them. The same can be done with the command ":source. {scriptin}", If the end of the file is reached before the editor exits. further characters are read from the keyboard.
因此,您需要做的就是使用sed
類的工具將每次出現的[ESC]
轉換為轉義字符,將結果存儲在臨時文件中,然后將其提供給vim
:
s='iCourse{v3ry_g00d_fl4g}[ESC]13hs1[ESC]am_[ESC]9l2xli_[ESC]2li3[ESC]vypaks[ESC]:s/ry/15'
cmdfile=`mktemp`
echo -e `sed 's/\[ESC\]/\\\x1B/g' <<<"$s"` >$cmdfile
vim -s $cmdfile
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.