Invoke-TheHash – PowerShell Pass The Hash Utils

Invoke-TheHash contains PowerShell functions for performing NTLMv2 pass the hash WMI and SMB command execution. WMI and SMB services are accessed through .NET TCPClient connections. Local administrator privilege is not required client-side.


Requirements
Minimum PowerShell 2.0

Import
Import-Module ./Invoke-TheHash.psd1
or
. ./Invoke-WMIExec.ps1
. ./Invoke-SMBExec.ps1
. ./Invoke-TheHash.ps1

Functions

  • Invoke-WMIExec
  • Invoke-SMBExec
  • Invoke-TheHash
  • ConvertTo-TargetList

Invoke-WMIExec

  • WMI command execution function.

Parameters:

  • Target – Hostname or IP address of target.
  • Username – Username to use for authentication.
  • Domain – Domain to use for authentication. This parameter is not needed with local accounts or when using @domain after the username.
  • Hash – NTLM password hash for authentication. This module will accept either LM:NTLM or NTLM format.
  • Command – Command to execute on the target. If a command is not specified, the function will just check to see if the username and hash has access to WMI on the target.
  • Sleep – Default = 10 Milliseconds: Sets the function’s Start-Sleep values in milliseconds.

Example:
Invoke-WMIExec -Target 192.168.100.20 -Domain TESTDOMAIN -Username TEST -Hash F6F38B793DB6A94BA04A52F1D3EE92F0 -Command “command or launcher to execute” -verbose

Screenshot:

Invoke-SMBExec

  • SMB (PsExec) command execution function supporting SMB1, SMB2, and SMB signing.

Parameters:

  • Target – Hostname or IP address of target.
  • Username – Username to use for authentication.
  • Domain – Domain to use for authentication. This parameter is not needed with local accounts or when using @domain after the username.
  • Hash – NTLM password hash for authentication. This module will accept either LM:NTLM or NTLM format.
  • Command – Command to execute on the target. If a command is not specified, the function will just check to see if the username and hash has access to SCM on the target.
  • CommandCOMSPEC – Default = Enabled: Prepend %COMSPEC% /C to Command.
  • Service – Default = 20 Character Random: Name of the service to create and delete on the target.
  • SMB1 – (Switch) Force SMB1. The default behavior is to perform SMB version negotiation and use SMB2 if supported by the target.
  • Sleep – Default = 150 Milliseconds: Sets the function’s Start-Sleep values in milliseconds.

Example:
Invoke-SMBExec -Target 192.168.100.20 -Domain TESTDOMAIN -Username TEST -Hash F6F38B793DB6A94BA04A52F1D3EE92F0 -Command “command or launcher to execute” -verbose

Screenshot:

Invoke-TheHash

  • Function for running Invoke-WMIExec and Invoke-SMBExec against multiple targets.

Parameters:

  • Type – Sets the desired Invoke-TheHash function. Set to either WMIExec or SMBExec.
  • Targets – List of hostnames, IP addresses, or CIDR notation for targets.
  • TargetsExclude – List of hostnames and/or IP addresses to exclude form the list or targets.
  • PortCheckDisable – (Switch) Disable WMI or SMB port check. Since this function is not yet threaded, the port check serves to speed up he function by checking for an open WMI or SMB port before attempting a full synchronous TCPClient connection.
  • PortCheckTimeout – Default = 100: Set the no response timeout in milliseconds for the WMI or SMB port check.
  • Username – Username to use for authentication.
  • Domain – Domain to use for authentication. This parameter is not needed with local accounts or when using @domain after the username.
  • Hash – NTLM password hash for authentication. This module will accept either LM:NTLM or NTLM format.
  • Command – Command to execute on the target. If a command is not specified, the function will just check to see if the username and hash has access to WMI or SCM on the target.
  • CommandCOMSPEC – Default = Enabled: SMBExec type only. Prepend %COMSPEC% /C to Command.
  • Service – Default = 20 Character Random: SMBExec type only. Name of the service to create and delete on the target.
  • SMB1 – (Switch) Force SMB1. SMBExec type only. The default behavior is to perform SMB version negotiation and use SMB2 if supported by the target.
  • Sleep – Default = WMI 10 Milliseconds, SMB 150 Milliseconds: Sets the function’s Start-Sleep values in milliseconds.

Example:
Invoke-TheHash -Type WMIExec -Targets 192.168.100.0/24 -TargetsExclude 192.168.100.50 -Username Administrator -Hash F6F38B793DB6A94BA04A52F1D3EE92F0

Screenshot:

ConvertTo-TargetList

  • Converts Invoke-TheHash output to an array that contains only targets discovered to have Invoke-WMIExec or Invoke-SMBExec access. The output from this function can be fed back into the Targets parameter of Invoke-TheHash.

Be the first to comment on "Invoke-TheHash – PowerShell Pass The Hash Utils"

Leave a comment

Your email address will not be published.


*