From bc433a63b164003408867c2cfb834d5628408673 Mon Sep 17 00:00:00 2001 From: turtel Date: Fri, 16 Feb 2024 23:41:46 +0100 Subject: [PATCH] first commit --- .gitignore | 1 + Cargo.lock | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 9 ++++++ README.md | 13 ++++++++ src/main.rs | 34 ++++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4ecc3d5 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,92 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "portsChecker" +version = "1.1.0" +dependencies = [ + "colored", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8523400 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "portsChecker" +version = "1.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +colored = "2.1.0" diff --git a/README.md b/README.md new file mode 100644 index 0000000..23d38c3 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +Simple written by chatGPT lol ports checker. + + +Usage for Linux: +1. Download the "portsChecker" file +2. type 'chmod +x portsChecker' +3. run program with './portsChecker' + + +Usage for windows: +1. Install rust +2. Download or clone source code +3. Type 'cargo run' or 'build --release ' diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8746b6c --- /dev/null +++ b/src/main.rs @@ -0,0 +1,34 @@ +use std::io; +use std::net::{TcpStream}; +use colored::Colorize; + +fn main() { + println!("Welcome to the port scanner! (made by not you)"); + println!("Enter the IP address to check:"); + let mut ip = String::new(); + io::stdin().read_line(&mut ip).expect("Failed to read IP address"); + let ip = ip.trim(); + + println!("Enter the ports to check, separated by commas (e.g. 80,443,8080):"); + let mut ports = String::new(); + io::stdin().read_line(&mut ports).expect("Failed to read ports"); + println!("If not responding in about 10 seconds the port is propably closed, you don't have to wait for it to finish ;)"); + let ports: Vec<_> = ports.trim().split(',').map(|p| p.trim().parse::().unwrap()).collect(); + + for port in ports { + match TcpStream::connect(format!("{}:{}", ip, port)) { + Ok(_) => println!("{} {} {}", "Port".green(), port, "is open".green()), + Err(_) => println!("{} {} {}", "Port".green(), port, "is closed".red()), + } + } + + println!("Want do check another IP? Click ENTER if no type N"); + let mut answer = String::new(); + io::stdin().read_line(&mut answer).expect("Failed to read answer"); + if answer.trim() == "y" || answer.trim() == "Y" || answer.trim().is_empty() { + main(); + } else { + std::process::exit(0); + + } +}