Compare commits

...
Author SHA1 Message Date
Brandon 9ab15c9d8b cargo fmt 2020-08-07 17:11:14 +01:00
Brandon 7146c23ed9 cleanup 2020-08-07 17:06:43 +01:00
Brandon f37f2d8f9d switching to master 2020-08-07 16:50:42 +01:00
Brandon 5a3a4d1c0c cargo fmt 2020-08-07 16:36:14 +01:00
Brandon 33e7cd44b6 added quiet mode to macros 2020-08-07 16:33:25 +01:00
Brandon 8288856949 added quotes 2020-08-07 13:21:19 +01:00
Brandon c3b96e262d Merge pull request #130 from RustScan/bee-add-TUI-module
Bee add tui module
2020-08-07 12:53:46 +01:00
3 changed files with 66 additions and 44 deletions

No files matched your search

+2 -2
View File
@@ -29,7 +29,7 @@
<hr>
# 🤔 What is this?
1. Find ports quickly using Rustscan (**8 seconds at its fastest**).
1. Find ports quickly using Rustscan (**3 seconds at its fastest**).
2. Automatically runs `nmap` on those ports.
3. ???
4. Profit!
@@ -52,7 +52,7 @@
</tr>
</table>
<sub><b>Note</b> This is an older gif. RustScan's current top speed is 8 seconds for all 65k ports. This gif is 26 seconds.</sub><br>
<sub><b>Note</b> This is an older gif. RustScan's current top speed is 3 seconds for all 65k ports. This gif is 26 seconds.</sub><br>
RustScans **only** job is to reduce the friction between finding open ports and inputting them into nmap.
+26 -33
View File
@@ -111,36 +111,29 @@ fn main() {
// If we got here it means the IP was not found within the HashMap, this
// means the scan couldn't find any open ports for it.
if opts.quiet {
let x = format!("{} {:?}", "No ports found for", ip);
detail!(x);
} else {
let x = format!("{} Looks like I didn't find any open ports for {:?}. This is usually caused by a high batch size.
\n*I used {} batch size, consider lowering to {} with {} or a comfortable number for your system.
\n Alternatively, increase the timeout if your ping is high. Rustscan -T 2000 for 2000 second timeout.\n",
"ERROR",
ip,
opts.batch_size,
(opts.batch_size / 2).to_string(),
"'rustscan -b <batch_size> <ip address>'");
warning!(x);
}
let x = format!("{} Looks like I didn't find any open ports for {:?}. This is usually caused by a high batch size.
\n*I used {} batch size, consider lowering to {} with {} or a comfortable number for your system.
\n Alternatively, increase the timeout if your ping is high. Rustscan -T 2000 for 2000 second timeout.\n",
"ERROR",
ip,
opts.batch_size,
(opts.batch_size / 2).to_string(),
"'rustscan -b <batch_size> <ip address>'");
warning!(x, opts.quiet);
}
for (ip, ports) in ports_per_ip.iter_mut() {
let nmap_str_ports: Vec<String> = ports.into_iter().map(|port| port.to_string()).collect();
if !opts.quiet {
println!("\n");
detail!("Starting Nmap");
}
detail!("Starting Nmap", opts.quiet);
// nmap port style is 80,443. Comma separated with no spaces.
let ports_str = nmap_str_ports.join(",");
// if quiet mode is on nmap should not be spawned
if opts.quiet {
detail!(format!("Ports: {:?}", ports_str));
println!("{}", ports_str);
continue;
}
@@ -177,7 +170,8 @@ Faster Nmap scanning with Rust."#;
: https://discord.gg/GFrQsGy :
: https://github.com/RustScan/RustScan :
--------------------------------------"#;
println!("{}\n", info.gradient(Color::Red).bold());
println!("{}", info.gradient(Color::Yellow).bold());
funny_opening!();
let config_path = match dirs::config_dir() {
Some(mut path) => {
@@ -221,12 +215,10 @@ fn adjust_ulimit_size(opts: &Opts) -> rlimit::rlim {
match setrlimit(Resource::NOFILE, limit, limit) {
Ok(_) => {
if !opts.quiet {
detail!(format!(
"Automatically increasing ulimit value to {}.",
limit
));
}
detail!(
format!("Automatically increasing ulimit value to {}.", limit),
opts.quiet
);
}
Err(_) => println!("{}", "ERROR. Failed to set ulimit value."),
}
@@ -242,9 +234,12 @@ fn infer_batch_size(opts: &Opts, ulimit: rlimit::rlim) -> u16 {
// Adjust the batch size when the ulimit value is lower than the desired batch size
if ulimit < batch_size {
if !opts.quiet {
warning!("File limit is lower than default batch size. Consider upping with --ulimt. May cause harm to sensitive servers");
}
warning!(
"File limit is lower than default batch size.
Consider upping with --ulimt.
May cause harm to sensitive servers",
opts.quiet
);
// When the OS supports high file limits like 8000, but the user
// selected a batch size higher than this we should reduce it to
@@ -266,12 +261,10 @@ fn infer_batch_size(opts: &Opts, ulimit: rlimit::rlim) -> u16 {
// When the ulimit is higher than the batch size let the user know that the
// batch size can be increased unless they specified the ulimit themselves.
else if ulimit + 2 > batch_size && (opts.ulimit.is_none()) {
if !opts.quiet {
detail!(format!(
detail!(format!(
"File limit higher than batch size. Can increase speed by increasing batch size '-b {}'.",
ulimit - 100
));
}
), opts.quiet);
}
batch_size as u16
+38 -9
View File
@@ -1,35 +1,64 @@
/// Terminal User Interface Module for RustScan
/// Defines macros to use
// TODO make them work with formatted strings
#[macro_export]
macro_rules! warning {
($name:expr) => {
use ansi_term::Colour::Red;
if $name.len() > 200 {
panic!("Your warning is too long.")
}
println!("{} {}", Red.bold().paint("[!]"), $name);
};
// quiet mode
($name:expr, $quiet:expr) => {
use ansi_term::Colour::Red;
if !$quiet {
println!("{} {}", Red.bold().paint("[!]"), $name);
}
};
}
#[macro_export]
macro_rules! detail {
($name:expr) => {
use ansi_term::Colour::Blue;
if $name.len() > 200 {
panic!("Your detail is too long.")
}
println!("{} {}", Blue.bold().paint("[~]"), $name);
};
($name:expr, $quiet:expr) => {
use ansi_term::Colour::Blue;
if !$quiet {
println!("{} {}", Blue.bold().paint("[~]"), $name);
}
};
}
#[macro_export]
macro_rules! output {
($name:expr, $quiet:expr) => {
use ansi_term::Colour::RGB;
if !$quiet {
println!("{} {}", RGB(0, 255, 9).bold().paint("[>]"), $name);
}
};
($name:expr) => {
use ansi_term::Colour::RGB;
println!("{} {}", RGB(0, 255, 9).bold().paint("[>]"), $name);
};
}
#[macro_export]
macro_rules! funny_opening {
// prints a funny quote / opening
() => {
use rand::seq::SliceRandom;
let quotes = vec![
"Nmap? More like slowmap.🐢",
"🌍HACK THE PLANET🌍",
"Real hackers hack time ⌛",
"Please contribute more quotes to our GitHub https://github.com/rustscan/rustscan",
"😵 https://admin.tryhackme.com",
];
let random_quote = quotes.choose(&mut rand::thread_rng()).unwrap();
println!("{}\n", random_quote);
// println!("{} {}", RGB(0, 255, 9).bold().paint("[>]"), $name);
};
}