Skip to content

Commit 9c4e483

Browse files
authored
Merge branch 'master' into master
2 parents eca24d8 + 816da7a commit 9c4e483

File tree

51 files changed

+1033
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1033
-526
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/images/arte.png

2.41 MB
Loading

src/pentesting-cloud/aws-security/aws-persistence/aws-sts-persistence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ optional arguments:
4848
4949
<summary>Code to perform Role Juggling from PowerShell</summary>
5050
51-
```powershell
51+
```bash
5252
# PowerShell script to check for role juggling possibilities using AWS CLI
5353
5454
# Check for AWS CLI installation

src/pentesting-cloud/aws-security/aws-services/aws-cognito-enum/cognito-identity-pools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ For more information check https://github.com/padok-team/cognito-scanner
8888
The only thing an attacker need to know to **get AWS credentials** in a Cognito app as unauthenticated user is the **Identity Pool ID**, and this **ID must be hardcoded** in the web/mobile **application** for it to use it. An ID looks like this: `eu-west-1:098e5341-8364-038d-16de-1865e435da3b` (it's not bruteforceable).
8989

9090
> [!TIP]
91-
> The **IAM Cognito unathenticated role created via is called** by default `Cognito_<Identity Pool name>Unauth_Role`
91+
> The **IAM Cognito unauthenticated role created via is called** by default `Cognito_<Identity Pool name>Unauth_Role`
9292
9393
If you find an Identity Pools ID hardcoded and it allows unauthenticated users, you can get AWS credentials with:
9494

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

Lines changed: 96 additions & 277 deletions
Large diffs are not rendered by default.

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-basic-information/az-tokens-and-public-applications.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ new_azure_cli_bearer_tokens_for_graph_api = (
146146
pprint(new_azure_cli_bearer_tokens_for_graph_api)
147147
```
148148

149+
### Other access token fields
150+
151+
- **appid**: Application ID used to generate the token
152+
- **appidacr**: The Application Authentication Context Class Reference indicates how the client was authenticated, for a public client the value is 0, and if a client secret is used the value is 1
153+
- **acr**: The Authentication Context Class Reference claim is "0" when the end-user authentication did not meet the requirements of ISO/IEC 29115.
154+
- **amr**: The Authentication method indicates how the token was authenticated. A value of “pwd” indicates that a password was used.
155+
- **groups**: Indicates the groups where the principal is a member.
156+
- **iss**: The issues identifies the security token service (STS) that generated the token. e.g. https://sts.windows.net/fdd066e1-ee37-49bc-b08f-d0e152119b04/ (the uuid is the tenant ID)
157+
- **oid**: The object ID of the principal
158+
- **tid**: Tenant ID
159+
- **iat, nbf, exp**: Issued at (when it was issued), Not before (cannot be used before this time, usually same value as iat), Expiration time.
160+
161+
149162
## FOCI Tokens Privilege Escalation
150163

151164
Previously it was mentioned that refresh tokens should be tied to the **scopes** it was generated with, to the **application** and **tenant** it was generated to. If any of these boundaries is broken, it's possible to escalate privileges as it will be possible to generate access tokens to other resources and tenants the user has access to and with more scopes than it was originally intended.
@@ -198,6 +211,7 @@ pprint(microsoft_office_bearer_tokens_for_graph_api)
198211
## References
199212

200213
- [https://github.com/secureworks/family-of-client-ids-research](https://github.com/secureworks/family-of-client-ids-research)
214+
- [https://github.com/Huachao/azure-content/blob/master/articles/active-directory/active-directory-token-and-claims.md](https://github.com/Huachao/azure-content/blob/master/articles/active-directory/active-directory-token-and-claims.md)
201215

202216
{{#include ../../../banners/hacktricks-training.md}}
203217

src/pentesting-cloud/azure-security/az-enumeration-tools.md

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ export REQUESTS_CA_BUNDLE=/Users/user/Downloads/cacert.pem
9393

9494
{{#endtab }}
9595

96+
{{#tab name="CMD" }}
97+
98+
```bash
99+
set ADAL_PYTHON_SSL_NO_VERIFY=1
100+
set AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
101+
set HTTPS_PROXY="http://127.0.0.1:8080"
102+
set HTTP_PROXY="http://127.0.0.1:8080"
103+
104+
# If this is not enough
105+
# Download the certificate from Burp and convert it into .pem format
106+
# And export the following env variable
107+
openssl x509 -in cacert.der -inform DER -out cacert.pem -outform PEM
108+
set REQUESTS_CA_BUNDLE=C:\Users\user\Downloads\cacert.pem
109+
```
110+
111+
{{#endtab }}
112+
96113
{{#tab name="PS" }}
97114

98115
```bash
@@ -148,5 +165,269 @@ The Azure Active Directory (AD) module, now **deprecated**, is part of Azure Pow
148165
149166
Follow this link for the [**installation instructions**](https://www.powershellgallery.com/packages/AzureAD).
150167

168+
169+
## Automated Recon & Compliance Tools
170+
171+
### [turbot azure plugins](https://github.com/orgs/turbot/repositories?q=mod-azure)
172+
173+
Turbot with steampipe and powerpipe allows to gather information from Azure and Entra ID and perform compliance checks and find misconfigurations. The currently most recommended Azure modules to run are:
174+
175+
- [https://github.com/turbot/steampipe-mod-azure-compliance](https://github.com/turbot/steampipe-mod-azure-compliance)
176+
- [https://github.com/turbot/steampipe-mod-azure-insights](https://github.com/turbot/steampipe-mod-azure-insights)
177+
- [https://github.com/turbot/steampipe-mod-azuread-insights](https://github.com/turbot/steampipe-mod-azuread-insights)
178+
179+
```bash
180+
# Install
181+
brew install turbot/tap/powerpipe
182+
brew install turbot/tap/steampipe
183+
steampipe plugin install azure
184+
steampipe plugin install azuread
185+
186+
# Config creds via env vars or az cli default creds will be used
187+
export AZURE_ENVIRONMENT="AZUREPUBLICCLOUD"
188+
export AZURE_TENANT_ID="<tenant-id>"
189+
export AZURE_SUBSCRIPTION_ID="<subscription-id>"
190+
export AZURE_CLIENT_ID="<client-id>"
191+
export AZURE_CLIENT_SECRET="<secret>"
192+
193+
# Run steampipe-mod-azure-insights
194+
cd /tmp
195+
mkdir dashboards
196+
cd dashboards
197+
powerpipe mod init
198+
powerpipe mod install github.com/turbot/steampipe-mod-azure-insights
199+
steampipe service start
200+
powerpipe server
201+
# Go to http://localhost:9033 in a browser
202+
```
203+
204+
### [Prowler](https://github.com/prowler-cloud/prowler)
205+
206+
Prowler is an Open Source security tool to perform AWS, Azure, Google Cloud and Kubernetes security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness.
207+
208+
It basically would allow us to run hundreds of checks against an Azure environment to find security misconfigurations and gather the results in json (and other text format) or check them in the web.
209+
210+
```bash
211+
# Create a application with Reader role and set the tenant ID, client ID and secret in prowler so it access the app
212+
213+
# Launch web with docker-compose
214+
export DOCKER_DEFAULT_PLATFORM=linux/amd64
215+
curl -LO https://raw.githubusercontent.com/prowler-cloud/prowler/refs/heads/master/docker-compose.yml
216+
curl -LO https://raw.githubusercontent.com/prowler-cloud/prowler/refs/heads/master/.env
217+
## If using an old docker-compose version, change the "env_file" params to: env_file: ".env"
218+
docker compose up -d
219+
# Access the web and configure the access to run a scan from it
220+
221+
# Prowler cli
222+
python3 -m pip install prowler --break-system-packages
223+
docker run --rm toniblyx/prowler:v4-latest azure --list-checks
224+
docker run --rm toniblyx/prowler:v4-latest azure --list-services
225+
docker run --rm toniblyx/prowler:v4-latest azure --list-compliance
226+
docker run --rm -e "AZURE_CLIENT_ID=<client-id>" -e "AZURE_TENANT_ID=<tenant-id>" -e "AZURE_CLIENT_SECRET=<secret>" toniblyx/prowler:v4-latest azure --sp-env-auth
227+
## It also support other authentication types, check: prowler azure --help
228+
```
229+
230+
### [Monkey365](https://github.com/silverhack/monkey365)
231+
232+
It allows to perform Azure subscriptions and Microsoft Entra ID security configuration reviews automatically.
233+
234+
The HTML reports are stored inside the `./monkey-reports` directory inside the github repository folder.
235+
236+
```bash
237+
git clone https://github.com/silverhack/monkey365
238+
Get-ChildItem -Recurse monkey365 | Unblock-File
239+
cd monkey365
240+
Import-Module ./monkey365
241+
mkdir /tmp/monkey365-scan
242+
cd /tmp/monkey365-scan
243+
244+
Get-Help Invoke-Monkey365
245+
Get-Help Invoke-Monkey365 -Detailed
246+
247+
# Scan with user creds (browser will be run)
248+
Invoke-Monkey365 -TenantId <tenant-id> -Instance Azure -Collect All -ExportTo HTML
249+
250+
# Scan with App creds
251+
$SecureClientSecret = ConvertTo-SecureString "<secret>" -AsPlainText -Force
252+
Invoke-Monkey365 -TenantId <tenant-id> -ClientId <client-id> -ClientSecret $SecureClientSecret -Instance Azure -Collect All -ExportTo HTML
253+
```
254+
255+
### [ScoutSuite](https://github.com/nccgroup/ScoutSuite)
256+
257+
Scout Suite gathers configuration data for manual inspection and highlights risk areas. It's a multi-cloud security-auditing tool, which enables security posture assessment of cloud environments.
258+
259+
```bash
260+
virtualenv -p python3 venv
261+
source venv/bin/activate
262+
pip install scoutsuite
263+
scout --help
264+
265+
# Use --cli flag to use az cli credentials
266+
# Use --user-account to have scout prompt for user credentials
267+
# Use --user-account-browser to launch a browser to login
268+
# Use --service-principal to have scout prompt for app credentials
269+
270+
python scout.py azure --cli
271+
```
272+
273+
274+
### [Azure-MG-Sub-Governance-Reporting](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting)
275+
276+
It's a powershell script that helps you to **visualize all the resources and permissions inside a Management Group and the Entra ID** tenant and find security misconfigurations.
277+
278+
It works using the Az PowerShell module, so any authentication supported by this tool is supported by the tool.
279+
280+
```bash
281+
import-module Az
282+
.\AzGovVizParallel.ps1 -ManagementGroupId <management-group-id> [-SubscriptionIdWhitelist <subscription-id>]
283+
```
284+
285+
286+
## Automated Post-Exploitation tools
287+
288+
### [**ROADRecon**](https://github.com/dirkjanm/ROADtools)
289+
290+
The enumeration of ROADRecon offers information about the configuration of Entra ID, like users, groups, roles, conditional access policies...
291+
292+
```bash
293+
cd ROADTools
294+
pipenv shell
295+
# Login with user creds
296+
roadrecon auth -u [email protected] -p "Welcome2022!"
297+
# Login with app creds
298+
roadrecon auth --as-app --client "<client-id>" --password "<secret>" --tenant "<tenant-id>"
299+
roadrecon gather
300+
roadrecon gui
301+
```
302+
303+
### [**AzureHound**](https://github.com/BloodHoundAD/AzureHound)
304+
305+
```bash
306+
# Launch AzureHound
307+
## Login with app secret
308+
azurehound -a "<client-id>" -s "<secret>" --tenant "<tenant-id>" list -o ./output.json
309+
## Login with user creds
310+
azurehound -u "<user-email>" -p "<password>" --tenant "<tenant-id>" list -o ./output.json
311+
```
312+
313+
Launch the **BloodHound** web with **`curl -L https://ghst.ly/getbhce | docker compose -f - up`** and import the `output.json` file.
314+
315+
Then, in the **EXPLORE** tab, in the **CYPHER** section you can see a **folder** icon that contains pre-built queries.
316+
317+
### [**MicroBurst**](https://github.com/NetSPI/MicroBurst)
318+
319+
MicroBurst includes functions and scripts that support Azure Services discovery, weak configuration auditing, and post exploitation actions such as credential dumping. It is intended to be used during penetration tests where Azure is in use.
320+
321+
```bash
322+
Import-Module .\MicroBurst.psm1
323+
Import-Module .\Get-AzureDomainInfo.ps1
324+
Get-AzureDomainInfo -folder MicroBurst -Verbose
325+
```
326+
327+
### [**PowerZure**](https://github.com/hausec/PowerZure)
328+
329+
PowerZure was created out of the need for a framework that can both perform reconnaissance and exploitation of Azure, EntraID, and the associated resources.
330+
331+
It uses the **Az PowerShell** module, so any authentication supported by this tool is supported by the tool.
332+
333+
```bash
334+
# Login
335+
Import-Module Az
336+
Connect-AzAccount
337+
338+
# Clone and import PowerZure
339+
git clone https://github.com/hausec/PowerZure
340+
cd PowerZure
341+
ipmo ./Powerzure.psd1
342+
Invoke-Powerzure -h # Check all the options
343+
344+
# Info Gathering (read)
345+
Get-AzureCurrentUser # Get current user
346+
Get-AzureTarget # What can you access to
347+
Get-AzureUser -All # Get all users
348+
Get-AzureSQLDB -All # Get all SQL DBs
349+
Get-AzureAppOwner # Owners of apps in Entra
350+
Show-AzureStorageContent -All # List containers, shared and tables
351+
Show-AzureKeyVaultContent -All # List all contents in key vaults
352+
353+
354+
# Operational (write)
355+
Set-AzureUserPassword -Password <password> -Username <username> # Change password
356+
Set-AzureElevatedPrivileges # Get permissions from Global Administrator in EntraID to User Access Administrator in Azure RBAC.
357+
New-AzureBackdoor -Username <username> -Password <password>
358+
Invoke-AzureRunCommand -Command <command> -VMName <vmname>
359+
[...]
360+
```
361+
362+
### [**GraphRunner**](https://github.com/dafthack/GraphRunner/wiki/Invoke%E2%80%90GraphRunner)
363+
364+
GraphRunner is a post-exploitation toolset for interacting with the Microsoft Graph API. It provides various tools for performing reconnaissance, persistence, and pillaging of data from a Microsoft Entra ID (Azure AD) account.
365+
366+
```bash
367+
#A good place to start is to authenticate with the Get-GraphTokens module. This module will launch a device-code login, allowing you to authenticate the session from a browser session. Access and refresh tokens will be written to the global $tokens variable. To use them with other GraphRunner modules use the Tokens flag (Example. Invoke-DumpApps -Tokens $tokens)
368+
Import-Module .\GraphRunner.ps1
369+
Get-GraphTokens
370+
371+
#This module gathers information about the tenant including the primary contact info, directory sync settings, and user settings such as if users have the ability to create apps, create groups, or consent to apps.
372+
Invoke-GraphRecon -Tokens $tokens -PermissionEnum
373+
374+
#A module to dump conditional access policies from a tenant.
375+
Invoke-GraphRecon -Tokens $tokens -PermissionEnum
376+
377+
#A module to dump conditional access policies from a tenant.
378+
Invoke-DumpCAPS -Tokens $tokens -ResolveGuids
379+
380+
#This module helps identify malicious app registrations. It will dump a list of Azure app registrations from the tenant including permission scopes and users that have consented to the apps. Additionally, it will list external apps that are not owned by the current tenant or by Microsoft's main app tenant. This is a good way to find third-party external apps that users may have consented to.
381+
Invoke-DumpApps -Tokens $tokens
382+
383+
#Gather the full list of users from the directory.
384+
Get-AzureADUsers -Tokens $tokens -OutFile users.txt
385+
386+
#Create a list of security groups along with their members.
387+
Get-SecurityGroups -AccessToken $tokens.access_token
388+
389+
#Gets groups that may be able to be modified by the current user
390+
Get-UpdatableGroups -Tokens $tokens
391+
392+
#Finds dynamic groups and displays membership rules
393+
Get-DynamicGroups -Tokens $tokens
394+
395+
#Gets a list of SharePoint site URLs visible to the current user
396+
Get-SharePointSiteURLs -Tokens $tokens
397+
398+
#This module attempts to locate mailboxes in a tenant that have allowed other users to read them. By providing a userlist the module will attempt to access the inbox of each user and display if it was successful. The access token needs to be scoped to Mail.Read.Shared or Mail.ReadWrite.Shared for this to work.
399+
Invoke-GraphOpenInboxFinder -Tokens $tokens -Userlist users.txt
400+
401+
#This module attempts to gather a tenant ID associated with a domain.
402+
Get-TenantID -Domain
403+
404+
#Runs Invoke-GraphRecon, Get-AzureADUsers, Get-SecurityGroups, Invoke-DumpCAPS, Invoke-DumpApps, and then uses the default_detectors.json file to search with Invoke-SearchMailbox, Invoke-SearchSharePointAndOneDrive, and Invoke-SearchTeams.
405+
Invoke-GraphRunner -Tokens $tokens
406+
```
407+
408+
### [Stormspotter](https://github.com/Azure/Stormspotter)
409+
410+
Stormspotter creates an “attack graph” of the resources in an Azure subscription. It enables red teams and pentesters to visualize the attack surface and pivot opportunities within a tenant, and supercharges your defenders to quickly orient and prioritize incident response work.
411+
412+
**Unfortunately, it looks unmantained**.
413+
414+
```bash
415+
# Start Backend
416+
cd stormspotter\backend\
417+
pipenv shell
418+
python ssbackend.pyz
419+
420+
# Start Front-end
421+
cd stormspotter\frontend\dist\spa\
422+
quasar.cmd serve -p 9091 --history
423+
424+
# Run Stormcollector
425+
cd stormspotter\stormcollector\
426+
pipenv shell
427+
az login -u [email protected] -p Welcome2022!
428+
python stormspotter\stormcollector\sscollector.pyz cli
429+
# This will generate a .zip file to upload in the frontend (127.0.0.1:9091)
430+
```
431+
151432
{{#include ../../banners/hacktricks-training.md}}
152433

src/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-arc-vulnerable-gpo-deploy-script.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ When running this script, sys admins need to provide two main parameters: **Serv
1515

1616
An encrypted secret is generated in the AzureArcDeploy directory on the specified share using DPAPI-NG encryption. The encrypted secret is stored in a file named encryptedServicePrincipalSecret. Evidence of this can be found in the DeployGPO.ps1 script, where the encryption is performed by calling ProtectBase64 with $descriptor and $ServicePrincipalSecret as inputs. The descriptor consists of the Domain Computer and Domain Controller group SIDs, ensuring that the ServicePrincipalSecret can only be decrypted by the Domain Controllers and Domain Computers security groups, as noted in the script comments.
1717

18-
```powershell
18+
```bash
1919
# Encrypting the ServicePrincipalSecret to be decrypted only by the Domain Controllers and the Domain Computers security groups
2020
$DomainComputersSID = "SID=" + $DomainComputersSID
2121
$DomainControllersSID = "SID=" + $DomainControllersSID
@@ -34,24 +34,24 @@ We have the follow conditions:
3434

3535
There are several methods to obtain a machine account within an AD environment. One of the most common is exploiting the machine account quota. Another method involves compromising a machine account through vulnerable ACLs or various other misconfigurations.
3636

37-
```powershell
37+
```bash
3838
Import-MKodule powermad
3939
New-MachineAccount -MachineAccount fake01 -Password $(ConvertTo-SecureString '123456' -AsPlainText -Force) -Verbose
4040
```
4141

4242
Once a machine account is obtained, it is possible to authenticate using this account. We can either use the runas.exe command with the netonly flag or use pass-the-ticket with Rubeus.exe.
4343

44-
```powershell
44+
```bash
4545
runas /user:fake01$ /netonly powershell
4646
```
4747

48-
```powershell
48+
```bash
4949
.\Rubeus.exe asktgt /user:fake01$ /password:123456 /prr
5050
```
5151

5252
By having the TGT for our computer account stored in memory, we can use the following script to decrypt the service principal secret.
5353

54-
```powershell
54+
```bash
5555
Import-Module .\AzureArcDeployment.psm1
5656

5757
$encryptedSecret = Get-Content "[shared folder path]\AzureArcDeploy\encryptedServicePrincipalSecret"

0 commit comments

Comments
 (0)