Compare commits

..
22 Commits
Author SHA1 Message Date
Bee bd32f4ead4 2.1.1 2022-11-07 10:21:47 +00:00
Artem IvanovandBee 8625f939bf Minor cosmetic changes (#453)
* Minor cosmetic changes

* Minor cosmetic changes

* Update discord link

Co-authored-by: Bee <[email protected]>
2022-11-07 10:16:14 +00:00
Thijs0x57andBee 8f608eaf99 fix links to Docker & Kali wiki (#433)
In the readme there are 2 links to docker & kali, 'Usage' and 'Read the install guide'. These links weren't working.

Co-authored-by: Bee <[email protected]>
2022-11-03 10:08:03 +00:00
NugineandBee f9f2bf6cf8 Upgrade rlimit (#449)
Co-authored-by: Bee <[email protected]>
2022-11-03 09:56:54 +00:00
Callum Haughtey-WilkinsonandBee 6fb1196244 Improve doc for addresses (#457)
Improve documentation for addresses CLI arg to make it
clear that file parsing of addresses is already supported

(#452)

Co-authored-by: Bee <[email protected]>
2022-11-02 15:23:02 +00:00
Callum Haughtey-Wilkinson 61c43dd5d0 Allow CLI customisation of config file path (#456)
Allow CLI customisation of config file path with new
optional argument.

(#437)
2022-11-02 15:17:07 +00:00
Bee 075025113d 2.1.0 release 2022-04-27 13:30:24 +01:00
Bee e3645b5c81 Update Cargo.lock file to support latest version of Rust (#435) 2022-04-26 08:40:56 +01:00
Ryan Montgomery a444ab66e1 Update tui.rs (#396)
added a quote
2021-07-03 23:27:06 +01:00
dependabot-preview[bot]andBrandon 30856350d3 Bump futures from 0.3.7 to 0.3.13 (#358)
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.7 to 0.3.13.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.7...0.3.13)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Brandon <[email protected]>
2021-03-29 08:17:19 +01:00
dependabot-preview[bot]andBrandon 7bff40a526 Bump rlimit from 0.5.2 to 0.5.4 (#360)
Bumps [rlimit](https://github.com/Nugine/rlimit) from 0.5.2 to 0.5.4.
- [Release notes](https://github.com/Nugine/rlimit/releases)
- [Commits](https://github.com/Nugine/rlimit/compare/v0.5.2...v0.5.4)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Brandon <[email protected]>
2021-03-29 08:16:43 +01:00
dependabot-preview[bot]andBrandon a38c6aa13b Bump cidr-utils from 0.5.0 to 0.5.1 (#367)
Bumps [cidr-utils](https://github.com/magiclen/cidr-utils) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/magiclen/cidr-utils/releases)
- [Commits](https://github.com/magiclen/cidr-utils/compare/v0.5.0...v0.5.1)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Brandon <[email protected]>
2021-03-29 08:16:03 +01:00
dependabot-preview[bot] 9b2c58fee5 Bump anyhow from 1.0.34 to 1.0.40 (#368)
Bumps [anyhow](https://github.com/dtolnay/anyhow) from 1.0.34 to 1.0.40.
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.34...1.0.40)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-29 08:15:46 +01:00
dependabot-preview[bot] 198225a8da Bump serde from 1.0.117 to 1.0.124 (#361)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.117 to 1.0.124.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.117...v1.0.124)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2021-03-20 18:29:16 +00:00
Thomas de Queiroz Barros 9a9dff422e Partially fix #362: Fix examples (#363)
Include -a to specify addresses
2021-03-20 18:28:59 +00:00
Brandon 227703a57e Update README.md 2021-03-08 19:39:44 +00:00
bergabman 90bbed2a17 Scripting engine extra user argument interpretation error fixed. Scanner engine errors and error handling clarified. (#325) 2020-12-07 12:28:16 +00:00
dependabot-preview[bot] 311cafcdbc Bump env_logger from 0.8.1 to 0.8.2 (#317)
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.1 to 0.8.2.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.1...v0.8.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-11-23 22:41:41 +00:00
bee 02f1f6c7d1 fixing cargo lock 2020-11-06 12:32:13 +00:00
bee 2182a1bd01 Merge branch 'master' of github.com:RustScan/RustScan 2020-11-06 01:44:04 +00:00
bee 0a42331dab update logo 2020-11-06 01:43:56 +00:00
Bee a5e5797f9e Delete bump.yml 2020-11-06 00:07:23 +00:00
12 changed files with 488 additions and 542 deletions

No files matched your search

+3 -25
View File
@@ -13,9 +13,9 @@ jobs:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: check
# - uses: actions-rs/cargo@v1
# with:
# command: check
test:
name: Test Suite
@@ -46,25 +46,3 @@ jobs:
with:
command: fmt
args: --all -- --check
clippy:
name: Clippy linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
links:
name: markdown-link-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
-15
View File
@@ -1,15 +0,0 @@
on:
push:
tags: '*'
jobs:
homebrew:
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- uses: mislav/bump-homebrew-formula-action@v1
with:
# A PR will be sent to github.com/Homebrew/homebrew-core to update this formula:
formula-name: rustscan
env:
COMMITTER_TOKEN: ${{secrets.brew}}
Generated
+355 -391
View File
File diff suppressed because it is too large. Load diff
+7 -7
View File
@@ -1,7 +1,7 @@
[package]
name = "rustscan"
version = "2.0.0"
authors = ["Bee <brando[email protected]>"]
version = "2.1.1"
authors = ["Autumn <autum[email protected]>"]
edition = "2018"
description = "Faster Nmap Scanning with Rust"
homepage = "https://github.com/rustscan/rustscan"
@@ -21,22 +21,22 @@ colored = "2.0.0"
structopt = "0.3.20"
async-std = "1.7.0"
futures = "0.3"
rlimit = "0.5.2"
rlimit = "0.8.3"
shell-words = "1.0.0"
log = "0.4.0"
env_logger = "0.8.1"
env_logger = "0.8.2"
dirs = "3.0.1"
gcd = "2.0.1"
rand = "0.7.3"
colorful = "0.2.1"
ansi_term = "0.12.1"
toml = "0.5.7"
serde = "1.0.117"
serde = "1.0.124"
serde_derive = "1.0.116"
cidr-utils = "0.5.0"
cidr-utils = "0.5.1"
itertools = "0.9.0"
trust-dns-resolver = { version = "0.19.5", features = ["dns-over-rustls"] }
anyhow = "1.0.34"
anyhow = "1.0.40"
subprocess = "0.2.6"
text_placeholder = { version = "0.4", features = ["struct_context"] }
+5 -5
View File
@@ -1,6 +1,6 @@
<p align="center">
➡️
<a href="https://discord.gg/GFrQsGy">Discord</a> |
<a href="http://discord.skerritt.blog">Discord</a> |
<a href="https://github.com/RustScan/RustScan/wiki/Installation-Guide">Installation Guide</a> |
<a href="https://github.com/RustScan/RustScan#-usage">Usage Guide</a>
⬅️
@@ -15,7 +15,7 @@
<img src="https://img.shields.io/badge/Built%20with-Rust-Purple">
<img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/rustscan/rustscan/total?label=GitHub%20Downloads">
<img alt="Crates.io" src="https://img.shields.io/crates/d/rustscan?label=Cargo%20Downloads">
<img alt="Discord" src="https://img.shields.io/discord/736614461313515576">
<img alt="Discord" src="https://img.shields.io/discord/754001738184392704">
<img alt="Actions" src="https://github.com/RustScan/RustScan/workflows/Continuous%20integration/badge.svg?branch=master">
</p>
<hr>
@@ -23,7 +23,7 @@
| <p align="center"><a href="https://hub.docker.com/r/cmnatic/rustscan">🐋 Docker (Recommended) </a></p> | <p align="center"><a href="https://github.com/RustScan/RustScan/releases">👩‍💻 Kali / Debian </p> | <p align="center"><a href="https://aur.archlinux.org/packages/rustscan/">🏗️ Arch </a></p> | <p align="center"><a href="https://crates.io/crates/rustscan">🔧 Homebrew </a></p> |
| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| <p align="center"><img src="https://github.com/RustScan/RustScan/blob/master/pictures/docker.png?raw=true" /></p> | <p align="center"><img src="https://github.com/RustScan/RustScan/blob/master/pictures/kali.png?raw=true" /></p> | <p align="center"><img src="https://github.com/RustScan/RustScan/blob/master/pictures/arch.png?raw=true" /></p> | <p align="center"><img src="https://raw.githubusercontent.com/RustScan/RustScan/master/pictures/apple.png" /></p> |
| `docker pull rustscan/rustscan:2.0.0` <p>[Usage](https://github.com/RustScan/RustScan#docker-whale) | [Read the install guide](https://github.com/Rustscan/RustScan/blob/master/README.md#%EF%B8%8F-debian--kali) | `yay -S rustscan` | `brew install rustscan` |
| `docker pull rustscan/rustscan:2.0.0` <p>[Usage](https://github.com/RustScan/RustScan/wiki/Installation-Guide#docker-whale) | [Read the install guide](https://github.com/RustScan/RustScan/wiki/Installation-Guide#%EF%B8%8F-debian--kali) | `yay -S rustscan` | `brew install rustscan` |
<hr>
@@ -45,13 +45,13 @@ The Modern Port Scanner. **Find ports quickly (3 seconds at its fastest)**. Run
| Installation Guide | Documentation | Discord |
| -------------------------------------------------------------------------------------- | -------------------------------------------------------- | ---------------------------------------- |
| 📖 [Installation Guide](https://github.com/RustScan/RustScan#-full-installation-guide) | 📚 [Documentation](https://rustscan.github.io/RustScan/) | 🦜 [Discord](https://discord.gg/GFrQsGy) |
| 📖 [Installation Guide](https://github.com/RustScan/RustScan#-full-installation-guide) | 📚 [Documentation](https://rustscan.github.io/RustScan/) | 🦜 [Discord](http://discord.skerritt.blog) |
## 🙋 Table of Contents
- 📖 [Installation Guide](https://github.com/RustScan/RustScan/wiki/Installation-Guide)
- 🐋 [Docker Usage](https://github.com/RustScan/RustScan/wiki/Installation-Guide)
- 🦜 [Discord](https://discord.gg/GFrQsGy)
- 🦜 [Discord](http://discord.skerritt.blog)
- 🤸 [Usage](https://github.com/RustScan/RustScan/wiki/Usage)
- 🎪 [Community](https://github.com/RustScan/RustScan#-community)
+15 -12
View File
@@ -7,19 +7,21 @@ Before contributing, read our [code of conduct](https://github.com/RustScan/Rust
TL;DR if you abuse members of our community you will be **perma-banned** with no chance to get unbanned. No warnings either. 🤗
RustScan has 2 major labels for GitHub issues you should look at:
* Good First issue
These are issues for newcomers to open source!
[https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22](https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
* Help wanted
These are issues that aren't really for newcomers, but we could still do with help!
[https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3A%22help+wanted%22](https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3A%22help+wanted%22)
- Good First issue
These are issues for newcomers to open source!
[https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22](https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
- Help wanted
These are issues that aren't really for newcomers, but we could still do with help!
[https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3A%22help+wanted%22](https://github.com/RustScan/RustScan/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3A%22help+wanted%22)
If you want to, solve the issue or comment on the issue for help.
The [flow for contributing](https://guides.github.com/introduction/flow/) to open source software is:
* Fork the repo
* Make changes
* Pull request to the repo
The flow for contributing to open source software is:
- Fork the repo
- Make changes
- Pull request to the repo
And then comment on the issue that you've done.
@@ -28,6 +30,7 @@ RustScan also has some `// TODO`'s in the codebase, which are meant more for the
If you have any feature suggestions or bugs, leave a GitHub issue. We welcome any and all support :D
## Rewarding you
I cannot pay you :-( But, I can place your GitHub profile on the README under `#Contributors` as a thank you! :)
## Contributing development environment
@@ -39,7 +42,7 @@ To build it you just need to run:
you@home:~/RustScan$ docker build -t rustscan_contributing -f contributing.Dockerfile
```
Then you need to run the container with a volume so it can access, *with read and write permissions*, to RustScan files:
Then you need to run the container with a volume so it can access, _with read and write permissions_, to RustScan files:
```bash
you@home:~/RustScan$ docker run -ti --rm -v "$PWD":/rustscan -w /rustscan rustscan_contributing bash
@@ -63,4 +66,4 @@ You can also format, lint with `clippy` and test the code with the following com
root@container:/rustscan# cargo fmt
root@container:/rustscan# cargo clippy
root@container:/rustscan# cargo test
```
```
Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 55 KiB

+24 -13
View File
@@ -1,6 +1,7 @@
use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use structopt::{clap::arg_enum, StructOpt};
const LOWEST_PORT_NUMBER: u16 = 1;
@@ -70,7 +71,7 @@ fn parse_range(input: &str) -> Result<PortRange, String> {
/// - Discord https://discord.gg/GFrQsGy
/// - GitHub https://github.com/RustScan/RustScan
pub struct Opts {
/// A list of comma separated CIDRs, IPs, or hosts to be scanned.
/// A comma-delimited list or newline-delimited file of separated CIDRs, IPs, or hosts to be scanned.
#[structopt(short, long, use_delimiter = true)]
pub addresses: Vec<String>,
@@ -86,6 +87,10 @@ pub struct Opts {
#[structopt(short, long)]
pub no_config: bool,
/// Custom path to config file
#[structopt(short, long, parse(from_os_str))]
pub config_path: Option<PathBuf>,
/// Greppable mode. Only output the ports. No Nmap. Useful for grep or outputting to a file.
#[structopt(short, long)]
pub greppable: bool,
@@ -112,7 +117,7 @@ pub struct Opts {
/// Automatically ups the ULIMIT with the value you provided.
#[structopt(short, long)]
pub ulimit: Option<rlimit::RawRlim>,
pub ulimit: Option<u64>,
/// The order of scanning to be performed. The "serial" option will
/// scan ports in ascending order while the "random" option will scan
@@ -130,7 +135,7 @@ pub struct Opts {
/// The Script arguments to run.
/// To use the argument -A, end RustScan's args with '-- -A'.
/// Example: 'rustscan -T 1500 127.0.0.1 -- -A -sC'.
/// Example: 'rustscan -T 1500 -a 127.0.0.1 -- -A -sC'.
/// This command adds -Pn -vvv -p $PORTS automatically to nmap.
/// For things like --script '(safe and vuln)' enclose it in quotations marks \"'(safe and vuln)'\"")
#[structopt(last = true)]
@@ -216,7 +221,7 @@ pub struct Config {
batch_size: Option<u16>,
timeout: Option<u32>,
tries: Option<u8>,
ulimit: Option<rlimit::RawRlim>,
ulimit: Option<u64>,
scan_order: Option<ScanOrder>,
command: Option<Vec<String>>,
scripts: Option<ScriptsRequired>,
@@ -234,16 +239,11 @@ impl Config {
/// greppable = true
/// scan_order: "Serial"
///
pub fn read() -> Self {
let mut home_dir = match dirs::home_dir() {
Some(dir) => dir,
None => panic!("Could not infer config file path."),
};
home_dir.push(".rustscan.toml");
pub fn read(custom_config_path: Option<PathBuf>) -> Self {
let mut content = String::new();
if home_dir.exists() {
content = match fs::read_to_string(home_dir) {
let config_path = custom_config_path.unwrap_or_else(default_config_path);
if config_path.exists() {
content = match fs::read_to_string(config_path) {
Ok(content) => content,
Err(_) => String::new(),
}
@@ -261,6 +261,16 @@ impl Config {
}
}
/// Constructs default path to config toml
pub fn default_config_path() -> PathBuf {
let mut config_path = match dirs::home_dir() {
Some(dir) => dir,
None => panic!("Could not infer config file path."),
};
config_path.push(".rustscan.toml");
config_path
}
#[cfg(test)]
mod tests {
use super::{Config, Opts, PortRange, ScanOrder, ScriptsRequired};
@@ -300,6 +310,7 @@ mod tests {
no_config: true,
top: false,
scripts: ScriptsRequired::Default,
config_path: None,
}
}
}
+59 -51
View File
@@ -24,9 +24,7 @@ use scripts::{init_scripts, Script, ScriptFile};
use cidr_utils::cidr::IpCidr;
use colorful::{Color, Colorful};
use futures::executor::block_on;
use rlimit::{getrlimit, setrlimit, RawRlim, Resource, Rlim};
use std::collections::HashMap;
use std::convert::TryInto;
use std::fs::File;
use std::io::{prelude::*, BufReader};
use std::net::{IpAddr, ToSocketAddrs};
@@ -42,9 +40,10 @@ extern crate colorful;
extern crate dirs;
// Average value for Ubuntu
const DEFAULT_FILE_DESCRIPTORS_LIMIT: RawRlim = 8000;
#[cfg(unix)]
const DEFAULT_FILE_DESCRIPTORS_LIMIT: u64 = 8000;
// Safest batch size based on experimentation
const AVERAGE_BATCH_SIZE: RawRlim = 3000;
const AVERAGE_BATCH_SIZE: u16 = 3000;
#[macro_use]
extern crate log;
@@ -59,7 +58,7 @@ fn main() {
let mut rustscan_bench = NamedTimer::start("RustScan");
let mut opts: Opts = Opts::read();
let config = Config::read();
let config = Config::read(opts.config_path.clone());
opts.merge(&config);
debug!("Main() `opts` arguments are {:?}", opts);
@@ -68,7 +67,7 @@ fn main() {
Ok(scripts_to_run) => scripts_to_run,
Err(e) => {
warning!(
format!("Initiating scripts failed!\n{}", e.to_string()),
format!("Initiating scripts failed!\n{}", e),
opts.greppable,
opts.accessible
);
@@ -93,8 +92,11 @@ fn main() {
std::process::exit(1);
}
let ulimit: RawRlim = adjust_ulimit_size(&opts);
let batch_size: u16 = infer_batch_size(&opts, ulimit);
#[cfg(unix)]
let batch_size: u16 = infer_batch_size(&opts, adjust_ulimit_size(&opts));
#[cfg(not(unix))]
let batch_size: u16 = AVERAGE_BATCH_SIZE;
let scanner = Scanner::new(
&ips,
@@ -134,7 +136,7 @@ fn main() {
\n Alternatively, increase the timeout if your ping is high. Rustscan -t 2000 for 2000 milliseconds (2s) timeout.\n",
ip,
opts.batch_size,
"'rustscan -b <batch_size> <ip address>'");
"'rustscan -b <batch_size> -a <ip address>'");
warning!(x, opts.greppable, opts.accessible);
}
@@ -154,19 +156,20 @@ fn main() {
// Run all the scripts we found and parsed based on the script config file tags field.
for mut script_f in scripts_to_run.clone() {
output!(
format!("Script to be run {:?}\n", script_f.call_format,),
opts.greppable,
opts.accessible
);
// This part allows us to add commandline arguments to the Script call_format, appending them to the end of the command.
if !opts.command.is_empty() {
let user_extra_args: Vec<String> = shell_words::split(&opts.command.join(" "))
.expect("Failed to parse extra user commandline arguments");
let user_extra_args = &opts.command.join(" ");
debug!("Extra args vec {:?}", user_extra_args);
if script_f.call_format.is_some() {
let mut call_f = script_f.call_format.unwrap();
call_f.push_str(&format!(" {}", &user_extra_args.join(" ")));
call_f.push(' ');
call_f.push_str(user_extra_args);
output!(
format!("Running script {:?} on ip {}\nDepending on the complexity of the script, results may take some time to appear.", call_f, &ip),
opts.greppable,
opts.accessible
);
debug!("Call format {}", call_f);
script_f.call_format = Some(call_f);
}
}
@@ -175,7 +178,7 @@ fn main() {
let script = Script::build(
script_f.path,
*ip,
ports.to_vec(),
ports.clone(),
script_f.port,
script_f.ports_separator,
script_f.tags,
@@ -186,11 +189,7 @@ fn main() {
detail!(script_result.to_string(), opts.greppable, opts.accessible);
}
Err(e) => {
warning!(
&format!("Error {}", e.to_string()),
opts.greppable,
opts.accessible
);
warning!(&format!("Error {}", e), opts.greppable, opts.accessible);
}
}
}
@@ -208,22 +207,29 @@ fn main() {
/// Prints the opening title of RustScan
fn print_opening(opts: &Opts) {
debug!("Printing opening");
let s = r#".----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner."#;
let s = format!(
"{}\n{}\n{}\n{}\n{}",
r#".----. .-. .-. .----..---. .----. .---. .--. .-. .-."#,
r#"| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |"#,
r#"| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |"#,
r#"`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'"#,
r#"The Modern Day Port Scanner."#
);
println!("{}", s.gradient(Color::Green).bold());
let info = r#"________________________________________
: https://discord.gg/GFrQsGy :
: https://github.com/RustScan/RustScan :
--------------------------------------"#;
let info = format!(
"{}\n{}\n{}\n{}",
r#"________________________________________"#,
r#": http://discord.skerritt.blog :"#,
r#": https://github.com/RustScan/RustScan :"#,
r#" --------------------------------------"#
);
println!("{}", info.gradient(Color::Yellow).bold());
funny_opening!();
let config_path = dirs::home_dir()
.expect("Could not infer config file path.")
.join(".rustscan.toml");
let config_path = opts
.config_path
.clone()
.unwrap_or_else(input::default_config_path);
detail!(
format!("The config file is expected to be at {:?}", config_path),
@@ -301,7 +307,7 @@ fn resolve_ips_from_host(source: &str, backup_resolver: &Resolver) -> Vec<IpAddr
for ip in addrs {
ips.push(ip.ip());
}
} else if let Ok(addrs) = backup_resolver.lookup_ip(&source) {
} else if let Ok(addrs) = backup_resolver.lookup_ip(source) {
ips.extend(addrs.iter());
}
@@ -330,11 +336,11 @@ fn read_ips_from_file(
Ok(ips)
}
fn adjust_ulimit_size(opts: &Opts) -> RawRlim {
if opts.ulimit.is_some() {
let limit: Rlim = Rlim::from_raw(opts.ulimit.unwrap());
if setrlimit(Resource::NOFILE, limit, limit).is_ok() {
#[cfg(unix)]
fn adjust_ulimit_size(opts: &Opts) -> u64 {
use rlimit::Resource;
if let Some(limit) = opts.ulimit {
if Resource::NOFILE.set(limit, limit).is_ok() {
detail!(
format!("Automatically increasing ulimit value to {}.", limit),
opts.greppable,
@@ -349,13 +355,15 @@ fn adjust_ulimit_size(opts: &Opts) -> RawRlim {
}
}
let (rlim, _) = getrlimit(Resource::NOFILE).unwrap();
rlim.as_raw()
let (soft, _) = Resource::NOFILE.get().unwrap();
soft
}
fn infer_batch_size(opts: &Opts, ulimit: RawRlim) -> u16 {
let mut batch_size: RawRlim = opts.batch_size.into();
#[cfg(unix)]
fn infer_batch_size(opts: &Opts, ulimit: u64) -> u16 {
use std::convert::TryInto;
let mut batch_size: u64 = opts.batch_size.into();
// Adjust the batch size when the ulimit value is lower than the desired batch size
if ulimit < batch_size {
@@ -366,18 +374,18 @@ fn infer_batch_size(opts: &Opts, ulimit: RawRlim) -> u16 {
// When the OS supports high file limits like 8000, but the user
// selected a batch size higher than this we should reduce it to
// a lower number.
if ulimit < AVERAGE_BATCH_SIZE {
if ulimit < AVERAGE_BATCH_SIZE.into() {
// ulimit is smaller than aveage batch size
// user must have very small ulimit
// decrease batch size to half of ulimit
warning!("Your file limit is very small, which negatively impacts RustScan's speed. Use the Docker image, or up the Ulimit with '--ulimit 5000'. ", opts.greppable, opts.accessible);
info!("Halving batch_size because ulimit is smaller than average batch size");
batch_size = ulimit / 2
batch_size = ulimit / 2;
} else if ulimit > DEFAULT_FILE_DESCRIPTORS_LIMIT {
info!("Batch size is now average batch size");
batch_size = AVERAGE_BATCH_SIZE
batch_size = AVERAGE_BATCH_SIZE.into();
} else {
batch_size = ulimit - 100
batch_size = ulimit - 100;
}
}
// When the ulimit is higher than the batch size let the user know that the
+16 -12
View File
@@ -9,7 +9,7 @@ use async_std::prelude::*;
use colored::Colorize;
use futures::stream::FuturesUnordered;
use std::{
io::ErrorKind,
collections::HashSet,
net::{IpAddr, Shutdown, SocketAddr},
num::NonZeroU8,
time::Duration,
@@ -62,6 +62,7 @@ impl Scanner {
let mut socket_iterator: SocketIterator = SocketIterator::new(&self.ips, &ports);
let mut open_sockets: Vec<SocketAddr> = Vec::new();
let mut ftrs = FuturesUnordered::new();
let mut errors: HashSet<String> = HashSet::with_capacity(self.ips.len() * 1000);
for _ in 0..self.batch_size {
if let Some(socket) = socket_iterator.next() {
@@ -82,10 +83,17 @@ impl Scanner {
ftrs.push(self.scan_socket(socket));
}
if let Ok(socket) = result {
open_sockets.push(socket);
match result {
Ok(socket) => open_sockets.push(socket),
Err(e) => {
let error_string = e.to_string();
if errors.len() < self.ips.len() * 1000 {
errors.insert(error_string);
}
}
}
}
debug!("Typical socket connection errors {:?}", errors);
debug!("Open Sockets found: {:?}", &open_sockets);
open_sockets
}
@@ -127,19 +135,15 @@ impl Scanner {
return Ok(socket);
}
Err(e) => {
let error_string = e.to_string();
let mut error_string = e.to_string();
if e.kind() == ErrorKind::Other {
debug!("Socket connect error: {} {}", &error_string, &socket);
if !error_string.contains("No route to host")
&& !error_string.contains("Network is unreachable")
{
panic!("Too many open files. Please reduce batch size. The default is 5000. Try -b 2500.");
}
if error_string.to_lowercase().contains("too many open files") {
panic!("Too many open files. Please reduce batch size. The default is 5000. Try -b 2500.");
}
if nr_try == tries {
error_string.push(' ');
error_string.push_str(&socket.ip().to_string());
return Err(io::Error::new(io::ErrorKind::Other, error_string));
}
}
+3 -11
View File
@@ -231,17 +231,9 @@ impl Script {
};
to_run = default_template.fill_with_struct(&exec_parts)?;
}
debug!("\nScript format to run {}", to_run);
debug!("\nTo run {}", to_run);
let arguments = shell_words::split(
&to_run
.split(' ')
.map(ToString::to_string)
.collect::<Vec<String>>()
.join(" "),
)
.expect("Failed to parse script arguments");
let arguments = shell_words::split(&to_run).expect("Failed to parse script arguments");
execute_script(arguments)
}
@@ -249,7 +241,7 @@ impl Script {
#[cfg(not(tarpaulin_include))]
fn execute_script(mut arguments: Vec<String>) -> Result<String> {
debug!("\nArguments vec: {:?}", &arguments);
debug!("\nScript arguments vec: {:?}", &arguments);
let process = Exec::cmd(&arguments.remove(0)).args(&arguments);
match process.capture() {
Ok(c) => {
+1
View File
@@ -72,6 +72,7 @@ macro_rules! funny_opening {
"Real hackers hack time ⌛",
"Please contribute more quotes to our GitHub https://github.com/rustscan/rustscan",
"😵 https://admin.tryhackme.com",
"0day was here ♥",
];
let random_quote = quotes.choose(&mut rand::thread_rng()).unwrap();