mythic_facade/
mythic_facade.rs1use mythic::{Aes256HmacCrypto, C2Transport, MythicAgent, MythicError, TaskResponse};
13use uuid::Uuid;
14
15struct HttpC2 {
20 key_b64: Option<String>,
21}
22
23impl C2Transport for HttpC2 {
24 fn get_aes_psk(&self) -> Option<String> {
25 self.key_b64.clone()
26 }
27
28 fn random_iv(&self) -> Result<[u8; 16], MythicError> {
30 Ok([0u8; 16]) }
33
34 fn checkin(&self, pkt: &str) -> Result<String, MythicError> {
35 eprintln!("[HTTP] checkin → {} bytes", pkt.len());
36 Ok(String::new())
38 }
39
40 fn get_tasking(&self, pkt: &str) -> Result<String, MythicError> {
41 eprintln!("[HTTP] get_task → {} bytes", pkt.len());
42 Ok(String::new())
44 }
45
46 fn post_response(&self, pkt: &str) -> Result<String, MythicError> {
47 eprintln!("[HTTP] post_resp → {} bytes", pkt.len());
48 Ok(String::new())
49 }
50}
51
52fn main() {
53 let payload_uuid = Uuid::parse_str("f0f0f0f0-1111-2222-3333-444444444444").unwrap();
54
55 {
57 let c2 = HttpC2 { key_b64: None };
58 let agent = MythicAgent::easy_checkin(
59 payload_uuid,
60 &c2,
61 vec!["10.0.0.1".into()],
62 Some("linux".into()),
63 Some("root".into()),
64 Some("web01".into()),
65 Some(1337),
66 Some("x86_64".into()),
67 None, None, None, None, None, None,
68 )
69 .unwrap();
70 println!("Plaintext callback UUID: {}", agent.callback_uuid());
71 }
72
73 {
75 let key = Aes256HmacCrypto::new([0xAB; 32]).key_b64();
76 let c2 = HttpC2 { key_b64: Some(key) };
77 let agent = MythicAgent::easy_checkin(
78 payload_uuid,
79 &c2,
80 vec!["192.168.1.100".into()],
81 Some("windows".into()),
82 Some("admin".into()),
83 Some("DESKTOP-XYZ".into()),
84 Some(2048),
85 Some("x86_64".into()),
86 None, None, None, None, None, None,
87 )
88 .unwrap();
89 println!("Static-key callback UUID: {}", agent.callback_uuid());
90 }
91
92 {
94 let c2 = HttpC2 { key_b64: None };
95
96 let agent = MythicAgent::easy_checkin(
98 payload_uuid,
99 &c2,
100 vec!["10.0.0.2".into()],
101 Some("linux".into()),
102 Some("operator".into()),
103 Some("implant01".into()),
104 Some(9999),
105 Some("aarch64".into()),
106 None, None, None, None, None, None,
107 )
108 .unwrap();
109
110 match agent.get_tasking(1, &c2) {
112 Ok(resp) => {
113 for task in &resp.tasks {
114 println!("Received task {}: {}", task.id, task.command);
115
116 let _ = agent.post_response(
118 vec![TaskResponse::completed(task.id, "task executed successfully")],
119 &c2,
120 );
121 }
122 }
123 Err(e) => eprintln!("get_tasking failed: {e}"),
124 }
125 }
126
127 println!("All demo scenarios complete.");
128}