windows-hardening – skill Bảo mật cho agent AI
Củng cố bảo mật máy chủ Windows theo baseline bảo mật và CIS Benchmark. Cấu hình Group Policy, Windows Defender và các tính năng bảo mật. Dùng khi bảo vệ môi trường Windows Server.
Cài skill windows-hardening bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/windows-hardening-1132e.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /windows-hardening – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/windows-hardening-1132e.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $windows-hardening – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/windows-hardening-1132e.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /windows-hardening – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/windows-hardening-1132e.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /windows-hardening – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Windows Hardening
Secure Windows servers following Microsoft security baselines and CIS benchmarks.
Prerequisites
- Windows Server 2019 or later (2022 recommended)
- Only the least privilege required for the approved host/policy; Domain Admin is not a default prerequisite.
- PowerShell 5.1+ (built into Windows Server)
- Group Policy Management Console for domain environments
- Microsoft Security Compliance Toolkit (recommended)
Security Baseline Deployment
# Download and apply Microsoft Security Baseline
# Download from: https://www.microsoft.com/en-us/download/details.aspx?id=55319
# These optional community DSC modules are not the Security Compliance Toolkit; review publisher/version before separate installation.
Install-Module -Name SecurityPolicyDsc -Force
Install-Module -Name AuditPolicyDsc -Force
Install-Module -Name PSDesiredStateConfiguration -Force
# Import and apply a security baseline GPO (from Security Compliance Toolkit)
# Extract the toolkit, then:
# LGPO.exe is an executable, not a PowerShell module. Verify the downloaded Microsoft binary signature and version.
# Apply local group policy from baseline
.\LGPO.exe /g ".\GPO\{baseline-gpo-guid}"
# Export current security policy for review
secedit /export /cfg C:\SecurityAudit\current-policy.infAccount Policies
# ============================================
# Password Policy Configuration
# ============================================
# Set password policy via net accounts
# Example local-account settings only; align password expiry with current approved policy rather than blanket 90-day rotation.
net accounts /minpwlen:14 /minpwage:1 /uniquepw:24
# Or configure via PowerShell DSC
Configuration PasswordPolicy {
Import-DscResource -ModuleName SecurityPolicyDsc
Node localhost {
AccountPolicy PasswordPolicy {
Name = "PasswordPolicy"
Minimum_Password_Length = 14
Maximum_Password_Age = 0 # illustrative no periodic expiry; current baseline/incident policy governs
Minimum_Password_Age = 1
Enforce_password_history = 24
Password_must_meet_complexity_requirements = "Enabled"
Store_passwords_using_reversible_encryption = "Disabled"
}
}
}
# ============================================
# Account Lockout Policy
# ============================================
net accounts /lockoutthreshold:5 /lockoutwindow:30 /lockoutduration:30
# ============================================
# User Account Hardening
# ============================================
# Rename and disable default accounts
Rename-LocalUser -Name "Administrator" -NewName "LocalAdmin"
Disable-LocalUser -Name "Guest"
Disable-LocalUser -Name "DefaultAccount"
# Remove unnecessary local accounts
$unnecessaryAccounts = Get-LocalUser | Where-Object {
$_.Enabled -eq $true -and
$_.Name -notin @("LocalAdmin", "SYSTEM", "NetworkService", "LocalService")
}
foreach ($account in $unnecessaryAccounts) {
Write-Host "Review account: $($account.Name) - Last logon: $($account.LastLogon)"
}
# Configure Local Administrator Password Solution (LAPS)
# Legacy Microsoft LAPS example only: RSAT-AD-PowerShell does not install AdmPwd.PS.
# Prefer built-in Windows LAPS with its current schema/permissions/backup policy; do not mix legacy and modern commands.
Import-Module AdmPwd.PS # only when legacy LAPS was intentionally installed and remains supported
# Configure LAPS for the OU
Set-AdmPwdComputerSelfPermission -OrgUnit "OU=Servers,DC=example,DC=com"
Set-AdmPwdReadPasswordPermission -OrgUnit "OU=Servers,DC=example,DC=com" -AllowedPrincipals "Domain Admins"Group Policy Security Settings
# ============================================
# User Rights Assignment (via GPO or local policy)
# ============================================
# Restrict remote desktop access
# Computer Configuration > Policies > Windows Settings > Security Settings > Local Policies > User Rights Assignment
# "Allow log on through Remote Desktop Services" = Administrators, Remote Desktop Users
# Deny log on locally for service accounts
# "Deny log on locally" = Service accounts
# Configure via registry (alternative to GPO)
# Restrict anonymous enumeration of SAM accounts
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" `
-Name "RestrictAnonymousSAM" -Value 1
# Restrict anonymous enumeration of shares
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" `
-Name "RestrictAnonymous" -Value 1
# Do not display last user name
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" `
-Name "DontDisplayLastUserName" -Value 1
# ============================================
# Security Options
# ============================================
# Disable SMBv1 (critical security hardening)
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol -NoRestart
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
# Require SMB signing
Set-SmbServerConfiguration -RequireSecuritySignature $true -Force
Set-SmbClientConfiguration -RequireSecuritySignature $true -Force
# Disable LLMNR (prevent credential theft)
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" `
-Name "EnableMulticast" -Value 0
# Disable NetBIOS over TCP/IP
$adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true }
foreach ($adapter in $adapters) {
$adapter.SetTcpipNetbios(2) # 2 = Disable
}
# Disable WDigest (prevent plaintext password caching)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest" `
-Name "UseLogonCredential" -Value 0
# Enable LSA Protection
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" `
-Name "RunAsPPL" -Value 1
# Configure UAC
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" `
-Name "EnableLUA" -Value 1
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" `
-Name "ConsentPromptBehaviorAdmin" -Value 2
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" `
-Name "PromptOnSecureDesktop" -Value 1Windows Firewall Configuration
# ============================================
# Enable Windows Firewall on all profiles
# ============================================
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
# Default deny inbound, allow outbound
Set-NetFirewallProfile -Profile Domain -DefaultInboundAction Block -DefaultOutboundAction Allow
Set-NetFirewallProfile -Profile Public -DefaultInboundAction Block -DefaultOutboundAction Allow
Set-NetFirewallProfile -Profile Private -DefaultInboundAction Block -DefaultOutboundAction Allow
# Enable logging
Set-NetFirewallProfile -Profile Domain -LogAllowed True -LogBlocked True `
-LogFileName "%SystemRoot%\System32\LogFiles\Firewall\pfirewall.log" `
-LogMaxSizeKilobytes 32768
# ============================================
# Inbound Rules
# ============================================
# Allow RDP from management network only
New-NetFirewallRule -DisplayName "Allow RDP - Management" `
-Direction Inbound -Protocol TCP -LocalPort 3389 `
-RemoteAddress 10.0.100.0/24 -Action Allow -Profile Domain
# Allow WinRM from management network
New-NetFirewallRule -DisplayName "Allow WinRM - Management" `
-Direction Inbound -Protocol TCP -LocalPort 5985,5986 `
-RemoteAddress 10.0.100.0/24 -Action Allow -Profile Domain
# Allow ICMP from internal networks
New-NetFirewallRule -DisplayName "Allow ICMP - Internal" `
-Direction Inbound -Protocol ICMPv4 -IcmpType 8 `
-RemoteAddress 10.0.0.0/8 -Action Allow
# Allow specific application
New-NetFirewallRule -DisplayName "Allow IIS HTTPS" `
-Direction Inbound -Protocol TCP -LocalPort 443 `
-Action Allow -Profile Domain,Private
# Block all other inbound by default (already set above)
# ============================================
# Outbound Rules (optional - restrict egress)
# ============================================
# Allow DNS
New-NetFirewallRule -DisplayName "Allow DNS" `
-Direction Outbound -Protocol UDP -RemotePort 53 `
-Action Allow
# Allow HTTPS for updates
New-NetFirewallRule -DisplayName "Allow HTTPS Out" `
-Direction Outbound -Protocol TCP -RemotePort 443 `
-Action Allow
# Allow NTP
New-NetFirewallRule -DisplayName "Allow NTP" `
-Direction Outbound -Protocol UDP -RemotePort 123 `
-Action Allow
# ============================================
# Firewall Audit
# ============================================
# List all enabled firewall rules
Get-NetFirewallRule -Enabled True | Format-Table Displ… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- windows-privilege-escalation – Cung cấp phương pháp luận có hệ thống để phát hiện và khai thác lỗ hổng leo thang đặc…
- xss-html-injection – Thực hiện đánh giá toàn diện lỗ hổng chèn mã phía client trên ứng dụng web để phát hiện…
- zero-trust – Triển khai kiến trúc mạng zero-trust. Cấu hình truy cập dựa trên danh tính, phân đoạn vi…
- zeroize-audit – Phát hiện thiếu xóa an toàn (zeroization) dữ liệu nhạy cảm trong mã nguồn và xác định…
- 1password – Thiết lập op CLI, đăng nhập, rồi đọc hoặc chèn secret.
- 007 – Kiểm toán bảo mật, tăng cường bảo vệ, mô hình hóa mối đe dọa (STRIDE/PASTA), Red/Blue…
- a11y-audit – Skill kiểm toán khả năng tiếp cận để quét, sửa và xác minh mức A và AA của WCAG 2.2 trên…
- 401-403-bypass-techniques – Dùng khi các route HTTP được bảo vệ trả về 401 hoặc 403.