cli
E. Almqvist 2 years ago
parent 09bf94bcd2
commit 61d69b14c5
  1. 8
      src/ipv4.rs
  2. 4
      src/main.rs
  3. 13
      src/scanner.rs

@ -1,8 +1,8 @@
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::convert::TryInto;
use crate::util;
use anyhow::{anyhow, Result};
use convert_base::Convert;
use std::convert::TryInto;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
/*
Algorithm: O(n)
@ -38,7 +38,9 @@ impl IPv4 {
ip = ip.into_iter().rev().collect();
// convert to array
let ip: [u8; 4] = ip.try_into().unwrap_or_else(|_: Vec<u8>| panic!("Unable to convert Vec to [u8; 4] for IPv4!"));
let ip: [u8; 4] = ip
.try_into()
.unwrap_or_else(|_: Vec<u8>| panic!("Unable to convert Vec to [u8; 4] for IPv4!"));
Self {
id,

@ -4,6 +4,4 @@ mod util;
//use ipv4::IPv4;
fn main() {
}
fn main() {}

@ -1,9 +1,9 @@
use crate::ipv4;
use anyhow::Result;
use log::info;
use std::net::{SocketAddr, TcpStream};
use std::thread;
use std::thread::JoinHandle;
use std::net::{SocketAddr, TcpStream};
fn tcp_scan(mut target: ipv4::IPv4, target_port: u16) -> bool {
let dest = target.to_socketaddr(target_port).unwrap();
@ -19,7 +19,7 @@ fn create_scan_thread(
ip_list: Vec<ipv4::IPv4>,
thread_id: u32,
ips_per_thread: u32,
target_port: u16
target_port: u16,
) -> JoinHandle<Vec<bool>> {
thread::spawn(move || {
info!("Starting thread worker #{}", thread_id);
@ -53,13 +53,18 @@ pub fn start_scan(target_port: u16, num_threads: u32, ignorelist: Option<Vec<u64
ip_list.clone(),
thread_id,
ips_per_thread,
target_port
target_port,
));
}
// create the last thread to do the job
if ips_left > 0 {
threads.push(create_scan_thread(ip_list, num_threads, ips_left, target_port));
threads.push(create_scan_thread(
ip_list,
num_threads,
ips_left,
target_port,
));
}
Ok(())

Loading…
Cancel
Save