Connection to Commonly Abused Web Services

Adversaries may implement command and control (C2) communications that use common web services to hide their activity. This attack technique is typically targeted at an organization and uses web services common to the victim network, which allows the adversary to blend into legitimate traffic activity. These popular services are typically targeted since they have most likely been used before compromise, which helps malicious traffic blend in.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/04"
  3integration = ["endpoint"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/04/11"
  8
  9[transform]
 10[[transform.osquery]]
 11label = "Osquery - Retrieve DNS Cache"
 12query = "SELECT * FROM dns_cache"
 13
 14[[transform.osquery]]
 15label = "Osquery - Retrieve All Services"
 16query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
 17
 18[[transform.osquery]]
 19label = "Osquery - Retrieve Services Running on User Accounts"
 20query = """
 21SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
 22NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
 23user_account == null)
 24"""
 25
 26[[transform.osquery]]
 27label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
 28query = """
 29SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
 30services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
 31authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
 32"""
 33
 34[[transform.investigate]]
 35label = "Alerts associated with the user in the last 48h"
 36relativeFrom = "now-48h/h"
 37relativeTo = "now"
 38providers = [
 39  [
 40    {field = "event.kind", excluded = false, queryType = "phrase", value = "signal", valueType = "string"},
 41    {field = "user.id", excluded = false, queryType = "phrase", value = "{{user.id}}", valueType = "string"}
 42  ]
 43]
 44
 45
 46[[transform.investigate]]
 47label = "Alerts associated with the host in the last 48h"
 48relativeFrom = "now-48h/h"
 49relativeTo = "now"
 50providers = [
 51  [
 52    {field = "event.kind", excluded = false, queryType = "phrase", value = "signal", valueType = "string"},
 53    {field = "host.name", excluded = false, queryType = "phrase", value = "{{host.name}}", valueType = "string"}
 54  ]
 55]
 56
 57[[transform.investigate]]
 58label = "Investigate the Subject Process Network Events"
 59providers = [
 60  [
 61    {field = "process.entity_id", excluded = false, queryType = "phrase", value = "{{process.entity_id}}", valueType = "string"},
 62    {field = "event.category", excluded = false, queryType = "phrase", value = "network", valueType = "string"}
 63  ]
 64]
 65
 66
 67[rule]
 68author = ["Elastic"]
 69description = """
 70Adversaries may implement command and control (C2) communications that use common web services to hide their activity.
 71This attack technique is typically targeted at an organization and uses web services common to the victim network, which
 72allows the adversary to blend into legitimate traffic activity. These popular services are typically targeted since they
 73have most likely been used before compromise, which helps malicious traffic blend in.
 74"""
 75from = "now-9m"
 76index = ["logs-endpoint.events.network-*"]
 77language = "eql"
 78license = "Elastic License v2"
 79name = "Connection to Commonly Abused Web Services"
 80note = """## Triage and analysis
 81
 82### Investigating Connection to Commonly Abused Web Services
 83
 84Adversaries may use an existing, legitimate external Web service as a means for relaying data to/from a compromised system. Popular websites and social media acting as a mechanism for C2 may give a significant amount of cover due to the likelihood that hosts within a network are already communicating with them prior to a compromise.
 85
 86This rule looks for processes outside known legitimate program locations communicating with a list of services that can be abused for exfiltration or command and control.
 87
 88> **Note**:
 89> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 90> This investigation guide uses the [Investigate Markdown Plugin](https://www.elastic.co/guide/en/security/master/interactive-investigation-guides.html) introduced in Elastic Stack version 8.8.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 91
 92#### Possible investigation steps
 93
 94- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 95- Investigate other alerts associated with the user/host during the past 48 hours.
 96  - $investigate_0
 97  - $investigate_1
 98- Verify whether the digital signature exists in the executable.
 99- Identify the operation type (upload, download, tunneling, etc.).
100- Examine the host for derived artifacts that indicate suspicious activities:
101  - Analyze the process executable using a private sandboxed analysis system.
102  - Observe and collect information about the following activities in both the sandbox and the alert subject host:
103    - Attempts to contact external domains and addresses.
104      - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
105        - $investigate_2
106      - Examine the DNS cache for suspicious or anomalous entries.
107        - $osquery_0
108    - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
109    - Examine the host services for suspicious or anomalous entries.
110      - $osquery_1
111      - $osquery_2
112      - $osquery_3
113  - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
114
115### False positive analysis
116
117- This rule has a high chance to produce false positives because it detects communication with legitimate services. Noisy false positives can be added as exceptions.
118
119### Response and remediation
120
121- Initiate the incident response process based on the outcome of the triage.
122- Isolate the involved host to prevent further post-compromise behavior.
123- If the triage identified malware, search the environment for additional compromised hosts.
124  - Implement temporary network rules, procedures, and segmentation to contain the malware.
125  - Stop suspicious processes.
126  - Immediately block the identified indicators of compromise (IoCs).
127  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
128- Remove and block malicious artifacts identified during triage.
129- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
130- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
131- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
132"""
133risk_score = 21
134rule_id = "66883649-f908-4a5b-a1e0-54090a1d3a32"
135severity = "low"
136tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Command and Control", "Resources: Investigation Guide", "Data Source: Elastic Defend"]
137timestamp_override = "event.ingested"
138type = "eql"
139
140query = '''
141network where host.os.type == "windows" and network.protocol == "dns" and
142    process.name != null and user.id not in ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
143    /* Add new WebSvc domains here */
144    dns.question.name :
145       (
146        "raw.githubusercontent.*",
147        "pastebin.*",
148        "paste4btc.com",
149        "paste.ee",
150        "ghostbin.com",
151        "drive.google.com",
152        "?.docs.live.net",
153        "api.dropboxapi.*",
154        "content.dropboxapi.*",
155        "dl.dropboxusercontent.*",
156        "api.onedrive.com",
157        "*.onedrive.org",
158        "onedrive.live.com",
159        "filebin.net",
160        "*.ngrok.io",
161        "ngrok.com",
162        "*.portmap.*",
163        "*serveo.net",
164        "*localtunnel.me",
165        "*pagekite.me",
166        "*localxpose.io",
167        "*notabug.org",
168        "rawcdn.githack.*",
169        "paste.nrecom.net",
170        "zerobin.net",
171        "controlc.com",
172        "requestbin.net",
173        "slack.com",
174        "api.slack.com",
175        "slack-redir.net",
176        "slack-files.com",
177        "cdn.discordapp.com",
178        "discordapp.com",
179        "discord.com",
180        "apis.azureedge.net",
181        "cdn.sql.gg",
182        "?.top4top.io",
183        "top4top.io",
184        "www.uplooder.net",
185        "*.cdnmegafiles.com",
186        "transfer.sh",
187        "gofile.io",
188        "updates.peer2profit.com",
189        "api.telegram.org",
190        "t.me",
191        "meacz.gq",
192        "rwrd.org",
193        "*.publicvm.com",
194        "*.blogspot.com",
195        "api.mylnikov.org",
196        "file.io",
197        "stackoverflow.com",
198        "*files.1drv.com",
199        "api.anonfile.com",
200        "*hosting-profi.de",
201        "ipbase.com",
202        "ipfs.io",
203        "*up.freeo*.space",
204        "api.mylnikov.org",
205        "script.google.com",
206        "script.googleusercontent.com",
207        "api.notion.com",
208        "graph.microsoft.com",
209        "*.sharepoint.com",
210        "mbasic.facebook.com",
211        "login.live.com",
212        "api.gofile.io",
213        "api.anonfiles.com",
214        "api.notion.com",
215        "api.trello.com",
216        "gist.githubusercontent.com",
217        "files.pythonhosted.org",
218        "g.live.com",
219        "*.zulipchat.com") and
220        
221    /* Insert noisy false positives here */
222    not (
223      (
224        process.executable : (
225          "?:\\Program Files\\*.exe",
226          "?:\\Program Files (x86)\\*.exe",
227          "?:\\Windows\\System32\\WWAHost.exe",
228          "?:\\Windows\\System32\\smartscreen.exe",
229          "?:\\Windows\\System32\\MicrosoftEdgeCP.exe",
230          "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*\\MsMpEng.exe",
231          "?:\\Users\\*\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe",
232          "?:\\Users\\*\\AppData\\Local\\BraveSoftware\\*\\Application\\brave.exe",
233          "?:\\Users\\*\\AppData\\Local\\Vivaldi\\Application\\vivaldi.exe",
234          "?:\\Users\\*\\AppData\\Local\\Programs\\Opera*\\opera.exe",
235          "?:\\Users\\*\\AppData\\Local\\Programs\\Fiddler\\Fiddler.exe",
236          "?:\\Users\\*\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe",
237          "?:\\Users\\*\\AppData\\Local\\Microsoft\\OneDrive\\OneDrive.exe",
238          "?:\\Windows\\system32\\mobsync.exe",
239          "?:\\Windows\\SysWOW64\\mobsync.exe"
240        )
241      ) or
242    
243      /* Discord App */
244      (process.name : "Discord.exe" and (process.code_signature.subject_name : "Discord Inc." and
245       process.code_signature.trusted == true) and dns.question.name : ("discord.com", "cdn.discordapp.com", "discordapp.com")
246      ) or 
247
248      /* MS Sharepoint */
249      (process.name : "Microsoft.SharePoint.exe" and (process.code_signature.subject_name : "Microsoft Corporation" and
250       process.code_signature.trusted == true) and dns.question.name : "onedrive.live.com"
251      ) or 
252
253      /* Firefox */
254      (process.name : "firefox.exe" and (process.code_signature.subject_name : "Mozilla Corporation" and
255       process.code_signature.trusted == true)
256      ) or 
257
258      /* Dropbox */
259      (process.name : "Dropbox.exe" and (process.code_signature.subject_name : "Dropbox, Inc" and
260       process.code_signature.trusted == true) and dns.question.name : ("api.dropboxapi.com", "*.dropboxusercontent.com")
261      ) or 
262
263      /* Obsidian - Plugins are stored on raw.githubusercontent.com */
264      (process.name : "Obsidian.exe" and (process.code_signature.subject_name : "Dynalist Inc" and
265       process.code_signature.trusted == true) and dns.question.name : "raw.githubusercontent.com"
266      ) or 
267
268      /* WebExperienceHostApp */
269      (process.name : "WebExperienceHostApp.exe" and (process.code_signature.subject_name : "Microsoft Windows" and
270       process.code_signature.trusted == true) and dns.question.name : ("onedrive.live.com", "skyapi.onedrive.live.com")
271      ) or
272
273      (process.code_signature.subject_name : "Microsoft *" and process.code_signature.trusted == true and
274       dns.question.name : ("*.sharepoint.com", "graph.microsoft.com", "g.live.com", "login.live.com", "login.live.com")) or
275
276      (process.code_signature.trusted == true and
277       process.code_signature.subject_name :
278                             ("Johannes Schindelin",
279                              "Redis Inc.",
280                              "Slack Technologies, LLC",
281                              "Cisco Systems, Inc.",
282                              "Dropbox, Inc",
283                              "Amazon.com Services LLC"))
284    ) 
285'''
286
287
288[[rule.threat]]
289framework = "MITRE ATT&CK"
290[[rule.threat.technique]]
291id = "T1102"
292name = "Web Service"
293reference = "https://attack.mitre.org/techniques/T1102/"
294
295[[rule.threat.technique]]
296id = "T1568"
297name = "Dynamic Resolution"
298reference = "https://attack.mitre.org/techniques/T1568/"
299
300  [[rule.threat.technique.subtechnique]]
301  id = "T1568.002"
302  name = "Domain Generation Algorithms"
303  reference = "https://attack.mitre.org/techniques/T1568/002/"
304
305[rule.threat.tactic]
306id = "TA0011"
307name = "Command and Control"
308reference = "https://attack.mitre.org/tactics/TA0011/"
309[[rule.threat]]
310framework = "MITRE ATT&CK"
311[[rule.threat.technique]]
312id = "T1567"
313name = "Exfiltration Over Web Service"
314reference = "https://attack.mitre.org/techniques/T1567/"
315[[rule.threat.technique.subtechnique]]
316id = "T1567.001"
317name = "Exfiltration to Code Repository"
318reference = "https://attack.mitre.org/techniques/T1567/001/"
319
320[[rule.threat.technique.subtechnique]]
321id = "T1567.002"
322name = "Exfiltration to Cloud Storage"
323reference = "https://attack.mitre.org/techniques/T1567/002/"
324
325
326
327[rule.threat.tactic]
328id = "TA0010"
329name = "Exfiltration"
330reference = "https://attack.mitre.org/tactics/TA0010/"

Triage and analysis

Investigating Connection to Commonly Abused Web Services

Adversaries may use an existing, legitimate external Web service as a means for relaying data to/from a compromised system. Popular websites and social media acting as a mechanism for C2 may give a significant amount of cover due to the likelihood that hosts within a network are already communicating with them prior to a compromise.

This rule looks for processes outside known legitimate program locations communicating with a list of services that can be abused for exfiltration or command and control.

Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide. This investigation guide uses the Investigate Markdown Plugin introduced in Elastic Stack version 8.8.0. Older Elastic Stack versions will display unrendered Markdown in this guide.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Investigate other alerts associated with the user/host during the past 48 hours.
    • $investigate_0
    • $investigate_1
  • Verify whether the digital signature exists in the executable.
  • Identify the operation type (upload, download, tunneling, etc.).
  • Examine the host for derived artifacts that indicate suspicious activities:
    • Analyze the process executable using a private sandboxed analysis system.
    • Observe and collect information about the following activities in both the sandbox and the alert subject host:
      • Attempts to contact external domains and addresses.
        • Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' process.entity_id.
          • $investigate_2
        • Examine the DNS cache for suspicious or anomalous entries.
          • $osquery_0
      • Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
      • Examine the host services for suspicious or anomalous entries.
        • $osquery_1
        • $osquery_2
        • $osquery_3
    • Retrieve the files' SHA-256 hash values using the PowerShell Get-FileHash cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

False positive analysis

  • This rule has a high chance to produce false positives because it detects communication with legitimate services. Noisy false positives can be added as exceptions.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • If the triage identified malware, search the environment for additional compromised hosts.
    • Implement temporary network rules, procedures, and segmentation to contain the malware.
    • Stop suspicious processes.
    • Immediately block the identified indicators of compromise (IoCs).
    • Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
  • Remove and block malicious artifacts identified during triage.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Related rules

to-top