Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
ghostbuster — 通过分析你所有AWS账户中的资源,消除悬挂的弹性IP。 | Kitploit
工具/GitHubGitHub/assetnote/ghostbuster
侦察漏洞扫描器云安全子域名枚举DNS 分析
GitHubassetnote/ghostbuster

ghostbuster

通过分析你所有AWS账户中的资源,消除悬挂的弹性IP。

查看仓库
278361年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

目录

  • 目录
  • Ghostbuster
    • 问题描述
    • 项目特性
    • 安装 Ghostbuster
    • 使用 Ghostbuster
    • 输出示例
    • 设置 AWS 账户
    • 设置 Cloudflare(可选)
    • 作者
    • 许可证

Ghostbuster

通过分析你在所有 AWS 账户中的资源,消除悬挂的弹性 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 接管,攻击者可以:

  • 为子域名申请 SSL 证书
  • 监听所有端口的流量(可能发现仍发送到该子域名的敏感信息)
  • 运行服务器端脚本,能够窃取 HTTPOnly Cookie,当 cookie 的作用域为 *.domain.com 时,通常会导致一键账户接管攻击

项目特性

  • 动态遍历 .aws/config 中配置的每个 AWS 配置文件
  • 从 AWS Route53 拉取 A 记录
  • 从 Cloudflare 拉取 A 记录(可选)
  • 从 CSV 输入拉取 A 记录(可选)
  • 遍历所有区域、单个区域或逗号分隔的区域列表
  • 获取所有 AWS 账户关联的所有弹性 IP
  • 获取所有 AWS 账户关联的所有公共 IP
  • 交叉检查 DNS 记录与你组织拥有的 IP,以检测潜在的接管
  • 支持 Slack Webhook,发送接管通知

重要提示:

要使此工具有效,它必须拥有你 AWS 环境的完整视图。如果没有完整视图,将导致误报。

安装 Ghostbuster

安装 Ghostbuster 非常简单,只需运行:pip install ghostbuster。然后 CLI 工具可通过 ghostbuster 命令使用。

这需要 Python 3.x 环境。

使用 Ghostbuster

root@kitploit:~
❯ ghostbuster scan aws --help                                                                                                                                                                     
用法: ghostbuster scan aws [OPTIONS]

  扫描 AWS 账户中的悬挂弹性 IP。

选项:
  --profile TEXT          指定运行 ghostbuster 的特定 AWS 配置文件。
  --skipascii             启动时跳过打印 ASCII 艺术字。
  --json                  仅返回 JSON 对象。
  --slackwebhook TEXT     指定用于发送潜在接管通知的 Slack Webhook URL。
  --records PATH          手动指定要检查的 DNS 记录。Ghostbuster 将在检索到的 DNS 记录之后检查这些 IP。示例见 records.csv。
  --cloudflaretoken TEXT  从 Cloudflare 拉取 DNS 记录,提供 CF API 令牌。
  --allregions            在所有区域运行。
  --exclude TEXT          要排除的配置文件名称的逗号分隔列表。
  --regions TEXT          要运行的区域的逗号分隔列表。
  --help                  显示此消息并退出。

示例命令

运行 Ghostbuster,启用 Cloudflare DNS 记录访问,向 Slack Webhook 发送通知,遍历 .aws/config 或 .aws/credentials 中配置的每个 AWS 配置文件,针对所有 AWS 区域:

root@kitploit:~
❯ ghostbuster scan aws --cloudflaretoken APIKEY --slackwebhook https://hooks.slack.com/services/KEY --allregions

运行 Ghostbuster,并手动输入子域名 A 记录列表(示例文件见本仓库中的 records.csv):

root@kitploit:~
❯ ghostbuster scan aws --records records.csv

你可以使用 --regions 指定特定区域,设置为逗号分隔的区域列表,例如 us-east-1,us-west-1。

输出示例

root@kitploit:~
❯ ghostbuster scan aws --cloudflaretoken whougonnacall
正在从 Cloudflare 获取所有域名。
正在从 Cloudflare 获取所有区域的 DNS A 记录。
目前已获取 33 条 DNS A 记录。
正在获取 AWS 配置文件 default 的 Route53 托管区域。
正在获取 AWS 配置文件 account-five 的 Route53 托管区域。
正在获取 AWS 配置文件 account-four 的 Route53 托管区域。
正在获取 AWS 配置文件 account-four-deploy 的 Route53 托管区域。
正在获取 AWS 配置文件 account-two-deploy 的 Route53 托管区域。
正在获取 AWS 配置文件 account-one-deploy 的 Route53 托管区域。
正在获取 AWS 配置文件 account-three-deploy 的 Route53 托管区域。
正在获取 AWS 配置文件 account-six 的 Route53 托管区域。
正在获取 AWS 配置文件 account-seven 的 Route53 托管区域。
正在获取 AWS 配置文件 account-one 的 Route53 托管区域。
目前已获取 124 条 DNS A 记录。
正在获取区域 us-east-1 的 EIP,配置文件: default
正在获取区域 us-east-1 的网络接口 IP,配置文件: default
正在获取区域 us-east-1 的 EIP,配置文件: account-five
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-five
正在获取区域 us-east-1 的 EIP,配置文件: account-four
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-four
正在获取区域 us-east-1 的 EIP,配置文件: account-four-deploy
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-four-deploy
正在获取区域 us-east-1 的 EIP,配置文件: account-two-deploy
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-two-deploy
正在获取区域 us-east-1 的 EIP,配置文件: account-one-deploy
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-one-deploy
正在获取区域 us-east-1 的 EIP,配置文件: account-three-deploy
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-three-deploy
正在获取区域 us-east-1 的 EIP,配置文件: account-six
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-six
正在获取区域 us-east-1 的 EIP,配置文件: account-seven
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-seven
正在获取区域 us-east-1 的 EIP,配置文件: account-one
正在获取区域 us-east-1 的网络接口 IP,配置文件: account-one
从 AWS 获取到 415 个唯一的弹性 IP。


可能被接管: {'name': 'takeover.assetnotecloud.com', 'records': ['52.54.24.193']}

设置 AWS 账户

第一步是在你的 AWS 账户中创建密钥或角色,授予读取 Route53 记录、描述弹性地址和 EC2 网络接口所需的权限。

  1. 要创建新的 IAM 用户,请访问以下 URL:https://console.aws.amazon.com/iam/home#/users$new?step=details
  2. 仅选择 访问密钥 - 编程访问,然后点击 下一步:权限。
  3. 点击 直接附加现有策略,然后点击 创建策略。
  4. 点击 JSON,然后粘贴以下策略:
root@kitploit:~
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "GhostbusterPolicy",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeAddresses",
                "ec2:DescribeNetworkInterfaces",
                "route53:ListResourceRecordSets",
                "route53:ListHostedZonesByName",
                "route53:GetTrafficPolicyInstance",
                "route53:GetTrafficPolicy"
            ],
            "Resource": "*"
        }
    ]
}
  1. 点击 下一步:标签,然后点击 下一步:检查。
  2. 将策略名称设置为 GhostbusterPolicy。
  3. 点击 创建策略。
  4. 访问 https://console.aws.amazon.com/iam/home#/users$new?step=permissions&accessKey&userNames=ghostbuster&permissionType=policies
  5. 选择 GhostbusterPolicy。
  6. 点击 下一步:标签,然后点击 下一步:检查。
  7. 点击 创建用户,然后在你的 .aws/credentials 文件中设置 AWS 凭证。

对每个你拥有的 AWS 账户重复上述步骤。

无论你如何配置 AWS(多密钥,或跨账户假设角色配置文件),此工具都能工作。这由用于与 AWS 交互的库 boto3 管理。

配置示例:

.aws/credentials:

root@kitploit:~
[default]
aws_access_key_id = AKIAIII...
aws_secret_access_key = faAaAaA...

.aws/config:

root@kitploit:~
[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 配置中设置了环境中的所有账户,你就可以使用以下命令运行该工具:

设置用于 --roles 的 AWS 权限

Ghostbuster 可以使用角色而不是配置文件,这消除了在一个地方存放多个凭证的需要。但是,角色方法需要在你的组织中创建额外的 IAM 策略。

可以通过 --roles roles.csv 或 --autoroles 标志使用角色。要使 --roles 正常工作,需要在每个被扫描的账户中创建一个 命名为 GhostbusterTargetAccountRole 的角色:

root@kitploit:~
{
    "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 主角色。主角色必须能够担任 TargetAccountRole。

root@kitploit:~
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"
  }
}

设置用于 --autoroles 的 AWS 权限

与 --roles 相比,自动账户发现需要额外的权限。在设置好 --roles 后,考虑在具有组织概览的账户中添加以下 IAM 策略:

root@kitploit:~
{
    sid = "BaseAccess"

    actions = [
      "organizations:DescribeAccount",
      "organizations:ListAccounts"
    ]

    resources = ["*"]
    effect    = "Allow"
  }
}

然后,在运行 ghostbuster 的账户中,将以下策略附加到 ghostbuster 主角色,使其能够假设组织查找角色:

root@kitploit:~
{
    "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。

设置 Cloudflare(可选)

如果你希望 Ghostbuster 拉取你在 Cloudflare 中设置的所有 A 记录,你需要设置一个能够读取区域的 API 令牌。

https://dash.cloudflare.com/profile/api-tokens

按照下方截图所示设置 Cloudflare API 令牌:

获取到此 API 令牌后,将其记录下来(例如密码管理器)。要在 Ghostbuster 中使用它,通过 cloudflaretoken 参数传入。

作者

  • Shubham Shah - 初始工作 - github

也请参阅参与此项目的 贡献者 列表。

许可证

GNU Affero General Public License

测试 Ghostbuster

  1. 克隆此仓库。
  2. 使用 pip3 install virtualenv 安装 virtualenv。
  3. 使用 virtualenv venv 创建虚拟环境。
  4. 使用 . venv/bin/activate 激活虚拟环境。
  5. 进入仓库根目录,使用 pip3 install --editable . 安装 ghostbuster。
  6. 进行你的更改,然后运行 ghostbuster 命令。
下载工具