sharp share sorting utility
This commit is contained in:
7
sharpshares_sorter/Cargo.lock
generated
Normal file
7
sharpshares_sorter/Cargo.lock
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "sharpshares_sorter"
|
||||
version = "0.1.0"
|
||||
8
sharpshares_sorter/Cargo.toml
Normal file
8
sharpshares_sorter/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "sharpshares_sorter"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
56
sharpshares_sorter/src/main.rs
Normal file
56
sharpshares_sorter/src/main.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use std::fs;
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 3{
|
||||
print!("
|
||||
Usage:
|
||||
sharpshares_sorter /path/to/sharpshares/output /path/to/save/output
|
||||
");
|
||||
}
|
||||
else{
|
||||
let mut writable: Vec<&str> = Vec::new();
|
||||
let mut readable: Vec<&str> = Vec::new();
|
||||
let mut outfile = fs::File::create(&args[2]).expect("error creating output file");
|
||||
let shares = fs::read_to_string(&args[1]).expect("error reading shares file");
|
||||
let shares_vec: Vec<&str> = shares.split("\n").collect();
|
||||
for share in shares_vec{
|
||||
if share.len() != 0{
|
||||
let share_vec: Vec<&str> = share.split(" ").collect();
|
||||
let permission = share_vec[0];
|
||||
let share_name = share_vec[1];
|
||||
if permission.contains("r"){
|
||||
let share_name_trimmed = share_name.trim_end();
|
||||
readable.push(share_name_trimmed);
|
||||
}
|
||||
if permission.contains("w"){
|
||||
let share_name_trimmed = share_name.trim_end();
|
||||
writable.push(share_name_trimmed);
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("writable!");
|
||||
writeln!(outfile, "********************************Writable*********************************").expect("error writing writable to outfile");
|
||||
writeln!(outfile, "++++++++++++++++++++++++++++++++admin access+++++++++++++++++++++++++++++").expect("error writing admin access to outfile");
|
||||
for share in &writable{
|
||||
if share.contains("C$") || share.contains("c$") || share.contains("Admin$"){
|
||||
println!("{}", share);
|
||||
writeln!(outfile, "{}", share).expect("error writing admin share to outfile");
|
||||
}
|
||||
}
|
||||
writeln!(outfile, "++++++++++++++++++++++++++++++END OF ADMIN ACCESS++++++++++++++++++++++++++").expect("error writing admin ending porint");
|
||||
for share in &writable{
|
||||
println!("{}",share);
|
||||
writeln!(outfile, "{}", share).expect("error writing writable shares to outfile");
|
||||
}
|
||||
println!("===========================================================");
|
||||
println!("readable!");
|
||||
writeln!(outfile, "*******************************readable**********************************").expect("error writing readable to outfile");
|
||||
for share in readable{
|
||||
println!("{}", share);
|
||||
writeln!(outfile,"{}", share).expect("error writing readable share to outfile");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user