AWS - GuardDuty Enum
Reading time: 9 minutes
tip
AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
GuardDuty
According to the docs: GuardDuty는 기계 학습, 이상 탐지, 네트워크 모니터링 및 악성 파일 발견을 결합하여 AWS 및 업계 최고의 제3자 소스를 사용하여 AWS의 워크로드와 데이터를 보호하는 데 도움을 줍니다. GuardDuty는 AWS CloudTrail 이벤트 로그, Amazon Virtual Private Cloud (VPC) 흐름 로그, Amazon Elastic Kubernetes Service (EKS) 감사 및 시스템 수준 로그, DNS 쿼리 로그와 같은 여러 AWS 데이터 소스에서 수십억 개의 이벤트를 분석할 수 있습니다.
Amazon GuardDuty는 계정 내의 비정상적인 활동을 식별하고, 활동의 보안 관련성을 분석하며, 그것이 호출된 맥락을 제공합니다. 이를 통해 응답자는 추가 조사를 위해 시간을 할애해야 하는지 결정할 수 있습니다.
알림은 GuardDuty 콘솔(90일) 및 CloudWatch Events에 나타납니다.
warning
사용자가 GuardDuty를 비활성화하면 AWS 환경 모니터링이 중단되고 새로운 발견 사항이 전혀 생성되지 않으며, 기존 발견 사항이 손실됩니다.
단순히 중지하면 기존 발견 사항은 유지됩니다.
Findings Example
- Reconnaissance: 공격자가 수행하는 정찰을 나타내는 활동으로, 비정상적인 API 활동, 의심스러운 데이터베이스 로그인 시도, intra-VPC 포트 스캐닝, 비정상적인 실패한 로그인 요청 패턴 또는 알려진 나쁜 IP에서의 차단되지 않은 포트 프로빙 등이 포함됩니다.
- Instance compromise: 암호화폐 채굴, 백도어 명령 및 제어(C&C) 활동, 도메인 생성 알고리즘(DGA)을 사용하는 악성 소프트웨어, 아웃바운드 서비스 거부 활동, 비정상적으로 높은 네트워크 트래픽 볼륨, 비정상적인 네트워크 프로토콜, 알려진 악성 IP와의 아웃바운드 인스턴스 통신, 외부 IP 주소에 의해 사용된 임시 Amazon EC2 자격 증명, DNS를 통한 데이터 유출 등을 나타내는 활동입니다.
- Account compromise: 계정 손상을 나타내는 일반적인 패턴에는 비정상적인 지리적 위치 또는 익명화 프록시에서의 API 호출, AWS CloudTrail 로깅 비활성화 시도, 계정 비밀번호 정책을 약화시키는 변경, 비정상적인 인스턴스 또는 인프라 출시, 비정상적인 지역에서의 인프라 배포, 자격 증명 도용, 의심스러운 데이터베이스 로그인 활동, 알려진 악성 IP 주소에서의 API 호출 등이 포함됩니다.
- Bucket compromise: 자격 증명 남용을 나타내는 의심스러운 데이터 접근 패턴, 원격 호스트에서의 비정상적인 Amazon S3 API 활동, 알려진 악성 IP 주소에서의 무단 S3 접근, 이전에 버킷에 접근한 이력이 없는 사용자로부터 S3 버킷의 데이터를 검색하기 위한 API 호출 또는 비정상적인 위치에서 호출된 경우를 포함하여 버킷 손상을 나타내는 활동입니다. Amazon GuardDuty는 모든 Amazon S3 버킷에서 의심스러운 활동을 탐지하기 위해 AWS CloudTrail S3 데이터 이벤트(예: GetObject, ListObjects, DeleteObject)를 지속적으로 모니터링하고 분석합니다.
Finding Information
Finding summary:
- Finding type
- Severity: 7-8.9 High, 4-6.9 Medium, 01-3.9 Low
- Region
- Account ID
- Resource ID
- Time of detection
- Which threat list was used
The body has this information:
- Resource affected
- Action
- Actor: Ip address, port and domain
- Additional Information
All Findings
Access a list of all the GuardDuty findings in: https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html
Multi Accounts
By Invitation
다른 AWS GuardDuty 계정에 다른 계정을 초대하여 모든 계정이 동일한 GuardDuty에서 모니터링되도록 할 수 있습니다. 마스터 계정이 멤버 계정을 초대해야 하며, 멤버 계정의 대표가 초대를 수락해야 합니다.
Via Organization
조직 내의 어떤 계정이든 GuardDuty 위임 관리자로 지정할 수 있습니다. 오직 조직 관리 계정만이 위임 관리자를 지정할 수 있습니다.
위임 관리자 계정으로 지정된 계정은 GuardDuty 관리자 계정이 되며, 지정된 AWS 리전에서 GuardDuty가 자동으로 활성화되고, 해당 리전 내의 모든 계정에 대해 GuardDuty를 활성화하고 관리할 권한을 갖습니다. 조직 내의 다른 계정은 이 위임 관리자 계정과 연결된 GuardDuty 멤버 계정으로 조회하고 추가할 수 있습니다.
Enumeration
# Get Org config
aws guardduty list-organization-admin-accounts #Get Delegated Administrator
aws guardduty describe-organization-configuration --detector-id <id>
# Check external invitations
aws guardduty list-invitations
aws guardduty get-invitations-count
# Detector Information
aws guardduty list-detectors # 1 detector per account with GuardDuty
aws guardduty get-detector --detector-id <id> # Get detector info
aws guardduty get-master-account --detector-id <id>
# Get filters
aws guardduty list-filters --detector-id <id> # Check filters
aws guardduty get-filter --detector-id <id> --filter-name <name>
# Findings
aws guardduty list-findings --detector-id <id> # List findings
aws guardduty get-findings --detector-id <id> --finding-ids <id> # Get details about the finding
aws guardduty get-findings-statistics --detector-id <id> --finding-statistic-types <types>
# Get trusted IP addresses
aws guardduty list-ip-sets --detector-id <id>
aws guardduty get-ip-set --detector-id <id>
# Member accounts of the current AWS GuardDuty master account
aws guardduty list-members --detector-id <id>
aws guardduty get-members --detector-id <id> --account-ids <id>
aws guardduty get-member-detectors --detector-id <id> --account-ids <id>
# Continuously export its findings to an Amazon S3 bucket
aws guardduty list-publishing-destinations --detector-id <id>
# Intelligence sets that you have uploaded to GuardDuty
aws guardduty list-threat-intel-sets --detector-id <id>
aws guardduty get-threat-intel-set --detector-id <id> --threat-intel-set-id <id>
GuardDuty 우회
일반 지침
사용할 자격 증명의 행동에 대해 가능한 한 많은 정보를 찾아보세요:
- 사용 시간
- 위치
- 사용자 에이전트 / 서비스 (awscli, 웹 콘솔, lambda 등에서 사용될 수 있음)
- 정기적으로 사용되는 권한
이 정보를 바탕으로 접근을 사용하기 위해 가능한 한 동일한 시나리오를 재현하세요:
- 사용자에 의해 접근된 사용자 또는 역할인 경우, 동일한 시간에 동일한 지리적 위치(가능하다면 동일한 ISP와 IP)에서 사용해 보세요.
- 서비스에 의해 사용되는 역할인 경우, 동일한 지역에 동일한 서비스를 생성하고 동일한 시간대에서 사용하세요.
- 항상 이 주체가 사용한 동일한 권한을 사용하려고 하세요.
- 다른 권한을 사용하거나 권한을 남용해야 하는 경우(예: 1,000,000개의 cloudtrail 로그 파일 다운로드), 천천히 진행하고 AWS와의 최소한의 상호작용으로 수행하세요 (awscli는 때때로 쓰기 전에 여러 읽기 API를 호출합니다).
GuardDuty 무력화
guardduty:UpdateDetector
이 권한을 사용하면 경고를 트리거하지 않기 위해 GuardDuty를 비활성화할 수 있습니다.
aws guardduty update-detector --detector-id <detector-id> --no-enable
aws guardduty update-detector --detector-id <detector-id> --data-sources S3Logs={Enable=false}
guardduty:CreateFilter
이 권한을 가진 공격자는 발견 사항의 자동 아카이빙을 위한 필터를 사용할 수 있는 능력을 가지고 있습니다:
aws guardduty create-filter --detector-id <detector-id> --name <filter-name> --finding-criteria file:///tmp/criteria.json --action ARCHIVE
iam:PutRolePolicy
, (guardduty:CreateIPSet
|guardduty:UpdateIPSet
)
이전 권한을 가진 공격자는 GuardDuty의 신뢰할 수 있는 IP 목록을 수정하여 자신의 IP 주소를 추가하고 경고 생성을 피할 수 있습니다.
aws guardduty update-ip-set --detector-id <detector-id> --activate --ip-set-id <ip-set-id> --location https://some-bucket.s3-eu-west-1.amazonaws.com/attacker.csv
guardduty:DeletePublishingDestination
공격자는 경고를 방지하기 위해 대상을 제거할 수 있습니다:
aws guardduty delete-publishing-destination --detector-id <detector-id> --destination-id <dest-id>
caution
이 게시 목적지를 삭제해도 GuardDuty 콘솔 내에서 발견 사항의 생성이나 가시성에 영향을 미치지 않습니다. GuardDuty는 AWS 환경 내에서 이벤트를 계속 분석하고, 의심스럽거나 예상치 못한 행동을 식별하며, 발견 사항을 생성합니다.
특정 발견 우회 예시
수십 가지의 GuardDuty 발견 사항이 있지만, Red Teamer로서 모든 것이 당신에게 영향을 미치지는 않습니다, 그리고 더 좋은 점은, 각 발견 사항에 대한 전체 문서가 있습니다 https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html 그러니 행동을 취하기 전에 확인하여 걸리지 않도록 하세요.
여기 특정 GuardDuty 발견 사항 우회의 몇 가지 예가 있습니다:
PenTest:IAMUser/KaliLinux
GuardDuty는 일반적인 침투 테스트 도구로부터의 AWS API 요청을 감지하고 PenTest Finding을 트리거합니다.
이는 API 요청에 전달된 사용자 에이전트 이름에 의해 감지됩니다.
따라서, 사용자 에이전트를 수정하면 GuardDuty가 공격을 감지하지 못하도록 할 수 있습니다.
이를 방지하기 위해 botocore
패키지의 session.py
스크립트에서 사용자 에이전트를 수정하거나, Burp Suite를 AWS CLI 프록시로 설정하고 MitM을 사용하여 사용자 에이전트를 변경하거나, Ubuntu, Mac 또는 Windows와 같은 OS를 사용하면 이 경고가 발생하지 않도록 할 수 있습니다.
UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration
메타데이터 서비스에서 EC2 자격 증명을 추출하고 AWS 환경 외부에서 활용하면 UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.OutsideAWS
경고가 활성화됩니다. 반대로, EC2 인스턴스에서 이러한 자격 증명을 사용하면 UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.InsideAWS
경고가 발생합니다. 그러나 같은 계정 내의 다른 손상된 EC2 인스턴스에서 자격 증명을 사용하면 감지되지 않으며, 경고가 발생하지 않습니다.
tip
따라서, 발견한 기계 내부에서 유출된 자격 증명을 사용하여 이 경고를 발생시키지 않도록 하세요.
References
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-active.html
- https://docs.aws.amazon.com/guardduty/latest/ug/findings_suppression-rule.html
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_upload-lists.html
- https://docs.aws.amazon.com/cli/latest/reference/guardduty/delete-publishing-destination.html
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-ec2.html#unauthorizedaccess-ec2-torclient
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-iam.html#unauthorizedaccess-iam-instancecredentialexfiltrationoutsideaws
- https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_finding-types-iam.html#unauthorizedaccess-iam-instancecredentialexfiltrationinsideaws
- https://docs.aws.amazon.com/whitepapers/latest/aws-privatelink/what-are-vpc-endpoints.html
tip
AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE)
GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE)
Azure 해킹 배우기 및 연습하기:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks 지원하기
- 구독 계획 확인하기!
- **💬 Discord 그룹 또는 텔레그램 그룹에 참여하거나 Twitter 🐦 @hacktricks_live를 팔로우하세요.
- HackTricks 및 HackTricks Cloud 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.