Skip to content

Commit

Permalink
Updated to include psexec remote and to not re-import add-type
Browse files Browse the repository at this point in the history
  • Loading branch information
benpturner committed Jun 4, 2017
1 parent d749389 commit 3942a4a
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 95 deletions.
207 changes: 123 additions & 84 deletions Modules/Invoke-Pipekat.ps1

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions Modules/Invoke-PsExec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2232,11 +2232,13 @@ Function Get-MD4Hash {
END
{
Set-StrictMode -Version Latest
if (-not ([System.Management.Automation.PSTypeName]'dsafdsafdsafds').Type)
{
Add-Type -TypeDefinition @'
using System;
using System.Text;
using System.Runtime.InteropServices;
public class BCrypt
public class dsafdsafdsafds
{
[DllImport("bcrypt.dll", CharSet = CharSet.Auto)]
public static extern NTStatus BCryptOpenAlgorithmProvider(
Expand Down Expand Up @@ -2294,45 +2296,46 @@ Function Get-MD4Hash {
}
}
'@
}

[Byte[]]$HashBytes = New-Object Byte[] 16
[IntPtr]$PHAlgorithm = [IntPtr]::Zero
[IntPtr]$PHHash = [IntPtr]::Zero
$NTStatus = [BCrypt]::BCryptOpenAlgorithmProvider([Ref] $PHAlgorithm, 'MD4', $Null, 0)
$NTStatus = [dsafdsafdsafds]::BCryptOpenAlgorithmProvider([Ref] $PHAlgorithm, 'MD4', $Null, 0)
If ($NTStatus -NE 0)
{
Write-Error "BCryptOpenAlgorithmProvider failed with NTSTATUS $NTStatus"
If ($PHAlgorithm -NE [IntPtr]::Zero)
{
$NTStatus = [BCrypt]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
$NTStatus = [dsafdsafdsafds]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
}
Return
}
$NTStatus = [BCrypt]::BCryptCreateHash($PHAlgorithm, [Ref] $PHHash, [IntPtr]::Zero, 0, [IntPtr]::Zero, 0, 0)
$NTStatus = [dsafdsafdsafds]::BCryptCreateHash($PHAlgorithm, [Ref] $PHHash, [IntPtr]::Zero, 0, [IntPtr]::Zero, 0, 0)
If ($NTStatus -NE 0)
{
Write-Error "BCryptCreateHash failed with NTSTATUS $NTStatus"
If ($PHHash -NE [IntPtr]::Zero)
{
$NTStatus = [BCrypt]::BCryptDestroyHash($PHHash)
$NTStatus = [dsafdsafdsafds]::BCryptDestroyHash($PHHash)
}
If ($PHAlgorithm -NE [IntPtr]::Zero)
{
$NTStatus = [BCrypt]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
$NTStatus = [dsafdsafdsafds]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
}
Return
}

$NTStatus = [BCrypt]::BCryptHashData($PHHash, $DataToHash, $DataToHash.Length, 0)
$NTStatus = [BCrypt]::BCryptFinishHash($PHHash, $HashBytes, $HashBytes.Length, 0)
$NTStatus = [dsafdsafdsafds]::BCryptHashData($PHHash, $DataToHash, $DataToHash.Length, 0)
$NTStatus = [dsafdsafdsafds]::BCryptFinishHash($PHHash, $HashBytes, $HashBytes.Length, 0)

If ($PHHash -NE [IntPtr]::Zero)
{
$NTStatus = [BCrypt]::BCryptDestroyHash($PHHash)
$NTStatus = [dsafdsafdsafds]::BCryptDestroyHash($PHHash)
}
If ($PHAlgorithm -NE [IntPtr]::Zero)
{
$NTStatus = [BCrypt]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
$NTStatus = [dsafdsafdsafds]::BCryptCloseAlgorithmProvider($PHAlgorithm, 0)
}

$HashString = New-Object System.Text.StringBuilder
Expand Down
4 changes: 3 additions & 1 deletion Modules/Invoke-SMBExec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,6 @@ if($SMB_client.Connected)

}


Function Get-MD4Hash {
<#
.SYNOPSIS
Expand Down Expand Up @@ -2366,6 +2365,8 @@ Function Get-MD4Hash {
END
{
Set-StrictMode -Version Latest
if (-not ([System.Management.Automation.PSTypeName]'dsafdsafdsafds').Type)
{
Add-Type -TypeDefinition @'
using System;
using System.Text;
Expand Down Expand Up @@ -2428,6 +2429,7 @@ Function Get-MD4Hash {
}
}
'@
}

[Byte[]]$HashBytes = New-Object Byte[] 16
[IntPtr]$PHAlgorithm = [IntPtr]::Zero
Expand Down
3 changes: 3 additions & 0 deletions Modules/Invoke-WMIExec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,8 @@ Function Get-MD4Hash {
END
{
Set-StrictMode -Version Latest
if (-not ([System.Management.Automation.PSTypeName]'dsafdsafdsafds').Type)
{
Add-Type -TypeDefinition @'
using System;
using System.Text;
Expand Down Expand Up @@ -1612,6 +1614,7 @@ Function Get-MD4Hash {
}
}
'@
}

[Byte[]]$HashBytes = New-Object Byte[] 16
[IntPtr]$PHAlgorithm = [IntPtr]::Zero
Expand Down

0 comments on commit 3942a4a

Please sign in to comment.