網絡掃描:文件共享服務
文件共享是指主動在網絡上共享自己的計算機文件,最常見的文件共享服務有AFP和NFS等。本文介紹對文件共享服務實施掃描的方法。
1. 蘋果AFP服務
AFP服務是基于TCP協議工作的,其工作在TCP的548端口。我們可以借助Nmap的afp-serverinfo腳本來獲取對應的服務信息。獲取的信息包括服務器的主機名、IPv4和IPv6地址及硬件類型。使用該腳本的語法格式如下:
nmap -sV --script=afp-serverinfo.nse [--script-args=afp.password=password,afp.username=username]
該腳本可使用的參數及含義如下。
afp.password:指定AFP服務認證的密碼。
afp.username:指定AFP服務認證的用戶名。
實施AFP服務掃描。執行命令如下:
root@daxueba:~# nmap -sV -p548 --script=afp-serverinfo.nse 208.83.1.237
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-10 14:57 CST
Nmap scan report for 208.83.1.237
Host is up (0.32s latency).
PORT STATE SERVICE VERSION
548/tcp open afp Apple AFP (name: training-mac; protocol 3.4; VMware 7.1)
| afp-serverinfo:
| Server Flags: #服務標志
| Flags hex: 0x9ff3 #十六進制值
| Super Client: true #超級客戶端
| UUIDs: true #UUID
| UTF8 Server Name: true #UTF-8服務名
| Open Directory: true #打開的目錄
| Reconnect: true #重新連接
| Server Notifications: true #服務通知
| TCP/IP: true #TCP/IP
| Server Signature: true #服務簽名
| Server Messages: false #服務消息
| Password Saving Prohibited: false #禁止保存密碼
| Password Changing: true #修改密碼
| Copy File: true #復制文件
| Server Name: training-mac #服務名
| Machine Type: VMware7,1 #主機類型
| AFP Versions: AFP3.4, AFP3.3, AFP3.2, AFP3.1, AFPX03 #AFP版本
| UAMs: DHCAST128, DHX2, Recon1, Client Krb v2, GSS #安全策略
| Server Signature: 564d26a7799b0b7776d7ac94e7314059 #服務簽名
| Directory Names: #目錄名稱
| afpserver/training-mac.local@LOCAL
|_ UTF8 Server Name: training-mac #UTF-8服務名
Service Info: OS: Mac OS X; CPE: cpe:/o:apple:mac_os_x
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 29.38 seconds
從輸出信息中可以看到獲取到AFP服務的相關信息。例如,服務名為training-mac、主機類型為VMware7,1、AFP版本為AFP 3.4、AFP 3.3、AFP 3.2、AFP 3.1和AFP X03等。
2. 蘋果DAAP服務
DAAP服務是基于TCP協議工作的服務,其工作在TCP的3689端口。我們可以借助daap-get-library.nse腳本來實施掃描,該腳本通過從DAAP服務中獲取音樂列表,該列表包括藝人名字、專輯和歌曲標題。使用該腳本實施DAAP服務掃描的語法格式如下:
nmap -p 3689 --script=daap-get-library [--script-args=daap_item_limit=number]
其中,daap_item_limit用于設置輸出的歌曲數,默認是100。
實施蘋果DAAP服務掃描。執行命令如下:
root@daxueba:~# nmap -p 3689 --script=daap-get-library.nse 182.245.41.110
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-10 15:06 CST
Nmap scan report for 182.245.41.110
Host is up (0.090s latency).
PORT STATE SERVICE
3689/tcp open rendezvous
| daap-get-library:
| Abby-cloud-ex2
| unknown
| unknown
| \xE7\x90\xB4\xE9\x9F\xB5\xE8\x8C\xB6\xE5\xBF\x83\xE8\x83\x8C\
xE6\x99\xAF\xE9\x9F\xB3\xE4\xB9\x901.mp3 #歌曲名
| \xE7\x90\xB4\xE9\x9F\xB5\xE8\x8C\xB6\xE5\xBF\x83\xE8\x83\x8C\xE6\x99\xAF\xE9\x9F\xB3\xE4\xB9\x9011\xE5\x88\x86.mp3 #歌曲名
| \xE7\x8E\x8B\xE8\x8F\xB2
| \xE5\xB9\xBD\xE5\x85\xB0\xE6\x93\x8D
| \xE5\xB9\xBD\xE5\x85\xB0\xE6\x93\x8D
|_Output limited to 100 items
Nmap done: 1 IP address (1 host up) scanned in 8.23 seconds
從輸出信息中可以看到目標主機上開啟的DAAP服務,并且成功獲取到了其音樂列表。
3. NFS服務
NFS服務是基于TCP協議工作的服務,其工作在TCP的111端口。可以借助nfs-ls、nfs-showmount和nfs-statfs這3個腳本實施掃描,以獲取該服務的相關信息。下面介紹使用這3個腳本掃描NFS服務的方法。
(1)使用nfs-ls.nse腳本
nfs-ls.nse腳本用于獲取NFS服務中共享的文件列表。語法格式如下:
nmap -p 111 --script=nfs-ls.nse
使用nfs-ls.nse腳本實施掃描。執行命令如下:
root@daxueba:~# nmap -p 111 --script=nfs-ls.nse 192.168.1.6
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-10 15:13 CST
Nmap scan report for 192.168.1.6 (192.168.1.6)
Host is up (0.00040s latency).
PORT STATE SERVICE
111/tcp open rpcbind
| nfs-ls: Volume /
| access: Read Lookup Modify Extend Delete NoExecute
| PERMISSION UID GID SIZE TIME FILENAME
| drwxr-xr-x 0 0 4096 2012-05-14T03:35:33 bin
| drwxr-xr-x 0 0 4096 2010-04-16T06:16:02 home
| drwxr-xr-x 0 0 4096 2010-03-16T22:57:40 initrd
| lrwxrwxrwx 0 0 32 2010-04-28T20:26:18 initrd.img
| drwxr-xr-x 0 0 4096 2012-05-14T03:35:22 lib
| drwx------ 0 0 16384 2010-03-16T22:55:15 lost+found
| drwxr-xr-x 0 0 4096 2010-03-16T22:55:52 media
| drwxr-xr-x 0 0 4096 2010-04-28T20:16:56 mnt
| drwxr-xr-x 0 0 4096 2012-05-14T01:54:53 sbin
| drwxr-xr-x 0 0 4096 2010-04-28T04:06:37 usr
|_
MAC Address: 00:0C:29:3E:84:91 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.48 seconds
從輸出信息中可以看到,目標主機開放了NFS服務,并且顯示出了共享的文件。在輸出的結果中,顯示出了共享文件的權限(PERMISSION)、UID(用戶ID)、GID(組ID)、SIZE(文件大小)、TIME(時間)和文件名(FILENAME)6列信息。
(2)使用nfs-showmount.nse腳本
nfs-showmount.nse腳本用來顯示NFS共享目錄。語法格式如下:
nmap -p 111 --script=nfs-showmount [host]
使用nfs-showmount.nse腳本掃描NFS共享目錄。執行命令如下:
root@daxueba:~# nmap -p 111 --script=nfs-showmount.nse 192.168.1.6
Starting Nmap 7.70 ( https://nmap.org ) at 2021-08-10 15:16 CST
Nmap scan report for 192.168.1.6 (192.168.1.6)
Host is up (0.00026s latency).
PORT STATE SERVICE
111/tcp open rpcbind
| nfs-showmount:
|_ / *
MAC Address: 00:0C:29:3E:84:91 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.38 seconds
從輸出信息中可以看到,目標主機上NFS服務共享的目錄為根目錄(/)。