mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-09 06:21:54 -07:00
Bump Rust edition to 2024
Includes new cargo fmt changes
This commit is contained in:
committed by
Markus Unterwaditzer
parent
25978a4da4
commit
5019f2a9d1
+1
-1
@@ -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.
|
||||
|
||||
+5
-3
@@ -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
|
||||
|
||||
+6
-4
@@ -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<String, i32> = HashMap::new();
|
||||
let mut total_messages = 0;
|
||||
let mut warnings = 0;
|
||||
|
||||
+7
-7
@@ -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;
|
||||
|
||||
|
||||
+4
-4
@@ -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(_) => {}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,7 +15,9 @@ impl Analyzer for TestAnalyzer {
|
||||
}
|
||||
|
||||
fn get_description(&self) -> Cow<str> {
|
||||
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<Event> {
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
+6
-6
@@ -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,
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -86,7 +86,7 @@ impl TryFrom<&GsmtapMessage> for InformationElement {
|
||||
_ => {
|
||||
return Err(InformationElementError::UnsupportedGsmtapType(
|
||||
gsmtap_msg.header.gsmtap_type,
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
Ok(InformationElement::LTE(Box::new(lte)))
|
||||
|
||||
@@ -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<str> {
|
||||
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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -47,7 +47,7 @@ fn log_to_gsmtap(value: LogBody) -> Result<Option<GsmtapMessage>, 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<Option<GsmtapMessage>, 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<Option<GsmtapMessage>, 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<Option<GsmtapMessage>, 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<Option<GsmtapMessage>, GsmtapParserEr
|
||||
return Err(GsmtapParserError::InvalidLteRrcOtaHeaderPduNum(
|
||||
ext_header_version,
|
||||
pdu,
|
||||
))
|
||||
));
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
return Err(GsmtapParserError::InvalidLteRrcOtaExtHeaderVersion(
|
||||
ext_header_version,
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut header = GsmtapHeader::new(gsmtap_type);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<u8> {
|
||||
|
||||
Reference in New Issue
Block a user