From c1f38e393c627e1bdab259889d9f8ba202b2aacc Mon Sep 17 00:00:00 2001 From: Skyf0l <59019720+skyf0l@users.noreply.github.com> Date: Sun, 22 Sep 2024 22:54:43 +0200 Subject: [PATCH] chore: replace atty by std::io::IsTerminal --- Cargo.lock | 49 +++---------------------------------------------- Cargo.toml | 3 +-- src/main.rs | 7 ++++--- 3 files changed, 8 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 684b7f4..e95be03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,17 +114,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.3.0" @@ -832,15 +821,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -1096,7 +1076,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -1171,7 +1151,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -1652,9 +1632,8 @@ dependencies = [ [[package]] name = "rsacracker" -version = "0.6.8" +version = "0.6.9" dependencies = [ - "atty", "base-x", "base64 0.22.1", "clap", @@ -2340,28 +2319,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 52f21aa..b03c7ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsacracker" -version = "0.6.8" +version = "0.6.9" edition = "2021" authors = ["skyf0l "] description = "Powerful RSA cracker for CTFs. Supports RSA, X509, OPENSSH in PEM and DER formats." @@ -54,7 +54,6 @@ indicatif = "0.17" itertools = "0.13" discrete-logarithm = "1.0" base64 = "0.22" -atty = "0.2.14" [dependencies.rug] version = "1" diff --git a/src/main.rs b/src/main.rs index 7fafeea..07ca3e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use rug::{ Integer, }; use std::{ - io::{self, Read}, + io::{self, IsTerminal, Read}, sync::Arc, time::Duration, }; @@ -175,10 +175,11 @@ fn main() -> Result<(), MainError> { }; // Parse raw - let mut params = if !atty::is(atty::Stream::Stdin) { + let mut stdin = io::stdin(); + let mut params = if !stdin.is_terminal() { // Piped input let mut raw = String::new(); - io::stdin().read_to_string(&mut raw)?; + stdin.read_to_string(&mut raw)?; Parameters::from_raw(&raw) } else if let Some(raw) = args.raw.as_ref() { // rsacracker --raw