Created
November 15, 2016 04:31
-
-
Save johshoff/bed463ce8a122123e60bbc84bd1b1129 to your computer and use it in GitHub Desktop.
scan ips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::thread; | |
use std::net::TcpStream; | |
fn check_open_port(host: &str, port: u16) -> bool { | |
TcpStream::connect((host, port)).is_ok() | |
} | |
fn main() { | |
const PORT : u16 = 22; | |
println!("Scanning for port {}", PORT); | |
let mut threads = Vec::new(); | |
for x in 1..254 { | |
let ip = format!("192.168.1.{:?}", x); | |
threads.push(thread::spawn(move || { | |
if check_open_port(&ip, PORT) { | |
println!("{}:{}", ip, PORT); | |
} | |
})); | |
} | |
for thread in threads { | |
thread.join().unwrap(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment