如何使用键盘记录器制作XSS脆弱网站?
我想创建一个容易受到XSS攻击的网站,在该网站上,攻击者试图注入一个钥匙记录员,该钥匙记录员记录了本网站上每个受害者的击键。
在这里是已部署的网站,并遵循代码:
function submitted(){
alert("Submitted!");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="index.js"></script>
</head>
<body>
<h1>XSS keylogger test website</h1>
<form id="form">
<input type="text" id="fname" name="fname">
<input type="submit" value="Submit" onclick="submitted()">
</form>
</body>
</html>
JS脚本的一个示例,其中包含可以注入键盘记录器的代码:
<script>
function keyPressed(){
alert("key pressed");
}
window.captureEvents (Event.KEYPRESS);
window.onkeypress=keyPressed;
</script>
如果我只是将代码放入输入字段中,则什么都不会发生。如何将代码嵌入实际工作的网站中?
信息
该项目仅用于演示和学习目的。
I want to create an website which is vulnerable to an XSS attack where the attacker tries to inject an keylogger who logs the keystrokes of every victim on this website.
Here is the deployed website and following the code:
function submitted(){
alert("Submitted!");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="index.js"></script>
</head>
<body>
<h1>XSS keylogger test website</h1>
<form id="form">
<input type="text" id="fname" name="fname">
<input type="submit" value="Submit" onclick="submitted()">
</form>
</body>
</html>
An example of an JS script which contains code for an keyboard logger who could be injected:
<script>
function keyPressed(){
alert("key pressed");
}
window.captureEvents (Event.KEYPRESS);
window.onkeypress=keyPressed;
</script>
If I just put the code in the input field nothing happens. How can I embed the code into the website that it actually works?
INFO
The project is only used for demonstration and learning purposes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
鉴于您的设置,这并不是XSS的工作方式。 XSS可以通过:
Given your setup, that isn't really how XSS works. XSS works by either:
提交的有效载荷不会在页面上返回可能导致XSS。
在我看来,您必须进行的更改将在服务器端。
The payload being submitted is not being returned on the page which could cause an xss.
It seems to me that the change you would have to make would be on the server side.