Yamato-Security / hayabusa

Hayabusa (隼) is a sigma-based threat hunting and fast forensics timeline generator for Windows event logs.
GNU Affero General Public License v3.0
2.26k stars 200 forks source link

[bug] An error occurs when executing cargo run because the files in the config folder cannot be read. #618

Closed hach1yon closed 2 years ago

hach1yon commented 2 years ago

Describe the bug 下記2つのバグがあるようです。

hayabusa.exeをC:\Users\takai\dev\git\hayabusaにコピーして下記のように実行すると、エラーは解消される。

hayabusa.exe --directory=C:\Users\takai\dev\git\hayabusa-sample-evtx -r 
 .\rules\hayabusa\default\alerts\WindowsDefender\1116_WindowsDefenderAlert.yml

Step to Reproduce Steps to reproduce the behavior:

[ERROR] Hayabusa could not find the config directory. Please make sure that it is in the same directory as the hayabusa executable.


* --rules-configオプションをつけてcargo runしても反映されていないように見える

C:\Users\takai\dev\git\hayabusa>cargo run -- --directory=C:\Users\takai\dev\git\hayabusa-sample-evtx -r .\rules\hayabusa\default\alerts\WindowsDefender\1116_WindowsDefenderAlert.yml --rules-config=C:\Users\takai\dev\git\hayabusa\rules\config Compiling hayabusa v1.4.2-dev (C:\Users\takai\dev\git\hayabusa) Finished dev [unoptimized + debuginfo] target(s) in 2.76s Running target\debug\hayabusa.exe --directory=C:\Users\takai\dev\git\hayabusa-sample-evtx -r .\rules\hayabusa\default\alerts\WindowsDefender\1116_WindowsDefenderAlert.yml --rules-config=C:\Users\takai\dev\git\hayabusa\rules\config [ERROR] Cannot open file. [file:C:\Users\takai\dev\git\hayabusa\target\debug\rules/config/statistics_event_info.txt] [ERROR] Cannot open file. [file:C:\Users\takai\dev\git\hayabusa\target\debug\rules/config/target_event_IDs.txt]

[ERROR] Hayabusa could not find the config directory. Please make sure that it is in the same directory as the hayabusa executable.



**Expected behavior**

**Screenshots**

**Environment (please complete the following information):**
 - OS: Windows
 - hayabusa version v1.4.1

**Additional context**
YamatoSecurity commented 2 years ago

Velociraptor等のツールから実行すると、カレントディレクトリではないディレクトリからの実行になるので、configディレクトリが見つからないというエラーで失敗するというクレームが来ていたので、カレントディレクトリじゃなくても実行できるようにHayabusa.exeが入っているパスを調べて、そこにあるconfigを使っています。なので、開発時に./target/release/hayabusa.exeなどを実行すると、configディレクトリを./target/release/configで探してしまうので、失敗します。 hayabusa.exeが入っているパスにconfigを探して、無い場合はカレントディレクトリにconfigを探すようにすれば、どっちもいけると思います。

hitenkoku commented 2 years ago

以下の件について、--rules--rules-configについて対応をしようと思います。

hayabusa.exeが入っているパスにconfigを探して、無い場合はカレントディレクトリにconfigを探すようにすれば、どっちもいけると思います