
모든 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
또는 역할을 가장하는 대신, .aws/credentials 파일에 범위가 지정된 액세스 권한이 있는 프로필 및 연결된 키 목록을 구성할 수도 있습니다.
AWS 환경의 모든 계정으로 AWS 구성을 설정한 후, 다음 명령을 사용하여 도구를 실행할 수 있습니다:
Ghostbuster는 프로필 대신 역할을 사용할 수 있으므로 한 곳에 많은 자격 증명이 필요하지 않습니다. 그러나 역할 접근 방식은 조직 내에서 추가 IAM 정책을 생성해야 합니다.
역할은 --roles roles.csv 또는 --autoroles 플래그를 사용하여 사용할 수 있습니다. --roles가 작동하도록 설정하려면 스캔되는 모든 계정에 정확히 같은 이름으로 GhostbusterTargetAccountRole 역할을 생성해야 합니다:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GhostbusterTargetAccountRole",
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:DescribeNetworkInterfaces",
"ec2:DescribeRegions",
"route53:ListResourceRecordSets",
"route53:ListHostedZonesByName",
"route53:GetTrafficPolicyInstance",
"route53:GetTrafficPolicy"
],
"Resource": "*"
}
]
}
ghostbuster는 lambda/ec2 등에서 ghostbuster 역할로 실행됩니다. 이 역할을 ghostbuster 마스터 역할이라고 부르겠습니다. 마스터 역할은 TargetAccountRoles를 가장할 수 있어야 합니다.
resource "aws_iam_policy" "ghostbuster_target_account_roles" {
name = "ghostbuster_target_account_roles"
path = "/"
description = "DNS 및 탄력적 IP 데이터 검사 허용."
policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Resource" : ["arn:aws:iam::*:role/GhostbusterTargetAccountRole"]
}]
})
tags = {
Project = "ghostbuster"
}
}
자동 계정 검색에는 --roles에 비해 추가 권한이 필요합니다. --roles가 작동하도록 설정한 후, 조직 개요가 있는 계정에 다음 IAM 정책을 추가하는 것을 고려하세요:
{
sid = "BaseAccess"
actions = [
"organizations:DescribeAccount",
"organizations:ListAccounts"
]
resources = ["*"]
effect = "Allow"
}
}
그런 다음, ghostbuster를 실행하는 계정에서 ghostbuster 마스터 역할에 다음 정책을 연결하여 조직 조회 역할을 가장할 수 있도록 합니다:
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Resource" : ["arn:aws:iam::ORG_LOOKUP_ACCOUNT_ID:role/ghostbuster-org-role"]
}]
}
ORG_LOOKUP_ACCOUNT_ID를 실제 계정 ID로 바꾸는 것을 잊지 마세요.
Ghostbuster가 Cloudflare에 설정된 모든 A 레코드를 가져오게 하려면 영역을 읽을 수 있는 API 토큰을 설정해야 합니다.
https://dash.cloudflare.com/profile/api-tokens
아래 스크린샷과 같이 Cloudflare API 토큰을 설정하세요:

이 API 토큰을 얻은 후, 안전한 곳(비밀번호 관리자)에 기록해 두세요. Ghostbuster에서 사용하려면 cloudflaretoken 인수를 통해 전달하세요.
이 프로젝트에 참여한 기여자 목도 참조하세요.
GNU Affero General Public License
pip3 install virtualenv를 사용하여 virtualenv를 설치합니다.virtualenv venv를 사용하여 가상 환경을 생성합니다.. venv/bin/activate를 사용하여 가상 환경을 활성화합니다.pip3 install --editable .를 실행하여 ghostbuster를 설치합니다.