From ec3135839c34941de0e6384557cfb5fbc6b31114 Mon Sep 17 00:00:00 2001 From: Eric Marsden Date: Sun, 12 May 2024 09:51:46 +0200 Subject: [PATCH] Update crate dependencies In particular, move to a new version of the secret_service crate, which has moved to async-by-default queries, a new version of the winapi crate which has moved winbase behind a "winbase" feature flag, and a new version of the pbkdf2 crate which has moved some functionality behind a "simple" feature flag. --- Cargo.toml | 46 +++++++++++++++++++++++----------------------- src/crypt.rs | 15 +++++++++------ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5639a5d..62dda9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,38 +16,38 @@ name = "bench_scraper" path = "src/lib.rs" [dependencies] -aes = "0.8.2" -aes-gcm = "0.10.1" -base64 = "0.13.1" -block-padding = "0.3.2" +aes = "0.8.4" +aes-gcm = "0.10.3" +base64 = "0.22.1" +block-padding = "0.3.3" cbc = "0.1.2" -dirs = "4.0.0" +dirs = "5.0.1" json_dotpath = "1.1.0" -libsqlite3-sys = "0.25.2" -log = "0.4.17" -nom = "7.1.1" -pbkdf2 = { version = "0.11.0", features = ["sha1"] } -reqwest = { version = "0.11.0", default-features = false, features = ["cookies"], optional = true } -rusqlite = { version = "0.28.0", features = ["bundled"] } -serde = "1.0.147" -serde_json = "1.0.87" -strum = "0.24.1" -strum_macros = "0.24" -tempfile = "3.3.0" -time = { version = "0.3.15", features = ["formatting"] } -walkdir = "2.3.2" +libsqlite3-sys = "0.28.0" +log = "0.4.21" +nom = "7.1.3" +pbkdf2 = { version = "0.12.2", features = ["sha1", "simple"] } +reqwest = { version = "0.12.4", default-features = false, features = ["cookies"], optional = true } +rusqlite = { version = "0.31.0", features = ["bundled"] } +serde = "1.0.201" +serde_json = "1.0.117" +strum = "0.26.2" +strum_macros = "0.26.2" +tempfile = "3.10.1" +time = { version = "0.3.36", features = ["formatting"] } +walkdir = "2.5.0" [dev-dependencies] bench_scraper = { path = ".", features = ["reqwest"] } -csv = "1.1.6" -regex = "1.7.0" -reqwest = { version = "0.11.0", default-features = false, features = ["blocking", "cookies", "default-tls"] } +csv = "1.3.0" +regex = "1.10.4" +reqwest = { version = "0.12.4", default-features = false, features = ["blocking", "cookies", "default-tls"] } [target.'cfg(target_os="linux")'.dependencies] -secret-service = "2.0.2" +secret-service = { version = "3.0.1", features = ["rt-tokio-crypto-rust"] } [target.'cfg(target_os="windows")'.dependencies] -winapi = { version = "0.3.9", features = ["dpapi"] } +winapi = { version = "0.3.9", features = ["dpapi", "winbase"] } [features] reqwest = ["dep:reqwest"] diff --git a/src/crypt.rs b/src/crypt.rs index 3e18e28..96e61d1 100644 --- a/src/crypt.rs +++ b/src/crypt.rs @@ -1,5 +1,6 @@ #![warn(missing_docs)] // https://textslashplain.com/2020/09/28/local-data-encryption-in-chromium/ +use std::collections::HashMap; use aes_gcm::aead::Aead; use aes_gcm::KeyInit; use cbc::cipher::BlockDecryptMut; @@ -80,7 +81,7 @@ fn dpapi_crypt_unprotected_data(data: &[u8]) -> Result, Error> { let mut result: Vec = Vec::with_capacity(size); result.as_mut_ptr().copy_from(p_data_out.pbData, size); result.set_len(size); - winapi::um::winbase::LocalFree(p_data_out.pbData as *mut std::ffi::c_void); + winapi::um::winbase::LocalFree(p_data_out.pbData as *mut winapi::ctypes::c_void); Ok(result) } } @@ -92,12 +93,12 @@ fn dpapi_crypt_unprotected_data(data: &[u8]) -> Result, Error> { #[cfg(target_os = "linux")] pub fn get_chromium_master_key(name: &str, _path: &std::path::Path) -> Result { debug!("Getting chromium master key for: {}", name); - let ss = secret_service::SecretService::new(secret_service::EncryptionType::Plain)?; - let items = ss.search_items(vec![("Label", name)])?; - let secret: Vec = items + let ss = secret_service::blocking::SecretService::connect(secret_service::EncryptionType::Plain)?; + let items = ss.search_items(HashMap::from([("Label", name)]))?; + let secret: Vec = items.unlocked .first() .map_or_else(|| Ok(DEFAULT_CHROMIUM_SECRET.to_vec()), |i| i.get_secret())?; - let salt = pbkdf2::password_hash::SaltString::b64_encode(CHROMIUM_SALT)?; + let salt = pbkdf2::password_hash::SaltString::encode_b64(CHROMIUM_SALT)?; let hash = pbkdf2::Pbkdf2.hash_password_customized( &secret, Some(pbkdf2::Algorithm::Pbkdf2Sha1.ident()), @@ -143,6 +144,8 @@ pub fn get_chromium_master_key(name: &str, _path: &std::path::Path) -> Result Result { + use base64::prelude::*; + debug!("Getting chromium master key from: {:?}", path); for entry_result in walkdir::WalkDir::new(path) .follow_links(true) @@ -161,7 +164,7 @@ pub fn get_chromium_master_key(_name: &str, path: &std::path::Path) -> Result