From 0afdb73d6a1cf212b60beba39ba36a916d8dcb7e Mon Sep 17 00:00:00 2001 From: thewh1teagle <61390950+thewh1teagle@users.noreply.github.com> Date: Sat, 30 Sep 2023 15:40:46 +0300 Subject: [PATCH] fix: add macos implement for chromium based dec --- rookie-rs/src/chromium.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/rookie-rs/src/chromium.rs b/rookie-rs/src/chromium.rs index cf3c3b7..b010d6f 100644 --- a/rookie-rs/src/chromium.rs +++ b/rookie-rs/src/chromium.rs @@ -42,7 +42,7 @@ fn get_v10_key() -> Result, Box> { #[cfg(target_os = "macos")] -fn get_v10_key() -> Result, bcrypt_pbkdf::Error> { +fn get_v10_key() -> Result, Box> { use pbkdf2::pbkdf2_hmac; use sha1::Sha1; @@ -102,6 +102,34 @@ fn decrypt_encrypted_value(value: String, encrypted_value: &[u8], key: &[u8]) -> String::from_utf8(plaintext.to_vec()).unwrap() } +#[cfg(target_os = "macos")] +fn decrypt_encrypted_value(value: String, encrypted_value: &[u8], key: &[u8]) -> String { + let key_type = &encrypted_value[..3]; + if !value.is_empty() || !(key_type == b"v11" || key_type == b"v10") { // unknown key_type or value isn't encrypted + return value; + } + use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, KeyIvInit}; + + type Aes128CbcDec = cbc::Decryptor; + + + // Create an AES-128 cipher with the provided key. + + + let encrypted_value = & mut encrypted_value.to_owned()[3..]; + let iv: [u8; 16] = [b' '; 16]; + + println!("{:?}", key); + let mut key_array: [u8;16] = [0;16]; + key_array.copy_from_slice(&key[..16]); + let cipher = Aes128CbcDec::new(&key_array.into(), &iv.into()); + + let plaintext = cipher.decrypt_padded_mut::(encrypted_value).unwrap(); + + + String::from_utf8(plaintext.to_vec()).unwrap() +} + fn query_cookies(v10_key: Vec, db_path: PathBuf, domains: Option>) -> Result, Box> {