Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #76

Merged
merged 2 commits into from
Sep 4, 2022
Merged

Dev #76

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ serde_json = "1.0"
tokio = { version = "^1.0", features = ["full"] }
futures = "0.3"
futures-util = { version = "^0.3", default-features = false, features = ["alloc"] }
cherrybomb-swagger = "^0.1"
#cherrybomb-swagger = "^0.1"
cherrybomb-swagger = {path="../swagger"}
reqwest = { version = "^0.11",default_features = false, features = ["json","rustls-tls"] }
colored = "2.0.0"
url = { version = "2" }
Expand Down
2 changes: 1 addition & 1 deletion swagger/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use swagger::*;

#[tokio::main]
async fn main() {
let f_name = "";
let f_name = "../../../Downloads/openapi (1).json";
let swagger_value: serde_json::Value =
serde_json::from_str(&std::fs::read_to_string(f_name).unwrap()).unwrap();

Expand Down
13 changes: 7 additions & 6 deletions swagger/src/scan/active/http_client/req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl AttackRequestBuilder {
}
pub fn auth(&mut self, auth: Authorization) -> &mut Self {
self.auth = auth;
self.add_auth_to_params();
self
}
pub fn method(&mut self, method: Method) -> &mut Self {
Expand All @@ -36,11 +37,10 @@ impl AttackRequestBuilder {
self.payload = payload.to_string();
self
}
pub fn add_auth_to_params(&mut self)-> &mut Self{
pub fn add_auth_to_params(&mut self){
if let Some(a) = self.auth.get_auth(){
self.parameters.push(a);
}
self
}
pub fn build(&self)->AttackRequest{
AttackRequest {
Expand Down Expand Up @@ -82,11 +82,12 @@ impl AttackRequest {
let mut query = String::from('?');
let mut path_ext = self.path.to_string();
let mut headers = vec![];
let mut payload = self.payload.clone();
for param in self.parameters.iter() {
match param.dm {
// QuePay::Payload => {
// payload.push_str(&format!("\"{}\":{},", param.name, param.value))
// }
QuePay::Payload => {
payload.push_str(&format!("\"{}\":{},", param.name, param.value))
}
QuePay::Query => query.push_str(&format!("{}={}&", param.name, param.value)),
QuePay::Path => {
path_ext =
Expand All @@ -102,7 +103,7 @@ impl AttackRequest {
}
}
query.pop();
(self.payload.clone(), query, path_ext, headers)
(payload, query, path_ext, headers)
}
pub fn get_headers(&self,payload_headers: &[MHeader]) -> HashMap<String, String> {
self.headers
Expand Down