mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-04 16:57:26 -08:00
Translated ['src/pentesting-cloud/azure-security/README.md', 'src/pentes
This commit is contained in:
@@ -66,12 +66,23 @@ $token = (az account get-access-token --resource https://graph.microsoft.com --q
|
||||
$secureToken = ConvertTo-SecureString $token -AsPlainText -Force
|
||||
Connect-MgGraph -AccessToken $secureToken
|
||||
|
||||
# Get token from session
|
||||
Parameters = @{
|
||||
Method = "GET"
|
||||
Uri = "/v1.0/me"
|
||||
OutputType = "HttpResponseMessage"
|
||||
}
|
||||
$Response = Invoke-MgGraphRequest @Parameters
|
||||
$Headers = $Response.RequestMessage.Headers
|
||||
$Headers.Authorization.Parameter
|
||||
|
||||
|
||||
# Find commands
|
||||
Find-MgGraphCommand -command *Mg*
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
Connect-AzAccount #Open browser
|
||||
# Using credentials
|
||||
@@ -80,15 +91,11 @@ $creds = New-Object System.Management.Automation.PSCredential("test@corp.onmicro
|
||||
Connect-AzAccount -Credential $creds
|
||||
|
||||
# Get Access Token
|
||||
(Get-AzAccessToken).Token
|
||||
# Request access token to other endpoints: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse
|
||||
(Get-AzAccessToken -ResourceTypeName MSGraph).Token
|
||||
(Get-AzAccessToken -Resource "https://graph.microsoft.com").Token
|
||||
(ConvertFrom-SecureString (Get-AzAccessToken -ResourceTypeName Arm -AsSecureString).Token -AsPlainText)
|
||||
|
||||
# Connect with access token
|
||||
Connect-AzAccount -AccountId test@corp.onmicrosoft.com -AccessToken $token
|
||||
Connect-AzAccount -AccessToken $token -GraphAccessToken $graphaccesstoken -AccountId <ACCOUNT-ID>
|
||||
## The -AccessToken is from management.azure.com
|
||||
Connect-AzAccount -AccountId test@corp.onmicrosoft.com [-AccessToken $ManagementToken] [-GraphAccessToken $AADGraphToken] [-MicrosoftGraphAccessToken $MicrosoftGraphToken] [-KeyVaultAccessToken $KeyVaultToken]
|
||||
|
||||
# Connect with Service principal/enterprise app secret
|
||||
$password = ConvertTo-SecureString 'KWEFNOIRFIPMWL.--DWPNVFI._EDWWEF_ADF~SODNFBWRBIF' -AsPlainText -Force
|
||||
@@ -149,7 +156,7 @@ Connect-AzureAD -AccountId test@corp.onmicrosoft.com -AadAccessToken $token
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
जब आप किसी प्रोग्राम के माध्यम से **CLI** के जरिए Azure में **लॉगिन** करते हैं, तो आप **Microsoft** के एक **tenant** से संबंधित **Azure Application** का उपयोग कर रहे हैं। ये Applications, जैसे कि आप अपने खाते में बना सकते हैं, **एक क्लाइंट आईडी** रखते हैं। आप **उनमें से सभी को नहीं देख पाएंगे** जो आप कंसोल में **अनुमत एप्लिकेशन सूचियों** में देख सकते हैं, **लेकिन ये डिफ़ॉल्ट रूप से अनुमत हैं**।
|
||||
जब आप किसी प्रोग्राम के माध्यम से **CLI** के जरिए Azure में **लॉगिन** करते हैं, तो आप **Microsoft** के एक **tenant** से संबंधित **Azure Application** का उपयोग कर रहे हैं। ये Applications, जैसे कि आप अपने खाते में बना सकते हैं, **एक क्लाइंट आईडी** रखते हैं। आप **उनमें से सभी को नहीं देख पाएंगे** जो आप कंसोल में **अनुमत एप्लिकेशन सूचियों** में देख सकते हैं, **लेकिन वे डिफ़ॉल्ट रूप से अनुमत हैं**।
|
||||
|
||||
उदाहरण के लिए, एक **powershell script** जो **प्रमाणित** करती है, एक ऐप का उपयोग करती है जिसकी क्लाइंट आईडी **`1950a258-227b-4e31-a9cf-717495945fc2`** है। भले ही ऐप कंसोल में दिखाई न दे, एक सिस्टम एडमिन उस एप्लिकेशन को **ब्लॉक कर सकता है** ताकि उपयोगकर्ता उस ऐप के माध्यम से कनेक्ट करने वाले उपकरणों का उपयोग न कर सकें।
|
||||
|
||||
@@ -279,7 +286,7 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Enumerate users
|
||||
Get-AzADUser
|
||||
@@ -302,7 +309,7 @@ $password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText
|
||||
```
|
||||
### MFA & Conditional Access Policies
|
||||
|
||||
हर उपयोगकर्ता के लिए MFA जोड़ना अत्यधिक अनुशंसित है, हालाँकि, कुछ कंपनियाँ इसे सेट नहीं करेंगी या इसे Conditional Access के साथ सेट कर सकती हैं: उपयोगकर्ता को **MFA की आवश्यकता होगी यदि** वह किसी विशेष स्थान, ब्राउज़र या **कुछ शर्त** से लॉग इन करता है। यदि ये नीतियाँ सही तरीके से कॉन्फ़िगर नहीं की गई हैं, तो ये **bypasses** के प्रति संवेदनशील हो सकती हैं। जाँच करें:
|
||||
हर उपयोगकर्ता के लिए MFA जोड़ना अत्यधिक अनुशंसित है, हालाँकि, कुछ कंपनियाँ इसे सेट नहीं करेंगी या इसे Conditional Access के साथ सेट कर सकती हैं: उपयोगकर्ता को **MFA की आवश्यकता होगी यदि** वह किसी विशेष स्थान, ब्राउज़र या **कुछ शर्त** से लॉग इन करता है। यदि इन नीतियों को सही तरीके से कॉन्फ़िगर नहीं किया गया तो ये **bypasses** के प्रति संवेदनशील हो सकती हैं। जाँच करें:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
@@ -346,6 +353,22 @@ az role assignment list --include-groups --include-classic-administrators true -
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get all groups
|
||||
Get-AzADGroup
|
||||
# Get details of a group
|
||||
Get-AzADGroup -ObjectId <id>
|
||||
# Search group by string
|
||||
Get-AzADGroup -SearchString "admin" | fl * #Search at the beginnig of DisplayName
|
||||
Get-AzADGroup |?{$_.Displayname -match "admin"}
|
||||
# Get members of group
|
||||
Get-AzADGroupMember -GroupDisplayName <resource_group_name>
|
||||
# Get roles of group
|
||||
Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# Enumerate Groups
|
||||
@@ -373,22 +396,6 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
Get-AzureADGroup -ObjectId <id> | Get-AzureADGroupAppRoleAssignment | fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
```bash
|
||||
# Get all groups
|
||||
Get-AzADGroup
|
||||
# Get details of a group
|
||||
Get-AzADGroup -ObjectId <id>
|
||||
# Search group by string
|
||||
Get-AzADGroup -SearchString "admin" | fl * #Search at the beginnig of DisplayName
|
||||
Get-AzADGroup |?{$_.Displayname -match "admin"}
|
||||
# Get members of group
|
||||
Get-AzADGroupMember -GroupDisplayName <resource_group_name>
|
||||
# Get roles of group
|
||||
Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### समूह में उपयोगकर्ता जोड़ें
|
||||
@@ -433,28 +440,7 @@ az ad sp list --query '[?length(keyCredentials) > `0` || length(passwordCredenti
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# Get Service Principals
|
||||
Get-AzureADServicePrincipal -All $true
|
||||
# Get details about a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | fl *
|
||||
# Get SP by string name or Id
|
||||
Get-AzureADServicePrincipal -All $true | ?{$_.DisplayName -match "app"} | fl
|
||||
Get-AzureADServicePrincipal -All $true | ?{$_.AppId -match "103947652-1234-5834-103846517389"}
|
||||
# Get owner of SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwner |fl *
|
||||
# Get objects owned by a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwnedObject
|
||||
# Get objects created by a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalCreatedObject
|
||||
# Get groups where the SP is a member
|
||||
Get-AzureADServicePrincipal | Get-AzureADServicePrincipalMembership
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembership |fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get SPs
|
||||
Get-AzADServicePrincipal
|
||||
@@ -481,6 +467,27 @@ Headers = @{
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# Get Service Principals
|
||||
Get-AzureADServicePrincipal -All $true
|
||||
# Get details about a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | fl *
|
||||
# Get SP by string name or Id
|
||||
Get-AzureADServicePrincipal -All $true | ?{$_.DisplayName -match "app"} | fl
|
||||
Get-AzureADServicePrincipal -All $true | ?{$_.AppId -match "103947652-1234-5834-103846517389"}
|
||||
# Get owner of SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwner |fl *
|
||||
# Get objects owned by a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwnedObject
|
||||
# Get objects created by a SP
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalCreatedObject
|
||||
# Get groups where the SP is a member
|
||||
Get-AzureADServicePrincipal | Get-AzureADServicePrincipalMembership
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembership |fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
@@ -625,6 +632,19 @@ az ad app list --query '[?length(keyCredentials) > `0` || length(passwordCredent
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get Apps
|
||||
Get-AzADApplication
|
||||
# Get details of one App
|
||||
Get-AzADApplication -ObjectId <id>
|
||||
# Get App searching by string
|
||||
Get-AzADApplication | ?{$_.DisplayName -match "app"}
|
||||
# Get Apps with password
|
||||
Get-AzADAppCredential
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# List all registered applications
|
||||
@@ -637,23 +657,10 @@ Get-AzureADApplication -All $true | %{if(Get-AzureADApplicationPasswordCredentia
|
||||
Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
```bash
|
||||
# Get Apps
|
||||
Get-AzADApplication
|
||||
# Get details of one App
|
||||
Get-AzADApplication -ObjectId <id>
|
||||
# Get App searching by string
|
||||
Get-AzADApplication | ?{$_.DisplayName -match "app"}
|
||||
# Get Apps with password
|
||||
Get-AzADAppCredential
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
> एक ऐप जिसमें अनुमति **`AppRoleAssignment.ReadWrite`** है, **Global Admin** के रूप में **escalate** कर सकता है।\
|
||||
> एक ऐप जिसमें अनुमति **`AppRoleAssignment.ReadWrite`** है, **Global Admin** के रूप में **उच्चीकृत** हो सकता है।\
|
||||
> अधिक जानकारी के लिए [**यहाँ देखें**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48).
|
||||
|
||||
> [!NOTE]
|
||||
@@ -661,9 +668,9 @@ Get-AzADAppCredential
|
||||
> इसलिए, यदि आप इस **पासवर्ड** को ढूंढ लेते हैं, तो आप **service principal** के रूप में **tenant** के **अंदर** पहुँच सकते हैं।\
|
||||
> ध्यान दें कि यह पासवर्ड केवल उत्पन्न होने पर ही दिखाई देता है (आप इसे बदल सकते हैं लेकिन फिर से प्राप्त नहीं कर सकते)।\
|
||||
> **एप्लिकेशन** का **स्वामी** इसे **पासवर्ड** जोड़ सकता है (ताकि वह इसकी नकल कर सके)।\
|
||||
> इन सेवा प्रमुखों के रूप में लॉगिन **जोखिमपूर्ण** के रूप में **चिह्नित** नहीं होते हैं और इनमें **MFA** नहीं होगा।
|
||||
> इन service principals के रूप में लॉगिन **जोखिमपूर्ण** के रूप में **चिह्नित** नहीं होते हैं और इनमें **MFA** नहीं होगा।
|
||||
|
||||
यह संभव है कि Microsoft के सामान्य उपयोग किए जाने वाले ऐप IDs की सूची [https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications) पर मिले।
|
||||
Microsoft के सामान्य उपयोग किए जाने वाले App IDs की सूची [https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications) पर पाई जा सकती है।
|
||||
|
||||
### Managed Identities
|
||||
|
||||
@@ -716,7 +723,7 @@ az role assignment list --all --query "[?principalName=='carlos@carloshacktricks
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get role assignments on the subscription
|
||||
Get-AzRoleDefinition
|
||||
@@ -851,7 +858,7 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
|
||||
> [!WARNING]
|
||||
> यदि एक डिवाइस (VM) **AzureAD से जुड़ा** है, तो AzureAD के उपयोगकर्ता **लॉगिन करने में सक्षम** होंगे।\
|
||||
> इसके अलावा, यदि लॉगिन किया हुआ उपयोगकर्ता डिवाइस का **स्वामी** है, तो वह **स्थानीय व्यवस्थापक** होगा।
|
||||
> इसके अलावा, यदि लॉगिन करने वाला उपयोगकर्ता डिवाइस का **स्वामी** है, तो वह **स्थानीय व्यवस्थापक** होगा।
|
||||
|
||||
### प्रशासनिक इकाइयाँ
|
||||
|
||||
@@ -908,10 +915,10 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
|
||||
|
||||
Azure में विशेषाधिकार पहचान प्रबंधन (PIM) **अधिकतम विशेषाधिकार** को उपयोगकर्ताओं को अनावश्यक रूप से सौंपने से **रोकने** में मदद करता है।
|
||||
|
||||
PIM द्वारा प्रदान की जाने वाली मुख्य विशेषताओं में से एक यह है कि यह लगातार सक्रिय प्रिंसिपलों को भूमिकाएँ सौंपने की अनुमति नहीं देता, बल्कि उन्हें **एक निश्चित समय (जैसे 6 महीने)** के लिए **योग्य** बनाता है। फिर, जब भी उपयोगकर्ता उस भूमिका को सक्रिय करना चाहता है, तो उसे यह बताना होगा कि उसे विशेषाधिकार की आवश्यकता कितने समय के लिए है (जैसे 3 घंटे)। फिर एक **व्यवस्थापक को** अनुरोध को मंजूरी देने की आवश्यकता होती है।\
|
||||
PIM द्वारा प्रदान की जाने वाली मुख्य विशेषताओं में से एक यह है कि यह लगातार सक्रिय प्रिंसिपलों को भूमिकाएँ सौंपने की अनुमति नहीं देता, बल्कि उन्हें **एक निश्चित समय (जैसे 6 महीने)** के लिए **योग्य** बनाता है। फिर, जब भी उपयोगकर्ता उस भूमिका को सक्रिय करना चाहता है, तो उसे उस समय को इंगित करते हुए इसके लिए अनुरोध करना होगा जिसकी उसे आवश्यकता है (जैसे 3 घंटे)। फिर एक **व्यवस्थापक को** अनुरोध को मंजूरी देने की आवश्यकता होती है।\
|
||||
ध्यान दें कि उपयोगकर्ता **समय बढ़ाने** के लिए भी अनुरोध कर सकेगा।
|
||||
|
||||
इसके अलावा, **PIM ईमेल भेजता है** जब किसी को विशेषाधिकार वाली भूमिका सौंपा जाता है।
|
||||
इसके अलावा, **PIM ईमेल भेजता है** जब किसी को विशेषाधिकार वाली भूमिका सौंपा जा रहा हो।
|
||||
|
||||
<figure><img src="../../../images/image (354).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
@@ -919,10 +926,10 @@ PIM द्वारा प्रदान की जाने वाली म
|
||||
|
||||
- सक्रियण की अधिकतम अवधि (घंटे)
|
||||
- सक्रियण पर MFA की आवश्यकता
|
||||
- शर्तीय पहुँच प्रमाणीकरण संदर्भ की आवश्यकता
|
||||
- सक्रियण संदर्भ के लिए शर्तीय पहुँच प्रमाणीकरण की आवश्यकता
|
||||
- सक्रियण पर औचित्य की आवश्यकता
|
||||
- सक्रियण पर टिकट जानकारी की आवश्यकता
|
||||
- सक्रिय करने के लिए अनुमोदन की आवश्यकता
|
||||
- सक्रियण के लिए अनुमोदन की आवश्यकता
|
||||
- योग्य असाइनमेंट की समाप्ति के लिए अधिकतम समय
|
||||
- जब उस भूमिका के साथ कुछ क्रियाएँ होती हैं, तो सूचनाएँ भेजने के लिए और भी बहुत सी कॉन्फ़िगरेशन
|
||||
|
||||
@@ -936,7 +943,7 @@ PIM द्वारा प्रदान की जाने वाली म
|
||||
|
||||
### Entra पहचान सुरक्षा <a href="#title-text" id="title-text"></a>
|
||||
|
||||
Entra पहचान सुरक्षा एक सुरक्षा सेवा है जो **यह पहचानने** की अनुमति देती है कि जब कोई उपयोगकर्ता या साइन-इन बहुत जोखिम भरा होता है, तो उसे स्वीकार नहीं किया जा सकता, जिससे उपयोगकर्ता या साइन-इन प्रयास को **ब्लॉक** किया जा सकता है।
|
||||
Entra पहचान सुरक्षा एक सुरक्षा सेवा है जो **यह पहचानने** की अनुमति देती है कि जब कोई उपयोगकर्ता या साइन-इन बहुत जोखिम भरा होता है तो उसे स्वीकार नहीं किया जा सकता, जिससे उपयोगकर्ता या साइन-इन प्रयास को **ब्लॉक** किया जा सकता है।
|
||||
|
||||
यह व्यवस्थापक को इसे इस तरह कॉन्फ़िगर करने की अनुमति देता है कि जब जोखिम "कम और ऊपर", "मध्यम और ऊपर" या "उच्च" हो, तो प्रयासों को **ब्लॉक** किया जाए। हालाँकि, डिफ़ॉल्ट रूप से यह पूरी तरह से **निष्क्रिय** है:
|
||||
|
||||
@@ -947,7 +954,7 @@ Entra पहचान सुरक्षा एक सुरक्षा से
|
||||
|
||||
### Entra पासवर्ड सुरक्षा
|
||||
|
||||
Entra पासवर्ड सुरक्षा ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) एक सुरक्षा विशेषता है जो **कमजोर पासवर्ड के दुरुपयोग को रोकने में मदद करती है** जब कई असफल लॉगिन प्रयास होते हैं, तो खातों को लॉक करके।\
|
||||
Entra पासवर्ड सुरक्षा ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) एक सुरक्षा विशेषता है जो **कमजोर पासवर्ड के दुरुपयोग को रोकने में मदद करती है जब कई असफल लॉगिन प्रयास होते हैं**।\
|
||||
यह आपको एक कस्टम पासवर्ड सूची **बैन** करने की अनुमति भी देती है जिसे आपको प्रदान करना होगा।
|
||||
|
||||
यह **क्लाउड स्तर** और ऑन-प्रिमाइसेस सक्रिय निर्देशिका दोनों पर **लागू** किया जा सकता है।
|
||||
|
||||
Reference in New Issue
Block a user