Skip to content

Commit 66b7bc4

Browse files
authored
Merge pull request #50 from rusty-sec/print_report
adding auto-print for reports
2 parents aa44467 + e20dc76 commit 66b7bc4

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

src/core/mod.rs

+36
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
pub mod utils;
20+
use console::Style;
2021
use futures::lock::Mutex;
2122
use log::{debug, error, info, warn};
2223
use mlua::Lua;
@@ -118,6 +119,41 @@ impl<'a> LuaLoader<'a> {
118119

119120
fn get_utilsfunc(&self, lua: &Lua) {
120121
// ProgressBar
122+
let bar = self.bar.clone();
123+
lua.globals()
124+
.set(
125+
"print_report",
126+
lua.create_function(move |_, the_report: OutReport| {
127+
let good_msg = format!("[{}]", Style::new().green().apply_to("+").to_string());
128+
let info_msg = format!("[{}]", Style::new().blue().apply_to("#"));
129+
let report_msg = format!(
130+
"
131+
{GOOD} {NAME} on: {URL}
132+
{INFO} Description: {Description}
133+
{INFO} Vulnerable Parameter: {PARAM}
134+
{INFO} Risk: {RISK}
135+
{INFO} Used Payload: {ATTACK}
136+
{INFO} Matching Pattern: {MATCHING}
137+
#--------------------------------------------------#
138+
139+
",
140+
GOOD = good_msg,
141+
INFO = info_msg,
142+
NAME = the_report.name.unwrap(),
143+
URL = the_report.url.unwrap(),
144+
Description = the_report.description.unwrap(),
145+
PARAM = the_report.param.unwrap(),
146+
RISK = the_report.risk.unwrap(),
147+
ATTACK = the_report.attack.unwrap(),
148+
MATCHING = format!("{}",Style::new().on_red().apply_to(the_report.evidence.unwrap())),
149+
);
150+
bar.println(report_msg);
151+
Ok(())
152+
})
153+
.unwrap(),
154+
)
155+
.unwrap();
156+
121157
let bar = self.bar.clone();
122158
lua.globals()
123159
.set(

src/core/utils/report.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct OutReport {
2727
pub url: Option<String>, // the effected url
2828
pub param: Option<String>, // the effected parameter`
2929
pub attack: Option<String>, // the payload
30-
pub evidence: Option<String>, // matching payload
30+
pub evidence: Option<String>, // matching payload search pattern
3131
// TODO: Request: RequestOpts {url, method, timeout, etc...}
3232
}
3333

src/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ impl Lotus {
6363
let script_path = &self.script.clone();
6464
scripts.push((
6565
filename_to_string(&self.script).unwrap(),
66-
script_path.clone()
66+
script_path.clone(),
6767
));
6868
scripts
6969
}
70-
false => {
71-
self.get_scripts()
72-
}
70+
false => self.get_scripts(),
7371
};
7472

7573
// ProgressBar Settings
@@ -85,7 +83,8 @@ impl Lotus {
8583
let lualoader = Arc::clone(&lualoader);
8684
let script_path = match metadata(&self.script).unwrap().is_file() {
8785
true => {
88-
let script_path = Path::new(&self.script).parent().unwrap().to_str().unwrap();
86+
let script_path =
87+
Path::new(&self.script).parent().unwrap().to_str().unwrap();
8988
script_path.to_owned()
9089
}
9190
false => {

0 commit comments

Comments
 (0)