SMB/CIFS tools (2/5): mount.cifs options, macOS smbutil and mount_smbfs, rpcclient
Part 2 finishes the mount.cifs options (caching, inodes, Unix extensions), shows the macOS SMB tools smbutil and mount_smbfs, and then goes deep into rpcclient: the Samba tool that runs Windows RPC calls (users, SIDs, privileges) over SMB named pipes. rpcclient is a standard tool for Windows/Samba administration and security audits.
156.1 Why is it used?
- mount.cifs cache/inode options trade speed against safety when several clients write the same share.
- smbutil (macOS) lists shares, resolves NetBIOS names and shows signing/version of mounted shares; mount_smbfs mounts them.
- rpcclient queries the LSA: domain name, name-to-SID and SID-to-name, privileges and account rights.
- Where: mount.cifs from cifs-utils (Linux), smbutil/mount_smbfs built into macOS, rpcclient from samba-client/smbclient; Windows uses net use / New-SmbMapping.
156.2 How rpcclient works
- Lab: rpcclient on 192.168.176.20, Samba 4.19.9 on FILESRV 192.168.176.10.
- ncacn_np (default): SMB session on 445, login, open a named pipe (\pipe\lsarpc, samr, srvsvc) on the hidden IPC$ share, send DCE/RPC calls through it.
- ncacn_ip_tcp: the endpoint mapper on TCP 135 points to RPC services on high ports (49152-49154); srvinfo worked, lsaquery got ACCESS_DENIED, so use the named pipe for LSA.
- Step 1
1.Client 192.168.176.20 -> FILESRV:445: SMB session, login asha
- Step 2
2.Tree connect to the hidden IPC$ share
- Step 3
3.Open named pipe \pipe\lsarpc
- Step 4
4.Send the lsaquery RPC call through the pipe
- Step 5
5.Server replies: Domain Name: LAB (printed on the client)
Alternative ncacn_ip_tcp: TCP 135 endpoint map -> high port 49152+
156.3 mount.cifs: kernel check
- mount.cifs needs the cifs kernel module; the lab VM has CONFIG_CIFS=m (module, not loaded).
- A real mount would auto-load it, so these options are shown as syntax and tables only.
uname -rzcat /proc/config.gz | grep -E \ "^CONFIG_CIFS(_FSCACHE|_ALLOW_INSECURE_LEGACY)?="grep -E "^cifs " /proc/modules \ || echo "(cifs not loaded)"grep -E "cifs|smb3" /proc/filesystems \ || echo "(no cifs/smb3 filesystem registered)"# syntax only, NOT run (would load cifs):# mount -t cifs //192.168.176.10/docs /mnt/docs \# -o username=asha,cache=strict,actimeo=30$ uname -r6.18.54.1-microsoft-standard-WSL2$ zcat /proc/config.gz | grep -E "^CONFIG_CIFS...="CONFIG_CIFS=m$ grep -E "^cifs " /proc/modules(cifs not loaded)$ grep -E "cifs|smb3" /proc/filesystems(no cifs/smb3 filesystem registered)156.4 mount.cifs: caching, inodes and Unix extensions
| Option | Meaning |
|---|---|
| cache=strict | Cache only with an oplock/lease (default) |
| cache=none | No cache, every read/write goes to the server |
| cache=loose | Fast but risky with many writers (corruption) |
| actimeo=30 | Attribute cache seconds (default 1) |
| rsize= / wsize= | Max read/write request size (4MB) |
| fsc | FS-Cache local disk cache |
| resilienthandles / persistenthandles | Keep open files across reconnect (SMB2.1+) / cluster failover (SMB3+) |
| iocharset=utf8, mapchars | Path charset; map : ? | * > < to 0xF000 range |
| serverino / noserverino | Use server inode numbers (default) / client-made inodes |
| posix|unix|linux | Unix extensions: Unix permissions and symlinks with Samba |
| mfsymlinks, sfu | Minshall+French symlinks; SFU device files |
| snapshot=@GMT-... | Mount one previous version (kernel 4.19+) |
156.5 macOS smbutil
- Format: smbutil [-hv] command [-options] [args]; help view shows one command's usage.
- lookup NAME converts a NetBIOS name to IP (-w asks a WINS server, -t 0x20 = file server type); status / status -a show a host's NetBIOS names.
- view //user@server lists shares like smbclient -L (-G allow guest, -g guest only, -a anonymous only).
- identity shows the name the server knows you by; dfs shows DFS referrals.
- statshares -a shows SMB version, signing and features of mounted shares (-f json); multichannel, snapshot, smbstat for one file.
smbutil lookup FILESRVsmbutil status -a 192.168.1.10smbutil view //alice@fileserversmbutil view -g //fileserversmbutil identity '//CORP;alice@fileserver'smbutil statshares -asmbutil statshares -a -f jsonsmbutil multichannel -asmbutil snapshot -m /Volumes/sharesmbutil smbstat /Volumes/share/report.pdf156.6 macOS mount_smbfs
- Preferred: mount -t smbfs, which calls mount_smbfs.
- The URL can carry domain, user and password: //CORP;alice:Secr3t@fileserver/share.
- -f / -d set file/dir permissions; -N no password prompt; -s forces a new session; -t @GMT-... mounts a snapshot read-only.
- -o: nobrowse (hide from Finder), soft, sessionencrypt / shareencrypt, nodatacache / nomdatacache, nostreams.
mount -t smbfs //alice@fileserver/share ~/mnt/sharemount_smbfs -f 0644 -d 0755 \ //alice@fileserver/share ~/mnt/sharemount_smbfs -t @GMT-2026.03.27-20.52.19 \ //alice@fileserver/share ~/mnt/snapmount_smbfs -o nobrowse //alice@fileserver/share \ ~/mnt/share156.7 rpcclient: target and binding strings
- Target can be an IP, //NAME or a full binding string; all three gave Domain Name LAB for lsaquery.
- ncacn_np:host[pipe,options]: e.g. [lsarpc,sign,smb2].
- ncacn_ip_tcp with [sign]: srvinfo worked, lsaquery ACCESS_DENIED; with [connect] even srvinfo was denied.
- Options: [sign] integrity, [seal] encryption, [spnego]/[ntlm]/[krb5] login, [schannel], [print] packet dump.
rpcclient -U asha%LabPass1 -c lsaquery \ 192.168.176.10rpcclient -U asha%LabPass1 -c lsaquery \ 'ncacn_np:192.168.176.10[lsarpc]'rpcclient -U asha%LabPass1 -c getusername \ 'ncacn_np:192.168.176.10[lsarpc,sign,smb2]'rpcclient -U asha%LabPass1 -c 'srvinfo;lsaquery' \ 'ncacn_ip_tcp:192.168.176.10[sign]'rpcclient -U asha%LabPass1 -c srvinfo \ 'ncacn_ip_tcp:192.168.176.10[connect]'$ rpcclient -U asha%LabPass1 -c 'srvinfo;lsaquery' 'ncacn_ip_tcp:192.168.176.10[sign]' FILESRV Wk Sv PrQ Unx NT SNT Samba 4.19.9 platform_id : 500 os version : 6.1result was NT_STATUS_ACCESS_DENIED$ rpcclient -U asha%LabPass1 -c 'srvinfo' 'ncacn_ip_tcp:192.168.176.10[connect]'result was WERR_ACCESS_DENIED156.8 rpcclient: connection and authentication options
- -c 'cmd1;cmd2' runs commands and exits; -I IP skips name resolution (LABBOX did not resolve without it).
- -p 139 gave CONNECTION_REFUSED (server only on 445); -m NT1 warned max < min protocol.
- -U user%pass (wrong password = LOGON_FAILURE); in scripts use -A credfile (chmod 600) or the PASSWD variable.
- --use-kerberos=required against an IP failed: Kerberos needs a DNS name and a realm.
- -d 3 --debug-stdout shows connection and NTLMSSP steps; -s FILE alternate smb.conf; --option='name=value'.
rpcclient -U asha%LabPass1 -I 192.168.176.10 \ -c getusername LABBOXrpcclient -U asha%LabPass1 -p 139 \ -c getusername 192.168.176.10printf 'username = asha\npassword = LabPass1\ndomain = LAB\n' \ > /tmp/asha.cred; chmod 600 /tmp/asha.credrpcclient -A /tmp/asha.cred -c getusername \ 192.168.176.10PASSWD=LabPass1 rpcclient -U asha \ -c getusername 192.168.176.10$ rpcclient -U asha%LabPass1 -p 139 -c getusername 192.168.176.10Cannot connect to server. Error was NT_STATUS_CONNECTION_REFUSED$ rpcclient -U asha%LabPass1 -m NT1 -c getusername 192.168.176.10lp_load_ex: Max protocol NT1 is less than min protocol SMB2_02.Account Name: asha, Authority Name: FILESRV$ rpcclient -U asha --password=LabPass1 --use-kerberos=required ...Kerberos auth with 'asha@MYGROUP' (MYGROUP\asha) to access '192.168.176.10' not possibleCannot connect to server. Error was NT_STATUS_ACCESS_DENIED156.9 rpcclient interactive: general commands
- help lists commands of every pipe; list lsarpc shows one pipe's commands; getusername shows the session user.
- debuglevel N, timeout (default 10000 ms), transport ncacn_np|ncacn_ip_tcp.
- sign / seal / packet / none set protection for following pipe connections; schannel needs a machine account on a DC.
rpcclient $> debugleveldebuglevel is 0rpcclient $> timeouttimeout is 10000rpcclient $> timeout 30000timeout is 30000rpcclient $> transportUsage: transport [NCACN_NP|NCACN_IP_TCP]156.10 LSARPC: names, SIDs, privileges
- lsaquery: domain LAB; domain SID is null on a standalone server.
- lookupnames asha ravi root gives SIDs (last part = RID); lookupsids does the reverse (S-1-5-32-544 = BUILTIN\Administrators, S-1-1-0 = Everyone).
- lookupsids3 / lookupnames4 got ACCESS_DENIED: allowed only over schannel.
- enumprivs lists 9 privileges with LUIDs; lsaenumsid lists 6 SIDs with LSA accounts; enumtrust empty; dsroledominfo Machine Role = [2] (standalone server).
- Normal user: lsaaddpriv, createsecret denied; querysecret MYSECRET = OBJECT_NAME_NOT_FOUND.
rpcclient -U asha%LabPass1 192.168.176.10lsaquerylookupnames asha ravi rootlookupsids S-1-5-32-544 S-1-1-0lookupsids3 S-1-5-32-544enumprivsgetdispname SeBackupPrivilegelsaenumsidenumtrustdsroledominfoquitrpcclient $> lookupsids3 S-1-5-32-544result was NT_STATUS_ACCESS_DENIEDrpcclient $> lookupnames4 asharesult was NT_STATUS_ACCESS_DENIEDrpcclient $> enumtrustrpcclient $> dsroledominfoMachine Role = [2]Directory Service not running on server156.11 LSARPC as admin: granting a privilege
- Step 1
1.lookupnames ravi -> SID S-1-5-21-...-1001
- Step 2
2.lsaaddpriv SID SeBackupPrivilege (as root)
- Step 3
3.lsaenumprivsaccount / lsaenumacctrights show SeBackupPrivilege
- Step 4
4.lsaaddacctrights SID SeServiceLogonRight -> NO_SUCH_PRIVILEGE
- Step 5
5.lsadelpriv SID SeBackupPrivilege -> found 0 privileges
R="rpcclient -U root%LabRoot9 192.168.176.10 -c"RAVI=$($R 'lookupnames ravi' | cut -d' ' -f2)$R "lsaaddpriv $RAVI SeBackupPrivilege"$R "lsaenumprivsaccount $RAVI"$R "lsaenumacctrights $RAVI"$R "lsaaddacctrights $RAVI SeServiceLogonRight"$R "lsadelpriv $RAVI SeBackupPrivilege"$R "lsaenumacctrights $RAVI"$R "createtrustdom OTHERDOM S-1-5-21-111-222-333"+ ... lsaaddacctrights $RAVI SeServiceLogonRightresult was NT_STATUS_NO_SUCH_PRIVILEGE+ ... lsadelpriv $RAVI SeBackupPrivilege+ ... lsaenumacctrights $RAVIfound 0 privileges for SID S-1-5-21-2837656282-3035926080-34436280-1001+ ... createtrustdom OTHERDOM S-1-5-21-111-222-333result was NT_STATUS_NOT_SUPPORTED156.12 Comparison: ncacn_np vs ncacn_ip_tcp
| Point | ncacn_np (named pipe) | ncacn_ip_tcp |
|---|---|---|
| Transport | SMB 445 -> IPC$ -> \pipe\name | TCP 135 endpoint mapper -> high port |
| Default | Yes (plain IP or //NAME) | Only with a binding string |
| Lab result | lsaquery OK | srvinfo OK, lsaquery ACCESS_DENIED |
| Firewall | Only 445 | 135 + dynamic high ports |
156.13 Common mistakes
- Believing a null session (-U '' -N) dumps users on any server: with restrict anonymous = 2 and map to guest = never it got ACCESS_DENIED.
- Using cache=loose on a share with several writers.
- Using Kerberos with an IP address instead of a DNS name.
- Putting passwords in -U on shared machines instead of -A with chmod 600.
- Running rpcclient against servers you have no permission to test.
$ rpcclient -U '' -N -c lsaquery 192.168.176.10Cannot connect to server. Error was NT_STATUS_ACCESS_DENIED$ rpcclient -U '' -N -c getusername 192.168.176.10Cannot connect to server. Error was NT_STATUS_ACCESS_DENIED156.14 Interview tips
- rpcclient = SMB session on 445 + DCE/RPC through named pipes (lsarpc, samr, srvsvc) on IPC$.
- lookupnames = name to SID, lookupsids = SID to name; RID is the last part of the SID.
- Binding string picks the transport; [sign]/[seal] set integrity/encryption.
- Harden Samba with restrict anonymous = 2 and map to guest = never.