Skip to content

Mr-DS-ML-85/Harden-Windows

πŸ’»πŸ“œβš‘ Windows Port Hardening & Restore Scripts

πŸ›‘οΈ Harden your Windows PC by blocking open ports and disabling unused services.

This repository contains two PowerShell scripts for securing and restoring your Windows 10/11 system by managing open ports, services, and IPv6 settings.

πŸ’»πŸ“œβš‘ PowerShell Script βš‘πŸ“œπŸ’»

πŸ“ Files

πŸ“ Script πŸ“„ Description βš™οΈ Function
πŸ’»πŸ“œβš‘ Harden-Windows.ps1 Blocks dangerous ports and disables services πŸ›‘οΈ Harden your system
πŸ’»πŸ“œβš‘ Restore-WindowsDefaults.ps1 Restores default services, ports, and IPv6 ♻️ Rollback if needed

🧱 Harden-Windows.ps1 :

  • βœ… Blocks commonly exposed ports (e.g., 135, 139, 445, 5040, 49664–49669)
  • βœ… Disables unneeded Windows services like:
    • Remote Registry
    • Remote Desktop (RDP)
    • SMB file sharing
    • UPnP
  • ☰ (Optional) Disables IPv6 (commented by default)

βœ…βš™οΈ Prerequisites

  • Windows 11
  • Administrator privileges
  • Powershell 7.x.x
  • PowerShell execution policy temporarily modified

Installation :

Method 1: Download from Releases

Download the PowerShell(.ps1) files from Releases

Method 2: Git Clone

1) Install Git

2) 2. Clone the repository:

git clone https://github.com/Mr-DS-ML-85/Harden-Windows.git

πŸ”§Usage :

Navigate to the folder containing the scripts, then:

</> Execute:

cd C:\Users\USERNAME\Downloads
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Y
.\Harden-Windows.ps1

♻️ Restore-WindowsDefaults.ps1 :

♻️ Restore Default Settings πŸ”§

This script:

πŸ”‚ Re-enables all services disabled by the hardening script

πŸ”‚ Removes all firewall rules created to block ports

πŸ”‚ Restores IPv6 if it was disabled

πŸ”§Usage :

Navigate to the folder containing the scripts, then:

</> Execute:

cd C:\Users\USERNAME\Downloads
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Y
.\Restore-WindowsDefaults.ps1

⚠️ Warnings :

βœ…οΈ Use only if you're not running SMB shares, RDP, or printers

⚠️ Always test on a non-critical machine first

πŸ›  Requires Administrator privileges

βœ…πŸ§ͺπŸ“ Tested :

πŸ“¦ License :

  • This project is open-source and available under the πŸ“œ MIT License

🀝 Contribution :

  • Contributors are welcome to contribute and make sure checking CONTRIBUTING.md

Packages

 
 
 

Contributors