diff --git a/CHANGELOG-Japanese.md b/CHANGELOG-Japanese.md index f74b5e5e9..3a33e5a55 100644 --- a/CHANGELOG-Japanese.md +++ b/CHANGELOG-Japanese.md @@ -13,6 +13,7 @@ - `windash`文字が、`rules/config/windash_characters.txt`から動的に読み込まれるようになった。(#1440) (@fukusuket) - `logon-summary`コマンドがRDPイベントからのログオン情報を表示するようになった。注意: ファイルに保存する場合、Hayabusaはより詳細な情報を出力する。(#1468) (@fukusuket) - 見やすくなるように色を更新した。 (#1480) (@yamatosecurity) +- 実行開始と終了のメッセージを出力するようにした。 (#1492) (@fukusuket) **バグ修正:** diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c12213b6..3e75efa00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `windash` characters are now being dynamically read from `rules/config/windash_characters.txt`. (#1440) (@fukusuket) - `logon-summary` command now displays logon information from RDP events. Note: Hayabusa will output more detailed information when saving to a file. (#1468) (@fukusuket) - The colors were updated to make it easier to read. (#1480) (@yamatosecurity) +- Added start and finish messages of the day. (#1492) (@fukusuket) **Bug Fixes:** diff --git a/Cargo.lock b/Cargo.lock index c3c1e18a0..b57266983 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -256,9 +256,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.36" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" dependencies = [ "jobserver", "libc", @@ -368,7 +368,7 @@ dependencies = [ "crossterm", "strum", "strum_macros", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -394,7 +394,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -406,9 +406,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -481,9 +481,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -1093,15 +1093,15 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.8" +version = "0.17.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" +checksum = "cbf675b85ed934d3c67b5c5469701eec7db22689d0a2139d856e0925fa28b281" dependencies = [ "console", - "instant", "number_prefix", "portable-atomic", - "unicode-width", + "unicode-width 0.2.0", + "web-time", ] [[package]] @@ -1110,15 +1110,6 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "ipnetwork" version = "0.20.0" @@ -1723,9 +1714,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -1816,9 +1807,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -1897,18 +1888,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", @@ -2117,18 +2108,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -2198,6 +2189,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "untrusted" version = "0.9.0" @@ -2332,6 +2329,16 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "webpki-roots" version = "0.26.6" diff --git a/Cargo.toml b/Cargo.toml index 7d5114b1d..8cabbe735 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ nested="*" num = "0.4.0" num-format = "*" pulldown-cmark = { version = "0.9.*", default-features = false, features = ["simd"] } +rand = "0.8.*" regex = "1" serde = { version = "1.*", features = ["derive"] } serde_derive = "1.*" diff --git a/src/main.rs b/src/main.rs index 0c18fda00..948c0feb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ use std::borrow::BorrowMut; use std::ffi::{OsStr, OsString}; use std::fmt::Display; use std::fmt::Write as _; -use std::io::{copy, BufWriter, Write}; +use std::io::{copy, BufRead, BufWriter, Write}; use std::path::Path; use std::ptr::null_mut; use std::sync::Arc; @@ -16,6 +16,7 @@ use std::time::Duration; use std::{ env, fs::{self, File}, + io, path::PathBuf, vec, }; @@ -62,6 +63,7 @@ use libmimalloc_sys::mi_stats_print_out; use mimalloc::MiMalloc; use nested::Nested; use num_format::{Locale, ToFormattedString}; +use rand::seq::SliceRandom; use rust_embed::Embed; use serde_json::{Map, Value}; use termcolor::{BufferWriter, Color, ColorChoice}; @@ -221,7 +223,7 @@ impl App { .ok(); println!(); } - + let _ = self.output_open_close_message("opening_messages.txt", stored_static); write_color_buffer( &BufferWriter::stdout(ColorChoice::Always), None, @@ -616,7 +618,6 @@ impl App { } } } - println!(); let split_now_version = &now_version .replace("-dev", "") .split('.') @@ -647,8 +648,9 @@ impl App { true, ) .ok(); - println!(); } + println!(); + let _ = self.output_open_close_message("closing_messages.txt", stored_static); return; } Action::LevelTuning(option) => { @@ -717,6 +719,7 @@ impl App { ) .ok(); } + let _ = self.output_open_close_message("closing_messages.txt", stored_static); return; } Action::SetDefaultProfile(_) => { @@ -747,6 +750,7 @@ impl App { ) { AlertMessage::alert(&e).ok(); } + let _ = self.output_open_close_message("closing_messages.txt", stored_static); return; } Action::ListProfiles(_) => { @@ -774,7 +778,7 @@ impl App { ) .ok(); } - println!(); + let _ = self.output_open_close_message("closing_messages.txt", stored_static); return; } } @@ -807,6 +811,8 @@ impl App { if ERROR_LOG_STACK.lock().unwrap().len() > 0 { AlertMessage::create_error_log(stored_static.quiet_errors_flag); } + println!(); + let _ = self.output_open_close_message("closing_messages.txt", stored_static); // Debugフラグをつけていた時にはメモリ利用情報などの統計情報を画面に出力する if stored_static.config.debug { @@ -817,7 +823,6 @@ impl App { mi_stats_print_out(None, null_mut()); } } - println!(); } fn analysis_start( @@ -2376,6 +2381,37 @@ impl App { } } + fn output_open_close_message( + &self, + file_path: &str, + stored_static: &StoredStatic, + ) -> io::Result<()> { + if stored_static.common_options.quiet { + return Ok(()); + } + let checked_path = check_setting_path( + &CURRENT_EXE_PATH.to_path_buf(), + format!("rules/config/{}", file_path).as_str(), + true, + ); + if let Some(f) = checked_path { + if f.exists() { + let file = File::open(f)?; + let lines: Vec = + io::BufReader::new(file).lines().collect::>()?; + if let Some(random_line) = lines.choose(&mut rand::thread_rng()) { + println!("{}\n", random_line); + } + } else if let Some(contents) = ONE_CONFIG_MAP.get(file_path) { + let lines: Vec<&str> = contents.lines().collect(); + if let Some(random_line) = lines.choose(&mut rand::thread_rng()) { + println!("{}\n", random_line); + } + } + } + Ok(()) + } + /// check architecture fn is_matched_architecture_and_binary(&self) -> bool { if cfg!(target_os = "windows") { diff --git a/src/options/update.rs b/src/options/update.rs index ad7d1d068..e94eeb7ff 100644 --- a/src/options/update.rs +++ b/src/options/update.rs @@ -245,7 +245,6 @@ impl Update { ) .ok(); } - println!(); for (key, value) in &update_count_by_rule_type { println!("Updated {key} rules: {value}"); }