mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Better static runtime config, work on connections.
This commit is contained in:
Generated
+220
-12
@@ -57,6 +57,18 @@ dependencies = [
|
|||||||
"virtue",
|
"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]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.10.4"
|
version = "0.10.4"
|
||||||
@@ -115,6 +127,18 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
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]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.42"
|
version = "0.4.42"
|
||||||
@@ -153,6 +177,21 @@ dependencies = [
|
|||||||
"libc",
|
"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]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -272,12 +311,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.177"
|
version = "0.2.177"
|
||||||
@@ -294,6 +327,15 @@ dependencies = [
|
|||||||
"windows-link",
|
"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]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.28"
|
version = "0.4.28"
|
||||||
@@ -321,6 +363,38 @@ version = "1.21.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
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"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.103"
|
version = "1.0.103"
|
||||||
@@ -345,6 +419,44 @@ version = "5.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||||
|
dependencies = [
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
|
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]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.12.2"
|
version = "1.12.2"
|
||||||
@@ -386,6 +498,12 @@ version = "1.0.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.228"
|
version = "1.0.228"
|
||||||
@@ -413,7 +531,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.110",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -446,6 +564,51 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
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]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.110"
|
version = "2.0.110"
|
||||||
@@ -473,7 +636,7 @@ checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
|||||||
name = "unshell-cli"
|
name = "unshell-cli"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"static_init",
|
||||||
"unshell-crypt",
|
"unshell-crypt",
|
||||||
"unshell-lib",
|
"unshell-lib",
|
||||||
"unshell-obfuscate",
|
"unshell-obfuscate",
|
||||||
@@ -499,7 +662,10 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"crossbeam-channel",
|
||||||
|
"libc",
|
||||||
"libloading",
|
"libloading",
|
||||||
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"unshell-obfuscate",
|
"unshell-obfuscate",
|
||||||
@@ -511,7 +677,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.110",
|
||||||
"unshell-crypt",
|
"unshell-crypt",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -574,7 +740,7 @@ dependencies = [
|
|||||||
"bumpalo",
|
"bumpalo",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.110",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -587,6 +753,28 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"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]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.62.2"
|
version = "0.62.2"
|
||||||
@@ -608,7 +796,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.110",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -619,7 +807,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.110",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -651,3 +839,23 @@ name = "wit-bindgen"
|
|||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.8.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ea879c944afe8a2b25fef16bb4ba234f47c694565e97383b36f3a878219065c"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.8.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf955aa904d6040f70dc8e9384444cb1030aed272ba3cb09bbc4ab9e7c1f34f5"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.110",
|
||||||
|
]
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ name = "unshell-cli"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
unshell-lib = {path = "../unshell-lib"}
|
unshell-lib = {path = "../unshell-lib", features=["log_debug"]}
|
||||||
unshell-obfuscate = {path = "../unshell-obfuscate"}
|
unshell-obfuscate = {path = "../unshell-obfuscate"}
|
||||||
unshell-crypt = {path = "../unshell-crypt"}
|
unshell-crypt = {path = "../unshell-crypt"}
|
||||||
lazy_static = "1.5.0"
|
# lazy_static = "1.5.0"
|
||||||
|
static_init = "1.0.4"
|
||||||
|
|||||||
+37
-11
@@ -1,21 +1,47 @@
|
|||||||
use lazy_static::lazy_static;
|
use std::collections::HashMap;
|
||||||
use unshell_lib::{config::PayloadConfig, module::Manager};
|
|
||||||
use unshell_obfuscate::symbol;
|
|
||||||
|
|
||||||
lazy_static! {
|
use static_init::dynamic;
|
||||||
static ref PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
use unshell_lib::{
|
||||||
id: symbol!("Test ID"),
|
config::{PayloadConfig, RuntimeConfig},
|
||||||
components: unshell_lib::get_components(),
|
module::Manager,
|
||||||
runtime_config: vec![],
|
};
|
||||||
};
|
use unshell_obfuscate::{obs, symbol};
|
||||||
|
|
||||||
|
#[dynamic]
|
||||||
|
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
||||||
|
id: symbol!("Test ID"),
|
||||||
|
components: unshell_lib::get_components(),
|
||||||
|
runtime_config: vec![],
|
||||||
|
};
|
||||||
|
|
||||||
|
use std::alloc::{Layout, alloc};
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
|
fn leak<T>(value: T) -> &'static mut T {
|
||||||
|
unsafe {
|
||||||
|
let layout = Layout::new::<T>();
|
||||||
|
let ptr = alloc(layout) as *mut T;
|
||||||
|
ptr::write(ptr, value);
|
||||||
|
&mut *ptr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
unshell_lib::logger::PrettyLogger::init();
|
unshell_lib::logger::PrettyLogger::init();
|
||||||
|
|
||||||
Manager::run(&PAYLOAD_CONFIG, Vec::new());
|
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
|
||||||
|
|
||||||
// let mut serverruntime = unshell_lib::server::ListenerRuntime::new();
|
let runtime = leak(RuntimeConfig {
|
||||||
|
parent_component: symbol!("server").to_string(),
|
||||||
|
name: symbol!("server runtime").to_string(),
|
||||||
|
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
|
||||||
|
});
|
||||||
|
|
||||||
|
Manager::start_runtime(manager.clone(), runtime);
|
||||||
|
|
||||||
|
// Manager::st
|
||||||
|
|
||||||
|
Manager::join(manager);
|
||||||
|
|
||||||
// loop {
|
// loop {
|
||||||
// print!("> ");
|
// print!("> ");
|
||||||
|
|||||||
Generated
+16
@@ -153,6 +153,21 @@ dependencies = [
|
|||||||
"libc",
|
"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]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -521,6 +536,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"crossbeam-channel",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading",
|
"libloading",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
@@ -25,3 +25,4 @@ serde = {version = "1.0.228", features=["derive"]}
|
|||||||
serde_json = "1.0.145"
|
serde_json = "1.0.145"
|
||||||
libc = "0.2.177"
|
libc = "0.2.177"
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
|
crossbeam-channel = "0.5.15"
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ pub fn get_components() -> Vec<NamedComponent> {
|
|||||||
return vec![
|
return vec![
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
crate::client::get_named_component(),
|
crate::client::get_named_component(),
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
crate::server::get_named_component(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ pub mod client;
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod logger;
|
pub mod logger;
|
||||||
pub mod module;
|
pub mod module;
|
||||||
|
pub mod network;
|
||||||
pub mod server;
|
pub mod server;
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ impl Logger for DefaultLogger {
|
|||||||
fn log(&self, _: Record) {}
|
fn log(&self, _: Record) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
pub fn set_logger_box(logger: Box<dyn Logger>) {
|
pub fn set_logger_box(logger: Box<dyn Logger>) {
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ impl Manager {
|
|||||||
|
|
||||||
/// Create Manager, and run initilization for each Module
|
/// Create Manager, and run initilization for each Module
|
||||||
#[allow(static_mut_refs)]
|
#[allow(static_mut_refs)]
|
||||||
pub fn run(config: &'static PayloadConfig, modules: Vec<Module>) {
|
pub fn start(config: &'static PayloadConfig, modules: Vec<Module>) -> Arc<Mutex<Self>> {
|
||||||
// Construct self
|
// Construct self
|
||||||
let mut this = Self::new(&config.id, config.components.clone(), modules);
|
let mut this = Self::new(&config.id, config.components.clone(), modules);
|
||||||
|
|
||||||
@@ -51,11 +51,12 @@ impl Manager {
|
|||||||
|
|
||||||
let this = Arc::new(Mutex::new(this));
|
let this = Arc::new(Mutex::new(this));
|
||||||
|
|
||||||
Self::start_runtimes(this.clone(), &config.runtime_config);
|
debug!("Starting runtimes...");
|
||||||
|
for runtime in &config.runtime_config {
|
||||||
|
Self::start_runtime(this.clone(), runtime);
|
||||||
|
}
|
||||||
|
|
||||||
// drop(config);
|
this
|
||||||
|
|
||||||
Self::join(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_components(&mut self) {
|
fn load_components(&mut self) {
|
||||||
@@ -84,39 +85,8 @@ impl Manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start each runtime
|
|
||||||
fn start_runtimes(this: Arc<Mutex<Self>>, runtimes: &'static Vec<RuntimeConfig>) {
|
|
||||||
debug!("Starting runtimes...");
|
|
||||||
for runtime in runtimes {
|
|
||||||
let mut this_lock = this.lock().unwrap();
|
|
||||||
|
|
||||||
let component = match this_lock.components.get(&runtime.parent_component) {
|
|
||||||
Some(component) => component,
|
|
||||||
None => {
|
|
||||||
warn!(
|
|
||||||
"Could not find component '{}' which is referenced by runtime: {}",
|
|
||||||
runtime.parent_component, runtime.name
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
debug!("Starting runtime: {}", runtime.name);
|
|
||||||
|
|
||||||
let runtime = match (*component.start_runtime)(runtime) {
|
|
||||||
Ok(runtime) => runtime,
|
|
||||||
Err(e) => {
|
|
||||||
warn!("Failed to start runtime: {:?}", e);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this_lock.active_runtimes.push(runtime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Iterateratively loop through all runtimes, until all are finished executing
|
/// Iterateratively loop through all runtimes, until all are finished executing
|
||||||
fn join(this: Arc<Mutex<Self>>) {
|
pub fn join(this: Arc<Mutex<Self>>) {
|
||||||
loop {
|
loop {
|
||||||
let mut this_lock = this.lock().unwrap();
|
let mut this_lock = this.lock().unwrap();
|
||||||
|
|
||||||
@@ -140,20 +110,35 @@ impl Manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn get_component(&self) -> HashMap<&'static str, Box<dyn Component>> {
|
/// Start a runtime
|
||||||
// self.components.clone()
|
pub fn start_runtime<'a>(this: Arc<Mutex<Self>>, runtime: &'static RuntimeConfig) {
|
||||||
// }
|
let mut this_lock = this.lock().unwrap();
|
||||||
|
|
||||||
|
let component = match this_lock.components.get(&runtime.parent_component) {
|
||||||
|
Some(component) => component,
|
||||||
|
None => {
|
||||||
|
warn!(
|
||||||
|
"Could not find component '{}' which is referenced by runtime: {}",
|
||||||
|
runtime.parent_component, runtime.name
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
debug!("Starting runtime: {}", runtime.name);
|
||||||
|
|
||||||
|
let runtime = match (*component.start_runtime)(runtime) {
|
||||||
|
Ok(runtime) => runtime,
|
||||||
|
Err(e) => {
|
||||||
|
warn!("Failed to start runtime: {:?}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this_lock.active_runtimes.push(runtime);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> &str {
|
pub fn get_name(&self) -> &str {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub extern "C" fn test1234(&self, float: f32) {
|
|
||||||
// info!("Manager Test Sucsessfull! {}", float.powf(2.));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[allow(static_mut_refs, improper_ctypes_definitions)]
|
|
||||||
// pub extern "C" fn get_manager() -> Arc<Mutex<Manager>> {
|
|
||||||
// unsafe { MANAGER_RUNTIME.clone().unwrap() }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
use std::sync::{
|
||||||
|
Arc,
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{Announcement, ModuleError, network::Stream};
|
||||||
|
|
||||||
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
|
|
||||||
|
pub struct Connection {
|
||||||
|
tx: Sender<Announcement>,
|
||||||
|
rx: Receiver<Announcement>,
|
||||||
|
is_alive: Arc<AtomicBool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Connection {
|
||||||
|
pub fn new() -> (Connection, Connection) {
|
||||||
|
let (tx_mgr, rx) = crossbeam_channel::unbounded();
|
||||||
|
let (tx, rx_mgr) = crossbeam_channel::unbounded();
|
||||||
|
let alive = Arc::new(AtomicBool::new(false));
|
||||||
|
|
||||||
|
(
|
||||||
|
Self {
|
||||||
|
tx: tx_mgr,
|
||||||
|
rx: rx_mgr,
|
||||||
|
is_alive: alive.clone(),
|
||||||
|
},
|
||||||
|
Self {
|
||||||
|
tx,
|
||||||
|
rx,
|
||||||
|
is_alive: alive,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Stream<Announcement> for Connection {
|
||||||
|
fn is_alive(&self) -> bool {
|
||||||
|
self.is_alive.load(Ordering::Relaxed)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.rx.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read(&mut self) -> Option<Announcement> {
|
||||||
|
match self.rx.is_empty() {
|
||||||
|
true => None,
|
||||||
|
false => self.rx.recv().ok(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write(&mut self, data: Announcement) -> Result<(), crate::ModuleError> {
|
||||||
|
self.tx
|
||||||
|
.send(data)
|
||||||
|
.map_err(|_| ModuleError::Error("Failed to send".into()))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_clone(&self) -> Result<Box<dyn Stream<Announcement> + Send + Sync>, crate::ModuleError> {
|
||||||
|
Ok(Box::new(Self {
|
||||||
|
tx: self.tx.clone(),
|
||||||
|
rx: self.rx.clone(),
|
||||||
|
is_alive: self.is_alive.clone(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
mod connection;
|
||||||
|
|
||||||
|
pub use connection::Connection;
|
||||||
|
|
||||||
|
use crate::ModuleError;
|
||||||
|
|
||||||
|
/// This is the data transmission type
|
||||||
|
pub trait Stream<T>: Send + Sync {
|
||||||
|
// fn get_info(&self) -> String;
|
||||||
|
fn is_alive(&self) -> bool;
|
||||||
|
|
||||||
|
fn len(&self) -> usize;
|
||||||
|
fn read(&mut self) -> Option<T>;
|
||||||
|
|
||||||
|
fn write(&mut self, data: T) -> Result<(), ModuleError>;
|
||||||
|
|
||||||
|
fn try_clone(&self) -> Result<Box<dyn Stream<T> + Send + Sync>, ModuleError>;
|
||||||
|
}
|
||||||
@@ -1,3 +1,26 @@
|
|||||||
mod server_runtime;
|
mod server_runtime;
|
||||||
|
|
||||||
pub use server_runtime::ListenerRuntime;
|
pub use server_runtime::ListenerRuntime;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
ModuleError, ModuleRuntime,
|
||||||
|
config::{InterfaceWrapper, NamedComponent, RuntimeConfig},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const COMPONENT_NAME: &'static str = "server";
|
||||||
|
|
||||||
|
fn get_interface() -> Option<&'static (dyn InterfaceWrapper + Sync)> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_runtime(config: &'static RuntimeConfig) -> Result<Box<dyn ModuleRuntime>, ModuleError> {
|
||||||
|
Ok(Box::new(ListenerRuntime::new(config)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const fn get_named_component() -> NamedComponent {
|
||||||
|
NamedComponent {
|
||||||
|
name: COMPONENT_NAME,
|
||||||
|
get_interface: &get_interface,
|
||||||
|
start_runtime: &start_runtime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ use std::{
|
|||||||
thread::{self, JoinHandle},
|
thread::{self, JoinHandle},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::*;
|
use crate::{config::RuntimeConfig, *};
|
||||||
|
|
||||||
pub struct ListenerRuntime {
|
pub struct ListenerRuntime {
|
||||||
thread_handle: JoinHandle<()>,
|
thread_handle: JoinHandle<()>,
|
||||||
|
// join_signal: Arc<AtomicBool>,
|
||||||
// listener: TcpListener,
|
// listener: TcpListener,
|
||||||
streams: Arc<Mutex<Vec<TcpStream>>>,
|
streams: Arc<Mutex<Vec<TcpStream>>>,
|
||||||
// reader: BufReader<TcpListener>,
|
// reader: BufReader<TcpListener>,
|
||||||
@@ -16,9 +17,19 @@ pub struct ListenerRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ListenerRuntime {
|
impl ListenerRuntime {
|
||||||
pub fn new() -> ListenerRuntime {
|
pub fn new(config: &'static RuntimeConfig) -> Result<Self, ModuleError> {
|
||||||
// info!("Starting listener runtime on {}",);
|
// info!("Starting listener runtime on {}",);
|
||||||
let listener = TcpListener::bind("127.0.0.1:1234").unwrap();
|
|
||||||
|
let host = match config.config.get("host") {
|
||||||
|
Some(host) => host,
|
||||||
|
None => {
|
||||||
|
return Err(ModuleError::Error(
|
||||||
|
"Could not find HOST in Server Runtime".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let listener = TcpListener::bind(host).unwrap();
|
||||||
let streams = Arc::new(Mutex::new(Vec::new()));
|
let streams = Arc::new(Mutex::new(Vec::new()));
|
||||||
|
|
||||||
let streams_clone = streams.clone();
|
let streams_clone = streams.clone();
|
||||||
@@ -27,14 +38,14 @@ impl ListenerRuntime {
|
|||||||
let streams = streams_clone.clone();
|
let streams = streams_clone.clone();
|
||||||
for stream in listener.incoming() {
|
for stream in listener.incoming() {
|
||||||
let stream = stream.unwrap();
|
let stream = stream.unwrap();
|
||||||
println!("New connection from {}", stream.peer_addr().unwrap());
|
debug!("New connection from {}", stream.peer_addr().unwrap());
|
||||||
streams.lock().unwrap().push(stream);
|
streams.lock().unwrap().push(stream);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Self {
|
Ok(Self {
|
||||||
thread_handle,
|
thread_handle,
|
||||||
streams,
|
streams,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send(&mut self, announcement: &Announcement) -> Result<(), std::io::Error> {
|
pub fn send(&mut self, announcement: &Announcement) -> Result<(), std::io::Error> {
|
||||||
@@ -48,7 +59,7 @@ impl ListenerRuntime {
|
|||||||
stream.flush()?;
|
stream.flush()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Announcement {:?} sent", announcement);
|
debug!("Announcement {:?} sent", announcement);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -81,6 +92,7 @@ impl ModuleRuntime for ListenerRuntime {
|
|||||||
|
|
||||||
fn kill(self: Box<Self>) {
|
fn kill(self: Box<Self>) {
|
||||||
if !self.thread_handle.is_finished() {
|
if !self.thread_handle.is_finished() {
|
||||||
|
// self.join_signal.store(true, Ordering::Relaxed);
|
||||||
let _ = self.thread_handle.join();
|
let _ = self.thread_handle.join();
|
||||||
}
|
}
|
||||||
// drop(self);
|
// drop(self);
|
||||||
|
|||||||
Generated
+161
-13
@@ -57,6 +57,18 @@ dependencies = [
|
|||||||
"virtue",
|
"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]]
|
[[package]]
|
||||||
name = "block-buffer"
|
name = "block-buffer"
|
||||||
version = "0.10.4"
|
version = "0.10.4"
|
||||||
@@ -115,6 +127,18 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
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]]
|
[[package]]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.4.42"
|
version = "0.4.42"
|
||||||
@@ -153,6 +177,21 @@ dependencies = [
|
|||||||
"libc",
|
"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]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -272,12 +311,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.177"
|
version = "0.2.177"
|
||||||
@@ -294,6 +327,15 @@ dependencies = [
|
|||||||
"windows-link",
|
"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]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.28"
|
version = "0.4.28"
|
||||||
@@ -321,6 +363,29 @@ version = "1.21.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
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]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
@@ -383,6 +448,15 @@ dependencies = [
|
|||||||
"getrandom",
|
"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]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.12.2"
|
version = "1.12.2"
|
||||||
@@ -424,6 +498,12 @@ version = "1.0.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.228"
|
version = "1.0.228"
|
||||||
@@ -451,7 +531,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -484,6 +564,51 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
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]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.109"
|
version = "2.0.109"
|
||||||
@@ -527,6 +652,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"crossbeam-channel",
|
||||||
"libc",
|
"libc",
|
||||||
"libloading",
|
"libloading",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -541,7 +667,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
"unshell-crypt",
|
"unshell-crypt",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -549,7 +675,7 @@ dependencies = [
|
|||||||
name = "unshell-payload"
|
name = "unshell-payload"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"static_init",
|
||||||
"unshell-lib",
|
"unshell-lib",
|
||||||
"unshell-obfuscate",
|
"unshell-obfuscate",
|
||||||
]
|
]
|
||||||
@@ -613,7 +739,7 @@ dependencies = [
|
|||||||
"bumpalo",
|
"bumpalo",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -626,6 +752,28 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"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]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows-core"
|
||||||
version = "0.62.2"
|
version = "0.62.2"
|
||||||
@@ -647,7 +795,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -658,7 +806,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -708,5 +856,5 @@ checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.109",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ server = ["unshell-lib/server"]
|
|||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[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-lib = {path = "../unshell-lib", default-features = false}
|
||||||
unshell-obfuscate = {path = "../unshell-obfuscate"}
|
unshell-obfuscate = {path = "../unshell-obfuscate"}
|
||||||
|
|||||||
+28
-27
@@ -1,11 +1,10 @@
|
|||||||
use std::fs::File;
|
use std::collections::HashMap;
|
||||||
use std::{collections::HashMap, io::Read};
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use static_init::dynamic;
|
||||||
use unshell_lib::{
|
use unshell_lib::{
|
||||||
ModuleError,
|
ModuleError,
|
||||||
config::{PayloadConfig, RuntimeConfig},
|
config::{PayloadConfig, RuntimeConfig},
|
||||||
module::{Manager, Module},
|
module::Manager,
|
||||||
};
|
};
|
||||||
use unshell_obfuscate::{obs, symbol};
|
use unshell_obfuscate::{obs, symbol};
|
||||||
|
|
||||||
@@ -13,17 +12,17 @@ use unshell_obfuscate::{obs, symbol};
|
|||||||
extern crate unshell_lib;
|
extern crate unshell_lib;
|
||||||
|
|
||||||
// The main and initial 'configuration' for a payload
|
// The main and initial 'configuration' for a payload
|
||||||
lazy_static! {
|
|
||||||
static ref PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
#[dynamic]
|
||||||
id: symbol!("Test ID"),
|
static PAYLOAD_CONFIG: PayloadConfig = PayloadConfig {
|
||||||
components: unshell_lib::get_components(),
|
id: symbol!("Test ID"),
|
||||||
runtime_config: vec![RuntimeConfig {
|
components: unshell_lib::get_components(),
|
||||||
parent_component: symbol!("client").to_string(),
|
runtime_config: vec![RuntimeConfig {
|
||||||
name: symbol!("client runtime").to_string(),
|
parent_component: symbol!("client").to_string(),
|
||||||
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
|
name: symbol!("client runtime").to_string(),
|
||||||
}],
|
config: HashMap::from([(symbol!("host").to_string(), obs!("localhost:1234"))]),
|
||||||
};
|
}],
|
||||||
}
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Init the logger
|
// Init the logger
|
||||||
@@ -33,25 +32,27 @@ fn main() {
|
|||||||
debug!("Initialized");
|
debug!("Initialized");
|
||||||
|
|
||||||
match || -> Result<(), ModuleError> {
|
match || -> Result<(), ModuleError> {
|
||||||
let args = std::env::args();
|
// let args = std::env::args();
|
||||||
|
|
||||||
// TEMPORARY, load the module paths from command line args.
|
// TEMPORARY, load the module paths from command line args.
|
||||||
let mut modules = Vec::new();
|
// let mut modules = Vec::new();
|
||||||
for arg in args.skip(1) {
|
// for arg in args.skip(1) {
|
||||||
debug!("Loading module: {}", arg);
|
// debug!("Loading module: {}", arg);
|
||||||
|
|
||||||
let mut file = File::open(arg).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();
|
// let mut buffer = Vec::new();
|
||||||
file.read_to_end(&mut buffer)
|
// file.read_to_end(&mut buffer)
|
||||||
.map_err(|e| ModuleError::Error(e.to_string().into()))?;
|
// .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.
|
// Run the manager, this is blocking.
|
||||||
Manager::run(&PAYLOAD_CONFIG, modules);
|
let manager = Manager::start(&PAYLOAD_CONFIG, Vec::new());
|
||||||
|
|
||||||
|
Manager::join(manager);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}() {
|
}() {
|
||||||
|
|||||||
Reference in New Issue
Block a user