mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-27 13:13:06 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -4,59 +4,58 @@
|
||||
|
||||
## Lambda
|
||||
|
||||
Amazon Web Services (AWS) Lambda is described as a **compute service** that enables the execution of code without the necessity for server provision or management. It is characterized by its ability to **automatically handle resource allocation** needed for code execution, ensuring features like high availability, scalability, and security. A significant aspect of Lambda is its pricing model, where **charges are based solely on the compute time utilized**, eliminating the need for initial investments or long-term obligations.
|
||||
Amazon Web Services (AWS) Lambda को एक **compute service** के रूप में वर्णित किया गया है जो कोड को सर्वर प्रावधान या प्रबंधन की आवश्यकता के बिना निष्पादित करने की अनुमति देता है। यह **कोड निष्पादन** के लिए आवश्यक संसाधन आवंटन को **स्वचालित रूप से संभालने** की क्षमता के लिए जाना जाता है, जो उच्च उपलब्धता, स्केलेबिलिटी और सुरक्षा जैसी सुविधाओं को सुनिश्चित करता है। Lambda का एक महत्वपूर्ण पहलू इसका मूल्य निर्धारण मॉडल है, जहां **शुल्क केवल उपयोग किए गए कंप्यूट समय पर आधारित होते हैं**, प्रारंभिक निवेश या दीर्घकालिक प्रतिबद्धताओं की आवश्यकता को समाप्त करता है।
|
||||
|
||||
To call a lambda it's possible to call it as **frequently as you wants** (with Cloudwatch), **expose** an **URL** endpoint and call it, call it via **API Gateway** or even based on **events** such as **changes** to data in a **S3** bucket or updates to a **DynamoDB** table.
|
||||
एक लैम्ब्डा को कॉल करने के लिए इसे **जितनी बार चाहें** (Cloudwatch के साथ), **एक URL** एंडपॉइंट के माध्यम से एक्सपोज़ करके, **API Gateway** के माध्यम से या यहां तक कि **S3** बकेट में डेटा में **परिवर्तनों** या **DynamoDB** तालिका में अपडेट के आधार पर कॉल किया जा सकता है।
|
||||
|
||||
The **code** of a lambda is stored in **`/var/task`**.
|
||||
एक लैम्ब्डा का **कोड** **`/var/task`** में संग्रहीत होता है।
|
||||
|
||||
### Lambda Aliases Weights
|
||||
|
||||
A Lambda can have **several versions**.\
|
||||
And it can have **more than 1** version exposed via **aliases**. The **weights** of **each** of the **versions** exposed inside and alias will decide **which alias receive the invocation** (it can be 90%-10% for example).\
|
||||
If the code of **one** of the aliases is **vulnerable** you can send **requests until the vulnerable** versions receives the exploit.
|
||||
एक Lambda के पास **कई संस्करण** हो सकते हैं।\
|
||||
और इसके पास **एक से अधिक** संस्करण हो सकते हैं जो **aliases** के माध्यम से एक्सपोज़ किए जाते हैं। **हर** **संस्करण** के **वजन** जो एक alias के अंदर एक्सपोज़ किए जाते हैं, यह तय करेंगे कि **कौन सा alias कॉल प्राप्त करता है** (यह उदाहरण के लिए 90%-10% हो सकता है)।\
|
||||
यदि **एक** alias का कोड **कमजोर** है, तो आप **अनुरोध भेज सकते हैं जब तक कमजोर** संस्करण को एक्सप्लॉइट प्राप्त नहीं होता।
|
||||
|
||||
.png>)
|
||||
|
||||
### Resource Policies
|
||||
|
||||
Lambda resource policies allow to **give access to other services/accounts to invoke** the lambda for example.\
|
||||
For example this is the policy to allow **anyone to access a lambda exposed via URL**:
|
||||
Lambda संसाधन नीतियाँ अन्य सेवाओं/खातों को लैम्ब्डा को कॉल करने के लिए **पहुँच देने** की अनुमति देती हैं।\
|
||||
उदाहरण के लिए, यह नीति है जो **किसी को भी URL के माध्यम से एक्सपोज़ किए गए लैम्ब्डा तक पहुँचने** की अनुमति देती है:
|
||||
|
||||
<figure><img src="https://lh4.googleusercontent.com/4PNFKBdzr3nMrPqeKkTslgwWDKxkXMdQ1SNdv7NPHykj3GX8wODrQyXOFbjk4fxHfZ8pDm5ijWgk2Vq2EGXiPRT3TQfZf1fHycvdEKBuDxJDYos1CJeMHXSeg86ZB-Ol7CNtten6xkVFQj6AhDUEWNQJrQ=s2048" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Or this to allow an API Gateway to invoke it:
|
||||
या यह API Gateway को इसे कॉल करने की अनुमति देने के लिए:
|
||||
|
||||
<figure><img src="https://lh3.googleusercontent.com/Su0JlR0wBqb-99Z4N_2-_kMlX0Xzx2n_GpZuOPW5IeXR3FYbm8OHFDM3Ora1BpXiSjHpDVUlq4yEyXwaI3nBuze6DJ-wRf2ATsCuWbq0wuBCd34E9uIpqwheE6Cc_PopviI_93O_j2ZKXc1-AJtsBoLVUw=s2048" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Lambda Database Proxies
|
||||
|
||||
When there are **hundreds** of **concurrent lambda requests**, if each of them need to **connect and close a connection to a database**, it's just not going to work (lambdas are stateless, cannot maintain connections open).\
|
||||
Then, if your **Lambda functions interact with RDS Proxy instead** of your database instance. It handles the connection pooling necessary for scaling many simultaneous connections created by concurrent Lambda functions. This allows your Lambda applications to **reuse existing connections**, rather than creating new connections for every function invocation.
|
||||
जब **सैकड़ों** **समानांतर लैम्ब्डा अनुरोध** होते हैं, यदि प्रत्येक को **डेटाबेस से कनेक्ट और कनेक्शन बंद करने** की आवश्यकता होती है, तो यह काम नहीं करेगा (लैम्ब्डा स्टेटलेस होते हैं, कनेक्शन को खुला नहीं रख सकते)।\
|
||||
फिर, यदि आपके **Lambda कार्य RDS Proxy के साथ इंटरैक्ट करते हैं** आपके डेटाबेस इंस्टेंस के बजाय। यह समानांतर Lambda कार्यों द्वारा बनाए गए कई समवर्ती कनेक्शनों के लिए आवश्यक कनेक्शन पूलिंग को संभालता है। यह आपके Lambda अनुप्रयोगों को **मौजूदा कनेक्शनों का पुन: उपयोग** करने की अनुमति देता है, बजाय इसके कि हर कार्य कॉल के लिए नए कनेक्शन बनाए।
|
||||
|
||||
### Lambda EFS Filesystems
|
||||
|
||||
To preserve and even share data **Lambdas can access EFS and mount them**, so Lambda will be able to read and write from it.
|
||||
डेटा को संरक्षित और साझा करने के लिए **Lambdas EFS तक पहुँच सकते हैं और उन्हें माउंट कर सकते हैं**, ताकि Lambda इसे पढ़ और लिख सके।
|
||||
|
||||
### Lambda Layers
|
||||
|
||||
A Lambda _layer_ is a .zip file archive that **can contain additional code** or other content. A layer can contain libraries, a [custom runtime](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html), data, or configuration files.
|
||||
एक Lambda _layer_ एक .zip फ़ाइल संग्रह है जो **अतिरिक्त कोड** या अन्य सामग्री को **शामिल कर सकता है**। एक लेयर में पुस्तकालय, एक [कस्टम रनटाइम](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html), डेटा, या कॉन्फ़िगरेशन फ़ाइलें हो सकती हैं।
|
||||
|
||||
It's possible to include up to **five layers per function**. When you include a layer in a function, the **contents are extracted to the `/opt`** directory in the execution environment.
|
||||
प्रत्येक फ़ंक्शन में **पाँच लेयर** तक शामिल करना संभव है। जब आप किसी फ़ंक्शन में एक लेयर शामिल करते हैं, तो **सामग्री को `/opt`** निर्देशिका में निष्पादन वातावरण में निकाला जाता है।
|
||||
|
||||
By **default**, the **layers** that you create are **private** to your AWS account. You can choose to **share** a layer with other accounts or to **make** the layer **public**. If your functions consume a layer that a different account published, your functions can **continue to use the layer version after it has been deleted, or after your permission to access the layer is revoked**. However, you cannot create a new function or update functions using a deleted layer version.
|
||||
**डिफ़ॉल्ट** के रूप में, आप जो **लेयर** बनाते हैं वे आपके AWS खाते के लिए **निजी** होती हैं। आप एक लेयर को अन्य खातों के साथ **शेयर** करने या लेयर को **सार्वजनिक** बनाने का विकल्प चुन सकते हैं। यदि आपके फ़ंक्शन एक लेयर का उपभोग करते हैं जिसे एक अलग खाते ने प्रकाशित किया है, तो आपके फ़ंक्शन **लेयर संस्करण का उपयोग जारी रख सकते हैं** जब इसे हटा दिया गया हो, या जब आपकी लेयर तक पहुँचने की अनुमति रद्द कर दी गई हो। हालाँकि, आप एक नई फ़ंक्शन नहीं बना सकते या हटाए गए लेयर संस्करण का उपयोग करते हुए फ़ंक्शंस को अपडेट नहीं कर सकते।
|
||||
|
||||
Functions deployed as a container image do not use layers. Instead, you package your preferred runtime, libraries, and other dependencies into the container image when you build the image.
|
||||
कंटेनर छवि के रूप में तैनात फ़ंक्शन लेयर का उपयोग नहीं करते हैं। इसके बजाय, आप छवि बनाने के समय अपने पसंदीदा रनटाइम, पुस्तकालयों और अन्य निर्भरताओं को कंटेनर छवि में पैकेज करते हैं।
|
||||
|
||||
### Lambda Extensions
|
||||
|
||||
Lambda extensions enhance functions by integrating with various **monitoring, observability, security, and governance tools**. These extensions, added via [.zip archives using Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) or included in [container image deployments](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/), operate in two modes: **internal** and **external**.
|
||||
Lambda एक्सटेंशन कार्यों को विभिन्न **निगरानी, अवलोकन, सुरक्षा, और शासन उपकरणों** के साथ एकीकृत करके कार्यों को बढ़ाते हैं। ये एक्सटेंशन [.zip संग्रह का उपयोग करके Lambda लेयर्स](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) के माध्यम से जोड़े जाते हैं या [कंटेनर छवि तैनाती में शामिल होते हैं](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/), दो मोड में कार्य करते हैं: **आंतरिक** और **बाहरी**।
|
||||
|
||||
- **Internal extensions** merge with the runtime process, manipulating its startup using **language-specific environment variables** and **wrapper scripts**. This customization applies to a range of runtimes, including **Java Correto 8 and 11, Node.js 10 and 12, and .NET Core 3.1**.
|
||||
- **External extensions** run as separate processes, maintaining operation alignment with the Lambda function's lifecycle. They're compatible with various runtimes like **Node.js 10 and 12, Python 3.7 and 3.8, Ruby 2.5 and 2.7, Java Corretto 8 and 11, .NET Core 3.1**, and **custom runtimes**.
|
||||
- **आंतरिक एक्सटेंशन** रनटाइम प्रक्रिया के साथ विलीन होते हैं, इसके स्टार्टअप को **भाषा-विशिष्ट पर्यावरण चर** और **रैपर स्क्रिप्ट** का उपयोग करके संशोधित करते हैं। यह अनुकूलन कई रनटाइम्स पर लागू होता है, जिसमें **Java Correto 8 और 11, Node.js 10 और 12, और .NET Core 3.1** शामिल हैं।
|
||||
- **बाहरी एक्सटेंशन** अलग प्रक्रियाओं के रूप में चलते हैं, Lambda फ़ंक्शन के जीवन चक्र के साथ संचालन संरेखण बनाए रखते हैं। वे विभिन्न रनटाइम्स के साथ संगत होते हैं जैसे **Node.js 10 और 12, Python 3.7 और 3.8, Ruby 2.5 और 2.7, Java Corretto 8 और 11, .NET Core 3.1**, और **कस्टम रनटाइम**।
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
aws lambda get-account-settings
|
||||
|
||||
@@ -93,11 +92,9 @@ aws lambda list-event-source-mappings
|
||||
aws lambda list-code-signing-configs
|
||||
aws lambda list-functions-by-code-signing-config --code-signing-config-arn <arn>
|
||||
```
|
||||
### एक लैम्ब्डा को सक्रिय करें
|
||||
|
||||
### Invoke a lambda
|
||||
|
||||
#### Manual
|
||||
|
||||
#### मैनुअल
|
||||
```bash
|
||||
# Invoke function
|
||||
aws lambda invoke --function-name FUNCTION_NAME /tmp/out
|
||||
@@ -106,83 +103,70 @@ aws lambda invoke --function-name FUNCTION_NAME /tmp/out
|
||||
## user_name = event['user_name']
|
||||
aws lambda invoke --function-name <name> --cli-binary-format raw-in-base64-out --payload '{"policy_names": ["AdministratorAccess], "user_name": "sdf"}' out.txt
|
||||
```
|
||||
|
||||
#### Via exposed URL
|
||||
|
||||
#### उजागर URL के माध्यम से
|
||||
```bash
|
||||
aws lambda list-function-url-configs --function-name <function_name> #Get lambda URL
|
||||
aws lambda get-function-url-config --function-name <function_name> #Get lambda URL
|
||||
```
|
||||
|
||||
#### Call Lambda function via URL
|
||||
|
||||
Now it's time to find out possible lambda functions to execute:
|
||||
|
||||
अब संभावित लैम्ब्डा फ़ंक्शंस को निष्पादित करने का समय है:
|
||||
```
|
||||
aws --region us-west-2 --profile level6 lambda list-functions
|
||||
```
|
||||
|
||||
.png>)
|
||||
|
||||
A lambda function called "Level6" is available. Lets find out how to call it:
|
||||
|
||||
एक लैम्ब्डा फ़ंक्शन "Level6" उपलब्ध है। चलिए इसे कॉल करने का तरीका खोजते हैं:
|
||||
```bash
|
||||
aws --region us-west-2 --profile level6 lambda get-policy --function-name Level6
|
||||
```
|
||||
|
||||
.png>)
|
||||
|
||||
Now, that you know the name and the ID you can get the Name:
|
||||
|
||||
अब, जब आप नाम और आईडी जानते हैं, तो आप नाम प्राप्त कर सकते हैं:
|
||||
```bash
|
||||
aws --profile level6 --region us-west-2 apigateway get-stages --rest-api-id "s33ppypa75"
|
||||
```
|
||||
|
||||
.png>)
|
||||
|
||||
And finally call the function accessing (notice that the ID, Name and function-name appears in the URL): [https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Prod/level6](https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Prod/level6)
|
||||
और अंत में फ़ंक्शन को कॉल करें (ध्यान दें कि ID, Name और function-name URL में दिखाई देते हैं): [https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Prod/level6](https://s33ppypa75.execute-api.us-west-2.amazonaws.com/Prod/level6)
|
||||
|
||||
`URL:`**`https://<rest-api-id>.execute-api.<region>.amazonaws.com/<stageName>/<funcName>`**
|
||||
|
||||
#### Other Triggers
|
||||
#### अन्य ट्रिगर्स
|
||||
|
||||
There are a lot of other sources that can trigger a lambda
|
||||
बहुत सारे अन्य स्रोत हैं जो एक लैम्ब्डा को ट्रिगर कर सकते हैं
|
||||
|
||||
<figure><img src="../../../images/image (167).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Privesc
|
||||
### प्रिवेस्क
|
||||
|
||||
In the following page you can check how to **abuse Lambda permissions to escalate privileges**:
|
||||
अगली पृष्ठ पर आप देख सकते हैं कि **Lambda अनुमतियों का दुरुपयोग करके विशेषाधिकार कैसे बढ़ाएं**:
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-lambda-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Unauthenticated Access
|
||||
### अनधिकृत पहुंच
|
||||
|
||||
{{#ref}}
|
||||
../aws-unauthenticated-enum-access/aws-lambda-unauthenticated-access.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### पोस्ट एक्सप्लोइटेशन
|
||||
|
||||
{{#ref}}
|
||||
../aws-post-exploitation/aws-lambda-post-exploitation/
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### स्थिरता
|
||||
|
||||
{{#ref}}
|
||||
../aws-persistence/aws-lambda-persistence/
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## संदर्भ
|
||||
|
||||
- [https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-concepts.html#gettingstarted-concepts-layer](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-concepts.html#gettingstarted-concepts-layer)
|
||||
- [https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/](https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user