Skip to main content

ploit_malper/
models.rs

1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7pub struct ScanRecord {
8    pub target: String,
9    pub tool: String,
10    pub title: String,
11    pub severity: String,
12    pub port: Option<u16>,
13    pub cve: Option<String>,
14    pub service: Option<String>,
15    pub raw: Value,
16    #[serde(default, skip_serializing_if = "Vec::is_empty")]
17    pub affected_endpoints: Vec<String>,
18    #[serde(default, skip_serializing_if = "Option::is_none")]
19    pub nvd_description: Option<String>,
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub nvd_cvss_v3: Option<f32>,
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub nvd_cvss_v3_severity: Option<String>,
24    #[serde(default, skip_serializing_if = "Option::is_none")]
25    pub nvd_cvss_v2: Option<f32>,
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub nvd_published: Option<String>,
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub nvd_last_modified: Option<String>,
30    #[serde(default, skip_serializing_if = "Vec::is_empty")]
31    pub nvd_references: Vec<String>,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct DedupResult {
36    pub unique_count: usize,
37    pub removed_count: usize,
38    pub records: Vec<ScanRecord>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct DedupStats {
43    pub total: usize,
44    pub unique: usize,
45    pub removed: usize,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct ModuleSuggestion {
50    pub service_banner: String,
51    pub suggested_module: String,
52    pub confidence: String,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
56pub struct PayloadRecipe {
57    pub platform: String,
58    pub architecture: String,
59    pub lhost: String,
60    pub lport: u16,
61    pub format: String,
62    pub output_path: String,
63    pub encoder: Option<String>,
64    pub iterations: Option<u32>,
65    pub command: String,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct NVDCVEInfo {
70    pub cve_id: String,
71    pub description: String,
72    pub cvss_v3_score: Option<f32>,
73    pub cvss_v3_severity: Option<String>,
74    pub cvss_v2_score: Option<f32>,
75    pub published: String,
76    pub last_modified: String,
77    pub references: Vec<String>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct MSFWorkspaceInfo {
82    pub name: String,
83    pub scope: String,
84    pub host_count: u64,
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize)]
88pub struct MSFHostInfo {
89    pub address: String,
90    pub os_name: String,
91    pub os_flavor: String,
92    pub state: String,
93    pub notes_count: u64,
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
97pub struct MSFLoginResult {
98    pub success: bool,
99    pub token: String,
100    pub error: String,
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct MSFWorkspacesResult {
105    pub workspaces: Vec<MSFWorkspaceInfo>,
106    pub error: String,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct MSFHostsResult {
111    pub hosts: Vec<MSFHostInfo>,
112    pub error: String,
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
116pub struct MSFHostCheckResult {
117    pub exists: bool,
118    pub error: String,
119}
120
121/// A vulnerability grouped across multiple affected endpoints.
122#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct FindingGroup {
124    pub title: String,
125    pub severity: String,
126    pub count: usize,
127    pub target: String,
128    pub affected_endpoints: Vec<String>,
129    pub cves: Vec<String>,
130    pub ports: Vec<String>,
131    pub tools: Vec<String>,
132}
133
134/// High-level executive summary of a scan.
135#[derive(Debug, Clone, Serialize, Deserialize, Default)]
136pub struct ScanSummary {
137    pub host: String,
138    pub server: Option<String>,
139    pub framework: Option<String>,
140    pub severity_counts: BTreeMap<String, usize>,
141    pub top_risks: Vec<String>,
142}
143
144/// Weighted overall risk score with a rendered bar and justification.
145#[derive(Debug, Clone, Serialize, Deserialize)]
146pub struct RiskScore {
147    pub score: u32,
148    pub bar: String,
149    pub reasons: Vec<String>,
150}
151
152/// Metasploit suggestions grouped by purpose.
153#[derive(Debug, Clone, Serialize, Deserialize, Default)]
154pub struct ModuleCategories {
155    pub enumeration: Vec<ModuleSuggestion>,
156    pub validation: Vec<ModuleSuggestion>,
157    pub exploitation: Vec<ModuleSuggestion>,
158    pub manual_notes: Vec<String>,
159}
160
161/// A single MITRE ATT&CK tactic with matching techniques and evidence.
162#[derive(Debug, Clone, Serialize, Deserialize)]
163pub struct MitreTactic {
164    pub tactic: String,
165    pub techniques: Vec<String>,
166    pub findings: Vec<String>,
167}
168
169/// Additional CVE intelligence beyond raw NVD data.
170#[derive(Debug, Clone, Serialize, Deserialize)]
171pub struct CVEExtraInfo {
172    pub epss: Option<f32>,
173    pub in_kev: bool,
174    pub public_exploit: bool,
175    pub metasploit_modules: Vec<String>,
176}