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

References

Related rules

to-top