Skip to content

Commit d1a479f

Browse files
committed
Cargo fmt
1 parent b3d71c4 commit d1a479f

File tree

15 files changed

+266
-254
lines changed

15 files changed

+266
-254
lines changed

src/cli/args.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ pub enum Opts {
7979
help = "Number of allowed http redirects"
8080
)]
8181
redirects: u32,
82-
#[structopt(long="fuzz-workers",default_value = "15", help = "The number of workers who will be involved in the fuzzing process")]
82+
#[structopt(
83+
long = "fuzz-workers",
84+
default_value = "15",
85+
help = "The number of workers who will be involved in the fuzzing process"
86+
)]
8387
fuzz_workers: usize,
8488

8589
// threads
@@ -90,7 +94,11 @@ pub enum Opts {
9094
help = "Number of workers"
9195
)]
9296
workers: usize,
93-
#[structopt(short="v", long="verbose", help="verbose mode (show sending requests)")]
97+
#[structopt(
98+
short = "v",
99+
long = "verbose",
100+
help = "verbose mode (show sending requests)"
101+
)]
94102
verbose: bool,
95103

96104
#[structopt(

src/cli/input/load_scripts.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1+
use crate::lua::runtime::{
2+
encode_ext::EncodeEXT, http_ext::HTTPEXT, payloads_ext::PayloadsEXT, utils_ext::UtilsEXT,
3+
};
14
use crate::{filename_to_string, show_msg, CliErrors, LuaRunTime, MessageLevel};
25
use glob::glob;
36
use log::error;
47
use mlua::Lua;
58
use std::path::PathBuf;
6-
use crate::lua::runtime::{
7-
http_ext::HTTPEXT,
8-
encode_ext::EncodeEXT,
9-
utils_ext::UtilsEXT,
10-
payloads_ext::PayloadsEXT,
11-
};
12-
139

1410
/// Return Vector of scripts name and code with both methods
1511
pub fn get_scripts(script_path: PathBuf) -> Vec<(String, String)> {

src/cli/startup/urls.rs

+74-64
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct UrlArgs {
1717
pub requests_limit: i32,
1818
pub delay: u64,
1919
pub fuzz_workers: usize,
20-
pub verbose: bool
20+
pub verbose: bool,
2121
}
2222

2323
pub struct TargetData {
@@ -27,77 +27,87 @@ pub struct TargetData {
2727
}
2828

2929
pub fn args_urls() -> UrlArgs {
30-
let (urls, hosts, paths, exit_after, req_opts, lotus_obj, requests_limit, delay, fuzz_workers, verbose) =
31-
match Opts::from_args() {
32-
Opts::URLS {
33-
redirects,
34-
workers,
35-
scripts_workers,
30+
let (
31+
urls,
32+
hosts,
33+
paths,
34+
exit_after,
35+
req_opts,
36+
lotus_obj,
37+
requests_limit,
38+
delay,
39+
fuzz_workers,
40+
verbose,
41+
) = match Opts::from_args() {
42+
Opts::URLS {
43+
redirects,
44+
workers,
45+
scripts_workers,
46+
timeout,
47+
script_path,
48+
output,
49+
proxy,
50+
log,
51+
urls,
52+
headers,
53+
exit_after,
54+
requests_limit,
55+
delay,
56+
fuzz_workers,
57+
verbose,
58+
} => {
59+
// setup logger
60+
init_log(log).unwrap();
61+
let req_opts = RequestOpts {
62+
headers,
63+
proxy,
3664
timeout,
65+
redirects,
66+
};
67+
let lotus_obj = Lotus {
3768
script_path,
3869
output,
39-
proxy,
40-
log,
41-
urls,
42-
headers,
70+
workers,
71+
script_workers: scripts_workers,
72+
stop_after: Arc::new(Mutex::new(1)),
73+
};
74+
let urls = get_target_urls(urls);
75+
if urls.is_err() {
76+
match urls {
77+
Err(CliErrors::EmptyStdin) => {
78+
show_msg("No input in Stdin", MessageLevel::Error);
79+
}
80+
Err(CliErrors::ReadingError) => {
81+
show_msg("Cannot Read the urls file", MessageLevel::Error);
82+
}
83+
_ => {}
84+
};
85+
std::process::exit(1);
86+
}
87+
let urls_vec = urls
88+
.unwrap()
89+
.iter()
90+
.map(|url| url.to_string())
91+
.collect::<Vec<String>>();
92+
let paths = get_target_paths(urls_vec.clone());
93+
let hosts = get_target_hosts(urls_vec.clone());
94+
(
95+
urls_vec,
96+
hosts,
97+
paths,
4398
exit_after,
99+
req_opts,
100+
lotus_obj,
44101
requests_limit,
45102
delay,
46103
fuzz_workers,
47104
verbose,
48-
} => {
49-
// setup logger
50-
init_log(log).unwrap();
51-
let req_opts = RequestOpts {
52-
headers,
53-
proxy,
54-
timeout,
55-
redirects,
56-
};
57-
let lotus_obj = Lotus {
58-
script_path,
59-
output,
60-
workers,
61-
script_workers: scripts_workers,
62-
stop_after: Arc::new(Mutex::new(1)),
63-
};
64-
let urls = get_target_urls(urls);
65-
if urls.is_err() {
66-
match urls {
67-
Err(CliErrors::EmptyStdin) => {
68-
show_msg("No input in Stdin", MessageLevel::Error);
69-
}
70-
Err(CliErrors::ReadingError) => {
71-
show_msg("Cannot Read the urls file", MessageLevel::Error);
72-
}
73-
_ => {}
74-
};
75-
std::process::exit(1);
76-
}
77-
let urls_vec = urls
78-
.unwrap()
79-
.iter()
80-
.map(|url| url.to_string())
81-
.collect::<Vec<String>>();
82-
let paths = get_target_paths(urls_vec.clone());
83-
let hosts = get_target_hosts(urls_vec.clone());
84-
(
85-
urls_vec,
86-
hosts,
87-
paths,
88-
exit_after,
89-
req_opts,
90-
lotus_obj,
91-
requests_limit,
92-
delay,
93-
fuzz_workers,
94-
verbose
95-
)
96-
}
97-
_ => {
98-
std::process::exit(1);
99-
}
100-
};
105+
)
106+
}
107+
_ => {
108+
std::process::exit(1);
109+
}
110+
};
101111

102112
UrlArgs {
103113
target_data: TargetData { urls, hosts, paths },

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Lotus {
8686
request_option: RequestOpts,
8787
scan_type: ScanTypes,
8888
exit_after: i32,
89-
fuzz_workers: usize
89+
fuzz_workers: usize,
9090
) {
9191
let loaded_scripts = {
9292
if let ScanTypes::HOSTS = scan_type {

src/lua/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ pub mod network;
33
pub mod output;
44
pub mod parsing;
55
pub mod payloads;
6+
pub mod runtime;
67
pub mod scan;
78
pub mod threads;
8-
pub mod runtime;

src/lua/network/http.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Sender {
5858
match &self.proxy {
5959
Some(the_proxy) => Client::builder()
6060
.timeout(Duration::from_secs(self.timeout))
61-
.redirect(redirect::Policy::custom(move |attempt|{
61+
.redirect(redirect::Policy::custom(move |attempt| {
6262
if attempt.previous().len() != redirects as usize {
6363
attempt.follow()
6464
} else {
@@ -72,7 +72,7 @@ impl Sender {
7272
.build(),
7373
None => Client::builder()
7474
.timeout(Duration::from_secs(self.timeout))
75-
.redirect(redirect::Policy::custom(move |attempt|{
75+
.redirect(redirect::Policy::custom(move |attempt| {
7676
if attempt.previous().len() == redirects as usize {
7777
attempt.stop()
7878
} else {
@@ -145,7 +145,7 @@ impl Sender {
145145
let verbose_mode = VERBOSE_MODE.lock().unwrap();
146146
if *verbose_mode == true {
147147
let log_msg = format!("SENDING HTTP REQUEST: {}", url);
148-
log::debug!("{}",log_msg);
148+
log::debug!("{}", log_msg);
149149
BAR.lock().unwrap().println(log_msg);
150150
}
151151
*req_sent += 1;
@@ -175,14 +175,12 @@ impl Sender {
175175
let error_code = {
176176
if err.is_timeout() {
177177
"timeout_error"
178-
} else if err.is_connect(){
178+
} else if err.is_connect() {
179179
"connection_error"
180-
}
181-
else if err.is_redirect() {
180+
} else if err.is_redirect() {
182181
"too_many_redirects"
183-
}
184-
else if err.is_body() {
185-
"request_body_error"
182+
} else if err.is_body() {
183+
"request_body_error"
186184
} else if err.is_decode() {
187185
"decode_error"
188186
} else {
@@ -191,7 +189,7 @@ impl Sender {
191189
};
192190
let err = mlua::Error::RuntimeError(error_code.to_string());
193191
Err(err)
194-
},
192+
}
195193
}
196194
}
197195
}

src/lua/output/cve.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,10 @@ impl UserData for CveReport {
7171
Ok(())
7272
},
7373
);
74-
methods.add_method_mut(
75-
"clearMatcher",
76-
|_, this, ()| {
77-
this.matchers.clear();
78-
Ok(())
79-
}
80-
)
74+
methods.add_method_mut("clearMatcher", |_, this, ()| {
75+
this.matchers.clear();
76+
Ok(())
77+
})
8178
}
8279
}
8380

src/lua/runtime/encode_ext.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub trait EncodeEXT {
44
fn add_encode_function(&self);
55
}
66

7-
87
impl EncodeEXT for LuaRunTime<'_> {
98
fn add_encode_function(&self) {
109
self.lua
@@ -28,4 +27,3 @@ impl EncodeEXT for LuaRunTime<'_> {
2827
.unwrap();
2928
}
3029
}
31-

0 commit comments

Comments
 (0)