-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added check and stuff * Working on adding a new active test and diving into schemes. * slow progress on active tests * refactor structure for crates.io deployment. added `auth.rs` - unused * removed misconfigured tests from active tests * fixed version numbers * fixed version numbers 2 * Update main.rs * Update Cargo.toml * Update Cargo.toml * Update checks.rs Co-authored-by: raz <[email protected]> Co-authored-by: raz <[email protected]>
- Loading branch information
1 parent
8d8d7b3
commit 7003a0e
Showing
17 changed files
with
501 additions
and
214 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
use colored::*; | ||
use hyper::{body, Body, Client, Method, Request}; | ||
use hyper_rustls::HttpsConnectorBuilder; | ||
use std::fs::File; | ||
use std::io::{Read,Write}; | ||
use std::path::Path; | ||
|
||
|
||
const TOKEN_FILE:&str = ".cherrybomb/token.txt"; | ||
async fn sign_up(filename:&Path,dir:&Path)->bool{ | ||
/* | ||
match set_current_dir(dirs::home_dir().unwrap()){ | ||
Ok(_)=>(), | ||
Err(e)=>{ | ||
println!("{:?}",e); | ||
panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
} | ||
};*/ | ||
let mut file = match File::create(filename) { | ||
Ok(f) => f, | ||
Err(_) => { | ||
match std::fs::create_dir(dir){ | ||
Ok(_)=>{ | ||
match File::create(filename) { | ||
Ok(f)=>f, | ||
Err(e)=>{ | ||
//println!("{:?}",e); | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
} | ||
} | ||
Err(e)=>{ | ||
//println!("{:?}",e); | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
} | ||
} | ||
}; | ||
let res = match reqwest::get("https://cherrybomb.blstsecurity.com/token").await{ | ||
Ok(r)=>{ | ||
match r.text().await{ | ||
Ok(t)=>t, | ||
Err(_)=>{ | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
} | ||
}, | ||
Err(e)=>{ | ||
//println!("{:?}",e); | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
}; | ||
let json: serde_json::Value = match serde_json::from_str(&res) { | ||
Ok(j) => j, | ||
Err(_) => { | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
}; | ||
match file.write_all(json["client_token"].to_string().as_bytes()){ | ||
Ok(_)=>(), | ||
Err(_)=>{ | ||
//panic!("Could not generate a CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
} | ||
} | ||
true | ||
} | ||
async fn get_token()->String{ | ||
let mut filename = dirs::home_dir().unwrap(); | ||
filename.push(TOKEN_FILE); | ||
let dir = dirs::home_dir().unwrap(); | ||
let mut file = match File::open(&filename) { | ||
Ok(f) => f, | ||
Err(_) => { | ||
if sign_up(&filename,&dir).await{ | ||
match File::open(&filename) { | ||
Ok(f)=>f, | ||
Err(_)=>{ | ||
panic!("Could not validate the CLI token, please contact BLST at [email protected]"); | ||
} | ||
} | ||
}else{ | ||
panic!("Could not validate the CLI token, please contact BLST at [email protected]"); | ||
} | ||
/* | ||
println!( | ||
"{}", | ||
"file \"token.txt\" not found, make sure that you have it in this directory".red() | ||
); | ||
println!("{}", "to get your token go to your user details dashboard at https://www.blstsecurity.com/cherrybomb/UserDetails".purple().bold()); | ||
return false; | ||
*/ | ||
} | ||
}; | ||
let mut token = String::new(); | ||
match file.read_to_string(&mut token) { | ||
Ok(_) => (), | ||
Err(_) => { | ||
//panic!("Could not validate the CLI token, please contact BLST at [email protected]"); | ||
return String::new(); | ||
/* | ||
println!( | ||
"{}", | ||
"could not read the data from \"token.txt\", make sure the data is valid".red() | ||
); | ||
println!("{}", "to get your token go to your user details dashboard at https://www.blstsecurity.com/cherrybomb/UserDetails".purple().bold());*/ | ||
} | ||
} | ||
token | ||
} | ||
pub async fn get_access(action: &str) -> bool { | ||
let token = get_token().await; | ||
let connector = HttpsConnectorBuilder::new() | ||
.with_native_roots() | ||
.https_only() | ||
.enable_http1() | ||
.enable_http2() | ||
.build(); | ||
let client = Client::builder().build(connector); | ||
let req = Request::builder() | ||
.method(Method::POST) | ||
.uri("https://cherrybomb.blstsecurity.com/auth") | ||
.body(Body::from(format!( | ||
"{{\"client_token\":{},\"action\":\"{}\"}}", | ||
token, action | ||
).replace("\n",""))) | ||
.unwrap(); | ||
let r = match client.request(req).await { | ||
Ok(r) => r, | ||
Err(_) => { | ||
//println!("{}", "authentication request failed".red()); | ||
return false; | ||
} | ||
}; | ||
let txt = body::to_bytes(r.into_body()).await.unwrap(); | ||
let json: serde_json::Value = match serde_json::from_slice(&txt) { | ||
Ok(j) => j, | ||
Err(_) => { | ||
//panic!("Invalid CLI token, please contact BLST at [email protected]"); | ||
return false; | ||
/* | ||
println!("{}", "client_token not valid".red()); | ||
println!("{}", "to get your token go to your user details dashboard at https://www.blstsecurity.com/cherrybomb/UserDetails".purple().bold());*/ | ||
} | ||
}; | ||
match json["opt_in"].as_bool() { | ||
Some(b) => { | ||
if b { | ||
true | ||
} else { | ||
//panic!("Invalid CLI token, please contact BLST at [email protected]"); | ||
//println!("{}", json["msg"].to_string().red()); | ||
false | ||
} | ||
} | ||
None => { | ||
//panic!("Invalid CLI token, please contact BLST at [email protected]"); | ||
false | ||
/* | ||
println!( | ||
"{}", | ||
"error while parsing the response from the authenticator".red() | ||
); | ||
false*/ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ mod utils; | |
pub use utils::*; | ||
mod config; | ||
pub use config::*; | ||
mod auth; | ||
pub use auth::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
use super::*; | ||
use serde_json::json; | ||
|
||
impl<T: OAS + Serialize> ActiveScan<T> { | ||
pub async fn check_default(&self,auth:&Authorization) -> Vec<Alert> { | ||
pub async fn check_default(&self, auth: &Authorization) -> Vec<Alert> { | ||
let mut alerts = vec![]; | ||
let mut logs = AttackLog::default(); | ||
for (path, item) in self.oas.get_paths() { | ||
let urls = get_path_urls(&item, self.oas.servers()); | ||
for url in urls { | ||
/* | ||
let req = AttackRequest::builder() | ||
.uri(&url.1,&path) | ||
.uri(&url.1, &path) | ||
.method(url.0) | ||
.headers(vec![]) | ||
.parameters(vec![]) | ||
.auth(auth.clone()) | ||
.build(); | ||
if let Ok(res) = req.send_request(true).await{ | ||
if let Ok(res) = req.send_request(true).await { | ||
logs.requests.push(req); | ||
logs.responses.push(res); | ||
}else{ | ||
println!("FUCK"); | ||
}*/ | ||
alerts.push(Alert::with_certainty(Level::Low,"description","https://thingy".to_string(),Certainty::Certain)); | ||
} else { | ||
println!("request failed"); | ||
} | ||
alerts.push(Alert::with_certainty(Level::Low, "description", "https://thingy".to_string(), Certainty::Certain)); | ||
} | ||
} | ||
//println!("{:?}",logs); | ||
alerts | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.