
모든 AWS 계정 내 리소스에 대한 분석을 수행하여 고립된 탄력적 IP를 제거합니다.
모든 AWS 계정 내 리소스를 분석하여 유령 탄력적 IP(dangling elastic IP)를 제거합니다.
Ghostbuster는 모든 AWS 계정(Route53)에 있는 모든 DNS 레코드를 수집하고, 선택적으로 CSV 입력 또는 Cloudflare를 통해 레코드를 받을 수 있습니다.
레코드가 수집된 후, Ghostbuster는 모든 AWS 탄력적 IP 및 네트워크 인터페이스 공용 IP를 반복하여 이 데이터를 수집합니다.
DNS 레코드(route53, 파일 입력 또는 Cloudflare에서)의 전체 그림과 조직이 소유한 AWS IP의 전체 그림을 확보함으로써 이 도구는 더 이상 소유하지 않는 IP(유령 탄력적 IP)를 가리키는 하위 도메인을 감지할 수 있습니다.
AWS에 인프라를 배포할 때 IP가 연결된 EC2 인스턴스를 생성할 수 있습니다. 이러한 IP를 가리키는 DNS 레코드를 생성했지만 EC2 인스턴스에 새 IP가 할당되거나 파괴된 후 DNS 레코드를 제거하는 것을 잊으면 하위 도메인 탈취 공격에 취약해집니다.
탄력적 IP 탈취에 대한 많은 연구가 진행되었으며, 공격자가 대상 회사의 하위 도메인과 연결된 IP를 얻을 때까지 지속적으로 탄력적 IP를 요청하는 것이 가능합니다.
AWS는 이러한 공격 패턴을 시도하는 계정을 자주 차단하지만, AWS에서 장기적인 해결책을 발표하지는 않았습니다.
유령 탄력적 IP 하위 도메인 탈취 공격의 영향은 일반적으로 제공되는 콘텐츠만 제어할 수 있는 일반적인 하위 도메인 탈취보다 더 심각합니다. 유령 탄력적 IP 탈취를 통해 공격자는 다음을 수행할 수 있습니다:
*.domain.com 범위의 쿠키로 인해 한 번의 클릭으로 계정 탈취 공격으로 이어짐.aws/config에 구성된 각 AWS 프로필을 동적으로 반복중요:
이 도구가 효과적으로 작동하려면 AWS 환경의 전체 그림을 가지고 있어야 합니다. 전체 그림이 없으면 오탐(false positive) 결과가 발생할 수 있습니다.
Ghostbuster 설치는 pip install ghostbuster 명령을 실행하는 것만큼 간단합니다. 그러면 CLI 도구를 ghostbuster 명령으로 사용할 수 있습니다.
Python 3.x 환경이 필요합니다.
❯ ghostbuster scan aws --help
Usage: ghostbuster scan aws [OPTIONS]
AWS 계정 내 유령 탄력적 IP를 스캔합니다.
Options:
--profile TEXT ghostbuster를 실행할 특정 AWS 프로필을 지정합니다.
--skipascii Ghostbuster 시작 시 ASCII 아트를 출력하지 않습니다.
--json JSON 객체만 반환합니다.
--slackwebhook TEXT 잠재적 탈취에 대한 알림을 보낼 Slack 웹훅 URL을
지정합니다.
--records PATH 확인할 DNS 레코드를 수동으로 지정합니다.
Ghostbuster는 검색된 DNS 레코드를 확인한 후 이
IP들을 확인합니다. 예시는 records.csv를 참조하세요.
--cloudflaretoken TEXT Cloudflare에서 DNS 레코드를 가져옵니다. CF API
토큰을 제공하세요.
--allregions 모든 리전에서 실행합니다.
--exclude TEXT 제외할 프로필 이름의 쉼표로 구분된 목록입니다.
--regions TEXT 실행할 리전의 쉼표로 구분된 목록입니다.
--help 이 메시지를 표시하고 종료합니다.
명령 예시
Cloudflare DNS 레코드에 접근하여 Ghostbuster를 실행하고, Slack 웹훅에 알림을 보내며, .aws/config 또는 .aws/credentials에 구성된 모든 AWS 프로필을 모든 AWS 리전에 대해 반복합니다.
❯ ghostbuster scan aws --cloudflaretoken APIKEY --slackwebhook https://hooks.slack.com/services/KEY --allregions
수동으로 입력한 하위 도메인 A 레코드 목록으로 Ghostbuster 실행 (예제 파일은 이 저장소의 records.csv 참조):
❯ ghostbuster scan aws --records records.csv
--regions를 사용하여 특정 리전을 지정할 수 있습니다. 쉼표로 구분된 리전 목록입니다. 예: us-east-1,us-west-1.
❯ ghostbuster scan aws --cloudflaretoken whougonnacall
Obtaining all zone names from Cloudflare.
Obtaining DNS A records for all zones from Cloudflare.
Obtained 33 DNS A records so far.
Obtaining Route53 hosted zones for AWS profile: default.
Obtaining Route53 hosted zones for AWS profile: account-five.
Obtaining Route53 hosted zones for AWS profile: account-four.
Obtaining Route53 hosted zones for AWS profile: account-four-deploy.
Obtaining Route53 hosted zones for AWS profile: account-two-deploy.
Obtaining Route53 hosted zones for AWS profile: account-one-deploy.
Obtaining Route53 hosted zones for AWS profile: account-three-deploy.
Obtaining Route53 hosted zones for AWS profile: account-six.
Obtaining Route53 hosted zones for AWS profile: account-seven.
Obtaining Route53 hosted zones for AWS profile: account-one.
Obtained 124 DNS A records so far.
Obtaining EIPs for region: us-east-1, profile: default
Obtaining IPs for network interfaces for region: us-east-1, profile: default
Obtaining EIPs for region: us-east-1, profile: account-five
Obtaining IPs for network interfaces for region: us-east-1, profile: account-five
Obtaining EIPs for region: us-east-1, profile: account-four
Obtaining IPs for network interfaces for region: us-east-1, profile: account-four
Obtaining EIPs for region: us-east-1, profile: account-four-deploy
Obtaining IPs for network interfaces for region: us-east-1, profile: account-four-deploy
Obtaining EIPs for region: us-east-1, profile: account-two-deploy
Obtaining IPs for network interfaces for region: us-east-1, profile: account-two-deploy
Obtaining EIPs for region: us-east-1, profile: account-one-deploy
Obtaining IPs for network interfaces for region: us-east-1, profile: account-one-deploy
Obtaining EIPs for region: us-east-1, profile: account-three-deploy
Obtaining IPs for network interfaces for region: us-east-1, profile: account-three-deploy
Obtaining EIPs for region: us-east-1, profile: account-six
Obtaining IPs for network interfaces for region: us-east-1, profile: account-six
Obtaining EIPs for region: us-east-1, profile: account-seven
Obtaining IPs for network interfaces for region: us-east-1, profile: account-seven
Obtaining EIPs for region: us-east-1, profile: account-one
Obtaining IPs for network interfaces for region: us-east-1, profile: account-one
Obtained 415 unique elastic IPs from AWS.
Takeover possible: {'name': 'takeover.assetnotecloud.com', 'records': ['52.54.24.193']}
첫 번째 단계는 AWS 계정에서 Route53 레코드를 읽고 탄력적 주소와 EC2 네트워크 인터페이스를 설명하는 데 필요한 권한을 부여하는 키 또는 역할을 생성하는 것입니다.
액세스 키 - 프로그래밍 방식 액세스만 선택하고 다음: 권한을 클릭합니다.기존 정책 직접 연결을 클릭한 다음 정책 생성을 클릭합니다.JSON을 클릭하고 다음 정책을 붙여넣습니다:{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GhostbusterPolicy",
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:DescribeNetworkInterfaces",
"route53:ListResourceRecordSets",
"route53:ListHostedZonesByName",
"route53:GetTrafficPolicyInstance",
"route53:GetTrafficPolicy"
],
"Resource": "*"
}
]
}
다음: 태그를 클릭한 다음 다음: 검토를 클릭합니다.GhostbusterPolicy로 설정합니다.정책 생성을 클릭합니다.GhostbusterPolicy를 선택합니다.다음: 태그를 클릭한 다음 다음: 검토를 클릭합니다.사용자 생성을 클릭하고 .aws/credentials 파일에 AWS 자격 증명을 설정합니다.소유한 각 AWS 계정에 대해 위 단계를 반복합니다.
이 도구는 AWS 구성을 설정한 방식(여러 키 또는 교차 계정 역할 가장 프로필)에 관계없이 작동합니다. 이는 AWS와 인터페이스하는 데 사용되는 라이브러리인 boto3에 의해 관리됩니다.
예제 구성은 다음과 같습니다:
.aws/credentials:
[default]
aws_access_key_id = AKIAIII...
aws_secret_access_key = faAaAaA...
.aws/config:
[default]
output = table
region = us-east-1
[profile account-one]
role_arn = arn:aws:iam::911111111113:role/Ec2Route53Access
source_profile = default
region = us-east-1
[profile account-two]
role_arn = arn:aws:iam::911111111112:role/Ec2Route53Access
source_profile = default
region = us-east-1
[profile account-three]
region = us-east-1
role_arn = arn:aws:iam::911111111111:role/Ec2Route53Access
source_profile = default