diff options
author | mattifestation <mattgraeber@gmail.com> | 2014-11-17 08:24:54 -0500 |
---|---|---|
committer | mattifestation <mattgraeber@gmail.com> | 2014-11-17 08:24:54 -0500 |
commit | dc1a5e519fef327f694bc61d522c750fabf831aa (patch) | |
tree | d9f18099f490be8c5c670b13a61b3e1976a8624b /Persistence | |
parent | 956e4c968a1795d868e35fcb72311704d616cbaf (diff) | |
download | PowerSploit-dc1a5e519fef327f694bc61d522c750fabf831aa.tar.gz PowerSploit-dc1a5e519fef327f694bc61d522c750fabf831aa.zip |
Add-Persistence bugfix
When file paths were specified, they were not being properly validated.
Diffstat (limited to 'Persistence')
-rw-r--r-- | Persistence/Persistence.psd1 | 2 | ||||
-rw-r--r-- | Persistence/Persistence.psm1 | 32 |
2 files changed, 23 insertions, 11 deletions
diff --git a/Persistence/Persistence.psd1 b/Persistence/Persistence.psd1 index f51f7ce..e17faf1 100644 --- a/Persistence/Persistence.psd1 +++ b/Persistence/Persistence.psd1 @@ -4,7 +4,7 @@ ModuleToProcess = 'Persistence.psm1' # Version number of this module. -ModuleVersion = '1.1.0.0' +ModuleVersion = '1.1.1.0' # ID used to uniquely identify this module GUID = '633d0f10-a056-41da-869d-6d2f75430195' diff --git a/Persistence/Persistence.psm1 b/Persistence/Persistence.psm1 index 344c13d..7528f2e 100644 --- a/Persistence/Persistence.psm1 +++ b/Persistence/Persistence.psm1 @@ -417,11 +417,9 @@ function Add-Persistence [String] $PersistenceScriptName = 'Update-Windows', - [ValidateNotNullOrEmpty()] [String] $PersistentScriptFilePath = "$PWD\Persistence.ps1", - [ValidateNotNullOrEmpty()] [String] $RemovalScriptFilePath = "$PWD\RemovePersistence.ps1", @@ -446,35 +444,49 @@ function Add-Persistence throw 'You provided invalid user-level persistence options.' } - $Path = Split-Path $PersistentScriptFilePath -ErrorAction Stop + $Result = Get-Item $PersistentScriptFilePath -ErrorAction SilentlyContinue + if ($Result -and $Result.PSIsContainer) + { + throw 'You must provide a file name with the PersistentScriptFilePath option.' + } + + $Result = Get-Item $RemovalScriptFilePath -ErrorAction SilentlyContinue + if ($Result -and $Result.PSIsContainer) + { + throw 'You must provide a file name with the RemovalScriptFilePath option.' + } + + $PersistentPath = Split-Path $PersistentScriptFilePath -ErrorAction Stop $Leaf = Split-Path $PersistentScriptFilePath -Leaf -ErrorAction Stop $PersistentScriptFile = '' $RemovalScriptFile = '' - if ($Path -eq '') + if ($PersistentPath -eq '') { + # i.e. Only a file name was provided implying $PWD $PersistentScriptFile = "$($PWD)\$($Leaf)" } else { - $PersistentScriptFile = "$($Path)\$($Leaf)" + $PersistentScriptFile = "$(Resolve-Path $PersistentPath)\$($Leaf)" } - $Path = Split-Path $RemovalScriptFilePath -ErrorAction Stop + $RemovalPath = Split-Path $RemovalScriptFilePath -ErrorAction Stop $Leaf = Split-Path $RemovalScriptFilePath -Leaf -ErrorAction Stop - if ($Path -eq '') + if ($RemovalPath -eq '') { + # i.e. Only a file name was provided implying $PWD $RemovalScriptFile = "$($PWD)\$($Leaf)" } else { - $RemovalScriptFile = "$($Path)\$($Leaf)" + $RemovalScriptFile = "$(Resolve-Path $RemovalPath)\$($Leaf)" } if ($PSBoundParameters['FilePath']) { - Get-ChildItem $FilePath -ErrorAction Stop - $Script = [IO.File]::ReadAllText((Resolve-Path $Path)) + $null = Get-ChildItem $FilePath -ErrorAction Stop + $Script = [IO.File]::ReadAllText((Resolve-Path $FilePath)) } else { |