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

Added color by status code #29 #50

Merged
merged 1 commit into from
Oct 27, 2021
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ regex = "^1.1.7"
galvanic-test = "^0.2.0"
galvanic-assert = "0.8.7"
criterion = "^0.2.11"
console = "^0.15.0"

[[bench]]
name = "rustbuster"
Expand Down
24 changes: 22 additions & 2 deletions src/dirbuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::sync::mpsc::channel;
use std::sync::mpsc::Sender;
use std::{time::SystemTime};
use indicatif::{ProgressBar, ProgressStyle};
use console::style;

pub mod result_processor;
pub mod utils;
Expand All @@ -36,6 +37,25 @@ pub struct DirBuster {
pub output: String,
}

fn color_by_status_code(code: &str) -> String {
if code.starts_with("1") {
return style(code).blue().to_string();
}
else if code.starts_with("2") {
return style(code).green().to_string();
}
else if code.starts_with("3") {
return style(code).color256(226).to_string();
}
else if code.starts_with("4") {
return style(code).color256(208).to_string();
}
else if code.starts_with("5") {
return style(code).red().to_string();
}
return style(code).bold().to_string();
}

impl DirBuster {
pub fn run(self) {
let mut current_numbers_of_request = 0;
Expand Down Expand Up @@ -150,7 +170,7 @@ impl DirBuster {
bar.println(format!(
"{}\t{}{}{}{}",
msg.method,
msg.status,
color_by_status_code(&msg.status),
"\t".repeat(n_tabs),
msg.url,
extra
Expand All @@ -166,7 +186,7 @@ impl DirBuster {
save_dir_results(&output, &result_processor.results);
}
}

fn make_request_future(
&self,
tx: Sender<SingleDirScanResult>,
Expand Down