1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4
5pub const MODULE_EXPLOIT: &str = "exploit";
6pub const MODULE_AUXILIARY: &str = "auxiliary";
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ModuleOption {
11 pub name: String,
12 pub required: bool,
13 pub default: Option<String>,
14 pub description: String,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, Default)]
19pub struct ModuleInfo {
20 pub name: String,
21 pub module_type: String,
22 pub rank: String,
23 pub description: String,
24 pub platforms: Vec<String>,
25 pub targets: Vec<String>,
26 pub options: Vec<ModuleOption>,
27 pub required_options: Vec<String>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct ExploitStep {
34 pub module_type: String,
35 pub module_name: String,
36 pub cve: Option<String>,
38 pub vulnerability: String,
40 pub rank: String,
42 pub asset_id: String,
43 pub finding_id: String,
44 pub host: String,
46 pub service_port: Option<u16>,
47 pub service_protocol: Option<String>,
48 pub inferred_options: BTreeMap<String, String>,
50 pub missing_options: Vec<String>,
52 pub payload_compatibility: String,
54 pub confidence: String,
56 pub default_selected: bool,
58}
59
60impl ExploitStep {
61 pub fn resolved_options(&self) -> BTreeMap<String, String> {
63 self.inferred_options.clone()
64 }
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct ModuleRunResult {
70 pub job_id: Option<String>,
71 pub success: bool,
72 pub message: String,
73 pub raw: String,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct JobStatus {
79 pub job_id: String,
80 pub running: bool,
81 pub status: String,
82 pub error: Option<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87pub struct SessionInfo {
88 pub id: String,
89 pub typ: String,
90 pub target_host: String,
91 pub platform: String,
92 pub info: String,
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct LootInfo {
98 pub id: String,
99 pub name: String,
100 pub content_type: String,
101 pub host: String,
102 pub path: String,
103}
104
105#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
107pub enum ExploitStatus {
108 Planned,
110 Running,
112 Completed,
114 Failed,
116 Skipped,
118 DryRun,
120}
121
122impl ExploitStatus {
123 pub fn as_str(&self) -> &'static str {
124 match self {
125 ExploitStatus::Planned => "planned",
126 ExploitStatus::Running => "running",
127 ExploitStatus::Completed => "completed",
128 ExploitStatus::Failed => "failed",
129 ExploitStatus::Skipped => "skipped",
130 ExploitStatus::DryRun => "dry_run",
131 }
132 }
133
134 pub fn parse(value: &str) -> Self {
135 match value {
136 "running" => ExploitStatus::Running,
137 "completed" => ExploitStatus::Completed,
138 "failed" => ExploitStatus::Failed,
139 "skipped" => ExploitStatus::Skipped,
140 "dry_run" => ExploitStatus::DryRun,
141 _ => ExploitStatus::Planned,
142 }
143 }
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148pub struct ExploitOutcome {
149 pub step: ExploitStep,
150 pub status: ExploitStatus,
151 pub job_id: Option<String>,
152 pub session_id: Option<String>,
153 pub error: Option<String>,
154 pub loot: Vec<String>,
155 pub start_time: String,
156 pub finish_time: Option<String>,
157}
158
159#[derive(Debug, Clone, Default)]
161pub struct ExploitOptions {
162 pub dry_run: bool,
163 pub yes: bool,
164 pub module_filter: Option<String>,
165 pub target_filter: Option<String>,
166 pub payload_override: Option<String>,
167 pub workspace: Option<String>,
168 pub backend: Option<String>,
169 pub pocketbase_url: Option<String>,
170 pub sqlite_path: Option<String>,
171 pub verbose: bool,
172}