mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-16 14:52:43 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
|
||||
## IAM
|
||||
|
||||
You can find a **description of IAM** in:
|
||||
Puoi trovare una **descrizione di IAM** in:
|
||||
|
||||
{{#ref}}
|
||||
../aws-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
### Enumerazione
|
||||
|
||||
Main permissions needed:
|
||||
Permessi principali necessari:
|
||||
|
||||
- `iam:ListPolicies`, `iam:GetPolicy` and `iam:GetPolicyVersion`
|
||||
- `iam:ListPolicies`, `iam:GetPolicy` e `iam:GetPolicyVersion`
|
||||
- `iam:ListRoles`
|
||||
- `iam:ListUsers`
|
||||
- `iam:ListGroups`
|
||||
@@ -22,10 +22,9 @@ Main permissions needed:
|
||||
- `iam:ListAttachedUserPolicies`
|
||||
- `iam:ListAttachedRolePolicies`
|
||||
- `iam:ListAttachedGroupPolicies`
|
||||
- `iam:ListUserPolicies` and `iam:GetUserPolicy`
|
||||
- `iam:ListGroupPolicies` and `iam:GetGroupPolicy`
|
||||
- `iam:ListRolePolicies` and `iam:GetRolePolicy`
|
||||
|
||||
- `iam:ListUserPolicies` e `iam:GetUserPolicy`
|
||||
- `iam:ListGroupPolicies` e `iam:GetGroupPolicy`
|
||||
- `iam:ListRolePolicies` e `iam:GetRolePolicy`
|
||||
```bash
|
||||
# All IAMs
|
||||
## Retrieves information about all IAM users, groups, roles, and policies
|
||||
@@ -89,64 +88,54 @@ aws iam get-account-password-policy
|
||||
aws iam list-mfa-devices
|
||||
aws iam list-virtual-mfa-devices
|
||||
```
|
||||
### Permessi Brute Force
|
||||
|
||||
### Permissions Brute Force
|
||||
|
||||
If you are interested in your own permissions but you don't have access to query IAM you could always brute-force them.
|
||||
Se sei interessato ai tuoi permessi ma non hai accesso per interrogare IAM, puoi sempre forzarli.
|
||||
|
||||
#### bf-aws-permissions
|
||||
|
||||
The tool [**bf-aws-permissions**](https://github.com/carlospolop/bf-aws-permissions) is just a bash script that will run using the indicated profile all the **`list*`, `describe*`, `get*`** actions it can find using `aws` cli help messages and **return the successful executions**.
|
||||
|
||||
Lo strumento [**bf-aws-permissions**](https://github.com/carlospolop/bf-aws-permissions) è semplicemente uno script bash che eseguirà utilizzando il profilo indicato tutte le azioni **`list*`, `describe*`, `get*`** che può trovare utilizzando i messaggi di aiuto del cli `aws` e **restituirà le esecuzioni riuscite**.
|
||||
```bash
|
||||
# Bruteforce permissions
|
||||
bash bf-aws-permissions.sh -p default > /tmp/bf-permissions-verbose.txt
|
||||
```
|
||||
|
||||
#### bf-aws-perms-simulate
|
||||
|
||||
The tool [**bf-aws-perms-simulate**](https://github.com/carlospolop/bf-aws-perms-simulate) can find your current permission (or the ones of other principals) if you have the permission **`iam:SimulatePrincipalPolicy`**
|
||||
|
||||
Lo strumento [**bf-aws-perms-simulate**](https://github.com/carlospolop/bf-aws-perms-simulate) può trovare le tue attuali autorizzazioni (o quelle di altri principali) se hai l'autorizzazione **`iam:SimulatePrincipalPolicy`**
|
||||
```bash
|
||||
# Ask for permissions
|
||||
python3 aws_permissions_checker.py --profile <AWS_PROFILE> [--arn <USER_ARN>]
|
||||
```
|
||||
|
||||
#### Perms2ManagedPolicies
|
||||
|
||||
If you found **some permissions your user has**, and you think that they are being granted by a **managed AWS role** (and not by a custom one). You can use the tool [**aws-Perms2ManagedRoles**](https://github.com/carlospolop/aws-Perms2ManagedPolicies) to check all the **AWS managed roles that grants the permissions you discovered that you have**.
|
||||
|
||||
Se hai trovato **alcuni permessi che il tuo utente ha**, e pensi che siano concessi da un **ruolo AWS gestito** (e non da uno personalizzato). Puoi utilizzare lo strumento [**aws-Perms2ManagedRoles**](https://github.com/carlospolop/aws-Perms2ManagedPolicies) per controllare tutti i **ruoli gestiti AWS che concedono i permessi che hai scoperto di avere**.
|
||||
```bash
|
||||
# Run example with my profile
|
||||
python3 aws-Perms2ManagedPolicies.py --profile myadmin --permissions-file example-permissions.txt
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> It's possible to "know" if the permissions you have are granted by an AWS managed role if you see that **you have permissions over services that aren't used** for example.
|
||||
> È possibile "sapere" se i permessi che hai sono concessi da un ruolo gestito da AWS se vedi che **hai permessi su servizi che non vengono utilizzati** ad esempio.
|
||||
|
||||
#### Cloudtrail2IAM
|
||||
|
||||
[**CloudTrail2IAM**](https://github.com/carlospolop/Cloudtrail2IAM) is a Python tool that analyses **AWS CloudTrail logs to extract and summarize actions** done by everyone or just an specific user or role. The tool will **parse every cloudtrail log from the indicated bucket**.
|
||||
|
||||
[**CloudTrail2IAM**](https://github.com/carlospolop/Cloudtrail2IAM) è uno strumento Python che analizza **i log di AWS CloudTrail per estrarre e riassumere le azioni** eseguite da chiunque o solo da un utente o ruolo specifico. Lo strumento **analizzerà ogni log di cloudtrail dal bucket indicato**.
|
||||
```bash
|
||||
git clone https://github.com/carlospolop/Cloudtrail2IAM
|
||||
cd Cloudtrail2IAM
|
||||
pip install -r requirements.txt
|
||||
python3 cloudtrail2IAM.py --prefix PREFIX --bucket_name BUCKET_NAME --profile PROFILE [--filter-name FILTER_NAME] [--threads THREADS]
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> If you find .tfstate (Terraform state files) or CloudFormation files (these are usually yaml files located inside a bucket with the prefix cf-templates), you can also read them to find aws configuration and find which permissions have been assigned to who.
|
||||
> Se trovi .tfstate (file di stato Terraform) o file CloudFormation (questi sono solitamente file yaml situati all'interno di un bucket con il prefisso cf-templates), puoi anche leggerli per trovare la configurazione aws e scoprire quali permessi sono stati assegnati a chi.
|
||||
|
||||
#### enumerate-iam
|
||||
|
||||
To use the tool [**https://github.com/andresriancho/enumerate-iam**](https://github.com/andresriancho/enumerate-iam) you first need to download all the API AWS endpoints, from those the script **`generate_bruteforce_tests.py`** will get all the **"list\_", "describe\_", and "get\_" endpoints.** And finally, it will try to **access them** with the given credentials and **indicate if it worked**.
|
||||
Per utilizzare lo strumento [**https://github.com/andresriancho/enumerate-iam**](https://github.com/andresriancho/enumerate-iam) devi prima scaricare tutti gli endpoint API AWS, da questi lo script **`generate_bruteforce_tests.py`** otterrà tutti gli **endpoint "list\_", "describe\_" e "get\_"**. E infine, cercherà di **accedervi** con le credenziali fornite e **indicherà se ha funzionato**.
|
||||
|
||||
(In my experience the **tool hangs at some point**, [**checkout this fix**](https://github.com/andresriancho/enumerate-iam/pull/15/commits/77ad5b41216e3b5f1511d0c385da8cd5984c2d3c) to try to fix that).
|
||||
(Nella mia esperienza, lo **strumento si blocca a un certo punto**, [**controlla questa soluzione**](https://github.com/andresriancho/enumerate-iam/pull/15/commits/77ad5b41216e3b5f1511d0c385da8cd5984c2d3c) per cercare di risolvere il problema).
|
||||
|
||||
> [!WARNING]
|
||||
> In my experience this tool is like the previous one but working worse and checking less permissions
|
||||
|
||||
> Nella mia esperienza, questo strumento è simile al precedente ma funziona peggio e controlla meno permessi.
|
||||
```bash
|
||||
# Install tool
|
||||
git clone git@github.com:andresriancho/enumerate-iam.git
|
||||
@@ -163,11 +152,9 @@ cd ..
|
||||
# Enumerate permissions
|
||||
python3 enumerate-iam.py --access-key ACCESS_KEY --secret-key SECRET_KEY [--session-token SESSION_TOKEN] [--region REGION]
|
||||
```
|
||||
|
||||
#### weirdAAL
|
||||
|
||||
You could also use the tool [**weirdAAL**](https://github.com/carnal0wnage/weirdAAL/wiki). This tool will check **several common operations on several common services** (will check some enumeration permissions and also some privesc permissions). But it will only check the coded checks (the only way to check more stuff if coding more tests).
|
||||
|
||||
Puoi anche utilizzare lo strumento [**weirdAAL**](https://github.com/carnal0wnage/weirdAAL/wiki). Questo strumento controllerà **diverse operazioni comuni su diversi servizi comuni** (verificherà alcune autorizzazioni di enumerazione e anche alcune autorizzazioni di privesc). Ma controllerà solo i controlli codificati (l'unico modo per controllare più cose è codificare più test).
|
||||
```bash
|
||||
# Install
|
||||
git clone https://github.com/carnal0wnage/weirdAAL.git
|
||||
@@ -191,12 +178,10 @@ python3 weirdAAL.py -m recon_all -t MyTarget # Check all permissions
|
||||
# [+] elbv2 Actions allowed are [+]
|
||||
# ['DescribeLoadBalancers', 'DescribeAccountLimits', 'DescribeTargetGroups']
|
||||
```
|
||||
|
||||
#### Hardening Tools to BF permissions
|
||||
#### Strumenti di indurimento per BF permessi
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="CloudSploit" }}
|
||||
|
||||
```bash
|
||||
# Export env variables
|
||||
./index.js --console=text --config ./config.js --json /tmp/out-cloudsploit.json
|
||||
@@ -207,11 +192,9 @@ jq 'map(select(.status | contains("UNKNOWN") | not))' /tmp/out-cloudsploit.json
|
||||
# Get services by regions
|
||||
jq 'group_by(.region) | map({(.[0].region): ([map((.resource | split(":"))[2]) | unique])})' ~/Desktop/pentests/cere/greybox/core-dev-dev-cloudsploit-filtered.json
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="SteamPipe" }}
|
||||
|
||||
```bash
|
||||
# https://github.com/turbot/steampipe-mod-aws-insights
|
||||
steampipe check all --export=json
|
||||
@@ -220,50 +203,48 @@ steampipe check all --export=json
|
||||
# In this case you cannot output to JSON, so heck it in the dashboard
|
||||
steampipe dashboard
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### \<YourTool>
|
||||
|
||||
Neither of the previous tools is capable of checking close to all permissions, so if you know a better tool send a PR!
|
||||
Nessuno degli strumenti precedenti è in grado di controllare quasi tutti i permessi, quindi se conosci uno strumento migliore invia una PR!
|
||||
|
||||
### Unauthenticated Access
|
||||
### Accesso Non Autenticato
|
||||
|
||||
{{#ref}}
|
||||
../aws-unauthenticated-enum-access/aws-iam-and-sts-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Privilege Escalation
|
||||
### Escalation dei Privilegi
|
||||
|
||||
In the following page you can check how to **abuse IAM permissions to escalate privileges**:
|
||||
Nella pagina seguente puoi controllare come **abuse IAM permissions to escalate privileges**:
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-iam-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### IAM Post Exploitation
|
||||
### Post Sfruttamento IAM
|
||||
|
||||
{{#ref}}
|
||||
../aws-post-exploitation/aws-iam-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### IAM Persistence
|
||||
### Persistenza IAM
|
||||
|
||||
{{#ref}}
|
||||
../aws-persistence/aws-iam-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## IAM Identity Center
|
||||
## Centro Identità IAM
|
||||
|
||||
You can find a **description of IAM Identity Center** in:
|
||||
Puoi trovare una **descrizione del Centro Identità IAM** in:
|
||||
|
||||
{{#ref}}
|
||||
../aws-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Connect via SSO with CLI
|
||||
|
||||
### Connetti tramite SSO con CLI
|
||||
```bash
|
||||
# Connect with sso via CLI aws configure sso
|
||||
aws configure sso
|
||||
@@ -274,20 +255,18 @@ sso_account_id = <account_numbre>
|
||||
sso_role_name = AdministratorAccess
|
||||
sso_region = us-east-1
|
||||
```
|
||||
### Enumerazione
|
||||
|
||||
### Enumeration
|
||||
Gli elementi principali del Centro Identità sono:
|
||||
|
||||
The main elements of the Identity Center are:
|
||||
- Utenti e gruppi
|
||||
- Set di Permessi: Hanno politiche collegate
|
||||
- Account AWS
|
||||
|
||||
- Users and groups
|
||||
- Permission Sets: Have policies attached
|
||||
- AWS Accounts
|
||||
|
||||
Then, relationships are created so users/groups have Permission Sets over AWS Account.
|
||||
Poi, vengono create relazioni in modo che utenti/gruppi abbiano Set di Permessi su un Account AWS.
|
||||
|
||||
> [!NOTE]
|
||||
> Note that there are 3 ways to attach policies to a Permission Set. Attaching AWS managed policies, Customer managed policies (these policies needs to be created in all the accounts the Permissions Set is affecting), and inline policies (defined in there).
|
||||
|
||||
> Nota che ci sono 3 modi per allegare politiche a un Set di Permessi. Allegare politiche gestite da AWS, politiche gestite dal cliente (queste politiche devono essere create in tutti gli account che il Set di Permessi sta influenzando) e politiche inline (definite lì).
|
||||
```bash
|
||||
# Check if IAM Identity Center is used
|
||||
aws sso-admin list-instances
|
||||
@@ -321,11 +300,9 @@ aws identitystore list-group-memberships --identity-store-id <store-id> --group-
|
||||
## Get memberships or a user or a group
|
||||
aws identitystore list-group-memberships-for-member --identity-store-id <store-id> --member-id <member-id>
|
||||
```
|
||||
|
||||
### Local Enumeration
|
||||
|
||||
It's possible to create inside the folder `$HOME/.aws` the file config to configure profiles that are accessible via SSO, for example:
|
||||
|
||||
È possibile creare all'interno della cartella `$HOME/.aws` il file config per configurare i profili accessibili tramite SSO, ad esempio:
|
||||
```ini
|
||||
[default]
|
||||
region = us-west-2
|
||||
@@ -343,20 +320,16 @@ output = json
|
||||
role_arn = arn:aws:iam::<acc-id>:role/ReadOnlyRole
|
||||
source_profile = Hacktricks-Admin
|
||||
```
|
||||
|
||||
This configuration can be used with the commands:
|
||||
|
||||
Questa configurazione può essere utilizzata con i comandi:
|
||||
```bash
|
||||
# Login in ms-sso-profile
|
||||
aws sso login --profile my-sso-profile
|
||||
# Use dependent-profile
|
||||
aws s3 ls --profile dependent-profile
|
||||
```
|
||||
Quando un **profilo da SSO è utilizzato** per accedere a alcune informazioni, le credenziali sono **memorizzate** in un file all'interno della cartella **`$HOME/.aws/sso/cache`**. Pertanto possono essere **lette e utilizzate da lì**.
|
||||
|
||||
When a **profile from SSO is used** to access some information, the credentials are **cached** in a file inside the folder **`$HOME/.aws/sso/cache`**. Therefore they can be **read and used from there**.
|
||||
|
||||
Moreover, **more credentials** can be stored in the folder **`$HOME/.aws/cli/cache`**. This cache directory is primarily used when you are **working with AWS CLI profiles** that use IAM user credentials or **assume** roles through IAM (without SSO). Config example:
|
||||
|
||||
Inoltre, **ulteriori credenziali** possono essere memorizzate nella cartella **`$HOME/.aws/cli/cache`**. Questa directory di cache è utilizzata principalmente quando si **lavora con i profili AWS CLI** che utilizzano credenziali di utenti IAM o **assumono** ruoli tramite IAM (senza SSO). Esempio di configurazione:
|
||||
```ini
|
||||
[profile crossaccountrole]
|
||||
role_arn = arn:aws:iam::234567890123:role/SomeRole
|
||||
@@ -364,43 +337,36 @@ source_profile = default
|
||||
mfa_serial = arn:aws:iam::123456789012:mfa/saanvi
|
||||
external_id = 123456
|
||||
```
|
||||
|
||||
### Unauthenticated Access
|
||||
### Accesso non autenticato
|
||||
|
||||
{{#ref}}
|
||||
../aws-unauthenticated-enum-access/aws-identity-center-and-sso-unauthenticated-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Privilege Escalation
|
||||
### Escalation dei privilegi
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-sso-and-identitystore-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### Post sfruttamento
|
||||
|
||||
{{#ref}}
|
||||
../aws-post-exploitation/aws-sso-and-identitystore-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
|
||||
#### Create a user an assign permissions to it
|
||||
### Persistenza
|
||||
|
||||
#### Crea un utente e assegna permessi ad esso
|
||||
```bash
|
||||
# Create user identitystore:CreateUser
|
||||
aws identitystore create-user --identity-store-id <store-id> --user-name privesc --display-name privesc --emails Value=sdkabflvwsljyclpma@tmmbt.net,Type=Work,Primary=True --name Formatted=privesc,FamilyName=privesc,GivenName=privesc
|
||||
## After creating it try to login in the console using the selected username, you will receive an email with the code and then you will be able to select a password
|
||||
```
|
||||
- Crea un gruppo e assegna permessi e imposta su di esso un utente controllato
|
||||
- Dai permessi extra a un utente o gruppo controllato
|
||||
- Per impostazione predefinita, solo gli utenti con permessi dall'Account di Gestione potranno accedere e controllare l'IAM Identity Center.
|
||||
|
||||
- Create a group and assign it permissions and set on it a controlled user
|
||||
- Give extra permissions to a controlled user or group
|
||||
- By default, only users with permissions form the Management Account are going to be able to access and control the IAM Identity Center.
|
||||
|
||||
However, it's possible via Delegate Administrator to allow users from a different account to manage it. They won't have exactly the same permission, but they will be able to perform [**management activities**](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html).
|
||||
Tuttavia, è possibile tramite Delegate Administrator consentire agli utenti di un account diverso di gestirlo. Non avranno esattamente gli stessi permessi, ma potranno eseguire [**attività di gestione**](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html).
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user