Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/

This commit is contained in:
Translator
2024-12-31 20:36:01 +00:00
parent 388bdfdf0a
commit 0077c42f9c
245 changed files with 9025 additions and 11888 deletions

View File

@@ -4,7 +4,7 @@
## IAM
You can find a **description of IAM** in:
आप IAM का **विवरण** यहाँ पा सकते हैं:
{{#ref}}
../aws-basic-information/
@@ -12,9 +12,9 @@ You can find a **description of IAM** in:
### Enumeration
Main permissions needed:
मुख्य अनुमतियाँ आवश्यक हैं:
- `iam:ListPolicies`, `iam:GetPolicy` and `iam:GetPolicyVersion`
- `iam:ListPolicies`, `iam:GetPolicy` और `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` और `iam:GetUserPolicy`
- `iam:ListGroupPolicies` और `iam:GetGroupPolicy`
- `iam:ListRolePolicies` और `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
```
### 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.
यदि आप अपनी अनुमतियों में रुचि रखते हैं लेकिन आपके पास IAM को क्वेरी करने का एक्सेस नहीं है, तो आप हमेशा उन्हें ब्रूट-फोर्स कर सकते हैं।
#### 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**.
टूल [**bf-aws-permissions**](https://github.com/carlospolop/bf-aws-permissions) बस एक बैश स्क्रिप्ट है जो निर्दिष्ट प्रोफ़ाइल का उपयोग करके सभी **`list*`, `describe*`, `get*`** क्रियाएँ चलाएगी जो इसे `aws` cli सहायता संदेशों का उपयोग करके मिल सकती हैं और **सफल कार्यान्वयन** लौटाएगी।
```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`**
उपकरण [**bf-aws-perms-simulate**](https://github.com/carlospolop/bf-aws-perms-simulate) आपकी वर्तमान अनुमति (या अन्य प्रिंसिपलों की) को खोज सकता है यदि आपके पास अनुमति **`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**.
यदि आपने **कुछ अनुमतियाँ पाई हैं जो आपके उपयोगकर्ता के पास हैं**, और आप सोचते हैं कि ये **प्रबंधित AWS भूमिका** द्वारा दी जा रही हैं (और किसी कस्टम द्वारा नहीं)। आप टूल [**aws-Perms2ManagedRoles**](https://github.com/carlospolop/aws-Perms2ManagedPolicies) का उपयोग कर सकते हैं यह जांचने के लिए कि **कौन सी AWS प्रबंधित भूमिकाएँ उन अनुमतियों को प्रदान करती हैं जो आपने खोजी हैं कि आपके पास हैं**
```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.
> यह संभव है कि आप "जानें" कि आपके पास जो अनुमतियाँ हैं वे AWS प्रबंधित भूमिका द्वारा दी गई हैं यदि आप देखते हैं कि **आपके पास उन सेवाओं पर अनुमतियाँ हैं जो उपयोग में नहीं हैं** उदाहरण के लिए।
#### 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) एक Python उपकरण है जो **AWS CloudTrail लॉग का विश्लेषण करता है ताकि सभी या केवल एक विशिष्ट उपयोगकर्ता या भूमिका द्वारा किए गए कार्यों को निकाला और संक्षेपित किया जा सके**। यह उपकरण **निर्दिष्ट बकेट से हर cloudtrail लॉग को पार्स करेगा**
```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.
> यदि आप .tfstate (Terraform स्थिति फ़ाइलें) या CloudFormation फ़ाइलें (ये आमतौर पर एक बकेट के अंदर cf-templates उपसर्ग के साथ स्थित yaml फ़ाइलें होती हैं) पाते हैं, तो आप उन्हें aws कॉन्फ़िगरेशन खोजने और यह पता लगाने के लिए भी पढ़ सकते हैं कि किसे कौन सी अनुमतियाँ दी गई हैं।
#### 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**.
इस उपकरण का उपयोग करने के लिए [**https://github.com/andresriancho/enumerate-iam**](https://github.com/andresriancho/enumerate-iam) आपको पहले सभी API AWS एंडपॉइंट्स डाउनलोड करने की आवश्यकता है, जिनमें से स्क्रिप्ट **`generate_bruteforce_tests.py`** सभी **"list\_", "describe\_", और "get\_" एंडपॉइंट्स प्राप्त करेगी।** और अंततः, यह दिए गए क्रेडेंशियल्स के साथ **उन्हें एक्सेस करने की कोशिश करेगी** और **यह बताएगी कि क्या यह सफल रहा।**
(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).
(मेरे अनुभव में **उपकरण किसी बिंदु पर लटक जाता है**, [**इस फिक्स को देखें**](https://github.com/andresriancho/enumerate-iam/pull/15/commits/77ad5b41216e3b5f1511d0c385da8cd5984c2d3c) इसे ठीक करने के लिए प्रयास करने के लिए)।
> [!WARNING]
> In my experience this tool is like the previous one but working worse and checking less permissions
> मेरे अनुभव में यह उपकरण पिछले वाले की तरह है लेकिन खराब काम कर रहा है और कम अनुमतियों की जांच कर रहा है।
```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).
आप टूल [**weirdAAL**](https://github.com/carnal0wnage/weirdAAL/wiki) का भी उपयोग कर सकते हैं। यह टूल **कई सामान्य सेवाओं पर कई सामान्य ऑपरेशनों की जांच करेगा** (कुछ enumeration अनुमतियों और कुछ privesc अनुमतियों की भी जांच करेगा)। लेकिन यह केवल कोडेड जांचों की जांच करेगा (अधिक चीजों की जांच करने का एकमात्र तरीका अधिक परीक्षण कोड करना है)।
```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
#### BF अनुमतियों को मजबूत करने के उपकरण
{{#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!
पिछले किसी भी उपकरण में सभी अनुमतियों की जांच करने की क्षमता नहीं है, इसलिए यदि आप एक बेहतर उपकरण जानते हैं तो PR भेजें!
### Unauthenticated Access
### अनधिकृत पहुंच
{{#ref}}
../aws-unauthenticated-enum-access/aws-iam-and-sts-unauthenticated-enum.md
{{#endref}}
### Privilege Escalation
### विशेषाधिकार वृद्धि
In the following page you can check how to **abuse IAM permissions to escalate privileges**:
अगली पृष्ठ पर आप **IAM अनुमतियों का दुरुपयोग करके विशेषाधिकार बढ़ाने** का तरीका देख सकते हैं:
{{#ref}}
../aws-privilege-escalation/aws-iam-privesc.md
{{#endref}}
### IAM Post Exploitation
### IAM पोस्ट शोषण
{{#ref}}
../aws-post-exploitation/aws-iam-post-exploitation.md
{{#endref}}
### IAM Persistence
### IAM स्थिरता
{{#ref}}
../aws-persistence/aws-iam-persistence.md
{{#endref}}
## IAM Identity Center
## IAM पहचान केंद्र
You can find a **description of IAM Identity Center** in:
आप **IAM पहचान केंद्र का विवरण** यहाँ पा सकते हैं:
{{#ref}}
../aws-basic-information/
{{#endref}}
### Connect via SSO with CLI
### CLI के साथ SSO के माध्यम से कनेक्ट करें
```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
```
### Enumeration
The main elements of the Identity Center are:
Identity Center के मुख्य तत्व हैं:
- Users and groups
- Permission Sets: Have policies attached
- AWS Accounts
- उपयोगकर्ता और समूह
- अनुमति सेट: नीतियाँ संलग्न हैं
- AWS खाते
Then, relationships are created so users/groups have Permission Sets over AWS 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).
> ध्यान दें कि अनुमति सेट पर नीतियाँ संलग्न करने के 3 तरीके हैं। AWS प्रबंधित नीतियों को संलग्न करना, ग्राहक प्रबंधित नीतियाँ (इन नीतियों को उन सभी खातों में बनाना आवश्यक है जिन पर अनुमति सेट प्रभाव डाल रहा है), और इनलाइन नीतियाँ (जो वहाँ परिभाषित हैं)।
```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:
यह संभव है कि फ़ोल्डर `$HOME/.aws` के अंदर फ़ाइल config बनाई जाए ताकि उन प्रोफाइलों को कॉन्फ़िगर किया जा सके जो SSO के माध्यम से सुलभ हैं, उदाहरण के लिए:
```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:
यह कॉन्फ़िगरेशन निम्नलिखित कमांड के साथ उपयोग किया जा सकता है:
```bash
# Login in ms-sso-profile
aws sso login --profile my-sso-profile
# Use dependent-profile
aws s3 ls --profile dependent-profile
```
जब **SSO से प्रोफ़ाइल का उपयोग किया जाता है** कुछ जानकारी तक पहुँचने के लिए, तो क्रेडेंशियल्स **एक फ़ाइल में कैश** किए जाते हैं जो फ़ोल्डर **`$HOME/.aws/sso/cache`** के अंदर होती है। इसलिए इन्हें **वहाँ से पढ़ा और उपयोग किया जा सकता है**
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:
इसके अलावा, **अधिक क्रेडेंशियल्स** फ़ोल्डर **`$HOME/.aws/cli/cache`** में संग्रहीत किए जा सकते हैं। यह कैश निर्देशिका मुख्य रूप से तब उपयोग की जाती है जब आप **AWS CLI प्रोफ़ाइल के साथ काम कर रहे हैं** जो IAM उपयोगकर्ता क्रेडेंशियल्स का उपयोग करती हैं या IAM के माध्यम से **रोल्स को मानती हैं** (बिना SSO के)। कॉन्फ़िग उदाहरण:
```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
### अनधिकृत पहुँच
{{#ref}}
../aws-unauthenticated-enum-access/aws-identity-center-and-sso-unauthenticated-enum.md
{{#endref}}
### Privilege Escalation
### विशेषाधिकार वृद्धि
{{#ref}}
../aws-privilege-escalation/aws-sso-and-identitystore-privesc.md
{{#endref}}
### Post Exploitation
### पोस्ट शोषण
{{#ref}}
../aws-post-exploitation/aws-sso-and-identitystore-post-exploitation.md
{{#endref}}
### Persistence
#### Create a user an assign permissions to it
### स्थिरता
#### एक उपयोगकर्ता बनाएं और उसे अनुमतियाँ सौंपें
```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
```
- एक समूह बनाएं और इसे अनुमतियाँ सौंपें और उस पर एक नियंत्रित उपयोगकर्ता सेट करें
- एक नियंत्रित उपयोगकर्ता या समूह को अतिरिक्त अनुमतियाँ दें
- डिफ़ॉल्ट रूप से, केवल प्रबंधन खाते के उपयोगकर्ताओं के पास IAM पहचान केंद्र तक पहुँचने और उसे नियंत्रित करने की अनुमति होगी।
- 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).
हालांकि, डेलीगेट एडमिनिस्ट्रेटर के माध्यम से एक अलग खाते के उपयोगकर्ताओं को इसे प्रबंधित करने की अनुमति देना संभव है। उनके पास बिल्कुल वही अनुमति नहीं होगी, लेकिन वे [**प्रबंधन गतिविधियाँ**](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html) करने में सक्षम होंगे।
{{#include ../../../banners/hacktricks-training.md}}