Better static runtime config, work on connections.

This commit is contained in:
Michael Mikovsky
2025-11-25 14:27:06 -07:00
parent dc153774e5
commit 1efa3206ae
16 changed files with 634 additions and 122 deletions
+161 -13
View File
@@ -57,6 +57,18 @@ dependencies = [
"virtue",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "block-buffer"
version = "0.10.4"
@@ -115,6 +127,18 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "cfg_aliases"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "chrono"
version = "0.4.42"
@@ -153,6 +177,21 @@ dependencies = [
"libc",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "crypto-common"
version = "0.1.6"
@@ -272,12 +311,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.177"
@@ -294,6 +327,15 @@ dependencies = [
"windows-link",
]
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.28"
@@ -321,6 +363,29 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-link",
]
[[package]]
name = "ppv-lite86"
version = "0.2.21"
@@ -383,6 +448,15 @@ dependencies = [
"getrandom",
]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags 2.10.0",
]
[[package]]
name = "regex"
version = "1.12.2"
@@ -424,6 +498,12 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
version = "1.0.228"
@@ -451,7 +531,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
]
[[package]]
@@ -484,6 +564,51 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "static_init"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bae1df58c5fea7502e8e352ec26b5579f6178e1fdb311e088580c980dee25ed"
dependencies = [
"bitflags 1.3.2",
"cfg_aliases 0.2.1",
"libc",
"parking_lot",
"parking_lot_core",
"static_init_macro",
"winapi",
]
[[package]]
name = "static_init_macro"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1389c88ddd739ec6d3f8f83343764a0e944cd23cfbf126a9796a714b0b6edd6f"
dependencies = [
"cfg_aliases 0.1.1",
"memchr",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.109"
@@ -527,6 +652,7 @@ version = "0.0.0"
dependencies = [
"bincode",
"chrono",
"crossbeam-channel",
"libc",
"libloading",
"rand",
@@ -541,7 +667,7 @@ version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
"unshell-crypt",
]
@@ -549,7 +675,7 @@ dependencies = [
name = "unshell-payload"
version = "0.0.0"
dependencies = [
"lazy_static",
"static_init",
"unshell-lib",
"unshell-obfuscate",
]
@@ -613,7 +739,7 @@ dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
"wasm-bindgen-shared",
]
@@ -626,6 +752,28 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.62.2"
@@ -647,7 +795,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
]
[[package]]
@@ -658,7 +806,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
]
[[package]]
@@ -708,5 +856,5 @@ checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.109",
]
+2 -1
View File
@@ -15,7 +15,8 @@ server = ["unshell-lib/server"]
[dependencies]
lazy_static = "1.5.0"
# lazy_static = "1.5.0"
static_init = "1.0.4"
unshell-lib = {path = "../unshell-lib", default-features = false}
unshell-obfuscate = {path = "../unshell-obfuscate"}
+28 -27
View File
@@ -1,11 +1,10 @@
use std::fs::File;
use std::{collections::HashMap, io::Read};
use std::collections::HashMap;
use lazy_static::lazy_static;
use static_init::dynamic;
use unshell_lib::{
ModuleError,
config::{PayloadConfig, RuntimeConfig},
module::{Manager, Module},
module::Manager,
};
use unshell_obfuscate::{obs, symbol};
@@ -13,17 +12,17 @@ use unshell_obfuscate::{obs, symbol};
extern crate unshell_lib;
// The main and initial 'configuration' for a payload
lazy_static! {
static ref PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
id: symbol!("Test ID"),
components: unshell_lib::get_components(),
runtime_config: vec![RuntimeConfig {
parent_component: symbol!("client").to_string(),
name: symbol!("client runtime").to_string(),
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
}],
};
}
#[dynamic]
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
id: symbol!("Test ID"),
components: unshell_lib::get_components(),
runtime_config: vec![RuntimeConfig {
parent_component: symbol!("client").to_string(),
name: symbol!("client runtime").to_string(),
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
}],
};
fn main() {
// Init the logger
@@ -33,25 +32,27 @@ fn main() {
debug!("Initialized");
match || -> Result<(), ModuleError> {
let args = std::env::args();
// let args = std::env::args();
// TEMPORARY, load the module paths from command line args.
let mut modules = Vec::new();
for arg in args.skip(1) {
debug!("Loading module: {}", arg);
// let mut modules = Vec::new();
// for arg in args.skip(1) {
// debug!("Loading module: {}", arg);
let mut file = File::open(arg).map_err(|e| ModuleError::Error(e.to_string().into()))?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer)
.map_err(|e| ModuleError::Error(e.to_string().into()))?;
// let mut file = File::open(arg).map_err(|e| ModuleError::Error(e.to_string().into()))?;
// let mut buffer = Vec::new();
// file.read_to_end(&mut buffer)
// .map_err(|e| ModuleError::Error(e.to_string().into()))?;
modules.push(Module::new_bytes(&buffer)?)
// modules.push(Module::new_bytes(&buffer)?)
// modules.push(Module::new(&arg)?)
}
// // modules.push(Module::new(&arg)?)
// }
// Run the manager, this is blocking.
Manager::run(&PAYLOAD_CONFIG, modules);
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
Manager::join(manager);
Ok(())
}() {