|
|
|
@ -7,30 +7,6 @@ use rayon::prelude::*;
|
|
|
|
|
|
|
|
|
|
type DesCfb = Cfb<Des>;
|
|
|
|
|
|
|
|
|
|
pub struct EncryptionKeys {
|
|
|
|
|
current: u64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Iterator for EncryptionKeys {
|
|
|
|
|
type Item = Vec<u8>;
|
|
|
|
|
|
|
|
|
|
/// Increases the stored number by one
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> {
|
|
|
|
|
if self.current < std::u64::MAX {
|
|
|
|
|
self.current += 1;
|
|
|
|
|
Some(self.current.to_be_bytes().to_vec())
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EncryptionKeys {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self { current: 0 }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Encrypts data with des
|
|
|
|
|
pub fn encrypt_data(data: &[u8], key: &[u8]) -> Vec<u8> {
|
|
|
|
|
let iv = rand::thread_rng().gen::<[u8; 8]>();
|
|
|
|
@ -67,10 +43,9 @@ pub fn decrypt_with_dictionary(
|
|
|
|
|
});
|
|
|
|
|
if let Some((pw, key)) = pass {
|
|
|
|
|
println!("Password found: {}", pw);
|
|
|
|
|
Some(decrypt_data(data, &key))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
return Some(decrypt_data(data, &key));
|
|
|
|
|
}
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Decrypts data by generating all possible keys
|
|
|
|
@ -88,8 +63,7 @@ pub fn decrypt_brute_brute_force(data: &[u8], checksum: &[u8]) -> Option<Vec<u8>
|
|
|
|
|
let key: &[u8] = &num.to_le_bytes();
|
|
|
|
|
println!("Key found: {:?}", key);
|
|
|
|
|
|
|
|
|
|
Some(decrypt_data(data, key))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
return Some(decrypt_data(data, key));
|
|
|
|
|
}
|
|
|
|
|
None
|
|
|
|
|
}
|
|
|
|
|