Merge branch 'master' into bee-add-template-se

This commit is contained in:
Bee authored and GitHub committed 2020-09-23 16:47:03 +01:00
commit 21fbac6d73
3 files changed
+41 -9

No files matched your search

+4
View File
@@ -116,3 +116,7 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/*
.idea
.idea*
+5 -2
View File
@@ -1,8 +1,11 @@
FROM rust:alpine as builder
LABEL maintainer="CMNatic <https://github.com/CMNatic">
RUN apk add --no-cache build-base
# Encourage some layer caching here rather then copying entire directory that includes docs to builder container ~CMN
WORKDIR /usr/src/rustscan
COPY . .
COPY Cargo.toml Cargo.lock ./
COPY src src
RUN cargo install --path .
FROM alpine:3.12
@@ -13,4 +16,4 @@ RUN addgroup -S rustscan && \
apk add --no-cache nmap nmap-scripts wget
COPY --from=builder /usr/local/cargo/bin/rustscan /usr/local/bin/rustscan
USER rustscan
ENTRYPOINT [ "/usr/local/bin/rustscan" ]
ENTRYPOINT [ "/usr/local/bin/rustscan" ]
+32 -7
View File
@@ -21,8 +21,12 @@ use futures::executor::block_on;
use rlimit::Resource;
use rlimit::{getrlimit, setrlimit};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::net::ToSocketAddrs;
use std::process::Command;
use std::str::FromStr;
use std::{net::IpAddr, time::Duration};
extern crate colorful;
@@ -204,6 +208,24 @@ fn build_nmap_arguments<'a>(
arguments
}
#[cfg(not(tarpaulin_include))]
/// Parses an input file of IPs and uses those
fn read_ips_from_file(ips: String) -> Result<Vec<std::net::IpAddr>, std::io::Error> {
// if we cannot open it as a file, it is not a file so move on
let file = File::open(ips)?;
let reader = BufReader::new(file);
let mut ips: Vec<std::net::IpAddr> = Vec::new();
for str_ip in reader.lines() {
match IpAddr::from_str(&str_ip.unwrap()) {
Ok(x) => ips.push(x),
Err(y) => panic!("File does not contain valid IP address. Error at {}", y),
}
}
Ok(ips)
}
fn parse_addresses(opts: &Opts) -> Vec<IpAddr> {
let mut ips: Vec<IpAddr> = Vec::new();
@@ -212,13 +234,16 @@ fn parse_addresses(opts: &Opts) -> Vec<IpAddr> {
Ok(cidr) => cidr.iter().for_each(|ip| ips.push(ip)),
_ => match format!("{}:{}", &ip_or_host, 80).to_socket_addrs() {
Ok(mut iter) => ips.push(iter.nth(0).unwrap().ip()),
_ => {
warning!(
format!("Host {:?} could not be resolved.", ip_or_host),
opts.greppable,
opts.accessible
);
}
_ => match read_ips_from_file(ip_or_host.to_owned()) {
Ok(x) => ips.extend(x),
_ => {
warning!(
format!("Host {:?} could not be resolved.", ip_or_host),
opts.greppable,
opts.accessible
);
}
},
},
}
}