Skip to content

Commit

Permalink
Adding support for filtering of OS binaries, as well as defaulting to…
Browse files Browse the repository at this point in the history
… '-All'
  • Loading branch information
LeeHolmes committed Sep 22, 2016
1 parent cb91cdb commit 8efb0fa
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions AutoRuns.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ Begin {

)
Begin {
## Add 'All' if nothing else was supplied
if(($PSBoundParameters.Keys | ? { $_ -notin "ShowFileHash","VerifyDigitalSignature" }).Count -eq 0)
{
$All = [switch]::Present
}
}
Process {
if ($All -or $BootExecute) {
Expand Down Expand Up @@ -2160,30 +2165,38 @@ Begin {
If ($VerifyDigitalSignature) {
if ($_.ImagePath) {
If (Test-Path -Path $_.ImagePath -PathType Leaf) {
$_ | Add-Member -MemberType ScriptProperty -Name Signed -Value ({
try {
$signature = Get-AuthenticodeSignature -FilePath $($this.ImagePath) -ErrorAction Stop
Switch ($signature.Status) {
'Valid' {
$true
break
}
'NotSigned' {
$false
break
}
default {
$false
}
}

} catch {

## Add the signature status to the entry
$signature = Get-AuthenticodeSignature -FilePath $_.ImagePath -ErrorAction Stop
$signed = switch ($signature.Status) {
'Valid' {
$true
break
}
'NotSigned' {
$false
break
}
default {
$false
}
}) -Force -PassThru
}
$_ = $_ | Add-Member -MemberType NoteProperty -Name Signed -Value $signed -Force -PassThru

## Add a note whether this is an OS binary to allow for easy filtering:
## Get-PSAutorun -VerifyDigitalSignature | ? { -not $_.IsOSBinary }
if($signature.IsOSBinary)
{
$_ = $_ | Add-Member -MemberType NoteProperty -Name IsOSBInary -Value $signature.IsOSBinary -Force -PassThru
}

## Add the signer itself
$_ | Add-Member -MemberType NoteProperty -Name Publisher -Value $signature.SignerCertificate.Subject -Force -PassThru
}
} else {
$_ | Add-Member -MemberType NoteProperty -Name Signed -Value $null -Force -PassThru
$_ = $_ | Add-Member -MemberType NoteProperty -Name Signed -Value $null -Force -PassThru
$_ = $_ | Add-Member -MemberType NoteProperty -Name IsOSBinary -Value $null -Force -PassThru
$_ | Add-Member -MemberType NoteProperty -Name Publisher -Value $null -Force -PassThru
}
} else {
$_
Expand Down

0 comments on commit 8efb0fa

Please sign in to comment.