myph-v2~ rust shellcode loader with evasive capabilities |
| git clone https://github.com/djnnvx/myph-v2.git |
| log | files | refs | archive | README |
mod.rs (4783B)
1 pub mod lnk_generator; 2 mod loader; 3 pub mod templates; 4 5 pub mod dependencies; 6 7 pub use loader::*; 8 9 include!(concat!(env!("OUT_DIR"), "/internals_impl.rs")); 10 11 #[cfg(test)] 12 mod tests { 13 use super::*; 14 15 #[test] 16 fn test_generate_internals_source_with_decryption_xor() { 17 let source = templates::generate_internals_source_with_decryption("xor").unwrap(); 18 assert!( 19 source.contains("pub fn decrypt_xor"), 20 "Should contain XOR decryption function" 21 ); 22 assert!( 23 source.contains("xor_bytes(data, key)"), 24 "Should use xor_bytes for XOR decryption" 25 ); 26 } 27 28 #[test] 29 fn test_generate_internals_source_with_decryption_aes() { 30 let source = templates::generate_internals_source_with_decryption("aes").unwrap(); 31 assert!( 32 source.contains("pub fn decrypt_aes"), 33 "Should contain AES decryption function" 34 ); 35 assert!( 36 source.contains("Aes128CbcDec"), 37 "Should use AES128 CBC decryptor" 38 ); 39 assert!( 40 source.contains("Key must be 16 bytes"), 41 "Should validate key length" 42 ); 43 } 44 45 #[test] 46 fn test_generate_internals_source_with_decryption_chacha20() { 47 let source = templates::generate_internals_source_with_decryption("chacha20").unwrap(); 48 assert!( 49 source.contains("pub fn decrypt_chacha20"), 50 "Should contain ChaCha20 decryption function" 51 ); 52 assert!(source.contains("ChaCha20"), "Should use ChaCha20 cipher"); 53 assert!( 54 source.contains("Key must be 32 bytes"), 55 "Should validate key length" 56 ); 57 } 58 59 #[test] 60 fn test_generate_internals_source_with_decryption_blowfish() { 61 let source = templates::generate_internals_source_with_decryption("blowfish").unwrap(); 62 assert!( 63 source.contains("pub fn decrypt_blowfish"), 64 "Should contain Blowfish decryption function" 65 ); 66 assert!( 67 source.contains("BlowfishCbcDec"), 68 "Should use Blowfish CBC decryptor" 69 ); 70 assert!( 71 source.contains("between 1 and 56 bytes"), 72 "Should validate key length" 73 ); 74 } 75 76 #[test] 77 fn test_generate_internals_source_with_decryption_unknown() { 78 let result = templates::generate_internals_source_with_decryption("unknown"); 79 assert!( 80 result.is_err(), 81 "Should return error for unknown encryption type" 82 ); 83 assert!( 84 result.unwrap_err().contains("Unknown encryption type"), 85 "Error should mention unknown type" 86 ); 87 } 88 89 #[test] 90 fn test_generate_internals_source_with_decryption_aes256() { 91 let source = templates::generate_internals_source_with_decryption("aes256").unwrap(); 92 assert!( 93 source.contains("pub fn decrypt_aes256"), 94 "Should contain AES-256 decryption function" 95 ); 96 assert!( 97 source.contains("Aes256CbcDec"), 98 "Should use AES256 CBC decryptor" 99 ); 100 assert!( 101 source.contains("Key must be 32 bytes"), 102 "Should validate key length" 103 ); 104 } 105 106 #[test] 107 fn test_generate_internals_source_with_decryption_twofish() { 108 let source = templates::generate_internals_source_with_decryption("twofish").unwrap(); 109 assert!( 110 source.contains("pub fn decrypt_twofish"), 111 "Should contain Twofish decryption function" 112 ); 113 assert!( 114 source.contains("TwofishCbcDec"), 115 "Should use Twofish CBC decryptor" 116 ); 117 assert!( 118 source.contains("Key must be 32 bytes"), 119 "Should validate key length" 120 ); 121 } 122 123 #[test] 124 fn test_generate_internals_source_with_decryption_camellia() { 125 let source = templates::generate_internals_source_with_decryption("camellia").unwrap(); 126 assert!( 127 source.contains("pub fn decrypt_camellia"), 128 "Should contain Camellia decryption function" 129 ); 130 assert!( 131 source.contains("Camellia256CbcDec"), 132 "Should use Camellia256 CBC decryptor" 133 ); 134 assert!( 135 source.contains("Key must be 32 bytes"), 136 "Should validate key length" 137 ); 138 } 139 140 #[test] 141 fn test_generate_internals_source_without_decryption() { 142 let result = templates::generate_internals_source_with_decryption(""); 143 assert!(result.is_err(), "Empty encryption type should return error"); 144 assert!( 145 result.unwrap_err().contains("cannot be empty"), 146 "Error should mention empty type" 147 ); 148 } 149 }