Windows Fundamentals · beginner · ~11 min
**What you will learn** - Identify **SMB (TCP 445)** and **RDP (TCP 3389)** in a scan and explain what each service does on a Windows network. - Explain the specific weaknesses attackers abuse (SMBv1/EternalBlue, NTLM relay, RDP brute force, BlueKeep) *and* the concrete defence for each. - Harden a lab Windows host: disable SMBv1, require SMB signing, and put RDP behind Network Level Authentication (NLA) and a gateway. - **Verify** each hardening step actually took effect, instead of assuming a setting is applied. - Configure detection: which Windows event IDs and firewall logs reveal SMB abuse or RDP brute force, and what you must never log. - Write a short authorization checklist and lab cleanup steps before touching any host.
Security objective. The asset you are protecting is a Windows host's file shares (data on SMB) and its interactive login (remote control via RDP). The threats are unauthorized data access and remote takeover — the two most common ways ransomware and lateral movement start on Windows networks. By the end you will be able to detect an exposed or misconfigured service and prevent the abuse by hardening the service and turning on the right logs.
Windows machines talk to each other constantly, and two protocols carry most of that traffic:
This lesson builds directly on your prerequisites. From "Windows users, groups, and SIDs" you already know that every share permission and every RDP login is checked against a user's account and group membership — so a weak account is a weak service. From "TCP vs UDP, ports, and the ones to know" you know that 445 and 3389 are TCP ports a scanner can spot in seconds; seeing them open is your first signal that these services exist and need review.
We treat both protocols as things you defend. You will learn what an attacker looks for only so you can find it first, shut it down, and prove it stayed shut.
In authorized, professional work these two ports shape almost every internal Windows assessment and every Windows hardening project:
Blue-team and IT roles use exactly the same knowledge in reverse: to build secure defaults, monitor for abuse, and answer auditors. Knowing both sides makes you effective at either.
Each concept below is taught the same way: what it is, how it works, when it matters, and the pitfall that trips people up.
Definition. SMB is the Windows protocol for sharing files, printers, and named pipes, and for host-to-host communication. A share is a folder (or device) a host offers over the network, e.g. \\SERVER\Finance.
How it works. A client connects to port 445, authenticates (NTLM or Kerberos), and is granted access based on two layers: share permissions and underlying NTFS file permissions. Effective access is the more restrictive of the two.
When it matters. Every internal Windows environment uses SMB. The security question is always: which shares exist, who can read them, and what sensitive data is inside?
Pitfall. Admins often set share permissions to "Everyone: Full Control" and rely on NTFS to restrict access — then misconfigure NTFS. The result is a wide-open share. Always check both layers.
Definition. SMBv1 is the original, obsolete dialect of SMB. EternalBlue (MS17-010) is a remote-code-execution flaw in SMBv1.
How it works. SMBv1 has no modern integrity protection and a memory-handling bug that allowed remote code execution — the mechanism behind the 2017 WannaCry and NotPetya outbreaks.
When (and when not). SMBv1 should be disabled everywhere. There is essentially no modern reason to keep it; the only exception is a decommissioned legacy device you cannot replace, which should be isolated on its own network segment.
Pitfall. SMBv1 is sometimes silently re-enabled by old software installers or left on in a golden image. Finding it enabled is a real, reportable finding.
Definition. SMB signing cryptographically signs each message so it cannot be tampered with or replayed. NTLM relay forwards a victim's authentication to another server. Pass-the-hash reuses a stolen NTLM password hash to authenticate without knowing the password.
How it works. Without signing, an attacker positioned between client and server can relay the client's NTLM authentication to a third host and act as that user. Signing breaks relay because the relayed messages fail the signature check.
When it matters. In any Active Directory network. Enforcing SMB signing and reducing NTLM usage are core hardening steps.
Pitfall. Signing is often enabled but not required. "Enabled" means "use it if the other side asks"; "required" means "refuse unsigned sessions." Only required stops relay.
Definition. RDP gives an interactive graphical session on a remote host. NLA forces the user to authenticate before a full session (and its resources) is created.
How it works. With NLA on, the server checks credentials up front over a secure channel, so an unauthenticated attacker cannot reach the login screen or consume a session slot.
When (and when not). RDP belongs on internal/administrative networks reached through a VPN or an RD Gateway, with NLA and MFA. It should never be directly exposed to the internet.
Pitfall. Turning on RDP via a quick registry tweak often leaves NLA off and the Windows Firewall rule wide open, exposing 3389 to everything.
Definition. Brute force tries many passwords against one account; password spraying tries one common password against many accounts (to dodge lockouts). BlueKeep (CVE-2019-0708) is a pre-auth RCE flaw in unpatched RDP.
How it works. Exposed RDP invites automated password guessing 24/7. Unpatched systems add the risk of a network-level exploit with no credentials at all.
When it matters. The moment 3389 is reachable from an untrusted network.
Pitfall. Account lockout defends against brute force but can aid spraying (it locks accounts, causing denial of service) — layered controls (MFA, gateway, monitoring) matter more than lockout alone.
Definition. Enumeration is inventorying shares, users, and services. Lateral movement is using valid access on one host to reach another.
How it works. With one set of valid credentials, SMB (admin shares, remote execution) and RDP become the highways an attacker uses to spread. Defenders shrink this by least privilege, network segmentation, and monitoring.
Knowledge check
UNTRUSTED | TRUST BOUNDARY | WINDOWS HOST (asset)
------------------------------ | | ----------------------------------
Internet / other VLAN / guest | |
* scanner probing 445, 3389 -----+--> [Firewall]--+--> TCP 445 SMB service
* RDP brute-force bot -----+--> [RD Gtwy ] -+ |-- shares (Finance, IT, backups)
* NTLM relay (on-path) -----+--> [VPN ] -+ |-- NTLM / Kerberos auth
| | --> TCP 3389 RDP service
Entry points: | | |-- interactive login (NLA)
- open port 445 / 3389 | |
- SMBv1 enabled | Controls at | Detection:
- unsigned SMB sessions | the boundary:| - Security log 4624/4625/4776
- RDP without NLA / MFA | firewall, | - Security log 5140/5145 (share)
- unpatched (EternalBlue, | RD Gateway, | - firewall connection logs
BlueKeep) | VPN, MFA | - RDP Operational logs
The attacker's goal is to cross the trust boundary at an entry point. Your job as defender is to (1) close or gate the entry points, (2) harden the service so a crossing fails, and (3) log the attempt so you see it.
The key structures here are the service ports and the PowerShell / event sources you use to inspect and harden them. Run everything in a lab (see the code section for the authorization checklist).
SMB -> TCP 445 file sharing + auth (avoid legacy 137-139 NetBIOS too)
RDP -> TCP 3389 interactive graphical session
Annotated PowerShell primitives you will use (read-only checks first):
# Is SMBv1 enabled on THIS host? (want: State = Disabled)
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
# Server-side SMB settings; want EnableSMB1Protocol=$false, RequireSecuritySignature=$true
Get-SmbServerConfiguration | Select EnableSMB1Protocol, RequireSecuritySignature
# List the shares this host offers (know your own attack surface)
Get-SmbShare
# Is RDP listening, and is NLA required? (UserAuthentication=1 means NLA on)
Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name UserAuthentication
These are inspection commands: they change nothing. The hardening (state-changing) commands appear in the code section, each paired with a verification step.
Two protocols carry most Windows network activity — and most Windows attacks.
Server Message Block (SMB) is the protocol for Windows file and printer sharing, plus general communication between machines. Over SMB you can find shares (folders made available on the network), authenticate, and — with the right permissions — run remote commands.
Key points:
Remote Desktop Protocol (RDP) gives a graphical, interactive session on a remote machine.
Key points:
On an internal test, SMB enumeration finds data and footholds. Once you have credentials, RDP and SMB become the main channels for lateral movement — moving from one compromised host to another. Recognising ports 445 and 3389 in a scan immediately shapes your plan.
All commands below run only in a local, isolated lab — a Windows VM you own, snapshotted, with no bridge to production or the internet. Confirm the authorization checklist first.
AUTHORIZATION CHECKLIST (complete before running anything)
[ ] The host is a VM/lab you own or are explicitly, in-writing authorized to test.
[ ] It is isolated: host-only or internal network, no production/internet bridge.
[ ] You took a VM snapshot named e.g. "pre-lab-clean" so you can revert.
[ ] You are testing YOUR OWN accounts on YOUR OWN host — no third-party systems.
[ ] You have a rollback/cleanup plan (below) if a change breaks access.
WARNING: intentionally vulnerable — use only in a local, isolated, authorized lab. Do not deploy.
# INSECURE LAB SETUP (never on a real machine). This recreates the classic mistakes
# so you can then detect and fix them.
# a) Legacy SMBv1 left enabled (EternalBlue-vulnerable dialect)
Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart
# b) SMB signing NOT required (relay/tamper possible)
Set-SmbServerConfiguration -RequireSecuritySignature $false -Force
# c) An over-shared folder: share permission Everyone:Full, relying on NTFS alone
New-Item -Path C:\LabShare -ItemType Directory -Force | Out-Null
New-SmbShare -Name LabShare -Path C:\LabShare -FullAccess 'Everyone'
# d) RDP enabled but with NLA turned OFF (pre-auth session reachable)
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' `
-Name fDenyTSConnections -Value 0
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name UserAuthentication -Value 0
Why each line is dangerous: (a) exposes a wormable RCE dialect; (b) allows NTLM relay and message tampering; (c) advertises a share to Everyone; (d) lets an unauthenticated attacker reach a session and try BlueKeep-class attacks or brute force.
# SECURE HARDENING. Run as Administrator in the lab.
# a) Disable SMBv1 entirely
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
# b) REQUIRE SMB signing (enabled is not enough; require refuses unsigned sessions)
Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
# c) Fix the over-shared folder: least privilege on the share, then on NTFS
Grant-SmbShareAccess -Name LabShare -AccountName 'BUILTIN\Users' `
-AccessRight Read -Force
Revoke-SmbShareAccess -Name LabShare -AccountName 'Everyone' -Force
# d) Require Network Level Authentication for RDP
Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name UserAuthentication -Value 1
# e) Restrict who can reach 3389 at the firewall to the admin subnet only
# (placeholder RFC1918 lab range — replace with YOUR lab management subnet)
Set-NetFirewallRule -DisplayGroup 'Remote Desktop' `
-RemoteAddress 10.10.10.0/24 -Profile Domain,Private
# f) Turn on the detection you will need (share + logon auditing)
auditpol /set /subcategory:'File Share' /success:enable /failure:enable
auditpol /set /subcategory:'Logon' /success:enable /failure:enable
# VERIFICATION. Each check should print the SECURE value.
# SMBv1 must be Disabled and server-side flag false
Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol |
Select FeatureName, State # expect State: Disabled
Get-SmbServerConfiguration |
Select EnableSMB1Protocol, RequireSecuritySignature # expect False, True
# The share must NOT list Everyone, and only grant Read to Users
Get-SmbShareAccess -Name LabShare # expect BUILTIN\Users Read; no Everyone
# NLA must be required for RDP
(Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name UserAuthentication).UserAuthentication # expect 1
# Firewall rule scoped to the admin subnet only
Get-NetFirewallRule -DisplayGroup 'Remote Desktop' |
Get-NetFirewallAddressFilter | Select RemoteAddress # expect 10.10.10.0/24
Positive (accept-good) test: from a host inside 10.10.10.0/24, an authorized user can still open the RDP session and read LabShare — hardening must not break legitimate use.
Negative (reject-bad) test: from an out-of-scope address the RDP connection is refused, and connecting to the share as an anonymous/Everyone identity is denied. A legacy SMBv1-only client can no longer negotiate a session.
Expected result: every verify command prints the secure value (Disabled / False,True / no Everyone / 1 / the admin subnet). If any prints the insecure value, the change did not take — re-apply and re-verify before trusting the host.
# Revert the intentionally-vulnerable share and RDP change
Remove-SmbShare -Name LabShare -Force -ErrorAction SilentlyContinue
Remove-Item C:\LabShare -Recurse -Force -ErrorAction SilentlyContinue
Then revert the VM to the pre-lab-clean snapshot to guarantee a known-good state. Never leave a lab host with SMBv1 or non-required signing.
Walking through the three phases of the code:
| Step | Command | What happens | Why it matters |
|---|---|---|---|
| Baseline a | Enable-WindowsOptionalFeature ... SMB1Protocol |
Adds the SMBv1 dialect back to the host | Recreates the EternalBlue-vulnerable surface so you can practice detecting it |
| Baseline b | Set-SmbServerConfiguration -RequireSecuritySignature $false |
Server stops insisting on signed SMB messages | Opens the door to NTLM relay and tampering |
| Baseline c | New-SmbShare ... -FullAccess Everyone |
Publishes C:\LabShare to every identity |
Classic over-share; anyone reachable can browse it |
| Baseline d | UserAuthentication = 0 |
RDP accepts connections before authentication | Lets an unauthenticated attacker reach a session (brute force / BlueKeep surface) |
| Fix a | Disable-WindowsOptionalFeature + EnableSMB1Protocol $false |
Removes the SMBv1 dialect two ways (feature + server config) | Belt-and-suspenders: both the OS feature and the SMB server flag are off |
| Fix b | RequireSecuritySignature $true |
Server now refuses unsigned sessions | This is what actually defeats relay; "enabled" alone would not |
| Fix c | Grant/Revoke-SmbShareAccess |
Users get Read; Everyone is removed |
Least privilege at the share layer, not just NTFS |
| Fix d | UserAuthentication = 1 |
RDP demands auth before a session exists | Cuts pre-auth exposure to near zero |
| Fix e | Set-NetFirewallRule -RemoteAddress |
Only the admin subnet can reach 3389 | Moves the trust boundary; the internet can't even knock |
| Fix f | auditpol ... File Share / Logon |
Enables success+failure auditing | Without this, the detection events in the next section never fire |
| Verify | Get-* / property reads |
Print the live values | Turns "I ran the command" into "the state is provably correct" |
The key mental shift: a value like signing has three states — off, enabled, required. The verify step reads the live value so you never confuse "I typed the fix" with "the fix is in effect." UserAuthentication flips 0 -> 1; RequireSecuritySignature flips False -> True; the share's access list loses the Everyone row. Each verify line is chosen to read exactly the field the matching fix line changed.
| Wrong approach | Why it's wrong | Corrected approach | How to recognise / prevent |
|---|---|---|---|
| "I enabled SMB signing, so relay is blocked." | Enabled only signs when asked; an attacker just doesn't ask. | Set RequireSecuritySignature $true. |
Verify the live value reads True, not just that you ran a command. |
Turning on RDP with the registry fDenyTSConnections tweak and stopping there. |
Leaves NLA off and the firewall open to all. | Also set UserAuthentication 1, scope the firewall, add MFA/gateway. |
Check UserAuthentication = 1 and the firewall RemoteAddress. |
Sharing a folder as Everyone: Full Control, "NTFS will protect it." |
One NTFS misconfig makes it world-readable; two layers to get wrong. | Least privilege on both share and NTFS. | Get-SmbShareAccess should never show Everyone on sensitive shares. |
| Exposing 3389 to the internet "behind a strong password." | Bots brute-force and spray 24/7; passwords leak. | VPN/RD Gateway + MFA; never direct exposure. | External scan should show 3389 filtered/closed from the internet. |
| Assuming a patched OS means SMBv1 is gone. | Installers and images silently re-enable it. | Explicitly disable and verify SMBv1. | Get-WindowsOptionalFeature State must be Disabled. |
| Running enumeration or brute-force tests against a machine you don't own. | Illegal and unethical, regardless of intent. | Lab only, on hosts you own or are authorized to test. | Complete the authorization checklist first, every time. |
| "The scanner reported no findings, so RDP/SMB are secure." | A clean scan proves the scanner found nothing, not that the host is safe. | Treat scans as one input; verify configs and logs directly. | Pair every scan with the manual verify commands. |
When a hardening step or a test doesn't behave, work through these:
Get-SmbShareAccess (did the right group keep Read?) and the firewall RemoteAddress (is the admin subnet actually included?). Widen by the minimum needed, then re-verify.Get-SmbServerConfiguration shows signing required but clients still connect unsigned. Client-side signing settings differ from server-side; confirm you changed the server config on the server, and that clients aren't forcing SMBv1.auditpol /get /category:* to confirm auditing is actually on; share-access events (5140/5145) need the File Share subcategory enabled, and they can be high-volume.Questions to ask when it fails: Am I elevated? Is a GPO overriding my local change? Did I verify the live value or just the command's exit? Is this the server or the client setting? Is the source address in scope? Is the relevant audit subcategory enabled?
Security & safety — detection and logging. Hardening is only half the job; you must see attempts. On Windows, the primary sources are the Security event log and firewall connection logs.
What to log (and watch):
| Signal | Where | Abuse it reveals |
|---|---|---|
| 4625 (failed logon), many from one source | Security log | RDP/SMB brute force |
| 4625 across many accounts, one password-shaped pattern | Security log | Password spraying |
| 4624 Logon Type 10 at odd hours / new source | Security log | Suspicious RDP login |
| 4776 NTLM auth spikes | Security log | Relay / hash reuse activity |
| 5140 / 5145 share access | Security log (File Share auditing) | Share enumeration / mass reads |
| Inbound 445/3389 from untrusted ranges | Firewall log | Exposed service, external probing |
Every security-relevant log line should carry: timestamp, source IP/host, account attempted, target resource (share path or host), result (success/fail), the security decision (allowed/denied), and a correlation id to tie related events together.
Never log: passwords, NTLM hashes, Kerberos tickets, session cookies, private keys, full credential blobs, or unnecessary PII. Logging a failed password value just creates a new secret to steal. Record that auth failed and for which account, never the secret itself.
Which events signal abuse: a spike of 4625 from one IP (brute force), 4625 spread across many accounts (spraying), NLA-blocked RDP attempts, share access to sensitive paths by unexpected accounts, or SMBv1 negotiation attempts (should be zero after hardening).
How false positives arise: a mistyped password, a service account with a stale credential, a backup job hammering a share, a vulnerability scanner you authorized, or a user reconnecting after a VPN drop all look like attacks. Tune thresholds, all‑list known scanners/backup hosts, and correlate with change tickets before escalating. Detection without tuning drowns you in noise; tuning without detection leaves you blind.
Authorized real-world use case. A company hires you to review a Windows file server. With written authorization and a defined scope, you (1) scan and see 445 and 3389 open, (2) enumerate shares and find a Backups share readable by Everyone containing a config file with a database password, (3) confirm SMBv1 is still enabled and signing is only enabled, not required, and (4) find RDP reachable from the general staff VLAN without MFA. Your report doesn't stop at "vulnerable": for each item you give the remediation (remove Everyone, require signing, disable SMBv1, gate RDP behind the gateway + MFA) and a retest step proving it's fixed.
Professional best-practice habits:
Beginner vs advanced:
All tasks are lab-only, on a Windows VM you own or are explicitly authorized to test, isolated from production and the internet, with a snapshot taken first. Each ends by remediating and verifying — never by leaving a host weakened.
Beginner 1 — Inventory your own shares.
Get-SmbShare and Get-SmbShareAccess on your lab host; list each share, its path, and who can access it.Everyone or overly broad groups.Beginner 2 — Confirm SMBv1 and signing state.
State of SMBv1 and the values of EnableSMB1Protocol and RequireSecuritySignature.Get-WindowsOptionalFeature, Get-SmbServerConfiguration.Intermediate 1 — Harden and verify RDP.
UserAuthentication = 1, restrict the Remote Desktop firewall rule to your lab admin subnet, then verify both live values.RemoteAddress.Get-NetFirewallRule | Get-NetFirewallAddressFilter.Intermediate 2 — Turn on detection and read it.
auditpol, then filter the Security log for 4625.Challenge — Full remediate-and-retest report on the insecure baseline.
Main concepts. SMB (TCP 445) shares files and authenticates; RDP (TCP 3389) gives interactive remote sessions. Both are prime targets, so both are things you defend: know your shares, disable SMBv1, require (not merely enable) SMB signing, put RDP behind NLA + a gateway/VPN + MFA, and never expose 3389 to the internet.
Key syntax/commands. Inspect with Get-SmbShare, Get-SmbServerConfiguration, Get-WindowsOptionalFeature ... SMB1Protocol, and the RDP-Tcp UserAuthentication key. Harden with Set-SmbServerConfiguration, Grant/Revoke-SmbShareAccess, Set-NetFirewallRule, and auditpol. Always read the live value back to verify.
Common mistakes. Confusing "enabled" with "required" signing; enabling RDP without NLA or firewall scope; Everyone: Full Control shares; internet-exposed RDP; assuming a patch removed SMBv1; and trusting a clean scan as proof of security.
What to remember. Every hardening step needs three things: the fix, a verification that it took effect (reject-bad and accept-good), and detection/logging (4625/4624/4776/5140-5145 and firewall logs) so abuse is visible. Log the decision and context, never the secret. Test only on systems you own or are authorized to test, in an isolated, snapshotted lab, and reset it when done. Nothing is ever "completely secure" — you reduce risk and prove you did.