Saataa andagii !

This commit is contained in:
Lukian 2024-11-30 18:31:38 +01:00
commit 092492ba24
13 changed files with 389 additions and 0 deletions

2
reader/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target
Cargo.lock

10
reader/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "keylogger_logs_reader"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
libc = "0.2.153"
num-bigint-dig = "0.8.4"

40
reader/src/main.rs Normal file
View file

@ -0,0 +1,40 @@
use std::io;
use std::fs::File;
use std::io::Read;
use num_bigint_dig::{ToBigUint, RandBigInt, BigUint};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Timeval {
pub tv_sec: libc::c_long,
pub tv_usec: libc::c_long,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct InputEvent {
pub time: Timeval,
pub type_: libc::c_ushort,
pub code: libc::c_ushort,
pub value: libc::c_uint,
}
fn main() {
let mut f = File::open("/home/lucien/Documents/devoirs/projet-pei/src/data/logs/2024-04-26.log").expect("error opening file");
let mut buffer = [0; 384];
let d = BigUint::parse_bytes(b"633959252352879769414268328237234655198007316661163023777391807746244830540247767948443855415682008175601529021411039391840313318185231741827301362410641700643608368380245594661894472090504499073166019109062339257674002894413761118948212701255316059032971344450351851298362436113974926627054913636405882439315793769619506182013244298318698566484148552185502604241697761778810163119641370267909684282219737326096682836009711969384932494457163061834220764248176381108280474841227286418500241941495576383574505788225980542400074224688985134117693527572573321451492738181692632152599780061960977278794872092351976614468324388387378747822376461734816372605021310951703337525451548588541228821457303051142707331995242314511807098148708151025145265736969455083061017142240722663072698443409233801199735896318182689936557502323416873005259657496521896982570683306572548975472052579033816662895042418300552110513374202225883037863617", 10)
.unwrap();
let n = BigUint::parse_bytes(b"726893654806863106618546895057273655441264661325145055622991128175682274731729906015556264256579162493516172845029834644722324327896454261243147930093884060587847049206343040997875678249683217673083057390927228523219516562706789293756062419996669732335698292474241738313810472297868623226097796896132340484716735649944952179058084460249003603199405921560958818961267822766679758920394983786136620924522112830057005196535366761215933393212482864750854232592685811474461298568003115633675850369800934986362845952917985790835063623075408167396594117256336524956863695783013250764066998836408497995291717070517025671368786854251119784534482238786198981808730172431511580525492332130939522228645811310849928074140276569038233908484935569527065290886443920205920064757536160231476433607492303337517653184135797961475927231058895093552142050530878770429480616001550597029356030412941690284376485270056410912518806914509324633661109", 10)
.unwrap();
// read exactly 10 bytes
loop {
f.read_exact(&mut buffer).expect("error reading file");
let event_as_bigint = BigUint::from_bytes_be(&buffer);
let event_decrypted = &event_as_bigint.modpow(&d, &n);
let event_padded = &event_decrypted.to_bytes_be();
let event: InputEvent = unsafe { *(event_padded.as_ptr() as *const InputEvent) };
println!("{:?}", event);
}
}