From cda30bd819251cfc9a5004ee8e2895bced1286a8 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Mon, 8 Aug 2022 01:52:01 +0200 Subject: [PATCH] IPv4 permutations --- Cargo.toml | 1 + src/ipv4_gen.rs | 4 ---- src/main.rs | 4 ++-- src/permutations.rs | 11 +++++++++++ src/scanner.rs | 8 +++++--- 5 files changed, 19 insertions(+), 9 deletions(-) delete mode 100644 src/ipv4_gen.rs create mode 100644 src/permutations.rs diff --git a/Cargo.toml b/Cargo.toml index 26960ce..d345af8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,4 @@ edition = "2021" # packet = "0.1.4" anyhow = "1" log = "0.4" +permutator = "0.4.3" diff --git a/src/ipv4_gen.rs b/src/ipv4_gen.rs deleted file mode 100644 index a7f2a16..0000000 --- a/src/ipv4_gen.rs +++ /dev/null @@ -1,4 +0,0 @@ - -pub fn generate_ips() -> Vec> { - -} diff --git a/src/main.rs b/src/main.rs index 1756a81..16941b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,8 +5,8 @@ )] mod scanner; -mod ipv4_gen; +mod permutations; fn main() { - println!("Hello, world!"); + scanner::start_scan(100); } diff --git a/src/permutations.rs b/src/permutations.rs new file mode 100644 index 0000000..7080fe7 --- /dev/null +++ b/src/permutations.rs @@ -0,0 +1,11 @@ +use permutator::Permutation; + +pub fn get_ipv4_permutations(start_pos: [u8; 4]) -> Vec> { + let perms: Vec> = Vec::new(); + + // (2^8)^4 = 2^32 => 32bit + let range: Box<[u8; u32::max_value() as usize]> = (0..u8::max_value()).collect::>().try_into().expect("nope"); + + + perms +} diff --git a/src/scanner.rs b/src/scanner.rs index 1f62648..21d8784 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -1,23 +1,25 @@ use std::{net::{TcpStream, SocketAddr}, thread::JoinHandle}; use log::info; use std::thread; -use crate::ipv4_gen; +use crate::permutations; async fn check_ack(dest: &SocketAddr) -> bool { if let Ok(res) = TcpStream::connect(dest) { info!("Got TCP ack from: {:?}", dest); return true; } - return false; + false } pub fn start_scan(depth: u32) { - let threads: Vec> = Vec::new(); + let mut threads: Vec> = Vec::new(); for i in 0..depth { let thread = thread::spawn(|| { println!("hi"); + // do scan }); + threads.push(thread); } }