Public/Helpers/Invoke-Update.ps1
|
function Invoke-Update { [cmdletbinding()] param ( [Parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [string]$Repository = 'https://raw.githubusercontent.com/azurekid/blackcat/refs/heads/main/support-files/' ) begin { Write-Verbose "Starting function $($MyInvocation.MyCommand.Name)" $filesArray = @( 'permutations.txt', 'userAgents.json', 'ServiceTags.json', 'appRoleIds.csv', 'EntraRoles.csv', 'AzureRoles.csv', 'subdomains.json' ) } process { Write-Verbose "Creating helper directory" Test-Path -Path $helperPath -ErrorAction SilentlyContinue | New-Item -ItemType Directory -Path $helperPath -Force try { Write-Verbose "Downloading support files" foreach ($file in $filesArray) { $fileUri = "$Repository$file" $destinationPath = "$helperPath/$file" Write-Verbose "Downloading $file from $fileUri to $destinationPath" Invoke-WebRequest -Uri $fileUri -OutFile $destinationPath -ErrorAction Stop Update-AzureServiceTag -Region 'Azure Public' } } catch { Write-Message -FunctionName $($MyInvocation.MyCommand.Name) -Message $($_.Exception.Message) -Severity 'Error' } } <# .SYNOPSIS Downloads and updates helper files from a specified repository. .DESCRIPTION Downloads predefined helper files from repository URL and saves to local directory. .PARAMETER Repository Specifies the base URL of the repository from which to download the helper files. The default value is 'https://raw.githubusercontent.com/azurekid/blackcat/refs/heads/main/src/Helpers/'. .EXAMPLE Invoke-Update Downloads the helper files from the default repository URL and saves them to the local directory. .EXAMPLE Invoke-Update -Repository 'https://example.com/helpers/' Downloads the helper files from the specified repository URL and saves them to the local directory. .INPUTS None. You cannot pipe objects to this function. .OUTPUTS None. The function does not generate any output. .NOTES This is a utility/support function and does not directly map to MITRE ATT&CK tactics. This function downloads support files needed by BlackCat functions. #> } |