Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heuristics #34

Merged
merged 10 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ rustflags = ["-C", "target-feature=+crt-static"]

[alias]
test_pc = "test --target=x86_64-unknown-linux-gnu"
build_pc = "build --target=x86_64-unknown-linux-gnu"


[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

members = [
"orca",
"wavehunter",
"rayhunter",
]
resolver = "2"
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
# Orca
# Rayhunter

```
@@@@@@@ @@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@@ @@@@@@@@ @@@@@@@
@@! @@@ @@! @@@ @@! !@@ @@! @@@ @@! @@@ @@!@!@@@ @@! @@! @@! @@@
@!@!!@! @!@!@!@! !@!@! @!@!@!@! @!@ !@! @!@@!!@! @!! @!!!:! @!@!!@!
!!: :!! !!: !!! !!: !!: !!! !!: !!! !!: !!! !!: !!: !!: :!!
: : : : : : .: : : : :.:: : :: : : : :: ::: : : :



u. .u .
...ue888b .d88B :@8c . u
888R Y888r ="8888f8888r .udR88N us888u.
888R I888> 4888>'88" <888'888k .@88 "8888"
888R I888> 4888> ' 9888 'Y" 9888 9888
888R I888> 4888> 9888 9888 9888
u8888cJ888 .d888L .+ 9888 9888 9888
"*888*P" ^"8888*" ?8888u../ 9888 9888
'Y" "Y" "8888P' "888*""888"
"P' ^Y" ^Y'


Orca Realtime Cellular Analysis

_ _ _ _ _ _ _ _
)`'-.,_)`'-.,_)`'-.,_)`'-.,_)`'-.,_)`'-.,_)`'-.,_)`'-.,_

Expand All @@ -34,7 +25,7 @@ _ _ _ _ _ _ _ _
\__;
```

IMSI Catcher Catcher for the Orbic mobile hotspot. Based on code from [QCSuper](https://github.com/P1sec/QCSuper)
Rayhunter is an IMSI Catcher Catcher for the Orbic mobile hotspot. Based on code from [QCSuper](https://github.com/P1sec/QCSuper)

**THIS CODE IS PROOF OF CONCEPT AND SHOULD NOT BE RELIED UPON IN HIGH RISK SITUATIONS**

Expand All @@ -61,8 +52,8 @@ Build for arm using `cargo build`
Run tests using `cargo test_pc`


Push the scripts in `scripts/` to /etc/init.d on device and make a directory called /data/wavehunter using `adb shell` (and sshell for your root shell if you followed the steps above)
Push the scripts in `scripts/` to /etc/init.d on device and make a directory called /data/rayhunter using `adb shell` (and sshell for your root shell if you followed the steps above)

you also need to copy `config.toml.example` to /data/wavehunter/config.toml
you also need to copy `config.toml.example` to /data/rayhunter/config.toml

Then run ./make.sh this will build the binary and push it over adb. Restart your device or run `/etc/init.d wavehunter_daemon start` on the device and you are good to go.
Then run ./make.sh this will build the binary and push it over adb. Restart your device or run `/etc/init.d/rayhunter_daemon start` on the device and you are good to go.
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cat config.toml
qmdl_store_path = "/data/wavehunter/qmdl"
qmdl_store_path = "/data/rayhunter/qmdl"
port = 8080
readonly_mode = false
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cargo build --release
adb push target/armv7-unknown-linux-gnueabihf/release/wavehunter /data/wavehunter/wavehunter
adb push target/armv7-unknown-linux-gnueabihf/release/rayhunter /data/rayhunter/rayhunter
2 changes: 1 addition & 1 deletion wavehunter/Cargo.toml → rayhunter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "wavehunter"
name = "rayhunter"
version = "0.1.0"
edition = "2021"

Expand Down
10 changes: 5 additions & 5 deletions wavehunter/src/config.rs → rayhunter/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::WavehunterError;
use crate::error::RayhunterError;

use serde::Deserialize;

Expand All @@ -19,21 +19,21 @@ pub struct Config {
impl Default for Config {
fn default() -> Self {
Config {
qmdl_store_path: "/data/wavehunter".to_string(),
qmdl_store_path: "/data/rayhunter/qmdl".to_string(),
port: 8080,
readonly_mode: false,
}
}
}

pub fn parse_config<P>(path: P) -> Result<Config, WavehunterError> where P: AsRef<std::path::Path> {
pub fn parse_config<P>(path: P) -> Result<Config, RayhunterError> where P: AsRef<std::path::Path> {
let mut config = Config::default();
if let Ok(config_file) = std::fs::read_to_string(&path) {
let parsed_config: ConfigFile = toml::from_str(&config_file)
.map_err(WavehunterError::ConfigFileParsingError)?;
.map_err(RayhunterError::ConfigFileParsingError)?;
if let Some(path) = parsed_config.qmdl_store_path { config.qmdl_store_path = path }
if let Some(port) = parsed_config.port { config.port = port }
if let Some(debug_mode) = parsed_config.readonly_mode { config.readonly_mode = debug_mode }
if let Some(readonly_mode) = parsed_config.readonly_mode { config.readonly_mode = readonly_mode }
}
Ok(config)
}
Expand Down
6 changes: 3 additions & 3 deletions wavehunter/src/diag.rs → rayhunter/src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tokio::sync::mpsc::error::TryRecvError;
use tokio::task::JoinHandle;
use tokio_util::task::TaskTracker;

use crate::error::WavehunterError;
use crate::error::RayhunterError;
use crate::qmdl_store::QmdlStore;
use crate::server::ServerState;

Expand All @@ -22,7 +22,7 @@ pub enum DiagDeviceCtrlMessage {
Exit,
}

pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut qmdl_file_rx: Receiver<DiagDeviceCtrlMessage>, qmdl_store_lock: Arc<RwLock<QmdlStore>>) -> JoinHandle<Result<(), WavehunterError>> {
pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut qmdl_file_rx: Receiver<DiagDeviceCtrlMessage>, qmdl_store_lock: Arc<RwLock<QmdlStore>>) -> JoinHandle<Result<(), RayhunterError>> {
// mpsc channel for updating QmdlStore entry filesizes. First usize is the
// index, second is the size in bytes
let (tx, mut rx) = mpsc::channel::<(usize, usize)>(1);
Expand Down Expand Up @@ -67,7 +67,7 @@ pub fn run_diag_read_thread(task_tracker: &TaskTracker, mut dev: DiagDevice, mut
// returned here. Until then, the DiagDevice has already written those messages
// to the QMDL file, so we can just ignore them.
debug!("reading response from diag device...");
let _messages = dev.read_response().map_err(WavehunterError::DiagReadError)?;
let _messages = dev.read_response().map_err(RayhunterError::DiagReadError)?;
debug!("got diag response ({} messages)", _messages.len());

// keep track of how many bytes were written to the QMDL file so we can read
Expand Down
2 changes: 1 addition & 1 deletion wavehunter/src/error.rs → rayhunter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use orca::diag_device::DiagDeviceError;
use crate::qmdl_store::QmdlStoreError;

#[derive(Error, Debug)]
pub enum WavehunterError {
pub enum RayhunterError{
#[error("Config file parsing error: {0}")]
ConfigFileParsingError(#[from] toml::de::Error),
#[error("Diag intialization error: {0}")]
Expand Down
14 changes: 7 additions & 7 deletions wavehunter/src/main.rs → rayhunter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::qmdl_store::QmdlStore;
use crate::server::{ServerState, get_qmdl, serve_static};
use crate::pcap::get_pcap;
use crate::stats::get_system_stats;
use crate::error::WavehunterError;
use crate::error::RayhunterError;

use axum::response::Redirect;
use diag::{DiagDeviceCtrlMessage, start_recording, stop_recording};
Expand Down Expand Up @@ -73,11 +73,11 @@ async fn server_shutdown_signal(server_shutdown_rx: oneshot::Receiver<()>) {

// Loads a QmdlStore if one exists, and if not, only create one if we're not in
// readonly mode.
async fn init_qmdl_store(config: &config::Config) -> Result<QmdlStore, WavehunterError> {
async fn init_qmdl_store(config: &config::Config) -> Result<QmdlStore, RayhunterError> {
match (QmdlStore::exists(&config.qmdl_store_path).await?, config.readonly_mode) {
(true, _) => Ok(QmdlStore::load(&config.qmdl_store_path).await?),
(false, false) => Ok(QmdlStore::create(&config.qmdl_store_path).await?),
(false, true) => Err(WavehunterError::NoStoreReadonlyMode(config.qmdl_store_path.clone())),
(false, true) => Err(RayhunterError::NoStoreReadonlyMode(config.qmdl_store_path.clone())),
}
}

Expand All @@ -89,7 +89,7 @@ fn run_ctrl_c_thread(
diag_device_sender: Sender<DiagDeviceCtrlMessage>,
server_shutdown_tx: oneshot::Sender<()>,
qmdl_store_lock: Arc<RwLock<QmdlStore>>
) -> JoinHandle<Result<(), WavehunterError>> {
) -> JoinHandle<Result<(), RayhunterError>> {
task_tracker.spawn(async move {
match tokio::signal::ctrl_c().await {
Ok(()) => {
Expand All @@ -114,7 +114,7 @@ fn run_ctrl_c_thread(
}

#[tokio::main]
async fn main() -> Result<(), WavehunterError> {
async fn main() -> Result<(), RayhunterError> {
env_logger::init();

let args = parse_args();
Expand All @@ -130,9 +130,9 @@ async fn main() -> Result<(), WavehunterError> {
let qmdl_file = qmdl_store_lock.write().await.new_entry().await?;
let qmdl_writer = QmdlWriter::new(qmdl_file.into_std().await);
let mut dev = DiagDevice::new(Some(qmdl_writer))
.map_err(WavehunterError::DiagInitError)?;
.map_err(RayhunterError::DiagInitError)?;
dev.config_logs()
.map_err(WavehunterError::DiagInitError)?;
.map_err(RayhunterError::DiagInitError)?;

run_diag_read_thread(&task_tracker, dev, rx, qmdl_store_lock.clone());
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/misc-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ case "$1" in
/etc/init.d/start_atfwd_daemon start
fi

if [ -f /etc/init.d/wavehunter_daemon ]
if [ -f /etc/init.d/rayhunter_daemon ]
then
/etc/init.d/wavehunter_daemon start
/etc/init.d/rayhunter_daemon start
fi

if [ -f /etc/init.d/start_stop_qti_ppp_le ]
Expand Down Expand Up @@ -72,9 +72,9 @@ case "$1" in
/etc/init.d/start_loc_launcher stop
fi

if [ -f /etc/init.d/wavehunter_daemon ]
if [ -f /etc/init.d/rayhunter_daemon ]
then
/etc/init.d/wavehunter_daemon stop
/etc/init.d/rayhunter_daemon stop
fi

if [ -f /etc/init.d/init_qcom_audio ]
Expand Down
27 changes: 27 additions & 0 deletions scripts/rayhunter_daemon
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/sshell

set -e

case "$1" in
start)
echo -n "Starting rayhunter: "
start-stop-daemon -S -b --make-pidfile --pidfile /tmp/rayhunter.pid \
--startas /bin/bash -- -c "exec /data/rayhunter/rayhunter /data/rayhunter/config.toml > /data/rayhunter/rayhunter.log 2>&1"
echo "done"
;;
stop)
echo -n "Stopping rayhunter: "
start-stop-daemon -K -p /tmp/rayhunter.pid
echo "done"
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage rayhunter_daemon { start | stop | restart }" >&2
exit 1
;;
esac

exit 0
27 changes: 0 additions & 27 deletions scripts/wavehunter_daemon

This file was deleted.

Loading