[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M755BNM05R8S8N3XMVTFDYVS":3,"skill-same:01M755BNM05R8S8N3XMVTFDYVS":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":37,"commitSha":38,"skillDirectory":5,"forksCount":14,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":6,"updatedAt":42,"install":43,"resources":56},"01M755BNM05R8S8N3XMVTFDYVS","performing-cloud-forensics-investigation",null,"Conduct forensic investigations in cloud environments by collecting and analyzing logs, snapshots, and metadata from AWS, Azure, and GCP services.","SamuelChien\u002Fmega-skills-collection","SamuelChien","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F4652114?v=4","01M74KK34WVHA0P5ZYSJRDDFMG","Samuel Chien","01M74KK35FQN1N9VZ9EPTH3P2S",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fperforming-cloud-forensics-investigation\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fperforming-cloud-forensics-investigation\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: performing-cloud-forensics-investigation\ndescription: Conduct forensic investigations in cloud environments by collecting and analyzing logs, snapshots, and metadata from AWS, Azure, and GCP services.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags: [forensics, cloud-forensics, aws, azure, gcp, incident-response, log-analysis]\nversion: \"1.0\"\nauthor: mahipal\nlicense: Apache-2.0\n---\n\n# Performing Cloud Forensics Investigation\n\n## When to Use\n- When investigating a security breach in AWS, Azure, or GCP cloud environments\n- For collecting volatile and non-volatile evidence from cloud infrastructure\n- When tracing unauthorized access through cloud service API logs\n- During incident response requiring preservation of cloud-based evidence\n- For analyzing compromised virtual machines, containers, or serverless functions\n\n## Prerequisites\n- Administrative access to the cloud account under investigation\n- AWS CLI, Azure CLI, or gcloud CLI configured with appropriate permissions\n- Understanding of cloud-native logging (CloudTrail, Activity Log, Audit Log)\n- Forensic workstation with cloud SDKs installed\n- Knowledge of IAM, networking, and compute services in target cloud\n- Evidence preservation procedures for cloud environments\n\n## Workflow\n\n### Step 1: Preserve Cloud Evidence and Establish Scope\n\n```bash\n# === AWS Evidence Preservation ===\n# Snapshot compromised EC2 instance volumes\nINSTANCE_ID=\"i-0abc123def456789\"\nVOLUME_IDS=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID \\\n   --query 'Reservations[].Instances[].BlockDeviceMappings[].Ebs.VolumeId' --output text)\n\nfor vol in $VOLUME_IDS; do\n   aws ec2 create-snapshot --volume-id $vol \\\n      --description \"Forensic snapshot - Case 2024-001 - $(date -u)\" \\\n      --tag-specifications \"ResourceType=snapshot,Tags=[{Key=Case,Value=2024-001},{Key=Evidence,Value=true}]\"\ndone\n\n# Capture instance metadata\naws ec2 describe-instances --instance-ids $INSTANCE_ID \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Finstance_metadata.json\n\n# Capture security group rules\naws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances \\\n   --instance-ids $INSTANCE_ID --query 'Reservations[].Instances[].SecurityGroups[].GroupId' --output text) \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fsecurity_groups.json\n\n# Capture network interfaces\naws ec2 describe-network-interfaces --filters \"Name=attachment.instance-id,Values=$INSTANCE_ID\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fnetwork_interfaces.json\n\n# Isolate the instance (replace security group with forensic isolation SG)\naws ec2 modify-instance-attribute --instance-id $INSTANCE_ID \\\n   --groups sg-forensic-isolation\n\n# === Azure Evidence Preservation ===\n# Snapshot a compromised VM disk\naz snapshot create --resource-group forensics-rg \\\n   --name \"case-2024-001-osdisk-snapshot\" \\\n   --source \"\u002Fsubscriptions\u002FSUB_ID\u002FresourceGroups\u002FRG\u002Fproviders\u002FMicrosoft.Compute\u002Fdisks\u002Fvm-osdisk\"\n\n# === GCP Evidence Preservation ===\ngcloud compute disks snapshot compromised-disk \\\n   --snapshot-names=\"case-2024-001-forensic\" \\\n   --zone=us-central1-a\n```\n\n### Step 2: Collect Cloud API and Access Logs\n\n```bash\n# === AWS CloudTrail Logs ===\n# Download CloudTrail events for the investigation period\naws cloudtrail lookup-events \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   --end-time \"2024-01-20T23:59:59Z\" \\\n   --max-results 1000 \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_events.json\n\n# Filter for specific user activity\naws cloudtrail lookup-events \\\n   --lookup-attributes AttributeKey=Username,AttributeValue=compromised-user \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fuser_activity.json\n\n# Download S3 access logs\naws s3 sync s3:\u002F\u002Fmy-cloudtrail-bucket\u002FAWSLogs\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_s3\u002F\n\n# Query CloudTrail with Athena for large-scale analysis\naws athena start-query-execution \\\n   --query-string \"SELECT eventTime, eventName, userIdentity.arn, sourceIPAddress, errorCode\n                   FROM cloudtrail_logs\n                   WHERE eventTime BETWEEN '2024-01-15' AND '2024-01-20'\n                   AND sourceIPAddress NOT IN ('10.0.0.0\u002F8')\n                   ORDER BY eventTime\" \\\n   --result-configuration OutputLocation=s3:\u002F\u002Fforensics-bucket\u002Fathena-results\u002F\n\n# === AWS VPC Flow Logs ===\naws logs filter-log-events \\\n   --log-group-name \"vpc-flow-logs\" \\\n   --start-time $(date -d \"2024-01-15\" +%s000) \\\n   --end-time $(date -d \"2024-01-20\" +%s000) \\\n   --filter-pattern \"ACCEPT\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fvpc_flow_logs.json\n\n# === Azure Activity Log ===\naz monitor activity-log list \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   --end-time \"2024-01-20T23:59:59Z\" \\\n   --output json > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fazure_activity.json\n\n# === GCP Audit Logs ===\ngcloud logging read 'logName=\"projects\u002FPROJECT_ID\u002Flogs\u002Fcloudaudit.googleapis.com%2Factivity\"\n   AND timestamp>=\"2024-01-15T00:00:00Z\"\n   AND timestamp\u003C=\"2024-01-20T23:59:59Z\"' \\\n   --format=json > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fgcp_audit.json\n```\n\n### Step 3: Analyze IAM and Access Patterns\n\n```bash\n# Analyze compromised credentials usage\npython3 \u003C\u003C 'PYEOF'\nimport json\nfrom collections import defaultdict\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_events.json') as f:\n    data = json.load(f)\n\n# Analyze by source IP\nip_events = defaultdict(list)\nerror_events = []\ncritical_actions = []\n\nfor event in data.get('Events', []):\n    ct = json.loads(event.get('CloudTrailEvent', '{}'))\n    source_ip = ct.get('sourceIPAddress', 'Unknown')\n    event_name = ct.get('eventName', 'Unknown')\n    user_arn = ct.get('userIdentity', {}).get('arn', 'Unknown')\n    error = ct.get('errorCode')\n    timestamp = ct.get('eventTime', '')\n\n    ip_events[source_ip].append(event_name)\n\n    if error:\n        error_events.append({'time': timestamp, 'action': event_name, 'error': error, 'ip': source_ip})\n\n    # Flag critical actions\n    critical = ['CreateUser', 'CreateAccessKey', 'AttachUserPolicy', 'CreateRole',\n                'PutBucketPolicy', 'StopLogging', 'DeleteTrail', 'CreateKeyPair',\n                'RunInstances', 'AuthorizeSecurityGroupIngress']\n    if event_name in critical:\n        critical_actions.append({'time': timestamp, 'action': event_name, 'user': user_arn, 'ip': source_ip})\n\nprint(\"=== SOURCE IP ANALYSIS ===\")\nfor ip, events in sorted(ip_events.items(), key=lambda x: len(x[1]), reverse=True):\n    print(f\"  {ip}: {len(events)} events ({len(set(events))} unique actions)\")\n\nprint(f\"\\n=== ACCESS ERRORS ({len(error_events)} total) ===\")\nfor e in error_events[:10]:\n    print(f\"  [{e['time']}] {e['action']} -> {e['error']} from {e['ip']}\")\n\nprint(f\"\\n=== CRITICAL ACTIONS ({len(critical_actions)} total) ===\")\nfor a in critical_actions:\n    print(f\"  [{a['time']}] {a['action']} by {a['user']} from {a['ip']}\")\nPYEOF\n```\n\n### Step 4: Acquire and Analyze VM Disk Image\n\n```bash\n# Create a forensic analysis instance from the snapshot\nSNAPSHOT_ID=\"snap-0abc123def456789\"\n\n# Create volume from snapshot in isolated forensic VPC\nFORENSIC_VOL=$(aws ec2 create-volume --snapshot-id $SNAPSHOT_ID \\\n   --availability-zone us-east-1a \\\n   --tag-specifications \"ResourceType=volume,Tags=[{Key=Case,Value=2024-001}]\" \\\n   --query 'VolumeId' --output text)\n\n# Attach to forensic analysis instance (read-only mount)\naws ec2 attach-volume --volume-id $FORENSIC_VOL \\\n   --instance-id i-forensic-workstation \\\n   --device \u002Fdev\u002Fxvdf\n\n# On the forensic instance, mount read-only\nsudo mount -o ro \u002Fdev\u002Fxvdf1 \u002Fmnt\u002Fevidence\n\n# Perform standard disk forensics on the mounted volume\n# Extract logs, analyze file system, check for persistence\nls \u002Fmnt\u002Fevidence\u002Fvar\u002Flog\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fvar\u002Flog\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fvm_logs\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fetc\u002Fcrontab \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fpersistence\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fhome\u002F*\u002F.ssh\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fssh_keys\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fhome\u002F*\u002F.bash_history \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fbash_history\u002F\n```\n\n### Step 5: Generate Cloud Forensics Report\n\n```bash\n# Compile findings into structured report\npython3 \u003C\u003C 'PYEOF'\nreport = \"\"\"\nCLOUD FORENSICS INVESTIGATION REPORT\n======================================\nCase: 2024-001\nCloud Provider: AWS (Account: 123456789012)\nRegion: us-east-1\nInvestigation Period: 2024-01-15 to 2024-01-20\n\nEVIDENCE PRESERVED:\n- EC2 Instance Snapshot: snap-0abc123def456789 (i-0abc123def456789)\n- CloudTrail Logs: 2024-01-15 to 2024-01-20\n- VPC Flow Logs: 2024-01-15 to 2024-01-20\n- Instance Metadata: captured and hashed\n- Security Group Configuration: captured at time of isolation\n\nFINDINGS:\n1. Initial Access:\n   - Compromised IAM access key AKIA... used from IP 203.0.113.45\n   - First unauthorized API call: 2024-01-15 14:32:00 UTC\n   - IP geolocation: Foreign jurisdiction (not company IP range)\n\n2. Persistence:\n   - New IAM user 'backup-admin' created with AdministratorAccess\n   - New access key pair generated for backup-admin\n   - SSH key added to EC2 instance authorized_keys\n\n3. Lateral Movement:\n   - S3 bucket policies modified to allow public access\n   - Security group rules modified to allow SSH from 0.0.0.0\u002F0\n   - 3 additional EC2 instances launched for crypto-mining\n\n4. Data Exfiltration:\n   - S3 bucket 'company-confidential' accessed 234 times\n   - 12 GB of data downloaded via GetObject API calls\n   - Data transferred to external IP 185.x.x.x\n\n5. Anti-Forensics:\n   - CloudTrail logging disabled at 2024-01-18 03:00 UTC\n   - CloudWatch log groups deleted\n\nRECOMMENDATIONS:\n- Rotate all IAM credentials immediately\n- Enable MFA on all accounts\n- Restore CloudTrail logging\n- Review and restrict S3 bucket policies\n- Implement GuardDuty for continuous monitoring\n\"\"\"\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloud_forensics_report.txt', 'w') as f:\n    f.write(report)\nprint(report)\nPYEOF\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| Cloud API logging | Service logs recording all API calls (CloudTrail, Activity Log, Audit Log) |\n| Volume snapshots | Point-in-time copies of cloud disk volumes for forensic preservation |\n| VPC Flow Logs | Network traffic metadata logs showing source, destination, and action |\n| IAM credential compromise | Unauthorized use of access keys, tokens, or assumed roles |\n| Instance metadata | EC2\u002FVM configuration data including network, storage, and security settings |\n| Shared responsibility | Cloud provider secures infrastructure; customer secures data and access |\n| Evidence volatility | Cloud resources can be terminated; evidence must be preserved quickly |\n| Multi-region artifacts | Attacks may span regions requiring cross-region log collection |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| AWS CLI | Command-line interface for AWS service interaction and log collection |\n| CloudTrail | AWS API call logging service for investigation and auditing |\n| Azure Monitor | Azure logging and diagnostics platform |\n| GCP Cloud Logging | Google Cloud audit and access logging service |\n| Athena | AWS serverless SQL query service for analyzing CloudTrail logs at scale |\n| Prowler | Open-source AWS security assessment and forensic collection tool |\n| ScoutSuite | Multi-cloud security auditing tool |\n| CADO Response | Cloud-native digital forensics and incident response platform |\n\n## Common Scenarios\n\n**Scenario 1: Compromised IAM Access Keys**\nIdentify the compromised key in CloudTrail, trace all API calls made with the key, determine the source IPs and actions taken, check for persistence mechanisms (new users, roles, keys), revoke the compromised credentials, assess data access scope.\n\n**Scenario 2: Cryptojacking on EC2 Instances**\nDetect unauthorized instance launches in CloudTrail, snapshot the mining instances for analysis, examine security group changes that allowed C2 communication, identify the initial access vector (stolen keys, SSRF), calculate resource costs incurred.\n\n**Scenario 3: S3 Data Breach**\nAnalyze S3 access logs and CloudTrail for GetObject\u002FPutBucketPolicy events, identify who modified bucket policies to allow public access, determine the scope of data exposure, check for data downloads from unauthorized IPs, assess regulatory reporting requirements.\n\n**Scenario 4: Container Escape in EKS\u002FAKS\u002FGKE**\nCollect Kubernetes audit logs and cloud provider logs, analyze pod creation events for privilege escalation attempts, examine node-level logs for container escape evidence, check for unauthorized access to cloud metadata service (169.254.169.254), trace lateral movement to cloud APIs.\n\n## Output Format\n\n```\nCloud Forensics Summary:\n  Cloud: AWS (us-east-1) Account: 123456789012\n  Investigation: 2024-01-15 to 2024-01-20\n  Incident Type: IAM Credential Compromise + Data Exfiltration\n\n  Evidence Collected:\n    EBS Snapshots:    3 volumes preserved\n    CloudTrail Events: 12,456 (1,234 from attacker IP)\n    VPC Flow Logs:    45,678 records\n    S3 Access Logs:   2,345 entries\n\n  Attack Timeline:\n    2024-01-15 14:32 - Compromised access key first used from 203.0.113.45\n    2024-01-15 14:45 - New IAM user created with admin privileges\n    2024-01-16 02:00 - S3 bucket policy modified (public access enabled)\n    2024-01-16 03:00 - 12 GB downloaded from company-confidential bucket\n    2024-01-18 03:00 - CloudTrail logging disabled\n\n  Impact Assessment:\n    Data Exposed: 12 GB from 3 S3 buckets\n    Resources Created: 3 EC2 instances (crypto mining)\n    Estimated Cost: $4,500 in unauthorized compute\n```\n","# Performing Cloud Forensics Investigation\n\n## When to Use\n- When investigating a security breach in AWS, Azure, or GCP cloud environments\n- For collecting volatile and non-volatile evidence from cloud infrastructure\n- When tracing unauthorized access through cloud service API logs\n- During incident response requiring preservation of cloud-based evidence\n- For analyzing compromised virtual machines, containers, or serverless functions\n\n## Prerequisites\n- Administrative access to the cloud account under investigation\n- AWS CLI, Azure CLI, or gcloud CLI configured with appropriate permissions\n- Understanding of cloud-native logging (CloudTrail, Activity Log, Audit Log)\n- Forensic workstation with cloud SDKs installed\n- Knowledge of IAM, networking, and compute services in target cloud\n- Evidence preservation procedures for cloud environments\n\n## Workflow\n\n### Step 1: Preserve Cloud Evidence and Establish Scope\n\n```bash\n# === AWS Evidence Preservation ===\n# Snapshot compromised EC2 instance volumes\nINSTANCE_ID=\"i-0abc123def456789\"\nVOLUME_IDS=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID \\\n   --query 'Reservations[].Instances[].BlockDeviceMappings[].Ebs.VolumeId' --output text)\n\nfor vol in $VOLUME_IDS; do\n   aws ec2 create-snapshot --volume-id $vol \\\n      --description \"Forensic snapshot - Case 2024-001 - $(date -u)\" \\\n      --tag-specifications \"ResourceType=snapshot,Tags=[{Key=Case,Value=2024-001},{Key=Evidence,Value=true}]\"\ndone\n\n# Capture instance metadata\naws ec2 describe-instances --instance-ids $INSTANCE_ID \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Finstance_metadata.json\n\n# Capture security group rules\naws ec2 describe-security-groups --group-ids $(aws ec2 describe-instances \\\n   --instance-ids $INSTANCE_ID --query 'Reservations[].Instances[].SecurityGroups[].GroupId' --output text) \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fsecurity_groups.json\n\n# Capture network interfaces\naws ec2 describe-network-interfaces --filters \"Name=attachment.instance-id,Values=$INSTANCE_ID\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fnetwork_interfaces.json\n\n# Isolate the instance (replace security group with forensic isolation SG)\naws ec2 modify-instance-attribute --instance-id $INSTANCE_ID \\\n   --groups sg-forensic-isolation\n\n# === Azure Evidence Preservation ===\n# Snapshot a compromised VM disk\naz snapshot create --resource-group forensics-rg \\\n   --name \"case-2024-001-osdisk-snapshot\" \\\n   --source \"\u002Fsubscriptions\u002FSUB_ID\u002FresourceGroups\u002FRG\u002Fproviders\u002FMicrosoft.Compute\u002Fdisks\u002Fvm-osdisk\"\n\n# === GCP Evidence Preservation ===\ngcloud compute disks snapshot compromised-disk \\\n   --snapshot-names=\"case-2024-001-forensic\" \\\n   --zone=us-central1-a\n```\n\n### Step 2: Collect Cloud API and Access Logs\n\n```bash\n# === AWS CloudTrail Logs ===\n# Download CloudTrail events for the investigation period\naws cloudtrail lookup-events \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   --end-time \"2024-01-20T23:59:59Z\" \\\n   --max-results 1000 \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_events.json\n\n# Filter for specific user activity\naws cloudtrail lookup-events \\\n   --lookup-attributes AttributeKey=Username,AttributeValue=compromised-user \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fuser_activity.json\n\n# Download S3 access logs\naws s3 sync s3:\u002F\u002Fmy-cloudtrail-bucket\u002FAWSLogs\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_s3\u002F\n\n# Query CloudTrail with Athena for large-scale analysis\naws athena start-query-execution \\\n   --query-string \"SELECT eventTime, eventName, userIdentity.arn, sourceIPAddress, errorCode\n                   FROM cloudtrail_logs\n                   WHERE eventTime BETWEEN '2024-01-15' AND '2024-01-20'\n                   AND sourceIPAddress NOT IN ('10.0.0.0\u002F8')\n                   ORDER BY eventTime\" \\\n   --result-configuration OutputLocation=s3:\u002F\u002Fforensics-bucket\u002Fathena-results\u002F\n\n# === AWS VPC Flow Logs ===\naws logs filter-log-events \\\n   --log-group-name \"vpc-flow-logs\" \\\n   --start-time $(date -d \"2024-01-15\" +%s000) \\\n   --end-time $(date -d \"2024-01-20\" +%s000) \\\n   --filter-pattern \"ACCEPT\" \\\n   > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fvpc_flow_logs.json\n\n# === Azure Activity Log ===\naz monitor activity-log list \\\n   --start-time \"2024-01-15T00:00:00Z\" \\\n   --end-time \"2024-01-20T23:59:59Z\" \\\n   --output json > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fazure_activity.json\n\n# === GCP Audit Logs ===\ngcloud logging read 'logName=\"projects\u002FPROJECT_ID\u002Flogs\u002Fcloudaudit.googleapis.com%2Factivity\"\n   AND timestamp>=\"2024-01-15T00:00:00Z\"\n   AND timestamp\u003C=\"2024-01-20T23:59:59Z\"' \\\n   --format=json > \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fgcp_audit.json\n```\n\n### Step 3: Analyze IAM and Access Patterns\n\n```bash\n# Analyze compromised credentials usage\npython3 \u003C\u003C 'PYEOF'\nimport json\nfrom collections import defaultdict\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloudtrail_events.json') as f:\n    data = json.load(f)\n\n# Analyze by source IP\nip_events = defaultdict(list)\nerror_events = []\ncritical_actions = []\n\nfor event in data.get('Events', []):\n    ct = json.loads(event.get('CloudTrailEvent', '{}'))\n    source_ip = ct.get('sourceIPAddress', 'Unknown')\n    event_name = ct.get('eventName', 'Unknown')\n    user_arn = ct.get('userIdentity', {}).get('arn', 'Unknown')\n    error = ct.get('errorCode')\n    timestamp = ct.get('eventTime', '')\n\n    ip_events[source_ip].append(event_name)\n\n    if error:\n        error_events.append({'time': timestamp, 'action': event_name, 'error': error, 'ip': source_ip})\n\n    # Flag critical actions\n    critical = ['CreateUser', 'CreateAccessKey', 'AttachUserPolicy', 'CreateRole',\n                'PutBucketPolicy', 'StopLogging', 'DeleteTrail', 'CreateKeyPair',\n                'RunInstances', 'AuthorizeSecurityGroupIngress']\n    if event_name in critical:\n        critical_actions.append({'time': timestamp, 'action': event_name, 'user': user_arn, 'ip': source_ip})\n\nprint(\"=== SOURCE IP ANALYSIS ===\")\nfor ip, events in sorted(ip_events.items(), key=lambda x: len(x[1]), reverse=True):\n    print(f\"  {ip}: {len(events)} events ({len(set(events))} unique actions)\")\n\nprint(f\"\\n=== ACCESS ERRORS ({len(error_events)} total) ===\")\nfor e in error_events[:10]:\n    print(f\"  [{e['time']}] {e['action']} -> {e['error']} from {e['ip']}\")\n\nprint(f\"\\n=== CRITICAL ACTIONS ({len(critical_actions)} total) ===\")\nfor a in critical_actions:\n    print(f\"  [{a['time']}] {a['action']} by {a['user']} from {a['ip']}\")\nPYEOF\n```\n\n### Step 4: Acquire and Analyze VM Disk Image\n\n```bash\n# Create a forensic analysis instance from the snapshot\nSNAPSHOT_ID=\"snap-0abc123def456789\"\n\n# Create volume from snapshot in isolated forensic VPC\nFORENSIC_VOL=$(aws ec2 create-volume --snapshot-id $SNAPSHOT_ID \\\n   --availability-zone us-east-1a \\\n   --tag-specifications \"ResourceType=volume,Tags=[{Key=Case,Value=2024-001}]\" \\\n   --query 'VolumeId' --output text)\n\n# Attach to forensic analysis instance (read-only mount)\naws ec2 attach-volume --volume-id $FORENSIC_VOL \\\n   --instance-id i-forensic-workstation \\\n   --device \u002Fdev\u002Fxvdf\n\n# On the forensic instance, mount read-only\nsudo mount -o ro \u002Fdev\u002Fxvdf1 \u002Fmnt\u002Fevidence\n\n# Perform standard disk forensics on the mounted volume\n# Extract logs, analyze file system, check for persistence\nls \u002Fmnt\u002Fevidence\u002Fvar\u002Flog\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fvar\u002Flog\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fvm_logs\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fetc\u002Fcrontab \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fpersistence\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fhome\u002F*\u002F.ssh\u002F \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fssh_keys\u002F\ncp -r \u002Fmnt\u002Fevidence\u002Fhome\u002F*\u002F.bash_history \u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fbash_history\u002F\n```\n\n### Step 5: Generate Cloud Forensics Report\n\n```bash\n# Compile findings into structured report\npython3 \u003C\u003C 'PYEOF'\nreport = \"\"\"\nCLOUD FORENSICS INVESTIGATION REPORT\n======================================\nCase: 2024-001\nCloud Provider: AWS (Account: 123456789012)\nRegion: us-east-1\nInvestigation Period: 2024-01-15 to 2024-01-20\n\nEVIDENCE PRESERVED:\n- EC2 Instance Snapshot: snap-0abc123def456789 (i-0abc123def456789)\n- CloudTrail Logs: 2024-01-15 to 2024-01-20\n- VPC Flow Logs: 2024-01-15 to 2024-01-20\n- Instance Metadata: captured and hashed\n- Security Group Configuration: captured at time of isolation\n\nFINDINGS:\n1. Initial Access:\n   - Compromised IAM access key AKIA... used from IP 203.0.113.45\n   - First unauthorized API call: 2024-01-15 14:32:00 UTC\n   - IP geolocation: Foreign jurisdiction (not company IP range)\n\n2. Persistence:\n   - New IAM user 'backup-admin' created with AdministratorAccess\n   - New access key pair generated for backup-admin\n   - SSH key added to EC2 instance authorized_keys\n\n3. Lateral Movement:\n   - S3 bucket policies modified to allow public access\n   - Security group rules modified to allow SSH from 0.0.0.0\u002F0\n   - 3 additional EC2 instances launched for crypto-mining\n\n4. Data Exfiltration:\n   - S3 bucket 'company-confidential' accessed 234 times\n   - 12 GB of data downloaded via GetObject API calls\n   - Data transferred to external IP 185.x.x.x\n\n5. Anti-Forensics:\n   - CloudTrail logging disabled at 2024-01-18 03:00 UTC\n   - CloudWatch log groups deleted\n\nRECOMMENDATIONS:\n- Rotate all IAM credentials immediately\n- Enable MFA on all accounts\n- Restore CloudTrail logging\n- Review and restrict S3 bucket policies\n- Implement GuardDuty for continuous monitoring\n\"\"\"\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Fcloud\u002Fcloud_forensics_report.txt', 'w') as f:\n    f.write(report)\nprint(report)\nPYEOF\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| Cloud API logging | Service logs recording all API calls (CloudTrail, Activity Log, Audit Log) |\n| Volume snapshots | Point-in-time copies of cloud disk volumes for forensic preservation |\n| VPC Flow Logs | Network traffic metadata logs showing source, destination, and action |\n| IAM credential compromise | Unauthorized use of access keys, tokens, or assumed roles |\n| Instance metadata | EC2\u002FVM configuration data including network, storage, and security settings |\n| Shared responsibility | Cloud provider secures infrastructure; customer secures data and access |\n| Evidence volatility | Cloud resources can be terminated; evidence must be preserved quickly |\n| Multi-region artifacts | Attacks may span regions requiring cross-region log collection |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| AWS CLI | Command-line interface for AWS service interaction and log collection |\n| CloudTrail | AWS API call logging service for investigation and auditing |\n| Azure Monitor | Azure logging and diagnostics platform |\n| GCP Cloud Logging | Google Cloud audit and access logging service |\n| Athena | AWS serverless SQL query service for analyzing CloudTrail logs at scale |\n| Prowler | Open-source AWS security assessment and forensic collection tool |\n| ScoutSuite | Multi-cloud security auditing tool |\n| CADO Response | Cloud-native digital forensics and incident response platform |\n\n## Common Scenarios\n\n**Scenario 1: Compromised IAM Access Keys**\nIdentify the compromised key in CloudTrail, trace all API calls made with the key, determine the source IPs and actions taken, check for persistence mechanisms (new users, roles, keys), revoke the compromised credentials, assess data access scope.\n\n**Scenario 2: Cryptojacking on EC2 Instances**\nDetect unauthorized instance launches in CloudTrail, snapshot the mining instances for analysis, examine security group changes that allowed C2 communication, identify the initial access vector (stolen keys, SSRF), calculate resource costs incurred.\n\n**Scenario 3: S3 Data Breach**\nAnalyze S3 access logs and CloudTrail for GetObject\u002FPutBucketPolicy events, identify who modified bucket policies to allow public access, determine the scope of data exposure, check for data downloads from unauthorized IPs, assess regulatory reporting requirements.\n\n**Scenario 4: Container Escape in EKS\u002FAKS\u002FGKE**\nCollect Kubernetes audit logs and cloud provider logs, analyze pod creation events for privilege escalation attempts, examine node-level logs for container escape evidence, check for unauthorized access to cloud metadata service (169.254.169.254), trace lateral movement to cloud APIs.\n\n## Output Format\n\n```\nCloud Forensics Summary:\n  Cloud: AWS (us-east-1) Account: 123456789012\n  Investigation: 2024-01-15 to 2024-01-20\n  Incident Type: IAM Credential Compromise + Data Exfiltration\n\n  Evidence Collected:\n    EBS Snapshots:    3 volumes preserved\n    CloudTrail Events: 12,456 (1,234 from attacker IP)\n    VPC Flow Logs:    45,678 records\n    S3 Access Logs:   2,345 entries\n\n  Attack Timeline:\n    2024-01-15 14:32 - Compromised access key first used from 203.0.113.45\n    2024-01-15 14:45 - New IAM user created with admin privileges\n    2024-01-16 02:00 - S3 bucket policy modified (public access enabled)\n    2024-01-16 03:00 - 12 GB downloaded from company-confidential bucket\n    2024-01-18 03:00 - CloudTrail logging disabled\n\n  Impact Assessment:\n    Data Exposed: 12 GB from 3 S3 buckets\n    Resources Created: 3 EC2 instances (crypto mining)\n    Estimated Cost: $4,500 in unauthorized compute\n```\n",{"name":5,"tags":25,"author":33,"domain":34,"license":15,"version":35,"subdomain":36,"description":7},[26,27,28,29,30,31,32],"forensics","cloud-forensics","aws","azure","gcp","incident-response","log-analysis","mahipal","cybersecurity","1.0","digital-forensics","main","c2b1fdccc779e99ac814e55fb69ca8d71215dd0f","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection","https:\u002F\u002Fgithub.com\u002FSamuelChien","http:\u002F\u002Fsamuelchien.com\u002F","2026-05-26 08:27:14",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add SamuelChien\u002Fmega-skills-collection --skill performing-cloud-forensics-investigation",{"tool":49,"command":50},"bunx","bunx skills add SamuelChien\u002Fmega-skills-collection --skill performing-cloud-forensics-investigation",{"tool":52,"command":53},"pnpm","pnpm dlx skills add SamuelChien\u002Fmega-skills-collection --skill performing-cloud-forensics-investigation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fperforming-cloud-forensics-investigation\u002FSKILL.md",true,[57,61,67],{"path":58,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fapi-reference.md","REFERENCE","参考文档",2483,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fperforming-cloud-forensics-investigation\u002Freferences\u002Fapi-reference.md",{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"scripts\u002Fagent.py","SCRIPT","脚本",8645,"https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fperforming-cloud-forensics-investigation\u002Fscripts\u002Fagent.py",[74,82,89,96,103,110],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":20},"01M76R4WZQZAXGGXMQCA0FZ716","zustand-store-ts","Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state\u002Faction separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.","MIT","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-ts\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":20},"01M76R4T9KENDH7FENGZQHBW4G","zustand-store-creator","Zustand Store Creator - Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":20},"01M76R3YWN84B7SANJ52X799ZE","zero-trust-config-helper","Zero Trust Config Helper - Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":20},"01M76R3HNSV2AEYSKHM915GJ58","zapier-integration-helper","Zapier Integration Helper - Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":20},"01M76R3DJSKAT4FA7DV4BF3GCE","zai-cli","Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP.\nUse when user needs image\u002Fvideo analysis, OCR, UI-to-code conversion, error diagnosis,\nreal-time web search, web page to markdown extraction, or GitHub code exploration.\nTrigger with phrases like \"analyze this image\", \"search the web for\", \"read this page\",\n\"explore this repo\", or \"use zai\". Requires Z_AI_API_KEY.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fzai-cli\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":20},"01M76R2KAM699XE9AJVAWE4H2E","yt-research","Research competitor YouTube channels, niches, and trending topics for your content strategy.\nUse this skill whenever the user says \"research channels\", \"analyze competitors\", \"find trending topics\",\n\"niche analysis\", \"competitive research\", \"what are other creators doing\", \"scrape YouTube channels\",\nor wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.","https:\u002F\u002Fgithub.com\u002FSamuelChien\u002Fmega-skills-collection\u002Fblob\u002Fmain\u002Fyt-research\u002FSKILL.md",[],[]]