Bekijk een demo×
×

Zie NinjaOne in actie!

Door dit formulier in te dienen geef ik aan akkoord te gaan met het privacybeleid van NinjaOne.

Hoe een Beleid voor Softwarebeperkingen Maken om Uitvoerbare Bestanden te Blokkeren van AppData en de Downloads-map van Gebruikers

In de huidige complexe IT-omgevingen is het van het grootste belang om de beveiliging van gebruikersomgevingen te handhaven. Voor IT-professionals en Managed Service Providers (MSP’s) is het beperken van de uitvoering van mogelijk schadelijke uitvoerbare bestanden op locaties zoals AppData of de Downloads-map van een gebruiker een uitdaging. Laten we eens diep duiken in een krachtige scriptoplossing om uitvoerbare bestanden van AppData en andere aangewezen locaties te blokkeren.

Beleid voor softwarebeperkingen begrijpen

Software Restriction Policies (SRP) is een functie van Windows waarmee beheerders kunnen bepalen welke software op hun computers mag draaien. SRP kan worden gebruikt om specifieke uitvoerbare bestanden, bestandsextensies of zelfs hele mappen te blokkeren.

Wanneer een uitvoerbaar bestand wordt uitgevoerd, controleert Windows de SRP-instellingen om te zien of het bestand mag worden uitgevoerd. Als het bestand niet mag worden uitgevoerd, wordt er een foutbericht weergegeven.

SRP is een krachtig hulpmiddel dat kan worden gebruikt om computers te beschermen tegen malware en andere beveiligingsrisico’s. Het is echter belangrijk om SRP voorzichtig te gebruiken, omdat het ook legitieme software kan blokkeren.

Het Disable-AppDataExe.ps1 script

Het Disable-AppDataExe.ps1 script is een PowerShell-script dat kan worden gebruikt om uitvoerbare bestanden in de mappen %AppData% en %UserProfile%Downloads te blokkeren. Het script is aanpasbaar, dus je kunt kiezen welke bestandsextensies je wilt blokkeren en welke mappen je wilt beperken.

#Requires -Version 5.1

<#
.SYNOPSIS
    Creates a Software Restriction Policy to block executables from AppData and a user's Downloads folder.
.DESCRIPTION
    Creates a Software Restriction Policy to block executables from AppData and a user's Downloads folder.
.EXAMPLE
     -RestrictedDirectory "%APPDATA%", "%UserProfile%Downloads"
    Creates a Software Restriction Policy to block executables from AppData and a user's Downloads folder. This is the default.
.EXAMPLE
    PS C:> Disable-AppDataExe.ps1 -RestrictedDirectory "%APPDATA%", "%UserProfile%Downloads"
    Creates a Software Restriction Policy to block executables from AppData and a user's Downloads folder. This is the default.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Windows Server 2016 - DOES NOT SUPPORT WINDOWS 11
    Release Notes:
    Initial Release
    (c) 2023 NinjaOne
    By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use.
    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. 
    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. 
    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. 
    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. 
    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param (
    # Paths to block executions
    [Parameter()]
    [String[]]
    $RestrictedDirectory = @("%APPDATA%", "%UserProfile%Downloads"),
    # Executables
    [Parameter()]
    [String[]]
    $ExecutableTypes = @("ADE", "ADP", "BAS", "BAT", "CHM", "CMD", "COM", "CPL", "CRT", "EXE", "HLP", "HTA", "INF", "INS", "ISP", "LNK", "MDB", "MDE", "MSC", "MSI", "MSP", "MST", "OCX", "PCD", "PIF", "REG", "SCR", "SHS", "URL", "VB", "WSC")
)

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
        { Write-Output $true }
        else
        { Write-Output $false }
    }
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }
    # Clear existing rules
    $BaseRegPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\safer'
    if (Test-Path "$BaseRegPath") { Remove-Item "$BaseRegPath" -Recurse }
    # Create our rule settings
    New-Item "$BaseRegPath"
    New-Item "$($BaseRegPath)\codeidentifiers"
    New-Item "$($BaseRegPath)\codeidentifiers\0"
    New-Item "$($BaseRegPath)\codeidentifiers\0\Paths"
    New-ItemProperty "$($BaseRegPath)\codeidentifiers" -Name 'authenticodeenabled' -Value 0 -PropertyType DWord
    New-ItemProperty "$($BaseRegPath)\codeidentifiers" -Name 'DefaultLevel' -Value 262144 -PropertyType DWord
    New-ItemProperty "$($BaseRegPath)\codeidentifiers" -Name 'TransparentEnabled' -Value 1 -PropertyType DWord
    New-ItemProperty "$($BaseRegPath)\codeidentifiers" -Name 'PolicyScope' -Value 0 -PropertyType DWord
    New-ItemProperty "$($BaseRegPath)\codeidentifiers" -Name 'ExecutableTypes' -Value $ExecutableTypes -PropertyType MultiString

    foreach ($Directory in $RestrictedDirectory) {
        $pathguid = [guid]::newguid()
        $newpathkey = "$($BaseRegPath)\codeidentifiers\0\Paths{" + $pathguid + "}"
        if ((Test-Path -LiteralPath $newpathkey) -ne $true) { New-Item $newpathkey }
        New-ItemProperty -LiteralPath $newpathkey -Name 'SaferFlags' -Value 0 -PropertyType DWord
        New-ItemProperty -LiteralPath $newpathkey -Name 'ItemData' -Value $Directory -PropertyType ExpandString
    }
    gpupdate.exe /force
}

 

Het script gebruiken

Om het script Disable-AppDataExe.ps1 te kunnen gebruiken, moet PowerShell zijn geïnstalleerd en moet het script worden uitgevoerd met beheerdersrechten. Zodra u het script hebt, kan u het uitvoeren door de volgende opdracht in te voeren op de PowerShell prompt:

.Disable-AppDataExe.ps1

Het script blokkeert dan het uitvoeren van de opgegeven uitvoerbare bestanden in de opgegeven mappen.

Slotbeschouwingen:

Het Disable-AppDataExe.ps1 script is een handig hulpmiddel om te voorkomen dat uitvoerbare bestanden in specifieke mappen worden uitgevoerd. Het is echter belangrijk om u bewust te zijn van de beperkingen. Door te begrijpen hoe SRP werkt en hoe u het script moet gebruiken, kunt u uw computers helpen beschermen tegen malware en andere beveiligingsrisico’s.

Hier zijn enkele extra dingen om in gedachten te houden bij het gebruik van het Disable-AppDataExe.ps1 script:

  • Het script blokkeert alleen uitvoerbare bestanden in de opgegeven mappen. Uitvoerbare bestanden in andere mappen, zoals de map Program Files, worden niet geblokkeerd.
  • Het script blokkeert geen uitvoerbare bestanden die worden uitgevoerd vanaf een opdrachtprompt of een batchbestand.
  • Het script kan omzeild worden door gebruikers met beheerdersrechten. (Misschien ben je geïnteresseerd in hoe je lokale beheerdersrechten uitschakelt met PowerShell).

NinjaOne kan IT-professionals helpen om uitvoerbare bestanden naadloos te blokkeren op een onbeperkt aantal eindpunten. NinjaOne is een cloud-based IT-beheerplatform dat verschillende beveiligingsfuncties biedt, waaronder de mogelijkheid om SRP (Software Restriction Policies) te maken en te implementeren. De SRP-functie van NinjaOne is eenvoudig te gebruiken en kan worden aangepast om uitvoerbare bestanden in specifieke mappen, bestandsextensies of zelfs volledige toepassingen te blokkeren. Bovendien kan de SRP-functie van NinjaOne centraal worden beheerd, waardoor het eenvoudig is om op te schalen naar een onbeperkt aantal eindpunten.

Hier zijn enkele voordelen van het gebruik van NinjaOne om uitvoerbare bestanden te blokkeren:

  • Naadloze implementatie: De SRP-functie van NinjaOne kan worden ingezet op eindpunten zonder dat afzonderlijke installaties of configuraties nodig zijn. Dit maakt het gemakkelijk om het beleid snel en eenvoudig uit te rollen naar een groot aantal eindpunten.
  • Gecentraliseerd beheer: De SRP-functie van NinjaOne kan centraal worden beheerd vanaf één console. Dit maakt het eenvoudig om SRP-beleidslijnen aan te maken, te wijzigen en te implementeren op al uw eindpunten.
  • Flexibiliteit: De SRP-functie van NinjaOne is flexibel en kan worden aangepast aan de specifieke behoeften van je organisatie. Je kunt uitvoerbare bestanden blokkeren op map, bestandsextensie of zelfs toepassing.
  • Schaalbaarheid: De SRP-functie van NinjaOne kan worden opgeschaald naar een onbeperkt aantal eindpunten. Dit maakt het een sterke oplossing voor organisaties van elke grootte.

Meer informatie over NinjaOne Endpoint Management.

Volgende stappen

Het opbouwen van een efficiënt en effectief IT-team vereist een gecentraliseerde oplossing die fungeert als uw kerndienstleveringstool. NinjaOne stelt IT-teams in staat om al hun apparaten te monitoren, beheren, beveiligen en ondersteunen, waar ze ook zijn, zonder de noodzaak van complexe on-premises infrastructuur.

Leer meer over NinjaOne Endpoint Management, bekijk een live rondleiding, of start uw gratis trial van het NinjaOne-platform

Categorieën:

Dit vindt u misschien ook leuk

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).