diff --git a/lib/src/analysis/test_analyzer.rs b/lib/src/analysis/test_analyzer.rs index f754035..dafdacc 100644 --- a/lib/src/analysis/test_analyzer.rs +++ b/lib/src/analysis/test_analyzer.rs @@ -1,9 +1,12 @@ use std::borrow::Cow; -use telcom_parser::lte_rrc::{BCCH_DL_SCH_MessageType, BCCH_DL_SCH_MessageType_c1}; +use telcom_parser::lte_rrc::{ + BCCH_DL_SCH_MessageType, BCCH_DL_SCH_MessageType_c1, PLMN_IdentityInfo, +}; use super::analyzer::{Analyzer, Event, EventType, Severity}; use super::information_element::{InformationElement, LteInformationElement}; +use deku::bitvec::*; pub struct TestAnalyzer { packet_num: usize, @@ -27,7 +30,9 @@ impl Analyzer for TestAnalyzer { } fn get_description(&self) -> Cow<'_, str> { - Cow::from("This is an analyzer which can be used to test that your rayhunter is working. It will generate an alert for every SIB1 message (a beacon from the cell tower) that it sees. Do not leave this on when you are hunting or it will be very noisy.") + Cow::from( + "This is an analyzer which can be used to test that your rayhunter is working. It will generate an alert for every SIB1 message (a beacon from the cell tower) that it sees. Do not leave this on when you are hunting or it will be very noisy.", + ) } fn get_version(&self) -> u32 { @@ -42,15 +47,30 @@ impl Analyzer for TestAnalyzer { && let BCCH_DL_SCH_MessageType::C1(c1) = &sch_msg.message && let BCCH_DL_SCH_MessageType_c1::SystemInformationBlockType1(sib1) = c1 { + let cid = sib1 + .cell_access_related_info + .cell_identity + .0 + .as_bitslice() + .load::(); + let plmn = &sib1.cell_access_related_info.plmn_identity_list.0; + let mcc_string: String; + let mnc_string: String; + if let Some(mcc) = &plmn[0].plmn_identity.mcc { + mcc_string = format!("{}{}{}", mcc.0[0].0, mcc.0[1].0, mcc.0[2].0); + } else { + mcc_string = "nomcc".to_string(); + } + let mnc = &plmn[0].plmn_identity.mnc; + mnc_string = format!("{}{}{}", mnc.0[0].0, mnc.0[1].0, mnc.0[2].0); + return Some(Event { event_type: EventType::QualitativeWarning { severity: Severity::Low, }, message: format!( - "SIB1 received (packet {}) CID: {}, PLMN: {:?}", - self.packet_num, - sib1.cell_access_related_info.cell_identity.0, - sib1.cell_access_related_info.plmn_identity_list.0 + "SIB1 received (packet {}) CID: {}, PLMN: {}-{}", + self.packet_num, cid, mcc_string, mnc_string ), }); }