|
|
@ -4,6 +4,7 @@ use cfb_mode::Cfb;
|
|
|
|
use des::Des;
|
|
|
|
use des::Des;
|
|
|
|
use rand::Rng;
|
|
|
|
use rand::Rng;
|
|
|
|
use rayon::prelude::*;
|
|
|
|
use rayon::prelude::*;
|
|
|
|
|
|
|
|
use std::sync::Mutex;
|
|
|
|
|
|
|
|
|
|
|
|
type DesCfb = Cfb<Des>;
|
|
|
|
type DesCfb = Cfb<Des>;
|
|
|
|
|
|
|
|
|
|
|
@ -35,15 +36,24 @@ pub fn decrypt_with_dictionary(
|
|
|
|
dict: Vec<PassKey>,
|
|
|
|
dict: Vec<PassKey>,
|
|
|
|
checksum: &[u8],
|
|
|
|
checksum: &[u8],
|
|
|
|
) -> Option<Vec<u8>> {
|
|
|
|
) -> Option<Vec<u8>> {
|
|
|
|
|
|
|
|
let decrypted = Mutex::<Option<Vec<u8>>>::new(None);
|
|
|
|
let pass = dict.par_iter().find_first(|(_pw, key)| {
|
|
|
|
let pass = dict.par_iter().find_first(|(_pw, key)| {
|
|
|
|
let decrypted_data = decrypt_data(&data, key);
|
|
|
|
let decrypted_data = decrypt_data(&data, key);
|
|
|
|
let decr_check = sha_checksum(&decrypted_data);
|
|
|
|
let decr_check = sha_checksum(&decrypted_data);
|
|
|
|
|
|
|
|
return if decr_check == checksum {
|
|
|
|
decr_check == checksum
|
|
|
|
let mut decry = decrypted.lock().unwrap();
|
|
|
|
|
|
|
|
*decry = Some(decrypted_data);
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if let Some((pw, key)) = pass {
|
|
|
|
if let Some((pw, _key)) = pass {
|
|
|
|
println!("Password found: {}", pw);
|
|
|
|
println!("Password found: {}", pw);
|
|
|
|
return Some(decrypt_data(data, &key));
|
|
|
|
let decry = decrypted.lock().unwrap();
|
|
|
|
|
|
|
|
if let Some(decrypted_data) = (*decry).clone() {
|
|
|
|
|
|
|
|
return Some(decrypted_data);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|