myph-v2~ rust shellcode loader with evasive capabilities |
| git clone https://github.com/djnnvx/myph-v2.git |
| log | files | refs | archive | README |
encryption.rs (1570B)
1 /// Get the decryption function name for a given encryption type 2 pub fn get_decrypt_function(encryption_type: &str) -> Result<&'static str, String> { 3 match encryption_type { 4 "xor" => Ok("internals::decrypt_xor"), 5 "aes" => Ok("internals::decrypt_aes"), 6 "aes256" => Ok("internals::decrypt_aes256"), 7 "chacha20" => Ok("internals::decrypt_chacha20"), 8 "blowfish" => Ok("internals::decrypt_blowfish"), 9 "twofish" => Ok("internals::decrypt_twofish"), 10 "camellia" => Ok("internals::decrypt_camellia"), 11 _ => Err(format!("Unknown encryption type: {}", encryption_type)), 12 } 13 } 14 15 /// Get the expect clause for a given encryption type 16 pub fn get_expect_clause(encryption_type: &str) -> &'static str { 17 if encryption_type == "xor" { 18 "" 19 } else { 20 ".expect(\"Failed to decrypt\")" 21 } 22 } 23 24 #[cfg(test)] 25 mod tests { 26 use super::*; 27 28 #[test] 29 fn test_get_decrypt_function_xor() { 30 assert_eq!( 31 get_decrypt_function("xor").unwrap(), 32 "internals::decrypt_xor" 33 ); 34 } 35 36 #[test] 37 fn test_get_decrypt_function_aes() { 38 assert_eq!( 39 get_decrypt_function("aes").unwrap(), 40 "internals::decrypt_aes" 41 ); 42 } 43 44 #[test] 45 fn test_get_decrypt_function_invalid() { 46 assert!(get_decrypt_function("invalid").is_err()); 47 } 48 49 #[test] 50 fn test_get_expect_clause() { 51 assert_eq!(get_expect_clause("xor"), ""); 52 assert_eq!(get_expect_clause("aes"), ".expect(\"Failed to decrypt\")"); 53 } 54 }