Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit bd6fe64

Browse files
Cast DllCharacteristics to [Int]
Fix for System.InvalidCastException: #152
1 parent 445f7b2 commit bd6fe64

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Exfiltration/Invoke-NinjaCopy.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ $RemoteScriptBlock = {
22052205
$PEInfo = Get-PEBasicInfo -PEBytes $PEBytes -Win32Types $Win32Types
22062206
$OriginalImageBase = $PEInfo.OriginalImageBase
22072207
$NXCompatible = $true
2208-
if (($PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_NX_COMPAT) -ne $Win32Constants.IMAGE_DLLCHARACTERISTICS_NX_COMPAT)
2208+
if (([Int] $PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_NX_COMPAT) -ne $Win32Constants.IMAGE_DLLCHARACTERISTICS_NX_COMPAT)
22092209
{
22102210
Write-Warning "PE is not compatible with DEP, might cause issues" -WarningAction Continue
22112211
$NXCompatible = $false
@@ -2263,7 +2263,7 @@ $RemoteScriptBlock = {
22632263
Write-Verbose "Allocating memory for the PE and write its headers to memory"
22642264

22652265
[IntPtr]$LoadAddr = [IntPtr]::Zero
2266-
if (($PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) -ne $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE)
2266+
if (([Int] $PEInfo.DllCharacteristics -band $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) -ne $Win32Constants.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE)
22672267
{
22682268
Write-Warning "PE file being reflectively loaded is not ASLR compatible. If the loading fails, try restarting PowerShell and trying again" -WarningAction Continue
22692269
[IntPtr]$LoadAddr = $OriginalImageBase

0 commit comments

Comments
 (0)