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

adding auto-print for reports #50

Merged
merged 1 commit into from
Nov 9, 2022
Merged
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
36 changes: 36 additions & 0 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

pub mod utils;
use console::Style;
use futures::lock::Mutex;
use log::{debug, error, info, warn};
use mlua::Lua;
Expand Down Expand Up @@ -118,6 +119,41 @@ impl<'a> LuaLoader<'a> {

fn get_utilsfunc(&self, lua: &Lua) {
// ProgressBar
let bar = self.bar.clone();
lua.globals()
.set(
"print_report",
lua.create_function(move |_, the_report: OutReport| {
let good_msg = format!("[{}]", Style::new().green().apply_to("+").to_string());
let info_msg = format!("[{}]", Style::new().blue().apply_to("#"));
let report_msg = format!(
"
{GOOD} {NAME} on: {URL}
{INFO} Description: {Description}
{INFO} Vulnerable Parameter: {PARAM}
{INFO} Risk: {RISK}
{INFO} Used Payload: {ATTACK}
{INFO} Matching Pattern: {MATCHING}
#--------------------------------------------------#

",
GOOD = good_msg,
INFO = info_msg,
NAME = the_report.name.unwrap(),
URL = the_report.url.unwrap(),
Description = the_report.description.unwrap(),
PARAM = the_report.param.unwrap(),
RISK = the_report.risk.unwrap(),
ATTACK = the_report.attack.unwrap(),
MATCHING = format!("{}",Style::new().on_red().apply_to(the_report.evidence.unwrap())),
);
bar.println(report_msg);
Ok(())
})
.unwrap(),
)
.unwrap();

let bar = self.bar.clone();
lua.globals()
.set(
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct OutReport {
pub url: Option<String>, // the effected url
pub param: Option<String>, // the effected parameter`
pub attack: Option<String>, // the payload
pub evidence: Option<String>, // matching payload
pub evidence: Option<String>, // matching payload search pattern
// TODO: Request: RequestOpts {url, method, timeout, etc...}
}

Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ impl Lotus {
let script_path = &self.script.clone();
scripts.push((
filename_to_string(&self.script).unwrap(),
script_path.clone()
script_path.clone(),
));
scripts
}
false => {
self.get_scripts()
}
false => self.get_scripts(),
};

// ProgressBar Settings
Expand All @@ -85,7 +83,8 @@ impl Lotus {
let lualoader = Arc::clone(&lualoader);
let script_path = match metadata(&self.script).unwrap().is_file() {
true => {
let script_path = Path::new(&self.script).parent().unwrap().to_str().unwrap();
let script_path =
Path::new(&self.script).parent().unwrap().to_str().unwrap();
script_path.to_owned()
}
false => {
Expand Down