move structs to structs.rs, add get_home(), i hate perms i hate perms i hate perms i hate perms

This commit is contained in:
SadlyNotSappho 2023-09-29 11:55:16 -07:00
parent efe9e18692
commit eeaf79dc13
3 changed files with 144 additions and 39 deletions

View File

@ -1,33 +1,29 @@
pub struct Data {
pub vulnerable_folders: Vec<Folder>,
pub pinged_home: bool,
pub known_malware: Vec<Malware>,
pub cam_access: bool,
pub mic_access: bool,
}
pub mod structs;
pub struct Folder {
pub path: String,
pub r#type: FolderType,
pub name: String
}
use std::process;
pub enum FolderType {
ApplicationData,
Binary,
SystemData,
Kernel
}
pub struct Malware {
pub r#type: Vec<MalwareType>,
pub name: String,
}
pub enum MalwareType {
DataThief, // sells data to ad companies (cough cough google chrome cough cough)
LoginStealer, // fuckin skyblock mods, probably
TrojanHorse, // pretends to be something its not (cough cough google chrome cough cough)
Ransomware, // encrypts your files and makes you pay to get them back
Spyware, // parental controls apps
pub fn get_home() -> String {
match std::env::consts::OS {
"linux" => match std::env::var("HOME") {
Ok(var) => var,
Err(why) => {
eprintln!("lib::get_home: Couldn't get $HOME on Linux: {why:?}");
process::exit(1);
}
},
"windows" => match std::env::var("userprofile") {
Ok(var) => var,
Err(why) => {
eprintln!("lib::get_home: Couldn't get $userprofile on Windows: {why:?}");
process::exit(1)
}
},
_ => match std::env::var("HOME") {
Ok(var) => var,
Err(why) => {
eprintln!("lib::get_home: Couldn't get $HOME on other OS: {why:?}");
process::exit(1)
}
},
}
}

View File

@ -1,9 +1,14 @@
use std::{fmt::Write, thread, time::Duration, sync::mpsc};
use std::{fmt::Write, thread, time::Duration, sync::mpsc, process, fs};
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
use security_checker::{structs::Folder, get_home};
fn main() {
println!("Running SCAM...");
// TODO: add support for other OSes
if std::env::consts::OS != "linux" {
println!("This currently only supports linux. Sorry!");
process::exit(1)
}
println!("SCAMing you...");
let pb = ProgressBar::new(100);
pb.set_style(ProgressStyle::with_template("[{elapsed_precise}] [{wide_bar:.cyan/blue}] {pos}/{len} ({eta})")
.unwrap()
@ -20,14 +25,28 @@ fn main() {
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("hi i ran :D");
thread::sleep(Duration::from_secs(60));
tx.send(val).unwrap();
let mut out = vec![];
let folders = Folder::linux();
for mut folder in folders {
folder.path = folder.path.replace('~', &get_home()[..]);
// check if we have write perms for all of the folders, if so, push to out
let md = fs::metadata(&folder.path).unwrap();
let perms = md.permissions();
let readonly = perms.readonly();
println!("{readonly} - {}", folder.path);
if !readonly {
println!("can write to {}", folder.path);
out.push(folder)
}
};
tx.send(out)
});
pb.finish();
println!("Ran SCAM. Here's your output!")
println!("Ran SCAM. Here's your output!");
// let recieved = rx.recv().unwrap();
// println!("{recieved:?}");
let recieved = rx.recv().unwrap();
println!("{recieved:?}");
}

90
src/structs.rs Normal file
View File

@ -0,0 +1,90 @@
pub struct Data {
pub vulnerable_folders: Vec<Folder>,
pub pinged_home: bool,
pub known_malware: Vec<Malware>,
pub cam_access: bool,
pub mic_access: bool,
pub root: bool,
}
#[derive(Debug)]
pub struct Folder {
pub path: String,
pub r#type: FolderType,
pub contains: String,
}
#[derive(Debug)]
pub enum FolderType {
ApplicationData,
Binary,
SystemData,
Kernel,
}
pub struct Malware {
pub r#type: Vec<MalwareType>,
pub name: String,
}
pub enum MalwareType {
DataThief, // sells data to ad companies (cough cough google chrome cough cough)
LoginStealer, // fuckin skyblock mods, probably
TrojanHorse, // pretends to be something its not (cough cough google chrome cough cough)
Ransomware, // encrypts your files and makes you pay to get them back
Spyware, // parental controls apps
}
impl Folder {
pub fn linux() -> Vec<Folder> {
vec![
// system folders
Folder {
path: String::from("/usr/bin"),
r#type: FolderType::Binary,
contains: "Installed Programs".to_string(),
},
Folder {
path: "/boot".to_string(),
r#type: FolderType::Kernel,
contains: "Boot Files, Kernel".to_string(),
},
Folder {
path: "/lib".to_string(),
r#type: FolderType::SystemData,
contains: "Kernel Modules, Libraries".to_string(),
},
Folder {
path: "/usr/lib".to_string(),
r#type: FolderType::SystemData,
contains: "Libraries, Object Files".to_string(),
},
Folder {
path: "/dev".to_string(),
r#type: FolderType::SystemData,
contains: "Access To All Devices".to_string(),
},
Folder {
path: "/tmp".to_string(),
r#type: FolderType::ApplicationData,
contains: "Temporary Application Data".to_string()
},
// user specific files
Folder {
path: "~/.config".to_string(),
r#type: FolderType::ApplicationData,
contains: "Permanent Application Data, Login Info".to_string()
},
Folder {
path: "~/.local/share".to_string(),
r#type: FolderType::ApplicationData,
contains: String::from("Permanent Application Data, Login Info")
},
Folder {
path: "~/.cache".to_string(),
r#type: FolderType::ApplicationData,
contains: "Cached Data From Applications".to_string()
}
]
}
}