SkillPilotAI

SMB/CIFS: smbclient, mount.cifs, rpcclient, smbget, smbtree, net (Samba), smbutil, mount_smbfs (3/5)

Part 3 walks through the remaining rpcclient pipes (DFS, SRVSVC, SAMR, SPOOLSS, NETLOGON, FSRVP, EPMAPPER, EVENTLOG and more) on a standalone Samba server, and then smbget, a wget-like downloader for smb:// URLs. The key lesson: which RPC pipes exist depends on the server role, and many calls need admin rights.

157.1 Why is it used?

  • SRVSVC: list shares, sessions and open files (who has which file open).
  • SAMR: list and query users, groups and the SAM domain; create/delete users (admin).
  • SPOOLSS: printers, forms, drivers and print jobs.
  • EPMAPPER (epmlookup): find out which pipes/services a server actually offers.
  • smbget: download a file or folder from an smb:// URL in one command, with resume and update.

157.2 How it works: one SMB connection, many pipes

  • Lab: client 192.168.177.20 (rpcclient, smbget), filesrv 192.168.177.10 running Samba 4.19 as a standalone server.
  • rpcclient logs in on 445, opens IPC$, then talks to a named pipe per service (srvsvc, samr, spoolss...).
  • A pipe that belongs to another role (netlogon on a DC) is simply not there: OBJECT_NAME_NOT_FOUND.
srvsvc works, netlogon does not
  1. 1.Client 192.168.177.20 -> filesrv:445, login asha

  2. 2.Open IPC$ and \pipe\srvsvc

  3. 3.srvinfo -> FILESRV Wk Sv PrQ Unx NT SNT

  4. 4.Open \pipe\netlogon (only exists on a domain controller)

  5. 5.Server: NT_STATUS_OBJECT_NAME_NOT_FOUND

Use epmlookup first to see which pipes the server registers

157.3 DFS and SHUTDOWN

  • dfsversion: DFS present; dfsenum empty (no DFS links created).
  • dfsexist and shutdowninit do not exist in this version (SHUTDOWN group in help is empty).
  • Other commands: dfsadd / dfsremove / dfsgetinfo PATH SRV SHARE, dfsenumex, shutdownabort.
Output
rpcclient $> dfsexistcommand not found: dfsexistrpcclient $> shutdowninitcommand not found: shutdowninitrpcclient $> help       SHUTDOWN---------------    ----------------------       EPMAPPER

157.4 SRVSVC: server, shares, sessions, files

  • srvinfo: server name, type flags, OS version 6.1.
  • netshareenumall lists all shares including hidden IPC$; netsharegetinfo docs gives path and current users.
  • netsessenum / netfileenum: ACCESS_DENIED for normal user asha; root (mapped to BUILTIN\Administrators) saw 2 sessions and ravi's open notes.txt.
  • Admin changes: netshareadd, netsharedel, netsharesetinfo, netsessdel; netfilegetsec reads a file's security descriptor.
Terminal
rpcclient -U asha%LabPass157 192.168.177.10rpcclient $> srvinforpcclient $> netshareenumallrpcclient $> netsharegetinfo docsrpcclient -U root%LabRoot157 192.168.177.10rpcclient $> netsessenumrpcclient $> netfileenumrpcclient $> netconnenum docs
Output
rpcclient $> netsharegetinfo docsnetname: docs  remark:  Team documents  path:  C:\srv\docs  max_uses:  -1  num_uses:  1(root = BUILTIN\Administrators)rpcclient $> netsessenumtrying level: 1Received 2 entries.rpcclient $> netfileenumC:\srv\docs\notes.txt

157.5 SAMR: users, groups, domains

  • enumdomusers lists users with RIDs; queryuser 0x3e8 shows asha's details.
  • querydominfo reports role domain PDC even on standalone Samba.
  • lookupdomain LAB fails (NO_SUCH_DOMAIN): the SAM domain is named after the server, FILESRV.
  • createdomuser bob: denied for asha; as root it worked (smb.conf add user script creates a real Linux user); deletedomuser removed it.
  • Password commands (chgpasswd 1-4, setuserinfo level 23/24): only in your own lab.
Output
rpcclient $> lookupdomain LABresult was NT_STATUS_NO_SUCH_DOMAINrpcclient $> lookupdomain FILESRVSAMR_LOOKUP_DOMAIN: Domain Name: FILESRV  Domain SID: S-1-5-21-2948381736-3316672030-2812897159rpcclient $> deletedomuser bobrpcclient $> enumdomusersuser:[asha] rid:[0x3e8]user:[root] rid:[0x3ea]user:[ravi] rid:[0x3e9][srv]$ id bobid: unknown user bob
Read (SAMR)Change (SAMR)
enumdomusers / enumdomgroups / enumalsgroupscreatedomuser / createdomgroup / createdomalias
queryuser RID / querygroup RIDdeletedomuser / deletedomgroup / deletealias
queryusergroups / querygroupmemsamlookupnames / samlookuprids
querydispinfo / querydominfochgpasswd, chgpasswd2|3|4
getdompwinfo / getusrdompwinfosetuserinfo / setuserinfo2 (level 23/24 = password)

157.6 SPOOLSS: printers, forms, jobs

  • Lab: dummy printer Laser1 (no CUPS); asha printed one page with smbclient.
  • asha: enumprinters works, getprinter and enumjobs give ACCESS_DENIED.
  • root: printer info, built-in forms (Letter, A4 210000 x 297000) and asha's job.
  • Other commands: addprinter, setprinter, setjob, enumdrivers, adddriver, addform, getdata, setprinterdata, enumprocs, enummonitors.
Output
(root) rpcclient $> getprinter Laser1  name:[\\192.168.177.10\Laser1]rpcclient $> enumforms Laser1Letter  flag: FORM_BUILTIN (1)A4  width: 210000, length: 297000rpcclient $> enumjobs Laser10: jobid[1]: asha Remote Downlevel Document page.txt-252  0/0 pages

157.7 Pipes that depend on the server role

PipePurposeResult on standalone Samba
NETLOGONDC names, trusts, samlogondsr_getdcname / netrenumtrusteddomains: pipe not found
FSRVPShadow copies (fss_create_expose)Version 1 for root, fss_is_path_sup docs: ACCESS_DENIED
CLUSAPIFailover cluster resources/nodesCould not initialise clusapi (NT_STATUS_NO_MEMORY)
DRSUAPIAD replicationBind fails
ECHOTest piperpcecho not found (test builds only)
EPMAPPERepmlookup: registered endpointsWorks: lists all registered pipes
EVENTLOGRead/write event logsasha denied; root: Application has 0 records
WINREG / WKSSVC / NTSVCSRegistry, workstation, PnPenumkey HKLM invalid parameter; wkstagetinfo OK; ntsvcs version 1024
Output
rpcclient $> clusapi_open_clusterdo_cmd: Could not initialise clusapi. Error was NT_STATUS_NO_MEMORY(asha) rpcclient $> eventlog_numrecord Applicationresult was NT_STATUS_ACCESS_DENIED(root) rpcclient $> eventlog_numrecord Applicationnumber of records: 0rpcclient $> winreg_enumkey HKLMresult was WERR_INVALID_PARAMETERrpcclient $> wkssvc_getjoininformationresult was DOS code 0x0000002e

157.8 smbget: download options

  • smbget is like wget for SMB: smb://[dom;]user[:pw@]server/share/path.
  • It never overwrites an existing file (second run: file exists error).
  • -u downloads only if the remote is newer; -o sets the local name; --recursive gets a folder.
  • --stdout prints the file; -D shows progress dots; --resume adds only the missing bytes.
  • Careful: in current Samba -O = socket options and -R = name resolve (not stdout/recursive like old guides).
smbget download and guest rejection
  1. 1.Client: smbget -U asha smb://192.168.177.10/docs/notes.txt

  2. 2.Request with asha's login reaches filesrv:445

  3. 3.notes.txt (21 bytes) comes back: Downloaded 21b in 0 seconds

  4. 4.smbget -a (guest) sends the same request

  5. 5.map to guest = never: You don't have enough permissions

Terminal
S=smb://192.168.177.10; U=asha%LabPass157smbget -U $U $S/docs/notes.txtsmbget -U $U -u $S/docs/notes.txtsmbget -U $U -o meeting.txt $S/docs/notes.txtsmbget -U $U --recursive $S/docs/reportssmbget -U $U -q --stdout $S/docs/notes.txtsmbget -U $U -D $S/public/big.isohead -c 1000000 ../big.iso > big.isosmbget -U $U --resume $S/public/big.isocmp big.iso ../big.iso && echo identical
Output
$ smbget -U $U --recursive $S/docs/reportssmb://192.168.177.10/docs/reports/q3.txtsmb://192.168.177.10/docs/reports/q4.txtDownloaded 35b in 0 seconds$ smbget -U $U -D $S/public/big.iso...............................................Downloaded 2.86MB in 0 seconds$ smbget -U $U --resume $S/public/big.isoDownloaded 1.91MB in 0 seconds-rw-r--r--  1 root root 3000000 Nov  9 07:34 big.isoidentical

157.9 smbget: connection and authentication

  • Guest and a wrong password give the same permissions message: check credentials first.
  • -W LAB sets the domain (default MYGROUP); -n sets NetBIOS name; -m max protocol; -A credentials file (chmod 600).
  • --use-kerberos=required with an IP is not possible; -m NT1 fails against the client's SMB2 minimum.
  • -b blocksize (default 64000), --limit-rate KB/s (1000 took 3 s for the 3 MB file), -e / --client-protection=encrypt.
Output
$ smbget -U $U --use-kerberos=required ...Kerberos auth with 'asha@MYGROUP' (MYGROUP\asha) to access '192.168.177.10' not possible$ smbget -U $U -m NT1 ...lp_load_ex: Max protocol NT1 is less than min protocol SMB2_02.smbc_open: Invalid argument

157.10 Common mistakes

  • Expecting every rpcclient command to work everywhere: pipes depend on the server role.
  • Reading ACCESS_DENIED on netsessenum as a broken server: sessions/files are admin only.
  • Using lookupdomain with the workgroup name on a standalone server instead of the server name.
  • Using old smbget flags -O / -R for stdout / recursive.
  • Expecting smbget to overwrite: use -u or delete the old file.

157.11 Interview tips

  • Enumerate shares: SRVSVC netshareenumall; users: SAMR enumdomusers + queryuser RID (authorized systems only).
  • Check epmlookup first to see which pipes exist.
  • Sessions and open files need BUILTIN\Administrators.
  • smbget = wget for SMB: --recursive, --stdout, --resume, -u.