Skip to content

Commit 38ce0c7

Browse files
committed
more azure stuff
1 parent b5fc2d2 commit 38ce0c7

File tree

7 files changed

+152
-84
lines changed

7 files changed

+152
-84
lines changed

src/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@
398398
- [Az - Enumeration Tools](pentesting-cloud/azure-security/az-enumeration-tools.md)
399399
- [Az - Unauthenticated Enum & Initial Entry](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md)
400400
- [Az - OAuth Apps Phishing](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-oauth-apps-phishing.md)
401-
- [Az - VMs Unath](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-vms-unath.md)
401+
- [Az - Storage Unath](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-storage-unauth.md)
402+
- [Az - VMs Unath](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-vms-unauth.md)
402403
- [Az - Device Code Authentication Phishing](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-device-code-authentication-phishing.md)
403404
- [Az - Password Spraying](pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/az-password-spraying.md)
404405
- [Az - Services](pentesting-cloud/azure-security/az-services/README.md)

src/pentesting-cloud/azure-security/README.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## Basic Information
66

7+
Learn the basics of Azure and Entra ID in the following page:
8+
79
{{#ref}}
810
az-basic-information/
911
{{#endref}}
@@ -12,11 +14,16 @@ az-basic-information/
1214

1315
In order to audit an AZURE environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal Azure services and **external services** connected.
1416

15-
From a Red Team point of view, the **first step to compromise an Azure environment** is to manage to obtain some **credentials** for Azure AD. Here you have some ideas on how to do that:
17+
From a Red Team point of view, the **first step to compromise an Azure environment** is to manage to obtain some **foothold**.
18+
19+
### Initial Access
20+
21+
Here you can find the most common ways to get initial access to an Azure/Entra ID environment:
1622

17-
- **Leaks** in github (or similar) - OSINT
23+
- **OSINT**: Check for **leaks** in Github or any other open source platform that could contain **credentials** or interesting information.
24+
-
1825
- **Social** Engineering
19-
- **Password** reuse (password leaks)
26+
- **Password** reuse, leaks or [password spraying](az-unauthenticated-enum-and-initial-entry/az-password-spraying.md)
2027
- Vulnerabilities in Azure-Hosted Applications
2128
- [**Server Side Request Forgery**](https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html) with access to metadata endpoint
2229
- **Local File Read**
@@ -31,7 +38,6 @@ From a Red Team point of view, the **first step to compromise an Azure environme
3138
- **Internal** Employee
3239
- [**Common Phishing**](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/phishing-methodology/index.html) (credentials or Oauth App)
3340
- [Device Code Authentication Phishing](az-unauthenticated-enum-and-initial-entry/az-device-code-authentication-phishing.md)
34-
- [Azure **Password Spraying**](az-unauthenticated-enum-and-initial-entry/az-password-spraying.md)
3541

3642
Even if you **haven't compromised any user** inside the Azure tenant you are attacking, you can **gather some information** from it:
3743

@@ -49,10 +55,21 @@ az-unauthenticated-enum-and-initial-entry/
4955
5056
### SSRF
5157

52-
If you found a SSRF in a machine inside Azure check this page for tricks:
58+
If you found a SSRF in a server inside Azure check this page for tricks:
59+
60+
{{#ref}}
61+
https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html#azure{{#endref}}
62+
63+
### Subdomain Takeover
64+
65+
- [https://godiego.co/posts/STO-Azure/](https://godiego.co/posts/STO-Azure/)
66+
67+
### Azure & Entra ID tooling
68+
69+
The following tools will be super useful to enumerate both Entra ID tenants and Azure environments slowly (to avoid detection) or automatically (to save time):
5370

5471
{{#ref}}
55-
https://book.hacktricks.wiki/en/generic-methodologies-and-resources/phishing-methodology/index.html
72+
az-enumeration-tools.md
5673
{{#endref}}
5774

5875
### Bypass Login Conditions
@@ -68,9 +85,7 @@ In cases where you have some valid credentials but you cannot login, these are s
6885

6986
After bypassing it, you might be able to get back to your initial setup and you will still have access.
7087

71-
### Subdomain Takeover
7288

73-
- [https://godiego.co/posts/STO-Azure/](https://godiego.co/posts/STO-Azure/)
7489

7590
### Whoami
7691

@@ -132,7 +147,7 @@ Get-AzRoleAssignment -SignInName [email protected] # For current user
132147
133148
### Entra ID Enumeration
134149

135-
By default, any user should have **enough permissions to enumerate** things such us, users, groups, roles, service principals... (check [default AzureAD permissions](az-basic-information/index.html#default-user-permissions)).\
150+
By default, any user should have **enough permissions to enumerate** things such as users, groups, roles, service principals... (check [default AzureAD permissions](az-basic-information/index.html#default-user-permissions)).\
136151
You can find here a guide:
137152

138153
{{#ref}}
@@ -143,17 +158,7 @@ az-services/az-azuread.md
143158
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
144159
> In the following section you can check some ways to **enumerate some common services.**
145160
146-
## App Service SCM
147-
148-
Kudu console to log in to the App Service 'container'.
149-
150-
## Webshell
151-
152-
Use portal.azure.com and select the shell, or use shell.azure.com, for a bash or powershell. The 'disk' of this shell are stored as an image file in a storage-account.
153-
154-
## Azure DevOps
155-
156-
Azure DevOps is separate from Azure. It has repositories, pipelines (yaml or release), boards, wiki, and more. Variable Groups are used to store variable values and secrets.
161+
###
157162

158163
{{#include ../../banners/hacktricks-training.md}}
159164

src/pentesting-cloud/azure-security/az-basic-information/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
All the **resources** must be **inside a resource group** and can belong only to a group and if a resource group is deleted, all the resources inside it are also deleted.
3434

35-
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUfe8U30iP_vdZCvxX4g8nEPRLoo7v0kmCGkDn1frBPn3_GIoZ7VT2LkdsVQWCnrG_HSYNRRPM-1pSECUkbDAB-9YbUYLzpvKVLDETZS81CHWKYM4fDl3oMo5-yvTMnjdLTS2pz8U67xUTIzBhZ25MFMRkq5koKY=s2048?key=gSyKQr3HTyhvHa28Rf7LVA" alt=""><figcaption><p><a href="https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1">https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1</a></p></figcaption></figure>
35+
<figure><img src="https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1" alt=""><figcaption><p><a href="https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1">https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1</a></p></figcaption></figure>
3636

3737
### Azure Resource IDs
3838

src/pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@
77
### Tenant Enumeration
88

99
There are some **public Azure APIs** that just knowing the **domain of the tenant** an attacker could query to gather more info about it.\
10-
You can query directly the API or use the PowerShell library [**AADInternals**](https://github.com/Gerenios/AADInternals)**:**
10+
You can query directly the API or use the PowerShell library [**AADInternals**](https://github.com/Gerenios/AADInternals) (`Install-Module AADInternals`):
1111

12-
| API | Information | AADInternals function |
13-
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
14-
| login.microsoftonline.com/\<domain>/.well-known/openid-configuration | **Login information**, including tenant ID | `Get-AADIntTenantID -Domain <domain>` |
15-
| autodiscover-s.outlook.com/autodiscover/autodiscover.svc | **All domains** of the tenant | `Get-AADIntTenantDomains -Domain <domain>` |
16-
| login.microsoftonline.com/GetUserRealm.srf?login=\<UserName> | <p><strong>Login information</strong> of the tenant, including tenant Name and domain <strong>authentication type.</strong><br>If <code>NameSpaceType</code> is <strong><code>Managed</code></strong>, it means <strong>AzureAD</strong> is used.</p> | `Get-AADIntLoginInformation -UserName <UserName>` |
17-
| login.microsoftonline.com/common/GetCredentialType | Login information, including **Desktop SSO information** | `Get-AADIntLoginInformation -UserName <UserName>` |
12+
- **Login information including tenant ID**
13+
- `Get-AADIntTenantID -Domain <domain>` (main API `login.microsoftonline.com/<domain>/.well-known/openid-configuration`)
14+
- **All valid doimains in the tenant**
15+
- `Get-AADIntTenantDomains -Domain <domain>` (main API `autodiscover-s.outlook.com/autodiscover/autodiscover.svc`)
16+
- **Login information of the user**. If `NameSpaceType` is `Managed`, it means EntraID is used
17+
- `Get-AADIntLoginInformation -UserName <UserName>` (main API `login.microsoftonline.com/GetUserRealm.srf?login=<UserName>`)
1818

19-
You can query all the information of an Azure tenant with **just one command of the** [**AADInternals**](https://github.com/Gerenios/AADInternals) **library**:
19+
You can query all the information of an Azure tenant with **just one command from** [**AADInternals**](https://github.com/Gerenios/AADInternals):
2020

2121
```bash
22+
# Doesn't work in macos because 'Resolve-DnsName' doesn't exist
2223
Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table
23-
```
2424

25-
Output Example of the Azure tenant info:
25+
## Output Example of the Azure tenant info:
2626

27-
```
2827
Tenant brand: Company Ltd
2928
Tenant name: company
3029
Tenant id: 1937e3ab-38de-a735-a830-3075ea7e5b39
@@ -44,6 +43,9 @@ Moreover, the output presents the names of all verified domains associated with
4443

4544
### User Enumeration
4645

46+
> [!TIP]
47+
> Note that even if a tenant is using several emails for the same user, the **username is unique**. This means that it'll noly work with the domain the user has associated and not with the other domains.
48+
4749
It's possible to **check if a username exists** inside a tenant. This includes also **guest users**, whose username is in the format:
4850

4951
```
@@ -83,26 +85,34 @@ external.user_outlook.com#EXT#@company.onmicrosoft.com
8385
Get-Content .\users.txt | Invoke-AADIntUserEnumerationAsOutsider -Method Normal
8486
```
8587

86-
There are **three different enumeration methods** to choose from:
88+
Currenlty there are **4 different enumeration methods** to choose from. You can find information in `Get-Help Invoke-AADIntUserEnumerationAsOutsider`:
89+
90+
It supports following enumeration methods: Normal, Login, Autologon, and RST2.
91+
92+
- The **Normal** method seems currently work with all tenants. Previously it required Desktop SSO (aka Seamless SSO) to be enabled for at least one domain.
93+
94+
- The **Login** method works with any tenant, but enumeration queries will be logged to Azure AD sign-in log as failed login events!
95+
96+
- The **Autologon** method doesn't seem to work with all tenants anymore. Probably requires that DesktopSSO or directory sync is enabled.
8797

88-
| Method | Description |
89-
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
90-
| Normal | This refers to the GetCredentialType API mentioned above. The default method. |
91-
| Login | <p>This method tries to log in as the user.<br><strong>Note:</strong> queries will be logged to sign-ins log.</p> |
92-
| Autologon | <p>This method tries to log in as the user via autologon endpoint.<br><strong>Queries are not logged</strong> to sign-ins log! As such, works well also for password spray and brute-force attacks.</p> |
9398

9499
After discovering the valid usernames you can get **info about a user** with:
95100

96101
```bash
97102
Get-AADIntLoginInformation -UserName [email protected]
98103
```
99104

100-
The script [**o365creeper**](https://github.com/LMGsec/o365creeper) also allows you to discover **if an email is valid**.
105+
The script [**o365spray**](https://github.com/0xZDH/o365spray) also allows you to discover **if an email is valid**.
101106

102107
```bash
103-
# Put in emails.txt emails such as:
104-
105-
python.exe .\o365creeper\o365creeper.py -f .\emails.txt -o validemails.txt
108+
git clone https://github.com/0xZDH/o365spray
109+
cd o365spray
110+
python3 -m pip install -r requirements.txt
111+
112+
# Check 1 email
113+
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -u carlos
114+
# Check a list of emails
115+
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -U /tmp/users.txt
106116
```
107117

108118
**User Enumeration via Microsoft Teams**
@@ -113,10 +123,16 @@ The API of Microsoft Teams allows to search for users. In particular the "user s
113123

114124
Depending on the API response it is possible to distinguish between non-existing users and existing users that have a valid Teams subscription.
115125

116-
The script [**TeamsEnum**](https://github.com/sse-secure-systems/TeamsEnum) could be used to validate a given set of usernames against the Teams API.
126+
The script [**TeamsEnum**](https://github.com/sse-secure-systems/TeamsEnum) could be used to validate a given set of usernames against the Teams API but you need access to a user with Teams access to use it.
117127

118128
```bash
119-
python3 TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json
129+
# Install
130+
git clone https://github.com/sse-secure-systems/TeamsEnum
131+
cd TeamsEnum
132+
python3 -m pip install -r requirements.txt
133+
134+
# Login and ask for password
135+
python3 ./TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json
120136
```
121137

122138
Output:
@@ -192,58 +208,54 @@ Output:
192208
}
193209
```
194210

195-
## Azure Services
211+
### Password Spraying / Brute-Force
196212

197-
Know that we know the **domains the Azure tenant** is using is time to try to find **Azure services exposed**.
213+
{{#ref}}
214+
az-password-spraying.md
215+
{{#endref}}
198216

199-
You can use a method from [**MicroBust**](https://github.com/NetSPI/MicroBurst) for such goal. This function will search the base domain name (and a few permutations) in several **azure service domains:**
217+
## Azure Services using domains
218+
219+
It's also possible to try to find **Azure services exposed** in common azure subdomains like the ones documented in this [post:
220+
](https://www.netspi.com/blog/technical-blog/cloud-penetration-testing/enumerating-azure-services/)
221+
222+
- App Services: `azurewebsites.net`
223+
- App Services – Management: `scm.azurewebsites.net`
224+
- App Services: `p.azurewebsites.net`
225+
- App Services: `cloudapp.net`
226+
- Storage Accounts-Files: `file.core.windows.net`
227+
- Storage Accounts-Blobs: `blob.core.windows.net`
228+
- Storage Accounts-Queues: `queue.core.windows.net`
229+
- Storage Accounts-Tables: `table.core.windows.net`
230+
- Databases-Redis: `redis.cache.windows.net`
231+
- Databases-Cosmos DB: `documents.azure.com`
232+
- Databases-MSSQL: `database.windows.net`
233+
- Key Vaults: `vault.azure.net`
234+
- Microsoft Hosted Domain: `onmicrosoft.com`
235+
- Email: `mail.protection.outlook.com`
236+
- SharePoint: `sharepoint.com`
237+
- CDN: `azureedge.net`
238+
- Search Appliance: `search.windows.net`
239+
- API Services: `azure-api.net`
240+
241+
You can use a method from [**MicroBust**](https://github.com/NetSPI/MicroBurst) for such goal. This function will search the base domain name (and a few permutations) in several **azure domains:**
200242

201243
```bash
202244
Import-Module .\MicroBurst\MicroBurst.psm1 -Verbose
203245
Invoke-EnumerateAzureSubDomains -Base corp -Verbose
204246
```
205247

206-
## Open Storage
207-
208-
You could discover open storage with a tool such as [**InvokeEnumerateAzureBlobs.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Invoke-EnumerateAzureBlobs.ps1) which will use the file **`Microburst/Misc/permitations.txt`** to generate permutations (very simple) to try to **find open storage accounts**.
209-
210-
```bash
211-
Import-Module .\MicroBurst\MicroBurst.psm1
212-
Invoke-EnumerateAzureBlobs -Base corp
213-
[...]
214-
https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
215-
[...]
216-
217-
# Access https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
218-
# Check: <Name>ssh_info.json</Name>
219-
# Access then https://corpcommon.blob.core.windows.net/secrets/ssh_info.json
220-
```
221-
222-
### SAS URLs
223-
224-
A _**shared access signature**_ (SAS) URL is an URL that **provides access** to certain part of a Storage account (could be a full container, a file...) with some specific permissions (read, write...) over the resources. If you find one leaked you could be able to access sensitive information, they look like this (this is to access a container, if it was just granting access to a file the path of the URL will also contain that file):
225-
226-
`https://<storage_account_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D`
227-
228-
Use [**Storage Explorer**](https://azure.microsoft.com/en-us/features/storage-explorer/) to access the data
229-
230-
## Compromise Credentials
231248

232-
### Phishing
249+
## Phishing
233250

234-
- [**Common Phishing**](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/phishing-methodology/index.html) (credentials or OAuth App -[Illicit Consent Grant Attack](az-oauth-apps-phishing.md)-)
251+
- [**Common Phishing**](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/phishing-methodology/index.html) for credentials or via [OAuth Apps](az-oauth-apps-phishing.md)
235252
- [**Device Code Authentication** Phishing](az-device-code-authentication-phishing.md)
236253

237-
### Password Spraying / Brute-Force
238-
239-
{{#ref}}
240-
az-password-spraying.md
241-
{{#endref}}
242-
243254
## References
244255

245256
- [https://aadinternals.com/post/just-looking/](https://aadinternals.com/post/just-looking/)
246257
- [https://www.securesystems.de/blog/a-fresh-look-at-user-enumeration-in-microsoft-teams/](https://www.securesystems.de/blog/a-fresh-look-at-user-enumeration-in-microsoft-teams/)
258+
- [https://www.netspi.com/blog/technical-blog/cloud-penetration-testing/enumerating-azure-services/](https://www.netspi.com/blog/technical-blog/cloud-penetration-testing/enumerating-azure-services/)
247259

248260
{{#include ../../../banners/hacktricks-training.md}}
249261

0 commit comments

Comments
 (0)