diff --git a/src/config.toml b/src/config.toml new file mode 100644 index 0000000..b836158 --- /dev/null +++ b/src/config.toml @@ -0,0 +1,7 @@ +hostname = "mein-iserv.de" +session-cookie = "markus" + +[target] +ip = 10.0.0.0 +room = 23 +compilation = 2 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 1147bd7..4a9bddf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,21 +4,21 @@ use clap::Parser; #[clap(author, version, about, long_about = None)] struct Args { #[clap(short, long)] - hostname: String, + hostname: Option, //example: "IServSAT=mvuvFvCZSlpvuwhk0mmNwF1NKEQypM4d; IServSession=xEPqyJO1a5nsVd34HEpbPqQGMMQKapvw; nav-show-additional-modules=true; PHPSESSID=mchbrl11epjnnp851q0i4rt8rc" #[clap(short, long)] - session_cookie: String, + session_cookie: Option, #[clap(long)] - target_ip: String, + target_ip: Option, #[clap(long)] - target_room: u16, + target_room: Option, #[clap(long)] target_compilation: Option, } macro_rules! print_banner { ($f: expr, $($arg: expr),*) => { - println!(concat!("-----------------------------------\n", $f, "\n-----------------------------------"), $($arg),*) + println!(concat!("----------------------------------------\n", $f, "\n----------------------------------------"), $($arg),*) }; } @@ -37,7 +37,7 @@ fn ipad(args: &Args) -> Result<(), Box> { let header = ("Cookie", &args.session_cookie); let client = reqwest::blocking::Client::new(); let resp = client - .get(format!("https://{}/iserv/admin/hosts", args.hostname)) + .get(format!("https://{}/iserv/admin/hosts", args.hostname.unwrap())) .header(header.0, header.1) .query(¶ms) .send()?; @@ -55,9 +55,9 @@ fn ipad(args: &Args) -> Result<(), Box> { // skip rest of loop when no entry appeared if json_part == "null" { println!( -"################################### +"######################################## No new host: skipping (Retry in 5s) -################################### +######################################## "); //sleep for 5 seconds std::thread::sleep(std::time::Duration::from_secs(5)); @@ -76,7 +76,7 @@ No new host: skipping (Retry in 5s) return Ok(()) } let plain = &resp.text()?; - let mut form_ip: &str = &args.target_ip; //default + let mut form_ip: &str = &args.target_ip; let form_name = squeeze_html_form(plain, "name=\"host[name]\"", "value=\"", "\""); let form_tags = squeeze_html_form(plain, "name=\"host[tags][]\"", "value=\"", "\""); let form_mac = squeeze_html_form(plain, "name=\"host[mac]\"", "value=\"", "\"");