
Elimina gli IP elastici inutilizzati effettuando un'analisi delle tue risorse in tutti i tuoi account AWS.
Elimina gli elastic IP sospesi eseguendo un'analisi delle tue risorse in tutti i tuoi account AWS.
Ghostbuster ottiene tutti i record DNS presenti in tutti i tuoi account AWS (Route53) e può opzionalmente importare record tramite input CSV o tramite Cloudflare.
Dopo aver raccolto questi record, Ghostbuster scorre tutti i tuoi Elastic IP AWS e gli IP pubblici delle interfacce di rete e raccoglie questi dati.
Avendo un quadro completo dei record DNS (da route53, input file o cloudflare) e un quadro completo degli IP AWS posseduti dalla tua organizzazione, questo strumento può rilevare sottodomini che puntano a elastic IP sospesi (IP che non possiedi più).
Quando si distribuisce infrastruttura su AWS, è possibile avviare istanze EC2 a cui è associato un IP. Quando crei record DNS che puntano a questi IP, ma dimentichi di rimuovere i record DNS dopo che l'istanza EC2 ha ricevuto un nuovo IP o è stata distrutta, sei suscettibile ad attacchi di subdomain takeover.
È stata fatta una grande quantità di ricerca sui takeover di elastic IP, dove è possibile per gli aggressori rivendicare continuamente elastic IP fino a ottenere un IP associato a un sottodominio dell'azienda che stanno prendendo di mira.
Sebbene AWS bani frequentemente gli account che tentano di eseguire questo schema di attacco, non è stata rilasciata una soluzione a lungo termine da AWS.
L'impatto degli attacchi di subdomain takeover con elastic IP sospesi è più grave di un tipico subdomain takeover in cui puoi solo controllare il contenuto servito. Con i takeover di elastic IP sospesi, un attaccante può fare quanto segue:
*.domain.com.aws/configImportante:
Affinché questo strumento sia efficace, deve avere un quadro completo del tuo ambiente AWS. Se non ha un quadro completo, porterà a falsi positivi.
Installare Ghostbuster è semplice: basta eseguire pip install ghostbuster. Lo strumento CLI sarà quindi accessibile tramite il comando ghostbuster.
Richiede un ambiente Python 3.x.
❯ ghostbuster scan aws --help
Usage: ghostbuster scan aws [OPTIONS]
Scan for dangling elastic IPs inside your AWS accounts.
Options:
--profile TEXT Specify a specific AWS profile to run ghostbuster
on.
--skipascii Skip printing the ASCII art when starting up
Ghostbuster.
--json Only return a JSON object.
--slackwebhook TEXT Specify a Slack webhook URL to send notifications
about potential takeovers.
--records PATH Manually specify DNS records to check against.
Ghostbuster will check these IPs after checking
retrieved DNS records. See records.csv for an
example.
--cloudflaretoken TEXT Pull DNS records from Cloudflare, provide a CF API
token.
--allregions Run on all regions.
--exclude TEXT Comma delimited list of profile names to exclude.
--regions TEXT Comma delimited list of regions to run on.
--help Show this message and exit.
Comandi di esempio
Esegui Ghostbuster con accesso ai record DNS di Cloudflare, invia notifiche a un webhook Slack, itera attraverso ogni profilo AWS configurato in .aws/config o .aws/credentials per tutte le regioni AWS
❯ ghostbuster scan aws --cloudflaretoken APIKEY --slackwebhook https://hooks.slack.com/services/KEY --allregions
Esegui Ghostbuster con un elenco manuale di record A di sottodominio (vedi records.csv in questo repository per un file di esempio):
❯ ghostbuster scan aws --records records.csv
È possibile specificare regioni specifiche usando --regions impostato su un elenco di regioni separate da virgole, ad esempio 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']}
Il primo passo è creare chiavi o ruoli nei tuoi account AWS che concedano i privilegi necessari per leggere i record Route53 e descrivere gli indirizzi elastic e le interfacce di rete EC2.
Access key - Programmatic access e clicca su Next: Permissions.Attach existing policies directly e poi clicca su Create policy.JSON e quindi incolla la seguente policy:{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GhostbusterPolicy",
"Effect": "Allow",
"Action": [
"ec2:DescribeAddresses",
"ec2:DescribeNetworkInterfaces",
"route53:ListResourceRecordSets",
"route53:ListHostedZonesByName",
"route53:GetTrafficPolicyInstance",
"route53:GetTrafficPolicy"
],
"Resource": "*"
}
]
}
Next: Tags e poi su Next: Review.GhostbusterPolicy.Create Policy.GhostbusterPolicy.Next: Tags e poi su Next: Review.Create user e configura le credenziali AWS nel tuo file .aws/credentials.Ripeti i passaggi precedenti per ogni account AWS che possiedi.
Questo strumento funzionerà con qualsiasi configurazione AWS tu abbia impostato (chiavi multiple o profili cross-account assume role). Questo è gestito da boto3, la libreria usata per interfacciarsi con AWS.
Un esempio di configurazione è il seguente:
.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
In alternativa, invece di avere ruoli assunti, puoi anche configurare il file .aws/credentials per avere un elenco di profili e chiavi associate con accesso con ambito.
Una volta configurato l'AWS con tutti gli account nel tuo ambiente AWS, puoi eseguire lo strumento usando il seguente comando:
Ghostbuster può utilizzare ruoli invece di profili, il che elimina la necessità di avere così tante credenziali in un unico posto. Tuttavia, l'approccio con i ruoli richiederà la creazione di policy IAM aggiuntive all'interno della tua organizzazione.
I ruoli possono essere utilizzati tramite i flag --roles roles.csv o --autoroles. Per configurare --roles in modo che funzioni, è necessario creare un ruolo GhostbusterTargetAccountRole esattamente con questo nome in ogni account che viene scansionato:
{
"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 verrà eseguito in lambda/ec2/qualsiasi cosa con il ruolo ghostbuster - chiamiamolo ruolo master ghostbuster. Il ruolo master deve essere in grado di assumere i TargetAccountRoles.
resource "aws_iam_policy" "ghostbuster_target_account_roles" {
name = "ghostbuster_target_account_roles"
path = "/"
description = "Allow inspecting DNS and elastic IP data."
policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Resource" : ["arn:aws:iam::*:role/GhostbusterTargetAccountRole"]
}]
})
tags = {
Project = "ghostbuster"
}
}
La scoperta automatica degli account richiede autorizzazioni aggiuntive rispetto a --roles. Dopo aver configurato --roles per funzionare, considera di aggiungere la seguente policy IAM in un account che ha una visione d'insieme dell'organizzazione:
{
sid = "BaseAccess"
actions = [
"organizations:DescribeAccount",
"organizations:ListAccounts"
]
resources = ["*"]
effect = "Allow"
}
}
Quindi, nell'account che esegue ghostbuster, allega la seguente policy al ruolo master ghostbuster in modo che possa assumere il ruolo di ricerca dell'organizzazione:
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Resource" : ["arn:aws:iam::ORG_LOOKUP_ACCOUNT_ID:role/ghostbuster-org-role"]
}]
}
Non dimenticare di sostituire ORG_LOOKUP_ACCOUNT_ID con l'ID account effettivo.
Se vuoi che Ghostbuster recuperi tutti i record A che hai impostato in Cloudflare, dovrai configurare un token API in grado di leggere le zone.
https://dash.cloudflare.com/profile/api-tokens
Configura un token API Cloudflare come mostrato nello screenshot qui sotto:

Una volta ottenuto questo token API, annotalo in un posto sicuro (gestore di password). Per utilizzarlo con Ghostbuster, passalo tramite l'argomento cloudflaretoken.
Vedi anche l'elenco dei contributori che hanno partecipato a questo progetto.
GNU Affero General Public License
pip3 install virtualenvvirtualenv venv. venv/bin/activatepip3 install --editable .