diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 1b72da6..4aef0bc 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rayhunter-daemon" version = "0.4.0" -edition = "2021" +edition = "2024" [features] # These feature flags are mutually exclusive, and exactly one must be enabled. diff --git a/bin/src/analysis.rs b/bin/src/analysis.rs index 2c9543b..226e73f 100644 --- a/bin/src/analysis.rs +++ b/bin/src/analysis.rs @@ -165,9 +165,11 @@ async fn perform_analysis( .expect("failed to get QMDL file metadata") .len(); let mut qmdl_reader = QmdlReader::new(qmdl_file, Some(file_size as usize)); - let mut qmdl_stream = pin::pin!(qmdl_reader - .as_stream() - .try_filter(|container| future::ready(container.data_type == DataType::UserSpace))); + let mut qmdl_stream = pin::pin!( + qmdl_reader + .as_stream() + .try_filter(|container| future::ready(container.data_type == DataType::UserSpace)) + ); info!("Starting analysis for {name}..."); while let Some(container) = qmdl_stream diff --git a/bin/src/check.rs b/bin/src/check.rs index eb45bf4..2e4a6f6 100644 --- a/bin/src/check.rs +++ b/bin/src/check.rs @@ -9,7 +9,7 @@ use rayhunter::{ qmdl::QmdlReader, }; use std::{collections::HashMap, future, path::PathBuf, pin::pin}; -use tokio::fs::{metadata, read_dir, File}; +use tokio::fs::{File, metadata, read_dir}; mod dummy_analyzer; @@ -44,9 +44,11 @@ async fn analyze_file(enable_dummy_analyzer: bool, qmdl_path: &str, show_skipped .expect("failed to get QMDL file metadata") .len(); let mut qmdl_reader = QmdlReader::new(qmdl_file, Some(file_size as usize)); - let mut qmdl_stream = pin!(qmdl_reader - .as_stream() - .try_filter(|container| future::ready(container.data_type == DataType::UserSpace))); + let mut qmdl_stream = pin!( + qmdl_reader + .as_stream() + .try_filter(|container| future::ready(container.data_type == DataType::UserSpace)) + ); let mut skipped_reasons: HashMap = HashMap::new(); let mut total_messages = 0; let mut warnings = 0; diff --git a/bin/src/daemon.rs b/bin/src/daemon.rs index c140388..ac5aa8c 100644 --- a/bin/src/daemon.rs +++ b/bin/src/daemon.rs @@ -11,26 +11,26 @@ mod server; mod stats; use std::net::SocketAddr; -use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; +use std::sync::atomic::{AtomicBool, Ordering}; use crate::config::{parse_args, parse_config}; use crate::diag::run_diag_read_thread; use crate::error::RayhunterError; use crate::pcap::get_pcap; use crate::qmdl_store::RecordingStore; -use crate::server::{get_config, get_qmdl, get_zip, serve_static, set_config, ServerState}; +use crate::server::{ServerState, get_config, get_qmdl, get_zip, serve_static, set_config}; use crate::stats::{get_qmdl_manifest, get_system_stats}; use analysis::{ - get_analysis_status, run_analysis_thread, start_analysis, AnalysisCtrlMessage, AnalysisStatus, + AnalysisCtrlMessage, AnalysisStatus, get_analysis_status, run_analysis_thread, start_analysis, }; +use axum::Router; use axum::response::Redirect; use axum::routing::{get, post}; -use axum::Router; use diag::{ - delete_all_recordings, delete_recording, get_analysis_report, start_recording, stop_recording, - DiagDeviceCtrlMessage, + DiagDeviceCtrlMessage, delete_all_recordings, delete_recording, get_analysis_report, + start_recording, stop_recording, }; use log::{error, info}; use qmdl_store::RecordingStoreError; @@ -38,7 +38,7 @@ use rayhunter::diag_device::DiagDevice; use tokio::net::TcpListener; use tokio::select; use tokio::sync::mpsc::{self, Sender}; -use tokio::sync::{oneshot, RwLock}; +use tokio::sync::{RwLock, oneshot}; use tokio::task::JoinHandle; use tokio_util::task::TaskTracker; diff --git a/bin/src/diag.rs b/bin/src/diag.rs index 51ea09e..0454a27 100644 --- a/bin/src/diag.rs +++ b/bin/src/diag.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use axum::body::Body; use axum::extract::{Path, State}; -use axum::http::header::CONTENT_TYPE; use axum::http::StatusCode; +use axum::http::header::CONTENT_TYPE; use axum::response::{IntoResponse, Response}; use futures::{StreamExt, TryStreamExt}; use log::{debug, error, info, warn}; @@ -13,8 +13,8 @@ use rayhunter::diag::DataType; use rayhunter::diag_device::DiagDevice; use rayhunter::qmdl::QmdlWriter; use tokio::fs::File; -use tokio::sync::mpsc::{Receiver, Sender}; use tokio::sync::RwLock; +use tokio::sync::mpsc::{Receiver, Sender}; use tokio_util::io::ReaderStream; use tokio_util::task::TaskTracker; @@ -209,13 +209,13 @@ pub async fn delete_recording( return Err(( StatusCode::BAD_REQUEST, format!("no recording with name {qmdl_name}"), - )) + )); } Err(e) => { return Err(( StatusCode::INTERNAL_SERVER_ERROR, format!("couldn't delete recording: {e}"), - )) + )); } Ok(_) => {} } diff --git a/bin/src/display/generic_framebuffer.rs b/bin/src/display/generic_framebuffer.rs index 14d50ad..132e14f 100644 --- a/bin/src/display/generic_framebuffer.rs +++ b/bin/src/display/generic_framebuffer.rs @@ -1,4 +1,4 @@ -use image::{codecs::gif::GifDecoder, imageops::FilterType, AnimationDecoder, DynamicImage}; +use image::{AnimationDecoder, DynamicImage, codecs::gif::GifDecoder, imageops::FilterType}; use std::io::Cursor; use std::time::Duration; @@ -13,7 +13,7 @@ use tokio_util::task::TaskTracker; use std::thread::sleep; -use include_dir::{include_dir, Dir}; +use include_dir::{Dir, include_dir}; #[derive(Copy, Clone)] pub struct Dimensions { diff --git a/bin/src/display/orbic.rs b/bin/src/display/orbic.rs index 474ece5..787bb93 100644 --- a/bin/src/display/orbic.rs +++ b/bin/src/display/orbic.rs @@ -1,6 +1,6 @@ use crate::config; -use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use crate::display::DisplayState; +use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use tokio::sync::mpsc::Receiver; use tokio::sync::oneshot; diff --git a/bin/src/display/tplink.rs b/bin/src/display/tplink.rs index 74945e8..4c330ef 100644 --- a/bin/src/display/tplink.rs +++ b/bin/src/display/tplink.rs @@ -4,7 +4,7 @@ use tokio::sync::oneshot; use tokio_util::task::TaskTracker; use crate::config; -use crate::display::{tplink_framebuffer, tplink_onebit, DisplayState}; +use crate::display::{DisplayState, tplink_framebuffer, tplink_onebit}; use std::fs; diff --git a/bin/src/display/tplink_framebuffer.rs b/bin/src/display/tplink_framebuffer.rs index 2475e8e..95255eb 100644 --- a/bin/src/display/tplink_framebuffer.rs +++ b/bin/src/display/tplink_framebuffer.rs @@ -3,8 +3,8 @@ use std::io::Write; use std::os::fd::AsRawFd; use crate::config; -use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use crate::display::DisplayState; +use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use tokio::sync::mpsc::Receiver; use tokio::sync::oneshot; diff --git a/bin/src/display/wingtech.rs b/bin/src/display/wingtech.rs index be228cb..10fb54c 100644 --- a/bin/src/display/wingtech.rs +++ b/bin/src/display/wingtech.rs @@ -5,8 +5,8 @@ /// WT_PRODUCTION_VERSION=CT2MHS01_0.04.55 /// WT_HARDWARE_VERSION=89323_1_20 use crate::config; -use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use crate::display::DisplayState; +use crate::display::generic_framebuffer::{self, Dimensions, GenericFramebuffer}; use tokio::sync::mpsc::Receiver; use tokio::sync::oneshot; diff --git a/bin/src/dummy_analyzer.rs b/bin/src/dummy_analyzer.rs index 66876b7..8b4ddc8 100644 --- a/bin/src/dummy_analyzer.rs +++ b/bin/src/dummy_analyzer.rs @@ -15,7 +15,9 @@ impl Analyzer for TestAnalyzer { } fn get_description(&self) -> Cow { - Cow::from("Always returns true, if you are seeing this you are either a developer or you are about to have problems.") + Cow::from( + "Always returns true, if you are seeing this you are either a developer or you are about to have problems.", + ) } fn analyze_information_element(&mut self, ie: &InformationElement) -> Option { diff --git a/bin/src/pcap.rs b/bin/src/pcap.rs index 1911aee..fde865c 100644 --- a/bin/src/pcap.rs +++ b/bin/src/pcap.rs @@ -3,8 +3,8 @@ use crate::ServerState; use anyhow::Error; use axum::body::Body; use axum::extract::{Path, State}; -use axum::http::header::CONTENT_TYPE; use axum::http::StatusCode; +use axum::http::header::CONTENT_TYPE; use axum::response::{IntoResponse, Response}; use log::error; use rayhunter::diag::DataType; @@ -12,7 +12,7 @@ use rayhunter::gsmtap_parser; use rayhunter::pcap::GsmtapPcapWriter; use rayhunter::qmdl::QmdlReader; use std::sync::Arc; -use tokio::io::{duplex, AsyncRead, AsyncWrite}; +use tokio::io::{AsyncRead, AsyncWrite, duplex}; use tokio_util::io::ReaderStream; // Streams a pcap file chunk-by-chunk to the client by reading the QMDL data diff --git a/bin/src/qmdl_store.rs b/bin/src/qmdl_store.rs index f04550d..389ebf8 100644 --- a/bin/src/qmdl_store.rs +++ b/bin/src/qmdl_store.rs @@ -6,7 +6,7 @@ use rayhunter::util::RuntimeMetadata; use serde::{Deserialize, Serialize}; use thiserror::Error; use tokio::{ - fs::{self, try_exists, File, OpenOptions}, + fs::{self, File, OpenOptions, try_exists}, io::AsyncWriteExt, }; @@ -369,9 +369,11 @@ mod tests { RecordingStore::read_manifest(dir.path()).await.unwrap(), store.manifest ); - assert!(store.manifest.entries[entry_index] - .last_message_time - .is_none()); + assert!( + store.manifest.entries[entry_index] + .last_message_time + .is_none() + ); store .update_entry_qmdl_size(entry_index, 1000) diff --git a/bin/src/server.rs b/bin/src/server.rs index edf16a9..179e688 100644 --- a/bin/src/server.rs +++ b/bin/src/server.rs @@ -1,21 +1,21 @@ use anyhow::Error; -use async_zip::tokio::write::ZipFileWriter; use async_zip::Compression; use async_zip::ZipEntryBuilder; +use async_zip::tokio::write::ZipFileWriter; +use axum::Json; use axum::body::Body; use axum::extract::Path; use axum::extract::State; use axum::http::header::{self, CONTENT_LENGTH, CONTENT_TYPE}; use axum::http::{HeaderValue, StatusCode}; use axum::response::{IntoResponse, Response}; -use axum::Json; -use include_dir::{include_dir, Dir}; +use include_dir::{Dir, include_dir}; use log::error; use std::sync::Arc; use tokio::fs::write; -use tokio::io::{copy, duplex, AsyncReadExt}; +use tokio::io::{AsyncReadExt, copy, duplex}; use tokio::sync::mpsc::Sender; -use tokio::sync::{oneshot, RwLock}; +use tokio::sync::{RwLock, oneshot}; use tokio_util::compat::FuturesAsyncWriteCompatExt; use tokio_util::io::ReaderStream; @@ -23,7 +23,7 @@ use crate::analysis::{AnalysisCtrlMessage, AnalysisStatus}; use crate::config::Config; use crate::pcap::generate_pcap_data; use crate::qmdl_store::RecordingStore; -use crate::{display, DiagDeviceCtrlMessage}; +use crate::{DiagDeviceCtrlMessage, display}; pub struct ServerState { pub config_path: String, diff --git a/bin/src/stats.rs b/bin/src/stats.rs index 6867e62..6fdcfb4 100644 --- a/bin/src/stats.rs +++ b/bin/src/stats.rs @@ -3,9 +3,9 @@ use std::sync::Arc; use crate::qmdl_store::ManifestEntry; use crate::server::ServerState; +use axum::Json; use axum::extract::State; use axum::http::StatusCode; -use axum::Json; use log::error; use rayhunter::util::RuntimeMetadata; use serde::Serialize; diff --git a/lib/Cargo.toml b/lib/Cargo.toml index a50eee2..d333cd5 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rayhunter" version = "0.4.0" -edition = "2021" +edition = "2024" description = "Realtime cellular data decoding and analysis for IMSI catcher detection" diff --git a/lib/src/analysis/imsi_requested.rs b/lib/src/analysis/imsi_requested.rs index 90c01f2..3861687 100644 --- a/lib/src/analysis/imsi_requested.rs +++ b/lib/src/analysis/imsi_requested.rs @@ -1,8 +1,8 @@ use std::borrow::Cow; +use pycrate_rs::nas::NASMessage; use pycrate_rs::nas::emm::EMMMessage; use pycrate_rs::nas::generated::emm::emm_identity_request::IDTypeV; -use pycrate_rs::nas::NASMessage; use super::analyzer::{Analyzer, Event, EventType, Severity}; use super::information_element::{InformationElement, LteInformationElement}; diff --git a/lib/src/analysis/information_element.rs b/lib/src/analysis/information_element.rs index f885c8d..fdd7ae7 100644 --- a/lib/src/analysis/information_element.rs +++ b/lib/src/analysis/information_element.rs @@ -86,7 +86,7 @@ impl TryFrom<&GsmtapMessage> for InformationElement { _ => { return Err(InformationElementError::UnsupportedGsmtapType( gsmtap_msg.header.gsmtap_type, - )) + )); } }; Ok(InformationElement::LTE(Box::new(lte))) diff --git a/lib/src/analysis/priority_2g_downgrade.rs b/lib/src/analysis/priority_2g_downgrade.rs index b408a53..2c36525 100644 --- a/lib/src/analysis/priority_2g_downgrade.rs +++ b/lib/src/analysis/priority_2g_downgrade.rs @@ -4,8 +4,8 @@ use super::analyzer::{Analyzer, Event, EventType, Severity}; use super::information_element::{InformationElement, LteInformationElement}; use telcom_parser::lte_rrc::{ BCCH_DL_SCH_MessageType, BCCH_DL_SCH_MessageType_c1, CellReselectionPriority, - SystemInformationBlockType7, SystemInformationCriticalExtensions, SystemInformation_r8_IEsSib_TypeAndInfo, SystemInformation_r8_IEsSib_TypeAndInfo_Entry, + SystemInformationBlockType7, SystemInformationCriticalExtensions, }; /// Based on heuristic T7 from Shinjo Park's "Why We Cannot Win". @@ -41,7 +41,9 @@ impl Analyzer for LteSib6And7DowngradeAnalyzer { } fn get_description(&self) -> Cow { - Cow::from("Tests for LTE cells broadcasting a SIB type 6 and 7 which include 2G/3G frequencies with higher priorities.") + Cow::from( + "Tests for LTE cells broadcasting a SIB type 6 and 7 which include 2G/3G frequencies with higher priorities.", + ) } fn analyze_information_element( diff --git a/lib/src/diag_device.rs b/lib/src/diag_device.rs index 5f2d080..67686b3 100644 --- a/lib/src/diag_device.rs +++ b/lib/src/diag_device.rs @@ -1,6 +1,6 @@ use crate::diag::{ - build_log_mask_request, DataType, DiagParsingError, LogConfigRequest, LogConfigResponse, - Message, MessagesContainer, Request, RequestContainer, ResponsePayload, CRC_CCITT, + CRC_CCITT, DataType, DiagParsingError, LogConfigRequest, LogConfigResponse, Message, + MessagesContainer, Request, RequestContainer, ResponsePayload, build_log_mask_request, }; use crate::hdlc::hdlc_encapsulate; use crate::log_codes; diff --git a/lib/src/gsmtap_parser.rs b/lib/src/gsmtap_parser.rs index 2eb049b..b258626 100644 --- a/lib/src/gsmtap_parser.rs +++ b/lib/src/gsmtap_parser.rs @@ -47,7 +47,7 @@ fn log_to_gsmtap(value: LogBody) -> Result, GsmtapParserEr return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum( ext_header_version, pdu, - )) + )); } }, 0x09 | 0x0c => match packet.get_pdu_num() { @@ -63,7 +63,7 @@ fn log_to_gsmtap(value: LogBody) -> Result, GsmtapParserEr return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum( ext_header_version, pdu, - )) + )); } }, 0x0e..=0x10 => match packet.get_pdu_num() { @@ -79,7 +79,7 @@ fn log_to_gsmtap(value: LogBody) -> Result, GsmtapParserEr return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum( ext_header_version, pdu, - )) + )); } }, 0x13 | 0x1a | 0x1b => match packet.get_pdu_num() { @@ -102,7 +102,7 @@ fn log_to_gsmtap(value: LogBody) -> Result, GsmtapParserEr return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum( ext_header_version, pdu, - )) + )); } }, 0x14 | 0x18 | 0x19 => match packet.get_pdu_num() { @@ -125,13 +125,13 @@ fn log_to_gsmtap(value: LogBody) -> Result, GsmtapParserEr return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum( ext_header_version, pdu, - )) + )); } }, _ => { return Err(GsmtapParserError::InvalidLteRrcOtaExtHeaderVersion( ext_header_version, - )) + )); } }; let mut header = GsmtapHeader::new(gsmtap_type); diff --git a/lib/src/pcap.rs b/lib/src/pcap.rs index 3e0d59d..7d6f1d9 100644 --- a/lib/src/pcap.rs +++ b/lib/src/pcap.rs @@ -5,10 +5,10 @@ use crate::gsmtap::GsmtapMessage; use chrono::prelude::*; use deku::prelude::*; +use pcap_file_tokio::pcapng::PcapNgWriter; use pcap_file_tokio::pcapng::blocks::enhanced_packet::EnhancedPacketBlock; use pcap_file_tokio::pcapng::blocks::interface_description::InterfaceDescriptionBlock; use pcap_file_tokio::pcapng::blocks::section_header::{SectionHeaderBlock, SectionHeaderOption}; -use pcap_file_tokio::pcapng::PcapNgWriter; use pcap_file_tokio::{Endianness, PcapError}; use std::borrow::Cow; use thiserror::Error; diff --git a/lib/src/qmdl.rs b/lib/src/qmdl.rs index 0e89d62..386dee2 100644 --- a/lib/src/qmdl.rs +++ b/lib/src/qmdl.rs @@ -3,7 +3,7 @@ //! QmdlReader and QmdlWriter can read and write MessagesContainers to and from //! QMDL files. -use crate::diag::{DataType, HdlcEncapsulatedMessage, MessagesContainer, MESSAGE_TERMINATOR}; +use crate::diag::{DataType, HdlcEncapsulatedMessage, MESSAGE_TERMINATOR, MessagesContainer}; use futures::TryStream; use log::error; diff --git a/lib/tests/test_lte_parsing.rs b/lib/tests/test_lte_parsing.rs index f1e7a15..85ba292 100644 --- a/lib/tests/test_lte_parsing.rs +++ b/lib/tests/test_lte_parsing.rs @@ -133,7 +133,9 @@ fn test_lte_rrc_ota() { let (_, gsmtap_msg) = gsmtap_parser::parse(parsed).unwrap().unwrap(); assert_eq!( &gsmtap_msg.payload, - &[0x40, 0x85, 0x8e, 0xc4, 0xe5, 0xbf, 0xe0, 0x50, 0xdc, 0x29, 0x15, 0x16, 0x00,] + &[ + 0x40, 0x85, 0x8e, 0xc4, 0xe5, 0xbf, 0xe0, 0x50, 0xdc, 0x29, 0x15, 0x16, 0x00, + ] ); assert_eq!(gsmtap_msg.header.packet_type, 13); assert_eq!(gsmtap_msg.header.timeslot, 0); diff --git a/rootshell/Cargo.toml b/rootshell/Cargo.toml index 6703ba4..6b27ab6 100644 --- a/rootshell/Cargo.toml +++ b/rootshell/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rootshell" version = "0.4.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/telcom-parser/Cargo.toml b/telcom-parser/Cargo.toml index 5c99a41..d3ea146 100644 --- a/telcom-parser/Cargo.toml +++ b/telcom-parser/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "telcom-parser" version = "0.4.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/telcom-parser/src/lib.rs b/telcom-parser/src/lib.rs index 8fc1f27..b58ae02 100644 --- a/telcom-parser/src/lib.rs +++ b/telcom-parser/src/lib.rs @@ -1,4 +1,4 @@ -use asn1_codecs::{uper::UperCodec, PerCodecData, PerCodecError}; +use asn1_codecs::{PerCodecData, PerCodecError, uper::UperCodec}; use thiserror::Error; #[allow(warnings, unused, unreachable_patterns, non_camel_case_types)] pub mod lte_rrc; diff --git a/telcom-parser/tests/lte_rrc_test.rs b/telcom-parser/tests/lte_rrc_test.rs index c475eb5..e2340f1 100644 --- a/telcom-parser/tests/lte_rrc_test.rs +++ b/telcom-parser/tests/lte_rrc_test.rs @@ -1,4 +1,4 @@ -use asn1_codecs::{uper::UperCodec, PerCodecData}; +use asn1_codecs::{PerCodecData, uper::UperCodec}; use telcom_parser::lte_rrc::BCCH_DL_SCH_Message; fn hex_to_bin(hex: &str) -> Vec {