MCPcopy Create free account
hub / github.com/Nariod/RustPacker / build_replacements

Function build_replacements

src/puzzle.rs:108–141  ·  view source on GitHub ↗
(order: &Order, src_dir: &Path)

Source from the content-addressed store, hash-verified

106}
107
108fn build_replacements(order: &Order, src_dir: &Path) -> HashMap<&'static str, String> {
109 let (enc_output, include_path) = build_encrypted_output(order, src_dir);
110
111 let mut replacements: HashMap<&'static str, String> = HashMap::new();
112 replacements.insert("{{PATH_TO_SHELLCODE}}", include_path);
113 replacements.insert("{{DECRYPTION_FUNCTION}}", enc_output.decryption_function);
114 replacements.insert("{{MAIN}}", enc_output.main);
115 replacements.insert("{{DEPENDENCIES}}", enc_output.dependencies.unwrap_or_default());
116 replacements.insert("{{IMPORTS}}", enc_output.imports.unwrap_or_default());
117 replacements.insert("{{DLL_MAIN}}", String::new());
118 replacements.insert("{{DLL_FORMAT}}", String::new());
119 replacements.insert("{{TARGET_PROCESS}}", order.target_process.clone());
120 replacements.insert("{{SANDBOX}}", String::new());
121 replacements.insert("{{SANDBOX_IMPORTS}}", String::new());
122
123 if let Some(ref domain) = order.sandbox {
124 let sandbox_output = build_sandbox(domain);
125 replacements.insert("{{SANDBOX}}", sandbox_output.sandbox_function);
126 replacements.insert("{{SANDBOX_IMPORTS}}", sandbox_output.sandbox_import);
127 }
128
129 let api_key = non_zero_random_key();
130 replacements.insert("{{API_KEY}}", format!("0x{:02x}", api_key));
131 replacements.insert("{{OBF_NT_OPEN_PROCESS}}", obfuscate_api_name("NtOpenProcess", api_key));
132 replacements.insert("{{OBF_NT_ALLOCATE_VIRTUAL_MEMORY}}", obfuscate_api_name("NtAllocateVirtualMemory", api_key));
133 replacements.insert("{{OBF_NT_WRITE_VIRTUAL_MEMORY}}", obfuscate_api_name("NtWriteVirtualMemory", api_key));
134 replacements.insert("{{OBF_NT_PROTECT_VIRTUAL_MEMORY}}", obfuscate_api_name("NtProtectVirtualMemory", api_key));
135 replacements.insert("{{OBF_NT_CREATE_THREAD_EX}}", obfuscate_api_name("NtCreateThreadEx", api_key));
136 replacements.insert("{{OBF_NT_QUEUE_APC_THREAD}}", obfuscate_api_name("NtQueueApcThread", api_key));
137 replacements.insert("{{OBF_NT_TEST_ALERT}}", obfuscate_api_name("NtTestAlert", api_key));
138 replacements.insert("{{OBF_NT_DELAY_EXECUTION}}", obfuscate_api_name("NtDelayExecution", api_key));
139
140 replacements
141}
142
143fn apply_dll_format(
144 replacements: &mut HashMap<&'static str, String>,

Callers 1

assembleFunction · 0.85

Calls 4

build_encrypted_outputFunction · 0.85
build_sandboxFunction · 0.85
non_zero_random_keyFunction · 0.85
obfuscate_api_nameFunction · 0.85

Tested by

no test coverage detected