mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-06-08 06:01:53 -07:00
first commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/target
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"fcntl.h": "c"
|
||||
}
|
||||
}
|
||||
Generated
+40
@@ -0,0 +1,40 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "diag"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"nix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.150"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.27.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "diag"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2.150"
|
||||
nix = { version = "0.27.1", features = ["ioctl"]}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
cross rustc --target armv7-unknown-linux-gnueabihf -- -C target-feature=+crt-static
|
||||
adb push target/armv7-unknown-linux-gnueabihf/debug/diag /tmp/diag
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
use std::fs::File;
|
||||
use std::mem;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
fn main() {
|
||||
const DIAG_IOCTL_SWITCH_LOGGING: u32 = 7;
|
||||
const MEMORY_DEVICE_MODE: i32 = 2;
|
||||
const DIAG_IOCTL_REMOTE_DEV: u32 = 32;
|
||||
|
||||
let mut mode_param: [i32; 3] = [MEMORY_DEVICE_MODE, -1, 0]; // diag_logging_mode_param_t
|
||||
let use_mdm: i32 = 0;
|
||||
|
||||
let diag_fd: i32;
|
||||
|
||||
println!("Initializing DIAG");
|
||||
|
||||
let diag_result = File::options().read(true).write(true).open("/dev/diag");
|
||||
match &diag_result {
|
||||
Ok(file) => {
|
||||
diag_fd = file.as_raw_fd();
|
||||
}
|
||||
Err(_) => {
|
||||
println!("error opening diag device.");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsafe {
|
||||
if libc::ioctl(diag_fd, DIAG_IOCTL_SWITCH_LOGGING, MEMORY_DEVICE_MODE, 0, 0, 0) < 0
|
||||
&& libc::ioctl(
|
||||
diag_fd,
|
||||
DIAG_IOCTL_SWITCH_LOGGING,
|
||||
&mut mode_param as *mut _,
|
||||
mem::size_of::<[i32; 3]>(), 0, 0, 0, 0
|
||||
) < 0
|
||||
{
|
||||
println!("ioctl failed 1");
|
||||
//std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsafe {
|
||||
if libc::ioctl(diag_fd, DIAG_IOCTL_REMOTE_DEV, &use_mdm as *const i32) < 0 {
|
||||
println!("ioctl failed 2");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
println!("successfully opened diag device");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user