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

Be able to specify fields in conditions with %field% #740

Closed YamatoSecurity closed 1 year ago

YamatoSecurity commented 2 years ago

Sysmon 10+では、Sysmon EID 1 のプロセス作成イベントにファイルのPEヘッダーに書いてあるコンパイル時のファイル名(OriginalFilename)を記録してくれます。 攻撃者がlolbin攻撃で正常のバイナリを別のファイル名に変更する場合があるので、それを検知したいです。 最初は|equalsfieldでできると思っていましたが、現在のファイル名(Proc/Imageフィールド)がフルパスなので、使えません。 例:

Image: C:\Windows\System32\dllhost.exe、OriginalFilename: dllhost.exe -> true
Image: C:\Windows\System32\certutil.exe、OriginalFilename: CertUtil.exe -> true
Image: C:\Windows\System32\mshelper.exe、OriginalFilename: psexec.exe -> false
等々
filter:
    Image|endswithfield: OriginalFilename
condition: not filter

のようなルールを書きたいです。そうすると、mshelper.exeに名前変更されたpsexec.exeを検知できます。 ※大文字小文字が一致しない場合が多いので、大文字小文字を区別しないように実装する必要があります。

参考: https://medium.com/@olafhartong/sysmon-10-0-new-features-and-changes-e82106f2e00

hitenkoku commented 2 years ago

@YamatoSecurity 確認用のデータがありましたら提供いただけますでしょうか?

YamatoSecurity commented 2 years ago

hayabusa-sample-evtx/EVTX-ATTACK-SAMPLES/Privilege Escalation/privesc_unquoted_svc_sysmon_1_11.evtx で検証できます。 OriginalFileName: Cmd.Exe Image: C:\program.exe

hitenkoku commented 1 year ago

メモ

  1. まず今の形で対応できるかを確認する
  2. もしできなかったら、値のところで%で囲まれたフィールドの値を展開して対応できないかを検討する

2.ができれば以下のようなルールで対応できるようになるはず

filter:
    Image|re: ".*%OriginalFileName%"
condition: not filter