A local Windows RDP security monitor that hardens exposed Remote Desktop, blocks brute-force scanners, and alerts you when something important happens.
RDP-Guard is for people who must keep Remote Desktop reachable from the public internet, but still want a stronger safety layer than "change the port and hope nobody finds it." Internet-wide scanners constantly look for RDP. Once they find it, they try usernames, passwords, and repeated connection attempts until something gives.
RDP-Guard adds a fail2ban-style defense for Windows:
- 🚫 Auto-ban attackers after repeated failed RDP attempts.
- 🔥 Keep one clean firewall block rule instead of hundreds of messy rules.
- 👀 Monitor successful logins so you can spot access that was not you.
- 🔔 Show local Windows toast alerts for bans and RDP logins.
- 🔐 Apply RDP hardening such as NLA, TLS, high encryption, password policy, session limits, and larger Security logs.
- 🧰 Stay local-only: no cloud service, no webhook, no telemetry, no third-party account.
⚠️ Exposing RDP directly to the internet is always risky. A VPN, RD Gateway, or MFA-gated setup is better when possible. RDP-Guard is the extra protection layer for the real-world case where public RDP must stay open.
Open Command Prompt as Administrator, paste this, and press Enter:
powershell -NoProfile -ExecutionPolicy Bypass -Command "$cmd=Join-Path $env:TEMP 'Install-RDPGuard.cmd'; Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/smartboy223/RDP-Guard/main/Install-RDPGuard.cmd' -OutFile $cmd; & $cmd"The bootstrap installer will:
- ask which RDP port to protect,
- download or update files in
C:\Security\RDP-Guard, - preserve existing
config.jsonvalues andstate.jsonban history, - avoid deleting the install folder blindly,
- run
Install.ps1, - run
Test-RDPGuard.ps1validation.
The installer creates the firewall rules, applies hardening, creates the RDP-Guard event log, and registers the startup monitor task. The engine runs as SYSTEM at startup and every minute.
Already downloaded the repo? Run:
Install-RDPGuard.cmdChanging the RDP port is not enough. It only hides the service from the laziest scans. Real scanners sweep all ports and will eventually find open RDP.
Once found, an exposed RDP service needs more than a firewall allow rule:
- Attackers can flood failed logins and fill your logs.
- NLA pre-auth failures may not always appear as standard Security
4625events. - Repeated attempts from the same source should be blocked automatically.
- You need to know when someone successfully logs in, not only when they fail.
- Manual firewall cleanup becomes painful if every bad IP becomes its own rule.
RDP-Guard handles that routine defensive work for you while keeping everything on your machine.
| Layer | What RDP-Guard Does |
|---|---|
| 🧱 Firewall | Creates one clean public RDP allow rule and one maintained block rule |
| 🚨 Detection | Watches Security 4625 and RDP Core 140 failures |
| ⛔ Blocking | Bans IPs after repeated failures in a time window |
| 📈 Escalation | Repeat offenders get longer bans automatically |
| 🧹 Cleanup | Expired bans are removed from the active firewall rule |
| 🔔 Alerts | Optional local toast notifications for bans and successful RDP logins |
| 📜 Audit | Writes ban/unban events to the local RDP-Guard Windows Event Log |
| 🔐 Hardening | Enforces stronger RDP/security settings during install |
- Firewall hygiene: disables stale default RDP rules and replaces ad-hoc rules with one clean inbound rule on your chosen port.
- Auto-blocker: watches failed logins and bans offending IPs via a single self-maintaining firewall rule.
- Better RDP detection: reads both Security log Event
4625andMicrosoft-Windows-RemoteDesktopServices-RdpCoreTS/OperationalEvent140, catching scanners rejected before normal credential events. - Real ban expiry: bans expire automatically, and repeat offenders receive longer bans.
- CIDR whitelist support: loopback, LAN, link-local, and private ranges are protected from accidental blocking.
- Local monitor and alerts: ban/unban events are written locally, and optional toast alerts appear for new bans and successful RDP logins.
- Admin commands: list bans, manually block/unblock, and generate activity reports.
- Windows 10/11 Pro or Windows Server.
- Administrator rights to install.
- Windows PowerShell 5.1 or PowerShell 7+.
- Remote Desktop already enabled on the machine.
All tunables live in config.json; the engine re-reads it every run.
| Key | Default | Meaning |
|---|---|---|
rdpPort |
4002 |
Your RDP listening port |
threshold |
6 |
Failures from one IP before a ban |
lookbackMinutes |
15 |
Sliding window for counting failures |
banHours |
24 |
Base ban length |
escalation |
x2, cap 720h | Repeat offenders get longer bans |
whitelist |
RFC1918 + loopback | Never-block ranges, CIDR supported |
retentionDays |
30 |
How long expired records are kept for escalation memory |
allowRuleName |
RDP-Guard-Allow |
Managed inbound RDP allow rule |
alerts.toast |
true |
Enable local Windows toast alerts |
Import the admin module:
Import-Module "C:\Security\RDP-Guard\RDP-Guard.Admin.psm1" -ForceUseful commands:
Get-RDPGuardBans
Get-RDPGuardBans -IncludeExpired
Get-RDPGuardReport -Hours 24
Block-RDPGuardIP -IP 1.2.3.4 -Permanent
Unblock-RDPGuardIP -IP 1.2.3.4View activity with one command:
powershell -ExecutionPolicy Bypass -File "C:\Security\RDP-Guard\Show-Activity.ps1" -Hours 72Raw event log:
Get-WinEvent -LogName 'RDP-Guard' -MaxEvents 20The monitor is the part that makes this more useful than a one-time hardening script.
Every minute, the scheduled task:
- Reads recent failed RDP events.
- Counts failures by source IP.
- Skips trusted/whitelisted ranges.
- Adds or extends bans for repeated attackers.
- Expires old bans.
- Rebuilds one Windows Firewall block rule.
- Writes a local event log entry.
- Triggers optional local toast alerts.
Successful RDP logins are also visible in the activity report and can trigger a toast notification. That matters because the most important signal is not only "someone failed"; it is "someone got in."
Run:
powershell -ExecutionPolicy Bypass -File "C:\Security\RDP-Guard\Test-RDPGuard.ps1"The validator checks config, event log, scheduled tasks, firewall rules, listening port, and the full ban pipeline. It blocks a reserved test IP, verifies it appears in state/firewall/event log, then removes it.
The strongest upgrade for exposed RDP is MFA at Windows logon:
RDP-Guard does not bundle these. It stays self-contained and local-only, but MFA is strongly recommended if your endpoint is exposed.
From console access or another admin path:
Import-Module "C:\Security\RDP-Guard\RDP-Guard.Admin.psm1" -Force
Unblock-RDPGuardIP -IP <your-public-ip>Emergency clear:
Get-NetFirewallRule -DisplayName 'RDP-Guard-Block' | Remove-NetFirewallRulepowershell -ExecutionPolicy Bypass -File "C:\Security\RDP-Guard\Uninstall.ps1"Options:
-RemoveEventLog: delete the customRDP-Guardevent log.-RemoveAllowRule: remove the RDP allow rule. This closes RDP through the firewall.
Hardening settings are intentionally left in place.
| File | Purpose |
|---|---|
Install-RDPGuard.cmd |
Safe bootstrap installer/updater with RDP port prompt |
Install.ps1 / Uninstall.ps1 |
Setup and teardown |
RDP-Guard.ps1 |
Auto-blocker engine run by the scheduled task |
RDP-Guard.Common.ps1 |
Shared config, state, CIDR, firewall, and logging helpers |
RDP-Guard.Admin.psm1 |
Admin commands and reporting |
Show-Activity.ps1 / View-Activity.cmd |
Activity viewer |
Test-RDPGuard.ps1 / Validate-Setup.cmd |
End-to-end validation |
RDP-Guard.Toast.ps1 |
Local toast popups |
config.json |
Tunable settings |
state.json |
Runtime ban state, ignored by git |
Provided as-is, no warranty. You are responsible for testing it in your own environment and for the security of your systems. Exposing RDP to the internet carries inherent risk.
