use super::{ScanContext, ScanPhase};
use crate::protocols::signatures::SignatureTester;
use crate::{Args, Result};
use async_trait::async_trait;
pub struct SignaturePhase;
impl SignaturePhase {
pub fn new() -> Self {
Self
}
}
impl Default for SignaturePhase {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ScanPhase for SignaturePhase {
fn name(&self) -> &'static str {
"Enumerating Signature Algorithms"
}
fn should_run(&self, args: &Args) -> bool {
args.scan.show_sigs
}
async fn execute(&self, context: &mut ScanContext) -> Result<()> {
let tester = SignatureTester::new(context.target());
let signature_results = tester.enumerate_signatures().await?;
context.results.advanced_mut().signature_algorithms = Some(signature_results);
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_signature_phase_should_run() {
let phase = SignaturePhase::new();
let mut args = Args::default();
args.scan.show_sigs = true;
assert!(phase.should_run(&args));
let args = Args::default();
assert!(!phase.should_run(&args));
let mut args = Args::default();
args.scan.all = true;
assert!(!phase.should_run(&args));
}
#[test]
fn test_signature_phase_name() {
let phase = SignaturePhase::new();
assert_eq!(phase.name(), "Enumerating Signature Algorithms");
}
}