1

我在我的 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”更大的事情,因为我手动尝试过并且标志不正确。提前致谢!

4

1 回答 1

2

是的,有可能。当使用-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
于 2020-11-26T00:18:59.707 回答