Skip to content

Add param block and use the actual script location for finding YARA #4

Description

@s-nix

Add a param block similar to the following:

[CmdletBinding()]
param (
    [Parameter(Mandatory=$false)][int]$usrScanscope = $env:usrScanscope,
    [Parameter(Mandatory=$false)][bool]$usrUpdateDefs = $env:usrUpdateDefs,
    [Parameter(Mandatory=$false)][char]$usrMitigate = $env:usrMitigate
)

Use this to get the location of the script itself, not the current directory:

$scriptObject = Get-Item -Path $script:PSCommandPath
$script:workingPath = $($scriptObject.DirectoryName)

So that this:

foreach ($iteration in ('yara32.exe','yara64.exe')) {
    if (!(test-path $iteration)) {
        write-host "! ERROR: $iteration not found. It needs to be in the same directory as the script."
        write-host "  Download Yara from https://github.com/virustotal/yara/releases/latest and place them here."
        exit 1
    } else {
        write-host "- Verified presence of $iteration."
    }

becomes this

foreach ($iteration in ('yara32.exe','yara64.exe')) {
    if (!(test-path "$script:workingPath\$iteration")) {
        write-host "! ERROR: $iteration not found. It needs to be in the same directory as the script."
        write-host "  Download Yara from https://github.com/virustotal/yara/releases/latest and place them here."
        exit 1
    } else {
        write-host "- Verified presence of $iteration."
    }

Hope this helps 😊

Edit: Link to the fork which implements these changes: https://github.com/ProVal-Tech/log4shell-tool

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions