Skip to content

Commit 9fe1608

Browse files
committed
Better output
1 parent 62e5591 commit 9fe1608

File tree

4 files changed

+61
-60
lines changed

4 files changed

+61
-60
lines changed

scanners/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub mod scan;
21
pub mod model;
2+
pub mod scan;
33
pub use urlencoding::encode as url_encode;
44

55
#[cfg(test)]

scanners/src/model.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ pub struct Report {
55
pub curl: String,
66
pub url: String,
77
}
8-

scanners/src/scan.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fs::read_to_string;
66
use yaml_rust::YamlLoader;
77

88
mod xss;
9-
use xss::{accept_html,XssPayloads, XssUrlParamsValue};
9+
use xss::{accept_html, XssPayloads, XssUrlParamsValue};
1010

1111
#[derive(Debug)]
1212
pub enum Payloads {
@@ -174,9 +174,11 @@ impl Scanner {
174174
.start_handler(move |_| {
175175
log::info!("Thread pool is starting");
176176
})
177-
.num_threads(concurrency).build().unwrap();
177+
.num_threads(concurrency)
178+
.build()
179+
.unwrap();
178180

179-
threader.install(||{
181+
threader.install(|| {
180182
self.requests.par_iter().for_each(|request| {
181183
self.modules.iter().for_each(|module| {
182184
let module = module.as_str();

scanners/src/scan/xss/mod.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
extern crate scant3r_utils;
22

33
use crate::model::Report;
4+
use console::style;
45
use indicatif::ProgressBar;
56
use log::error;
67
use scant3r_utils::{
8+
injector::{Injector, Urlinjector},
79
random_str,
810
requests::{Curl, Msg},
9-
injector::{Injector, Urlinjector},
1011
};
11-
use console::style;
1212

1313
mod parser;
1414
use parser::{html_parse, html_search};
1515

1616
mod bypass;
1717
pub use bypass::{PayloadGen, XssPayloads};
1818

19-
20-
pub fn print_poc(report: &Report) {
21-
println!("{} Valid XSS\n{} URL: {}\n{} CURL: {}\n{} MATCH: {}\n{} PAYLOAD: \"{}\"", style("[+]").green(), style("[!]").yellow(), report.url, style("[!]").yellow(),report.curl,style("[!]").yellow(),report.match_payload,style("[!]").yellow(),report.payload.replace("\"","\\\""));
19+
pub fn print_poc(report: &Report) -> String {
20+
format!(
21+
"{} Valid XSS\n{} URL: {}\n{} MATCH: {}\n{} PAYLOAD: \"{}\"\n{} CURL: {}\n",
22+
style("[+]").green(),
23+
style("[!]").yellow(),
24+
report.url,
25+
style("[!]").yellow(),
26+
report.match_payload,
27+
style("[!]").yellow(),
28+
report.payload.replace("\"", "\\\""),
29+
style("[!]").yellow(),
30+
report.curl,
31+
)
2232
}
2333

2434
pub struct Xss<'t> {
@@ -29,8 +39,8 @@ pub struct Xss<'t> {
2939

3040
pub trait XssUrlParamsValue {
3141
// scan url params value
32-
fn value_reflected(&self) -> Vec<String>;
33-
fn value_scan(&self, _prog: &ProgressBar) -> Vec<Report>;
42+
fn value_reflected(&self) -> Vec<String>;
43+
fn value_scan(&self, _prog: &ProgressBar) -> Vec<Report>;
3444
}
3545

3646
impl Xss<'_> {
@@ -47,43 +57,40 @@ impl Xss<'_> {
4757
}
4858

4959
pub fn accept_html(req: &Msg) -> bool {
50-
let block_headers = vec![
51-
"application/json",
52-
"application/javascript",
53-
"text/javascript",
54-
"text/plain",
55-
"text/css",
56-
"image/jpeg",
57-
"image/png",
58-
"image/bmp",
59-
"image/gif",
60-
"application/rss+xml",
61-
];
60+
let block_headers = vec![
61+
"application/json",
62+
"application/javascript",
63+
"text/javascript",
64+
"text/plain",
65+
"text/css",
66+
"image/jpeg",
67+
"image/png",
68+
"image/bmp",
69+
"image/gif",
70+
"application/rss+xml",
71+
];
6272

63-
let mut is_html = false;
64-
match req.send() {
65-
Ok(resp) => {
66-
block_headers.iter().for_each(|header| {
67-
if resp.headers.contains_key("Content-Type") {
68-
if resp.headers.get("Content-Type").unwrap() == header {
69-
is_html = true;
70-
}
71-
} else {
72-
is_html = true;
73-
}
74-
})
75-
},
76-
Err(e) => {
77-
error!("{}", e);
78-
return false;
79-
},
73+
let mut is_html = false;
74+
match req.send() {
75+
Ok(resp) => block_headers.iter().for_each(|header| {
76+
if resp.headers.contains_key("Content-Type") {
77+
if resp.headers.get("Content-Type").unwrap() == header {
78+
is_html = true;
79+
}
80+
} else {
81+
is_html = true;
82+
}
83+
}),
84+
Err(e) => {
85+
error!("{}", e);
86+
return false;
8087
}
81-
is_html
8288
}
89+
is_html
90+
}
8391

8492
impl XssUrlParamsValue for Xss<'_> {
85-
86-
fn value_reflected(&self) -> Vec<String> {
93+
fn value_reflected(&self) -> Vec<String> {
8794
let mut reflected_parameters: Vec<String> = Vec::new();
8895
let payload = random_str(5);
8996
let check_requests = self.injector.url_value(&payload);
@@ -109,7 +116,7 @@ impl XssUrlParamsValue for Xss<'_> {
109116
reflected_parameters
110117
}
111118

112-
fn value_scan(&self, _prog: &ProgressBar) -> Vec<Report> {
119+
fn value_scan(&self, _prog: &ProgressBar) -> Vec<Report> {
113120
let mut _found: Vec<Report> = Vec::new();
114121
for param in self.value_reflected() {
115122
let mut req = self.request.clone();
@@ -130,27 +137,20 @@ impl XssUrlParamsValue for Xss<'_> {
130137
req.url = self.injector.set_urlvalue(&param, &pay.payload);
131138
match req.send() {
132139
Ok(resp) => {
133-
let d = html_search(resp.body.as_str(), &pay.search);
134-
if d.len() > count.len() {
135-
/*_prog.println(format!(
136-
"FOUND XSS \nReflect: {:?}\nPayload: {}\nMatch: {}\nCURL: \n{}",
137-
reflect,
138-
pay.payload,
139-
d,
140-
req.curl()
141-
));*/
142-
print_poc(&Report{
140+
let payload_found = html_search(resp.body.as_str(), &pay.search);
141+
if payload_found.len() > count.len() {
142+
_found.push(Report {
143143
url: req.url.to_string(),
144-
match_payload: d,
144+
match_payload: payload_found.clone(),
145145
payload: pay.payload.to_string(),
146146
curl: req.curl(),
147147
});
148-
/*_found.push(Report{
148+
_prog.println(print_poc(&Report {
149149
url: req.url.to_string(),
150-
match_payload: d,
150+
match_payload: payload_found,
151151
payload: pay.payload.to_string(),
152152
curl: req.curl(),
153-
});*/
153+
}));
154154
break;
155155
}
156156
}
@@ -162,5 +162,5 @@ impl XssUrlParamsValue for Xss<'_> {
162162
}
163163
}
164164
_found
165-
}
165+
}
166166
}

0 commit comments

Comments
 (0)