top of page

67 items found for ""

  • Disable LLMNR, IPv6 and Other Network Services

    The following tweaks are for disabling network features that are either legacy but still enabled or not required. ​ Each setting can be applied by running an elevated PowerShell directly or deployed from MDT or ConfigMgr. <# .Synopsis ​ .Description If IPv6 isnt deployed on the network should be disabled correctly via the Registry and not by unchecking the IPv6 component in network connections. ​ .Version #> #Disable IPv6 by setting 0xff, do not set fffffff as it slows down bootup New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters' -Name DisabledComponents -PropertyType DWORD -Value 0xff -Force ​ ​ <# .Synopsis Disable LLMNR ​ .Description LLMNR or Responder should be actively disabled as it broadcasts the password hash and account name of the user or service account. Open Run and type '\\server\share' as this is very unlikely to exist the client will query the network by broadcasting on port 5355 containing your account with the password hash. Kali running Responder will pick this up and feed it into 'John the Ripper', ​ Block ports TCP\UDP 5355 both InBound and OutBound ​ Or set 'Turn on Responder (RSPNDR) Driver' to 'Disable' in GPO 'Computer > Policies > Administrative Templates > Network > Link-Layer Topology Discovery' ​ .Version #> #Disabled LLMNR New-Item "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT" -Name DNSClient -ForceNew-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name EnableMultiCast -Value 0 -PropertyType DWORD -Force ​ <# .Synopsis Disable both LMHosts and NetBios ​ .Description LMHosts is the legacy file used for name resolution. ​ NetBios is often enabled by default on Windows system but is legacy for SMB and Printer traffic, it can be abused leading to the system being exploited. Port 139 is used by Nbtstat to query for Windows devices. ​ Block ports UDP 137-138 both InBound and OutBound Block ports TCP 139 both InBound and OutBound .Version #> #Disable LMHOSTS File in Network Settings $lmhost = @{ { DNSEnabledForWINSResolution = $false WINSEnableLMHostsLookup = $false } Invoke-CimMethod -ClassName win32_networkadapterconfiguration -methodName enableWins -Arguments $lmhost #Disable NetBios in Network Settings $netbios = Get-ChildItem -Recurse "HKLM:\SYSTEM\CurrentControlSet\Services\NetBT\Parameters\Interfaces" | where {$_.property -eq "NetBiosOptions"} foreach ($op in $netbios) { cd hklm: $opPath = $op.Name.Replace("HKEY_LOCAL_MACHINE","HKLM:") Set-ItemProperty $opPath -name NetBiosOptions -Value 2 -Force } ​ ​ ​ <# .Synopsis Disable Universal Plug and Play for network devices ​ .Description uPnP allows devices to discover and share data with other network devices, there is a small risk of this service being abused. Its a small but potential risk, more importantly it's a service that isn't needed, so it's disabled ​ Block port TCP 5000 Inbound Block port UDP 1901 Inbound ​ Stopping 'UPnP Device Host' Windows Service ​ .Version #> #Disable uPnP (Network Discovery) Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name AllowLLTDIOOnDomain -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name AllowLLTDIOOnPublicNet -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name AllowRspndrOnDomain -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name AllowRspndrOnPublicNet -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name EnableLLTDIO -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name EnableRspndr -Value 0 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name ProhibitLLTDIOOnPrivateNet -Value 1 -Force Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LLTD" -name ProhibitRspndrOnPrivateNet -Value 1 -Force ​ ​

  • Setting Folder Permissions with PowerShell

    ​There's been a few instances where setting folder permissions is required and I've found the following useful. ​ <# .Synopsis Change FOLDER permission for Authenticated User ​ .Description ​​ .Version #> ​ #Declares Inheritance $inherNone = [System.Security.AccessControl.InheritanceFlags]::None $propNone = [System.Security.AccessControl.PropagationFlags]::None $inherCnIn = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit $propInOn = [System.Security.AccessControl.PropagationFlags]::InheritOnly $inherObIn = [System.Security.AccessControl.InheritanceFlags]::ObjectInherit $propNoPr = [System.Security.AccessControl.PropagationFlags]::NoPropagateInherit #Declare Auth User $user = "Authenticated users" #Path to Folder $path = "C:\SomeFolder" ​ #Return current permissions (get-acl C:\SomeFolder).Access ​ #Removes Inheritance $aclInh = get-acl $path $aclInh.SetAccessRuleProtection($true,$true) Set-Acl $path $aclInh ​ #Remove Permissions $getAcl = Get-Acl $path $fileAcc = New-Object System.Security.AccessControl.FileSystemAccessRule("$User","FULL","$inherCnIn ,$inherObIn","None","Allow") $getAcl.SetAccessRule($fileAcc) $getAcl.removeAccessRuleAll($fileAcc) Set-Acl $path $getAcl #Add Permissions $getAcl = Get-Acl $path $fileAcc = New-Object System.Security.AccessControl.FileSystemAccessRule("$user","READ","$inherCnIn,$inherObIn", "None","Allow") $getAcl.SetAccessRule($fileAcc) Set-Acl $path $getAcl ​ #Add a DENY permission $getAcl = Get-Acl $path $fileAcc = New-Object System.Security.AccessControl.FileSystemAccessRule("$user","READ","$inherCnIn,$inherObIn","None","deny") $getAcl.SetAccessRule($fileAcc) Set-Acl $path $getAcl

  • Disable Windows Recovery

    Disabling Microsoft Windows Recovery Environment is a good idea because it reduces the risk of malicious software being installed on your computer. It also prevents unauthorized access to system files, which could lead to data loss or corruption. Additionally, disabling this feature helps prevent accidental changes to critical system settings that can cause serious problems and even render your computer unusable. ​ <# .Synopsis Updates Windows Boot and Recovery options ​ .Description Updates Windows Boot and Recovery options to prevent any boot options from being launched during the Windows boot. Windows will boot with a blank screen and provide no recovery options, This is one of a series of mitigations to prevent booting into PXE, Kali or Recovery options to perform attacks against the system. UEFI\BIOS - Update Boot order and remove PXE, USB and CD\DVD Boot Options UEFI\BIOS - Add a complex password to prevent unauthorised changed Bitlocker - Always encrypt the System drive with Bitlocker or alternative full disk encryption. Recovery Partition - Remove Recovery Partition from MDT\ConfigMgr disk configuration Bitlocker should be configured with TPM and Pin to prevent LPC (Low Pin Count) Bus sniffing attack ​​ .Version #> #disables automatic repair options for Windows cmd.exe /c "bcdedit.exe /set {default} recoveryenabled no" ​ #disables Windows Error Recovery screen cmd.exe /c "bcdedit.exe /set {default} BootStatusPolicy IgnoreAllFailures" ​ #disables all UI elements, logo, status, status messages cmd.exe /c "bcdedit.exe /set {default} bootuxdisabled on" #disables advanced startup options (F8) cmd.exe /c "bcdedit.exe /set {default} advancedoptions false" ​ #disables advanced startup option (F10) cmd.exe /c "bcdedit.exe /set {default} optionsedit false" ​​ #sets boot timeout out to zero cmd.exe /c "bcdedit.exe /timeout 0" ​ ​

  • Disable Windows Memory Dumps

    By disabling Memory Dumps it's no longer possible to recover the dump file and extract secure data that is held in memory in the clear. ​ <# .Synopsis Disables Windows Memory Dumps ​ .Description ​ Disabled Memory Dump to prevent extracting cleat text passwords using WinDbg ​ 0 = None 1 = Complete Memory Dump 2 = Kernel Memory Dump 3 = Small Memory Dump 7 = Automatic Memory Dump (Default) ​ .Version #> Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -name CrashDumpEnabled -Value 0 -Force ​

  • Hide the C:\ Drive

    There are 2 methods for hiding the C: or any other drive, GPO and a Regedt32 tweak. ​ There's obvious benefits preventing access to browse the System Drive like being able to Explore to a file and run it. However hiding C: needs to be considered as only part of the solution to prevent access. Its still possible to open PowerShell and cmd then 'cd' without restrictions, create desktop shortcuts to a named file and many others. Even after locking all routes down the audio control icon, assuming the user requires sound control provides a route into browsing the system. ​ There are,It's# .Synopsis Remove access to C: ​ .Description ​ Removes access to the C:\ by setting NoDrives and the value of 4 in the registry or set the User GPO settings 'Prevent access to drives from My Computer'. ​ .Version #> #Hides C for all users including Administrator New-ItemProperty -path 'HKLM:/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/Explorer' -Name NoDrives -PropertyType DWORD -Value 4 ​ #Hides C for the user the setting is applied against. ​ New-ItemProperty -path 'HKCU:/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/Explorer' -Name NoDrives -PropertyType DWORD -Value 4 ​ User GPO Settings ​

  • Windows Defence Application Control aka Device Guard

    Device Guard has the following requirements: Hardware Requirements UEFI Native Mode Windows 10/2016 x64 SLAT and Virtualization Extensions (Intel VT or AMD V) TPM ​ Windows Features Windows Defender Application Guard (Isolation mode prior to 1703) Hyper-V Platform (Not required after 1603) Hyper-V Hypervisor ​ GPO Settings Computer Configuration > Administrative Templates > System > Device Guard Turn on Virtualization Based Security (enable) Secure Boot and DMA Protection Enable Virtualization Based Protection of Code Deploy Code Integrity Policy (enable) C:\DeviceGuard\SIPolicy.p7b ​ (C:\DeviceGuard\SIPolicy.p7b is automatically copied and converted to C:\Windows\System32\Codeintegrity\) ​ From PowerShell execute Invoke-CimMethod -Namespace root/Microsoft/Windows/CI -ClassName PS_UpdateAndCompareCIPolicy -MethodName update -Arguments @{filepath = "C:\Windows\system32\CodeIntegrity\SIPolicy.p7b"} The system will create SIPolicy.p7b and a reboot will enforce Device Guard. ​ To create a Device Guard Policy run the following. ​ <# .Synopsis ​ .Description ​ .Version #> #Sets Working Folder for DG $CIPolicyPath = "C:\DeviceGuard" ​ #C:\DeviceGuard\InitalScan.xml $IntialCIPolicy = $CIPolicyPath+"\initialScan.xml" ​ #C:\DeviceGuard\SIPolicy.p7b $CIPolicyBin = $CIPolicyPath+"\SIPolicy.p7b" ​ #C:\DeviceGuard\CIPolicy.txt - Output from initial policy audit $CIPolicyTxt = $CIPolicyPath+"\CIPolicy.txt" ​ #Creates SIPolicy.p7b based on the IntialCIPolicy.xml New-CIPolicy -Level FilePublisher -Fallback Hash -FilePath $IntialCIPolicy -UserPEs 3> $CIPolicyTxt -ScanPath C:\ ​ #Enforces UMCI Set-RuleOption -FilePath $IntialCIPolicy -Option 0 #Enforcement Mode enabled Set-RuleOption -FilePath $IntialCIPolicy -Option 3 -delete ​ #Converts the audit to a p7b file copies to C:\DeviceGuard\ #GPO is set to move SIPolicy.p7b to C:\Windows\System32\CodeIntegrity ConvertFrom-CIPolicy -XmlFilePath $IntialCIPolicy -BinaryFilePath $CIPolicyBin ​ #Enable DG to enforce Invoke-CimMethod -Namespace root/Microsoft/Windows/CI -ClassName PS_UpdateAndCompareCIPolicy -MethodName update -Arguments @{filepath = "C:\Windows\System32\CodeIntegrity\SIPolicy.p7b"}

  • Disable Admin Shares

    <# .Synopsis Disable Admin Shares ​ .Description Disable Admin Shares C$, IPC$, ADMIN$ to prevent remote access and local access via \\127.0.0.1\c$ from a browser, shortcut or cmd. Disabling admin shares will prevent ConfigMgr from deploying the client agent and remote administrative access. ​ .Version #> #AutoShareWks New-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Services\LanmanServer\Parameters' -name AutoShareWks -PropertyType DWORD -Value 0 ​ #AutoShareServer New-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Services\LanmanServer\Parameters' -name AutoShareServer -PropertyType DWORD -Value 0

bottom of page