Trivia/eastereggs#212 (#266)

* add ninja arts #212

* add takoyakiday eggs #212

* add christmas eggs #212

* add happy newyear eggs #212

* changed encode from UTF-8 BOM to UTF-8

* add output easteregg #212

- changed analysis datetime from Utc to Local
- added output easteregg #213

* changed happynewyear arts #212

* fix ninja day #212

* fix christmas #212
This commit is contained in:
DustInDark
2021-12-07 01:52:27 +09:00
committed by GitHub
parent 50daf1d716
commit 493c5ddec1
6 changed files with 133 additions and 5 deletions
+29 -4
View File
@@ -1,7 +1,8 @@
extern crate serde;
extern crate serde_derive;
use chrono::{DateTime, Utc};
use chrono::Datelike;
use chrono::{DateTime, Local};
use evtx::{EvtxParser, ParserSettings};
use hayabusa::detections::detection;
use hayabusa::detections::detection::EvtxRecordInfo;
@@ -12,6 +13,7 @@ use hayabusa::{detections::configs, timeline::timeline::Timeline};
use hhmmss::Hhmmss;
use pbr::ProgressBar;
use serde_json::Value;
use std::collections::HashMap;
use std::{
fs::{self, File},
path::PathBuf,
@@ -22,9 +24,15 @@ use std::{
const MAX_DETECT_RECORDS: usize = 40000;
fn main() {
let analysis_start_time: DateTime<Local> = Local::now();
if !configs::CONFIG.read().unwrap().args.is_present("q") {
output_logo();
println!("");
output_eggs(&format!(
"{:02}/{:02}",
&analysis_start_time.month().to_owned(),
&analysis_start_time.day().to_owned()
));
}
if configs::CONFIG.read().unwrap().args.args.len() == 0 {
println!(
@@ -33,7 +41,6 @@ fn main() {
);
return;
}
let analysis_start_time: DateTime<Utc> = Utc::now();
if let Some(filepath) = configs::CONFIG.read().unwrap().args.value_of("filepath") {
if !filepath.ends_with(".evtx") {
AlertMessage::alert(
@@ -64,7 +71,7 @@ fn main() {
print_contributors();
return;
}
let analysis_end_time: DateTime<Utc> = Utc::now();
let analysis_end_time: DateTime<Local> = Local::now();
let analysis_duration = analysis_end_time.signed_duration_since(analysis_start_time);
println!("Elapsed Time: {}", &analysis_duration.hhmmssxxx());
println!("");
@@ -237,12 +244,30 @@ fn _output_with_omikuji(omikuji: Omikuji) {
println!("{}", content);
}
/// output logo
fn output_logo() {
let fp = &format!("art/logo.txt");
let content = fs::read_to_string(fp).unwrap();
let content = fs::read_to_string(fp).unwrap_or("".to_owned());
println!("{}", content);
}
/// output easter egg arts
fn output_eggs(exec_datestr: &str) {
let mut eggs: HashMap<&str, &str> = HashMap::new();
eggs.insert("01/01", "art/happynewyear.txt");
eggs.insert("02/22", "art/ninja.txt");
eggs.insert("08/08", "art/takoyaki.txt");
eggs.insert("12/25", "art/christmas.txt");
match eggs.get(exec_datestr) {
None => {}
Some(path) => {
let content = fs::read_to_string(path).unwrap_or("".to_owned());
println!("{}", content);
}
}
}
#[cfg(test)]
mod tests {
use crate::collect_evtxfiles;