76 lines
2.8 KiB
YAML
76 lines
2.8 KiB
YAML
---
|
|
- name: "Simulacion Red Team - Incidente 04: Fuga de Credenciales (CREDENTIAL_LEAK)"
|
|
hosts: localhost
|
|
connection: local
|
|
gather_facts: false
|
|
|
|
vars_files:
|
|
- vars.example.yml
|
|
|
|
pre_tasks:
|
|
- name: Autorizar simulacion y cargar configuracion local
|
|
ansible.builtin.import_tasks: preflight.yml
|
|
tags: always
|
|
|
|
tasks:
|
|
- name: Validar identidad desechable del actor IAM
|
|
ansible.builtin.import_tasks: iam_actor.yml
|
|
|
|
- name: Determinar direccion IP publica de la ejecucion
|
|
ansible.builtin.uri:
|
|
url: https://checkip.amazonaws.com
|
|
return_content: true
|
|
register: current_ip_req
|
|
retries: 3
|
|
delay: 2
|
|
|
|
- name: Fijar IP publica
|
|
ansible.builtin.set_fact:
|
|
current_ip: "{{ current_ip_req.content | trim }}"
|
|
|
|
- name: Notificar condiciones de la prueba
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "=== INICIO SIMULACION FUGA DE CREDENCIALES (CREDENTIAL_LEAK) ==="
|
|
- "IP Actual: {{ current_ip }}"
|
|
- "Criterio de activacion: Llamadas a la API de AWS (STS GetCallerIdentity) desde IP no autorizada"
|
|
- "Condicion positiva: ejecutar el perfil desechable desde una red fuera de authorized_ip_cidrs; conservar acceso administrativo de recuperacion"
|
|
|
|
- name: Ejecutar llamada a STS GetCallerIdentity
|
|
ansible.builtin.command: >
|
|
aws --profile {{ simulation_iam_profile }} sts get-caller-identity --output json
|
|
register: sts_caller_id
|
|
changed_when: false
|
|
|
|
- name: Mostrar identidad que ejecuto la llamada
|
|
ansible.builtin.debug:
|
|
msg: "{{ sts_caller_id.stdout | from_json }}"
|
|
|
|
- name: Consultar incidentes de CREDENTIAL_LEAK en DynamoDB
|
|
ansible.builtin.command: >
|
|
aws dynamodb scan
|
|
--table-name {{ dynamodb_incidents_table }}
|
|
--expression-attribute-names '{"#tp":"type"}'
|
|
--expression-attribute-values '{":t":{"S":"CREDENTIAL_LEAK"}}'
|
|
--filter-expression "#tp = :t"
|
|
--region {{ aws_region }}
|
|
--output json
|
|
register: ddb_leak_raw
|
|
changed_when: false
|
|
|
|
- name: Parsear registros de DynamoDB
|
|
ansible.builtin.set_fact:
|
|
ddb_leak_items: "{{ (ddb_leak_raw.stdout | from_json).Items | default([]) }}"
|
|
|
|
- name: Resumen ejecutivo del resultado
|
|
ansible.builtin.debug:
|
|
msg:
|
|
- "=========================================================="
|
|
- " REPORTE FINAL DE LA PRUEBA"
|
|
- "=========================================================="
|
|
- "Tipo de incidente: CREDENTIAL_LEAK"
|
|
- "IP Emisora: {{ current_ip }}"
|
|
- "Total Incidentes CREDENTIAL_LEAK en DynamoDB: {{ ddb_leak_items | length }}"
|
|
- "Evidencia S3: s3://{{ evidence_bucket }}/incident-04-credential-leak/"
|
|
- "=========================================================="
|