Detection rules › Elastic

Potential Data Exfiltration Through Wget

Source
github.com/elastic/protections-artifacts

Detects the use of wget to upload collected data or files to an internet server from suspicious working directories, including via HTTP POST options or use of cat/base64 on sensitive paths. Threat actors commonly collect data on a system and exfiltrate it back to their C2 server, and wget has been observed being abused for this purpose. Use of wget in this way, while not inherently malicious, should be considered highly abnormal and suspicious activity.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Detects the use of wget to upload collected data or files to an internet server from suspicious working directories,
including via HTTP POST options or use of cat/base64 on sensitive paths. Threat actors commonly collect data on a system
and exfiltrate it back to their C2 server, and wget has been observed being abused for this purpose. Use of wget in this
way, while not inherently malicious, should be considered highly abnormal and suspicious activity.
"""
id = "5389bdae-778e-48b6-af2e-0107327ca855"
license = "Elastic License v2"
name = "Potential Data Exfiltration Through Wget"
os_list = ["linux"]
reference = ["https://linux.die.net/man/1/wget"]
version = "1.0.3"

query = '''
process where event.type == "start" and event.action == "exec" and process.name == "wget" and
process.parent.executable != null and (
  process.args like ("--post-file*", "--post-data*", "--body-file*") or
  (
    process.command_line like ("*cat*", "*base64*") and
    process.command_line like (
      "*/etc/passwd*", "*/etc/shadow*", "*~/.ssh/*", "*.env*", "*credentials*", "*/tmp/*",
      "*/var/tmp/*", "*/dev/shm/*", "*/home/*/*", "*/root/*"
    )
  )
) and
(
  process.command_line like ("*http://*", "*https://*") or
  process.command_line regex ".*[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}.*"
) and (
  process.working_directory like (
    "/tmp*", "/var/tmp*", "/dev/shm*", "/run*", "/var/run*", "/home/*/*", "/root*",
    "/var/www*", "/boot*", "/srv*", "/mnt*", "/media*"
  ) or
  process.parent.working_directory like (
    "/tmp*", "/var/tmp*", "/dev/shm*", "/run*", "/var/run*", "/home/*/*", "/root*",
    "/var/www*", "/boot*", "/srv*", "/mnt*", "/media*"
  )
) and
not
(
  process.command_line like (
    "*://localhost*",
    "*://127.0.0.1*",
    "*://0.0.0.0*",
    "*://[::1]*",
    "*10.*.*.*",
    "*192.168.*.*",
    "*172.16.*.*",
    "*api.telegram.org*", /* already covered by another rule */
    "*https://storage.googleapis.com/detonate-prod/*",
    "*https://storage.googleapis.com/detonate-ci/*",
    "*https://artifactory.*.local/artifactory*"
  ) or
  process.working_directory like ("/home/*/*", "/root", "/opt/ft/nl/*") or
  process.parent.executable like "/opt/miniconda/bin/python*" or
  process.parent.command_line like ("*/var/spool/asterisk/wgetstderr*", "*lastaccesseduuid*")
)
'''

min_endpoint_version = "8.2.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1048"
name = "Exfiltration Over Alternative Protocol"
reference = "https://attack.mitre.org/techniques/T1048/"


[threat.tactic]
id = "TA0010"
name = "Exfiltration"
reference = "https://attack.mitre.org/tactics/TA0010/"

[internal]
min_endpoint_version = "8.2.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and event.action == "exec" and process.name == "wget" and
process.parent.executable != null and (
  process.args like ("--post-file*", "--post-data*", "--body-file*") or
  (
    process.command_line like ("*cat*", "*base64*") and
    process.command_line like (
      "*/etc/passwd*", "*/etc/shadow*", "*~/.ssh/*", "*.env*", "*credentials*", "*/tmp/*",
      "*/var/tmp/*", "*/dev/shm/*", "*/home/*/*", "*/root/*"
    )
  )
) and
(
  process.command_line like ("*http://*", "*https://*") or
  process.command_line regex ".*[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}.*"
) and (
  process.working_directory like (
    "/tmp*", "/var/tmp*", "/dev/shm*", "/run*", "/var/run*", "/home/*/*", "/root*",
    "/var/www*", "/boot*", "/srv*", "/mnt*", "/media*"
  ) or
  process.parent.working_directory like (
    "/tmp*", "/var/tmp*", "/dev/shm*", "/run*", "/var/run*", "/home/*/*", "/root*",
    "/var/www*", "/boot*", "/srv*", "/mnt*", "/media*"
  )
) and
not
(
  process.command_line like (
    "*://localhost*",
    "*://127.0.0.1*",
    "*://0.0.0.0*",
    "*://[::1]*",
    "*10.*.*.*",
    "*192.168.*.*",
    "*172.16.*.*",
    "*api.telegram.org*",
    "*https://storage.googleapis.com/detonate-prod/*",
    "*https://storage.googleapis.com/detonate-ci/*",
    "*https://artifactory.*.local/artifactory*"
  ) or
  process.working_directory like ("/home/*/*", "/root", "/opt/ft/nl/*") or
  process.parent.executable like "/opt/miniconda/bin/python*" or
  process.parent.command_line like ("*/var/spool/asterisk/wgetstderr*", "*lastaccesseduuid*")
)

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.command_linewildcard*://localhost*, *://127.0.0.1*, *://0.0.0.0*, *://[::1]*, *10.*.*.*, *192.168.*.*, *172.16.*.*, *api.telegram.org*, *https://storage.googleapis.com/detonate-prod/*, *https://storage.googleapis.com/detonate-ci/*, *https://artifactory.*.local/artifactory*excludes:process.command_line
process.parent.command_linematch/var/spool/asterisk/wgetstderr, lastaccesseduuidexcludes:process.parent.command_line field:"process.parent.command_line" value:"/var/spool/asterisk/wgetstderr" field:"process.parent.command_line" value:"lastaccesseduuid"
process.parent.executablestarts_with/opt/miniconda/bin/pythonexcludes:process.parent.executable field:"process.parent.executable" value:"/opt/miniconda/bin/python"
process.working_directorywildcard/home/*/*, /root, /opt/ft/nl/*excludes:process.working_directory field:"process.working_directory" value:"/home/*/*" field:"process.working_directory" value:"/root" field:"process.working_directory" value:"/opt/ft/nl/*"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • exec
field:"EventType" kind:eq value:"exec"
event.typeeq
  • start
field:"event.type" kind:eq value:"start"
process.argswildcard
  • --body-file*
  • --post-data*
  • --post-file*
field:"process.args" kind:wildcard
process.command_lineregex_match
  • .*[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.*
field:"CommandLine" kind:regex_match value:".*[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.*"
process.command_linewildcard
  • *.env*
  • */dev/shm/*
  • */etc/passwd*
  • */etc/shadow*
  • */home/*/*
  • */root/*
  • */tmp/*
  • */var/tmp/*
  • *base64*
  • *cat*
  • *credentials*
  • *http://*
  • *https://*
  • *~/.ssh/*
field:"CommandLine" kind:wildcard
process.nameeq
  • wget
field:"process_name" kind:eq value:"wget"
process.parent.executableis_not_null
  • (no value, null check)
field:"ParentImage" kind:is_not_null
process.parent.working_directorywildcard
  • /boot*
  • /dev/shm*
  • /home/*/*
  • /media*
  • /mnt*
  • /root*
  • /run*
  • /srv*
  • /tmp*
  • /var/run*
  • /var/tmp*
  • /var/www*
field:"process.parent.working_directory" kind:wildcard
process.working_directorywildcard
  • /boot*
  • /dev/shm*
  • /home/*/*
  • /media*
  • /mnt*
  • /root*
  • /run*
  • /srv*
  • /tmp*
  • /var/run*
  • /var/tmp*
  • /var/www*
field:"CurrentDirectory" kind:wildcard