|
|
|
@ -39,7 +39,8 @@ pub fn encrypt_data(data: &[u8], key: &[u8]) -> Vec<u8> {
|
|
|
|
|
cipher.encrypt(&mut buffer);
|
|
|
|
|
let mut cipher_text = iv.to_vec();
|
|
|
|
|
cipher_text.append(&mut buffer.to_vec());
|
|
|
|
|
return cipher_text;
|
|
|
|
|
|
|
|
|
|
cipher_text
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Decrypts data with des
|
|
|
|
@ -48,7 +49,8 @@ pub fn decrypt_data(data: &[u8], key: &[u8]) -> Vec<u8> {
|
|
|
|
|
let mut buffer = data[8..].to_vec();
|
|
|
|
|
let mut cipher = DesCfb::new_var(&key, &iv).unwrap();
|
|
|
|
|
cipher.decrypt(&mut buffer);
|
|
|
|
|
return buffer;
|
|
|
|
|
|
|
|
|
|
buffer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Decrypts data using a dictionary
|
|
|
|
@ -61,11 +63,7 @@ pub fn decrypt_with_dictionary(
|
|
|
|
|
let decrypted_data = decrypt_data(&data, key);
|
|
|
|
|
let decr_check = sha_checksum(&decrypted_data);
|
|
|
|
|
|
|
|
|
|
if decr_check == checksum {
|
|
|
|
|
true
|
|
|
|
|
} else {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
decr_check == checksum
|
|
|
|
|
});
|
|
|
|
|
if let Some((pw, key)) = pass {
|
|
|
|
|
println!("Password found: {}", pw);
|
|
|
|
@ -84,15 +82,12 @@ pub fn decrypt_brute_brute_force(data: &[u8], checksum: &[u8]) -> Option<Vec<u8>
|
|
|
|
|
let decrypted_data = decrypt_data(&data, key);
|
|
|
|
|
let decr_check = sha_checksum(&decrypted_data);
|
|
|
|
|
|
|
|
|
|
if decr_check == checksum {
|
|
|
|
|
true
|
|
|
|
|
} else {
|
|
|
|
|
false
|
|
|
|
|
}
|
|
|
|
|
decr_check == checksum
|
|
|
|
|
});
|
|
|
|
|
if let Some(num) = encryption_key {
|
|
|
|
|
let key: &[u8] = &num.to_le_bytes();
|
|
|
|
|
println!("Key found: {:?}", key);
|
|
|
|
|
|
|
|
|
|
Some(decrypt_data(data, key))
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|