E. Almqvist 2 years ago
parent 9e0d9de1e1
commit 8f70586cde
  1. 13
      src/ipv4.rs
  2. 4
      src/main.rs
  3. 16
      src/scanner.rs

@ -68,20 +68,17 @@ pub fn get_all(ignorelist: Option<Vec<u64>>) -> Result<Vec<IPv4>> {
let ignorelist = ignorelist.unwrap_or(Vec::new());
// Get all of the "ids"
let ids: Vec<u32> = (0..u32::max_value()).collect();
let mut ips: Vec<IPv4> = Vec::new();
let ips: Vec<IPv4> = ids
.iter()
.map(|&ip| {
for id in 0..u32::max_value() {
// Make IP
let mut ip = IPv4::new(ip as u64);
let mut ip = IPv4::new(id as u64);
// Make the IP "ignored" if it is in the ignorelist
ip.ignore = ignorelist.contains(&ip.id);
ip
})
.collect();
ips.push(ip);
}
Ok(ips)
}

@ -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();
}

@ -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<Vec<u64>>) -> 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<Vec<u64
));
}
// Append all of the results into the list
Ok(())
}

Loading…
Cancel
Save