SMB, NFS and RDP
Three protocols carry most of the "inside" traffic of an organisation: SMB for Windows file shares (and much of Windows administration), NFS for Unix file shares, and RDP for remote desktops. All three were designed for trusted internal networks, all three have been at the centre of major incidents when that assumption failed, and all three should be invisible from the Internet. This lesson looks at what each one exposes on the wire and in configuration, how misuse is spotted, and how they are hardened. Active Directory attacks that run over SMB (NTLM relay and friends) are covered in Windows and Active Directory Security.
SMB
SMB runs over TCP 445 (and, for very old clients, NetBIOS on 137–139). Versions matter more than anything else:
| Version | Introduced | Security-relevant features |
|---|---|---|
| SMB1 (CIFS) | 1980s–1990s | no encryption, weak signing; the protocol behind the 2017 WannaCry and NotPetya worms (MS17-010, "EternalBlue"). Disable it. |
| SMB 2.x | Windows Vista / Server 2008 | redesigned protocol, HMAC-SHA256 signing |
| SMB 3.x | Windows 8 / Server 2012 on | AES encryption per share or server, AES-CMAC/GMAC signing, pre-authentication integrity (3.1.1) against downgrades |
Every SMB2/3 message starts with a 64-byte header beginning \xfeSMB; SMB1 messages start \xffSMB. That makes SMB1 easy to spot in traffic. The program classifies the first bytes of a few synthetic SMB payloads (after the 4-byte NetBIOS session header) and decodes the SMB2 command and flags.
import struct
COMMANDS = {0: "NEGOTIATE", 1: "SESSION_SETUP", 3: "TREE_CONNECT", 5: "CREATE", 8: "READ", 9: "WRITE"}
payloads = { # synthetic: NetBIOS length (4 bytes) + start of the SMB header
"client A": "00000066" + "fe534d42" + "4000" + "0000" + "00000000" + "0000" + "0100" + "00000000",
"client B": "00000085" + "ff534d42" + "72" + "00000000" + "18",
"client C": "000000b2" + "fe534d42" + "4000" + "0100" + "00000000" + "0100" + "0000" + "08000000",
}
for who, hx in payloads.items():
b = bytes.fromhex(hx)
nb_len = int.from_bytes(b[1:4], "big")
proto = b[4:8]
if proto == b"\xffSMB":
print(f"{who}: SMB1 (command 0x{b[8]:02x} = NEGOTIATE) length {nb_len} -> ALERT: SMB1 in use")
continue
hdr_len, credit_charge, status, cmd, credits, flags = struct.unpack("<HHIHHI", b[8:24])
signed = bool(flags & 0x08)
print(f"{who}: SMB2/3 {COMMANDS.get(cmd, cmd)} header {hdr_len} bytes signed={signed} length {nb_len}")client A: SMB2/3 NEGOTIATE header 64 bytes signed=False length 102
client B: SMB1 (command 0x72 = NEGOTIATE) length 133 -> ALERT: SMB1 in use
client C: SMB2/3 SESSION_SETUP header 64 bytes signed=True length 178
Note < in the format string: SMB fields are little-endian, unlike the network-order headers of IP and TCP. (The 0x08 flag is SMB2_FLAGS_SIGNED.)
Detection: SMB1 negotiation anywhere (Windows can audit SMB1 access; IDS rules match \xffSMB), SMB to or from the Internet (TCP 445 at the perimeter), one host connecting to the ADMIN$/C$ shares of many others (lateral movement), and unsigned sessions to servers that should require signing.
Hardening: disable SMB1; require signing (long the default on domain controllers; Windows 11 24H2 Pro, Enterprise and Education require it for inbound and outbound connections, Windows Server 2025 for outbound ones, so check older systems and Home editions); enable SMB encryption for sensitive shares; block 445 at the perimeter and between workstations (workstations rarely need to talk SMB to each other); least-privilege share and NTFS permissions.
NFS
NFS exports directories from a server to clients. In NFSv3 and the default AUTH_SYS mode of NFSv4, the server trusts the user ID that the client sends. Anyone who controls a client machine (and is root on it) can claim any UID. Protection then depends entirely on which clients may mount, and on root_squash, which maps the client's root (UID 0) to an unprivileged user. With Kerberos (sec=krb5, krb5i, krb5p) users are authenticated, and krb5p also encrypts.
An exports audit is a configuration check, done here on a synthetic /etc/exports:
exports = """
/srv/home 10.10.0.0/24(rw,sync,root_squash,sec=krb5p)
/srv/backup *(rw,no_root_squash)
/srv/public 10.10.0.0/24(ro,all_squash)
/srv/build 10.10.0.50(rw,insecure,no_subtree_check)
"""
for line in exports.strip().splitlines():
path, *clients = line.split()
for c in clients:
host, _, opts = c.partition("(")
opts = set(opts.rstrip(")").split(","))
issues = []
if host == "*": issues.append("exported to every host")
if "no_root_squash" in opts: issues.append("client root is root on the share")
if "rw" in opts and not any(o.startswith("sec=krb5") for o in opts):
issues.append("writable with AUTH_SYS (client-chosen UIDs)")
if "insecure" in opts: issues.append("accepts requests from unprivileged ports")
print(f"{path:<12} {host:<14} {'; '.join(issues) or 'ok'}")/srv/home 10.10.0.0/24 ok
/srv/backup * exported to every host; client root is root on the share; writable with AUTH_SYS (client-chosen UIDs)
/srv/public 10.10.0.0/24 ok
/srv/build 10.10.0.50 writable with AUTH_SYS (client-chosen UIDs); accepts requests from unprivileged ports
Detection: NFS (TCP/UDP 2049, plus rpcbind 111 for v3) reachable from networks that shouldn't mount; showmount -e from an unexpected host; mount requests from unknown clients in the server logs. Hardening: export to specific hosts or subnets, root_squash (the default), read-only where possible, NFSv4 with Kerberos for anything sensitive, firewall 2049/111.
RDP
RDP (TCP and UDP 3389) gives a full graphical session. It is one of the most common initial-access routes in ransomware incidents, through guessed or stolen passwords and through vulnerabilities in the pre-authentication stage (BlueKeep, CVE-2019-0708, affected old Windows versions before any login).
- Network Level Authentication (NLA) makes the client authenticate (via CredSSP) before a session and its login screen are created, which reduces the pre-authentication attack surface and resource use. Keep it on.
- RDP traffic is TLS-encrypted, but a client that ignores certificate warnings can be intercepted.
The session checks which of the file-sharing and remote-desktop ports answer on the sandbox's loopback, after starting a stand-in listener on 3389 (Ncat, not a real RDP server). This is what an internal exposure check of one host looks like, in scope 127.0.0.1 only:
ncat -lk 127.0.0.1 3389 >/dev/null 2>&1 &
for i in $(seq 50); do ss -Htln 'sport = :3389' | grep -q . && break; sleep 0.1; done
nmap -sT -p 111,139,445,2049,3389 127.0.0.1
kill %1Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-11-22 10:16 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000069s latency).
PORT STATE SERVICE
111/tcp closed rpcbind
139/tcp closed netbios-ssn
445/tcp closed microsoft-ds
2049/tcp closed nfs
3389/tcp open ms-wbt-server
Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds
Nmap names 3389 ms-wbt-server from its port table only; it hasn't checked that RDP is really there (that would need -sV, which would find Ncat instead).
Detection: Internet-exposed 3389 in your own external scans; Windows Security log events 4625 (failed logon) in bursts and 4624 with logon type 10 (RemoteInteractive) from unusual sources; RDP between workstations; new RDP-enabled hosts. Hardening: never expose RDP directly; put it behind a VPN or an RD Gateway with MFA; NLA on; restrict who may log on remotely; account lockout or throttling; patch.
Pitfalls
- Blocking 445 at the perimeter but allowing it everywhere inside, which is how worms and ransomware spread laterally.
- NFS "secured" by IP allow lists on a network where clients can change their own addresses.
- Moving RDP to another port as protection. Scanners find it within hours.
Practice
1. Why is SMB1 still worth looking for in 2026?
Old devices (multifunction printers, NAS boxes, industrial and medical systems) may still require it, and enabling it for them re-enables it on servers. Each one is a candidate for wormable bugs and weak authentication; find them with traffic analysis and replace or isolate them.
2. A client is root on its own machine and mounts /srv/home with sec=sys. What can it do, and what changes with sec=krb5p?
With AUTH_SYS it can impersonate any user ID except root (root is squashed), so it can read and write every user's files. With krb5p each user must hold a Kerberos ticket, so impersonation requires that user's credentials, and the traffic is encrypted.
3. In the exports audit, why is /srv/public marked ok?
It is read-only and squashes every user to the anonymous ID (all_squash), and it is limited to the lab subnet. Client-chosen UIDs don't matter if nobody can write and everybody is anonymous.
Test yourself
How can SMB1 be recognised in a packet?
- The header starts with \xfeSMB
- The header starts with \xffSMB
- It uses port 3389
- It is always encrypted
What does root_squash do on an NFS export?
- Encrypts traffic
- Maps the client's root user to an unprivileged user
- Blocks all writes
- Requires Kerberos
What does Network Level Authentication add to RDP?
- Compression
- The user authenticates before a remote session is created
- A second port
- SMB signing
Which of these should never be reachable from the Internet?
- TCP 443 on a web server
- TCP 445 (SMB) and TCP 3389 (RDP)
- TCP 25 on a mail relay
- UDP 53 on an authoritative DNS server