Powershell-PostExploitation
Powershell-PostExploitation copied to clipboard
Not work on MSSQL 2012
I got this error for master.mdf from SQL Server 2012
New-Object : Cannot find type [OrcaMDF.RawCore.RawDataFile]: make sure the assembly containing this type is loaded.
At C:\Users\Admin\Desktop\Powershell-PostExploitation-master\Invoke-MDFHashes\Get-MDFHashes.ps1:18 char:27
+ $instance = New-Object <<<< "OrcaMDF.RawCore.RawDataFile" $mdf
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Unable to find type [OrcaMDF.RawCore.Types.RawType]: make sure that the assembly containing this type is loaded.
At C:\Users\Admin\Desktop\Powershell-PostExploitation-master\Invoke-MDFHashes\Get-MDFHashes.ps1:22 char:48
+ $model = @( [OrcaMDF.RawCore.Types.RawType] <<<< ::Int("id"),
+ CategoryInfo : InvalidOperation: (OrcaMDF.RawCore.Types.RawType:String) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
ANY UPDATE ON THIS?
Problem seems to be in grabbing the path information when loading the libraries
Changing:
[Reflection.Assembly]::LoadFile($currentLocation.Path + "\\OrcaMDF.RawCore.dll") | Out-Null [Reflection.Assembly]::LoadFile($currentLocation.Path + "\\OrcaMDF.Framework.dll") | Out-NUll
To:
[Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.RawCore.dll") | Out-Null [Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.Framework.dll") | Out-NUll
Worked for me
If that does not work replace:
[Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.RawCore.dll")
[Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.Framework.dll")
To:
Add-Type -AssemblyName .\OrcaMDF.RawCore.dll
Add-Type -AssemblyName .\OrcaMDF.Framework.dll
If that does not work replace:
[Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.RawCore.dll")
[Reflection.Assembly]::LoadFile($PSScriptRoot + "\\OrcaMDF.Framework.dll")
To:Add-Type -AssemblyName .\OrcaMDF.RawCore.dll
Add-Type -AssemblyName .\OrcaMDF.Framework.dll
I have tested both the solutions suggested by humurabbi & LMS57. humurabbi's solution works when using powershell in linux while LMS57's solution works only in windows's powershell.
For those still having issues
[System.Reflection.Assembly]::UnsafeLoadFrom($PSScriptRoot + "\OrcaMDF.RawCore.dll") | Out-Null [System.Reflection.Assembly]::UnsafeLoadFrom($PSScriptRoot + "\OrcaMDF.Framework.dll") | Out-NUll
If you're still having issues after editing the script, make sure that you have unblocked the dlls (right click -> properties).
And if you're still having issues with all of the above (which I was) try the following (worked for me):
[System.Reflection.Assembly]::UnsafeLoadFrom("C:\\Users\\admin\\Desktop\\MDF\\OrcaMDF.RawCore.dll") | Out-Null [System.Reflection.Assembly]::UnsafeLoadFrom("C:\\Users\\admin\\Desktop\\MDF\\OrcaMDF.Framework.dll") | Out-Null