Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Samirbous/292076c5ed8c7a3f82fb08692bb6cf4c to your computer and use it in GitHub Desktop.
Save Samirbous/292076c5ed8c7a3f82fb08692bb6cf4c to your computer and use it in GitHub Desktop.
// hunting on scheduled task via registry.data.bytes
from logs-endpoint.events.registry-*
| where host.os.type == "windows" and event.category == "registry" and event.action == "modification" and
registry.path like """HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks\\*Actions*"""
| eval scheduled_task_action = replace(TO_LOWER(FROM_BASE64(registry.data.bytes)), """\u0000""", "")
| eval scheduled_task_action = replace(scheduled_task_action, """(\u0003\fauthorfff|\u0003\fauthorff\u000e)""", "")
| where scheduled_task_action rlike """.*(users\\public\\|\\appdata\\roaming|programdata|powershell|rundll32|regsvr32|mshta.exe|cscript.exe|wscript.exe|cmd.exe|forfiles|msiexec).*""" and not scheduled_task_action like "localsystem*"
| keep scheduled_task_action, registry.path, agent.id
| stats count_agents = count_distinct(agent.id) by scheduled_task_action | where count_agents == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment