Skip to content

Commit

Permalink
fix: add macos implement for chromium based dec
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Sep 30, 2023
1 parent c14cd6c commit 0afdb73
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion rookie-rs/src/chromium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn get_v10_key() -> Result<Vec<u8>, Box<dyn std::error::Error>> {


#[cfg(target_os = "macos")]
fn get_v10_key() -> Result<Vec<u8>, bcrypt_pbkdf::Error> {
fn get_v10_key() -> Result<Vec<u8>, Box<dyn std::error::Error>> {
use pbkdf2::pbkdf2_hmac;
use sha1::Sha1;

Expand Down Expand Up @@ -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<aes::Aes128>;


// 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::<Pkcs7>(encrypted_value).unwrap();


String::from_utf8(plaintext.to_vec()).unwrap()
}



fn query_cookies(v10_key: Vec<u8>, db_path: PathBuf, domains: Option<Vec<&str>>) -> Result<Vec<Cookie>, Box<dyn Error>> {
Expand Down

0 comments on commit 0afdb73

Please sign in to comment.