-
Notifications
You must be signed in to change notification settings - Fork 24
/
Invoke-HoneyCreds.ps1
44 lines (34 loc) · 1.44 KB
/
Invoke-HoneyCreds.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
function Invoke-HoneyCreds {
[CmdletBinding()]
Param()
# Add Member Defition for LogonUser
$api = Add-Type -Name Ignore -MemberDefinition @"
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
"@ -passthru
# Get Credentals. Use DOMAIN\User for username
$creds = Get-Credential
$user = $($creds.GetNetworkCredential().UserName)
$password = $($creds.GetNetworkCredential().Password)
$domain = $($creds.GetNetworkCredential().Domain)
$plain = "$($user):$($password)"
# Impersonate the new user
[IntPtr]$token = [Security.Principal.WindowsIdentity]::GetCurrent().Token
$api::LogonUser($user, $domain, $password, 9, 0, [ref]$token) | Out-Null
$identity = New-Object Security.Principal.WindowsIdentity $token
$context = $Identity.Impersonate()
while($True) {
try {
Write-Verbose "Mapping Drive"
New-PSDrive -name X -PSProvider FileSystem -root \\$($domain)\C$ -Credential $creds -ErrorAction Ignore -ErrorVariable $err
Write-Verbose "Requesting http://$($domain).local with Basic Auth"
$headers = @{
Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($plain))
}
Invoke-WebRequest "http://$($domain).local" -Headers $headers
}
catch {
}
Start-Sleep -s 5
}
}