diff --git a/src/ipv4.rs b/src/ipv4.rs index b8ee418..1c2fa3c 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -68,20 +68,17 @@ pub fn get_all(ignorelist: Option>) -> Result> { let ignorelist = ignorelist.unwrap_or(Vec::new()); // Get all of the "ids" - let ids: Vec = (0..u32::max_value()).collect(); + let mut ips: Vec = Vec::new(); - let ips: Vec = ids - .iter() - .map(|&ip| { - // Make IP - let mut ip = IPv4::new(ip as u64); + for id in 0..u32::max_value() { + // Make IP + let mut ip = IPv4::new(id as u64); - // Make the IP "ignored" if it is in the ignorelist - ip.ignore = ignorelist.contains(&ip.id); + // Make the IP "ignored" if it is in the ignorelist + ip.ignore = ignorelist.contains(&ip.id); - ip - }) - .collect(); + ips.push(ip); + } Ok(ips) } diff --git a/src/main.rs b/src/main.rs index eb1fb10..dfdfa57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,10 @@ mod util; use clap::Parser; use cli::Args; +use scanner::start_scan; + fn main() { let args = Args::parse(); - println!("{:?}", args); + let _results = start_scan(args.port, args.threads as u32, None).unwrap(); } diff --git a/src/scanner.rs b/src/scanner.rs index ef40798..9e9734d 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -1,18 +1,19 @@ use crate::ipv4; use anyhow::Result; use log::info; -use std::net::{SocketAddr, TcpStream}; +use std::net::TcpStream; use std::thread; use std::thread::JoinHandle; fn tcp_scan(mut target: ipv4::IPv4, target_port: u16) -> bool { let dest = target.to_socketaddr(target_port).unwrap(); - if let Ok(res) = TcpStream::connect(dest) { - info!("* Got TCP ack from: {:?} | {:?}", dest, res); - return true; - } false +// if let Ok(res) = TcpStream::connect(dest) { +// info!("* Got TCP ack from: {:?} | {:?}", dest, res); +// return true; +// } +// false } fn create_scan_thread( @@ -38,8 +39,11 @@ fn create_scan_thread( } pub fn start_scan(target_port: u16, num_threads: u32, ignorelist: Option>) -> Result<()> { + println!("Starting wwmap..."); let ip_list = ipv4::get_all(ignorelist)?; + println!("Post list gen"); + let ips_per_thread = ((ip_list.len() as f32) / num_threads as f32) as u32; let ips_left = num_threads * ips_per_thread; // how many ips we have left after the first threads @@ -67,5 +71,7 @@ pub fn start_scan(target_port: u16, num_threads: u32, ignorelist: Option