TryHackMe 歴1ヵ月半が参加する Advent of Cyber 2022 [Day 18]

18 日目。

[Day 18] Lumberjack Lenny Learns New Rules

Sigma ルールを YAML 形式で記述してログを漁る(?)。そんなイメージ。

What is the Challenge #1 flag?

いずれの問題も Attack Scenario にある表を見ながら yaml ファイルを書き換えてフラグを得る。表の Attack Technique にはそれぞれフラグを得る課題のシナリオが書かれているので、Indicators of Compromise と Required Detection Fields を見ながら書き換える。

はじめの問題は

  • EventID: 4720
  • Service: Security

なので logsource → service の箇所に security を記述し、detection → selection に EventID を記述する。他の箇所は特に記述する必要はない。はじめわかんなすぎて title とか id とか果ては author なんかも埋めてた

title:
id: # UUID
status: # experimental, test, stable, deprecated, unsupported.
description:
author:
date:
modified:

logsource: # Outlines target source of the logs based on operating system, service being run, category of logs.
  product: # windows, linux, macos.
  service: security # sshd for Linux, Security for Windows, applocker, sysmon.
  category: # firewall, web, antivirus, process_creation, network_connection, file_access.

detection:
  selection:
    EventID:
      - 4720

  condition: selection # Action to be taken. Can use condition operators such as OR, AND, NOT when using multiple search identifiers.

falsepositives: # Legitimate services or use.

level:  # informational, low, medium, high or critical.

tags: # Associated TTPs from MITRE ATT&CK
  - {attack.tactic} # MITRE Tactic
  - {attack.technique} # MITRE Technique 

この状態で Run ボタンを押すとフラグが得られる。

From the Challenge 1 log, what user account was created?

右側の View Log が見られるようになっているので、その中の TargetUserName の値を回答する。

What is the Challenge #2 flag?

Attack Scenario の表を見ながら yaml ファイルを記述する。迷うのは detection → selectoin の箇所であろう。Image については解説の例にあるように endswith を用いた。CommandLine については contains|all を用いてオプション等は省いたが、/v がないと Rule too generic. Specify the filter. (Required filter: /v) と言われたので追記した。

detection:
  selection:
    EventID:
      - 1
    Image|endswith:
      - '\reg.exe'
    CommandLine|contains|all:
      - 'reg'
      - 'query'
      - 'Internet Explorer'
      - '/v'
      - 'svcVersion'

全体のコードは以下の通り。これで Run するとフラグが得られる。

title:
id: # UUID
status: # experimental, test, stable, deprecated, unsupported.
description:
author:
date:
modified:

logsource: # Outlines target source of the logs based on operating system, service being run, category of logs.
  product: # windows, linux, macos.
  service: sysmon # sshd for Linux, Security for Windows, applocker, sysmon.
  category: process_creation # firewall, web, antivirus, process_creation, network_connection, file_access.

detection:
  selection:
    EventID:
      - 1
    Image|endswith:
      - '\reg.exe'
    CommandLine|contains|all:
       - 'reg'
       - 'query'
       - 'Internet'
       - 'Explorer'
       - '/v'
       - 'svcVersion'

  condition: selection # Action to be taken. Can use condition operators such as OR, AND, NOT when using multiple search identifiers.

falsepositives: # Legitimate services or use.

level:  # informational, low, medium, high or critical.

tags: # Associated TTPs from MITRE ATT&CK
  - {attack.tactic} # MITRE Tactic
  - {attack.technique} # MITRE Technique 

What was the User's path in the Challenge #2 log file?

ログの User の値がいかにもなのでそれを回答する。

What is the Challenge #3 flag?

Flag2 と同様~と言いたかったが detection → selection の箇所でハマってしまった。CommandLine の箇所でいろいろコメントアウトしながら試したが、結局 /createcmd.exe があれば通るらしい。

detection:
  selection:
    EventID:
      - 1
    Image|endswith:
      - '\schtasks.exe'
    ParentImage|endswith:
      - '\cmd.exe'
    CommandLine|contains|all:
      # - 'schtasks'
      - '/create'
      # - 'T1053_005_OnLogon'
      # - 'onlogon'
      - 'cmd.exe'
      # - 'calc.exe'

全体のコードは以下の通り。これで Run するとフラグが得られる。

title:
id: # UUID
status: # experimental, test, stable, deprecated, unsupported.
description:
author:
date:
modified:

logsource: # Outlines target source of the logs based on operating system, service being run, category of logs.
  product: # windows, linux, macos.
  service: sysmon # sshd for Linux, Security for Windows, applocker, sysmon.
  category: process_creation # firewall, web, antivirus, process_creation, network_connection, file_access.

detection:
  selection:
    EventID:
      - 1
    Image|endswith:
      - '\schtasks.exe'
    ParentImage|endswith:
      - '\cmd.exe'
    CommandLine|contains|all:
      # - 'schtasks'
      - '/create'
      # - 'T1053_005_OnLogon'
      # - 'onlogon'
      - 'cmd.exe'
      # - 'calc.exe'
      
  condition: selection # Action to be taken. Can use condition operators such as OR, AND, NOT when using multiple search identifiers.

falsepositives: # Legitimate services or use.

level:  # informational, low, medium, high or critical.

tags: # Associated TTPs from MITRE ATT&CK
  - {attack.tactic} # MITRE Tactic

What was the MD5 hash associated with Challenge #3 logs?

ログの Hashes の値に MD5=... とあるのでそれを回答する。

Did you like learning about detection? Check out the Yara room to learn more!

No answer needed

感想

解説を読んだだけでは正直全然わからなかったので、いろいろ調べながら実行しながらで悪戦苦闘した。特に Flag3 の入手についてはいまだに納得がいかない……。