Hacking Articles Tips Tricks Videos Tutorials
468 subscribers
65.8K photos
15 videos
157 files
132K links
Exploit
Pentesting
Hacking
Red Team
Blue Team
Kali Linux
Bug Bounty
Black Hat
Cyber security etc

@Hacking_Video
@Hacking_attack
Download Telegram
Protect Against Subdomain Takeoverscans Amazon Route53 across an AWS Organization for domain records vulnerable to takeovervulnerable domains in Google Cloud DNS can be detected by Domain Protect for GCP (https://github.com/ovotech/domain-protect-gcp)
deploy to security audit account

___________________________
@hacking_Attack
@Hacking_Video
scan your entire AWS Organization

___________________________
@hacking_Attack
@Hacking_Video
receive alerts by Slack or email

___________________________
@hacking_Attack
@Hacking_Video
or manually scan from your laptop

___________________________
@hacking_Attack
@Hacking_Video
subdomain detection functionality
Scans Amazon Route53 to identify:Alias records for CloudFront distributions with missing S3 originCNAME records for CloudFront distributions with missing S3 originElasticBeanstalk Alias records vulnerable to takeoverElasticBeanstalk CNAMES vulnerable to takeoverRegistered domains with missing hosted zonesSubdomain NS delegations vulnerable to takeoverS3 Alias records vulnerable to takeoverS3 CNAMES vulnerable to takeoverVulnerable CNAME records for Azure resourcesCNAME records for missing Google Cloud Storage buckets
optional additional check
Turned off by default as it may result in Lambda timeouts for large organisationsA records for missing storage buckets, e.g. Google Cloud Load Balancer (https://www.kitploit.com/search/label/Load%20Balancer) with missing backend storageTo enable, create this Terraform variable in your tfvars file or CI/CD pipeline:lambdas = ["alias-cloudfront-s3", "alias-eb", "alias-s3", "cname-cloudfront-s3", "cname-eb", "cname-s3", "ns-domain", "ns-subdomain", "cname-azure", "cname-google", "a-storage"]

options
scheduled lambda functions with email and Slack alerts, across an AWS Organization, deployed using Terraformmanual scans (https://github.com/ovotech/domain-protect/blob/dev/manual-scans/README.md) run from your laptop or CloudShell, in a single AWS account
notifications
Slack channel notification per vulnerability (https://www.kitploit.com/search/label/Vulnerability) type, listing account names and vulnerable domainsEmail notification in JSON format with account names, account IDs and vulnerable domains by subscribing to SNS topic
requirements
Security audit account within AWS OrganizationsSecurity audit read-only role with an identical name in every AWS account of the OrganizationStorage bucket for Terraform state fileTerraform 1.0.x
usage
replace the Terraform state S3 bucket fields in the command below as appropriatefor local testing, duplicate terraform.tfvars.example, rename without the .example suffixenter details appropriate to your organization and savealternatively enter Terraform variables within your CI/CD pipelineterraform init -backend-config=bucket=TERRAFORM_STATE_BUCKET -backend-config=key=TERRAFORM_STATE_KEY -backend-config=region=TERRAFORM_STATE_REGION
terraform workspace new dev
terraform plan
terraform apply

AWS IAM policies
For least privilege access control, example AWS IAM policies are provided:domain-protect audit policy (https://github.com/ovotech/domain-protect/blob/dev/aws-iam-policies/domain-protect-audit.json) - attach to domain-protect audit role in every AWS accountdomain-protect audit trust relationship (https://github.com/ovotech/domain-protect/blob/dev/aws-iam-policies/domain-protect-audit-trust.json) for domain-protect audit role in every AWS accountdomain-protect audit trust relationship with External ID (https://github.com/ovotech/domain-protect/blob/dev/aws-iam-policies/domain-protect-audit-trust-external-id.json) for domain-protect audit role in every AWS accountdomain-protect deploy policy (https://github.com/ovotech/domain-protect/blob/dev/aws-iam-policies/domain-protect-deploy.json) - attach to IAM group or role assumed by CI/CD pipeline
adding new checks
create a new subdirectory within the terraform-modules/lambda/code directoryadd Python code file with same name as the subdirectoryadd the name of the file without extension to var.lambdas in variables.tf (https://github.com/ovotech/domain-protect/blob/dev/variables.tf)add a subdirectory within the terraform-modules/lambda/build directory, following the existing naming patternadd a .gitkeep file into the new directoryupdate the .gitignore file following the pattern of existing directoriesapply Terraform
adding notifications to extra Slack channels
add an extra channel to your slack_channels variable listadd an extra webhook URL or repeat the same webhook URL to your slack_webhook_urls variable listapply Terraform
testing

___________________________
@hacking_Attack
@Hacking_Video
use multiple Terraform workspace environments, e.g. dev, prduse the slack_channels_dev variable for your dev environment to notify a test Slack channelfor new subdomain takeover (https://www.kitploit.com/search/label/Subdomain%20Takeover) categories, create correctly configured and vulnerable domain names in Route53minimise the risk of malicious takeover by using a test domain, with domain names which are hard to enumerateremove any vulnerable domains as soon as possible
ci/cd
infrastructure has been deployed using CircleCIenvironment variables to be entered in CircleCI project settings:ENVIRONMENT VARIABLEEXAMPLE VALUE / COMMENTAWS_ACCESS_KEY_IDusing domain-protect deploy policy (https://github.com/ovotech/domain-protect/blob/dev/aws-iam-policies/domain-protect-deploy.json)AWS_SECRET_ACCESS_KEY-TERRAFORM_STATE_BUCKETtfstate48903TERRAFORM_STATE_KEYdomain-protectTERRAFORM_STATE_REGIONus-east-1TF_VAR_org_primary_account012345678901TF_VAR_security_audit_role_namenot needed if "domain-protect-audit" usedTF_VAR_external_idonly required if External ID is configuredTF_VAR_slack_channels["security-alerts"]TF_VAR_slack_channels_dev["security-alerts-dev"]TF_VAR_slack_webhook_urls["https://hooks.slack.com/services/XXX/XXX/XXX"]to validate an updated CircleCI configuration:docker run -v `pwd`:/whatever circleci/circleci-cli circleci config validate /whatever/.circleci/config.yml

limitations
this tool cannot guarantee 100% protection (https://www.kitploit.com/search/label/Protection) against subdomain takeoverit currently only scans Amazon Route53, and only checks a limited number of takeover typesvulnerable domains in Google Cloud DNS can be detected by Domain Protect for GCP (https://github.com/ovotech/domain-protect-gcp)

Download Domain-Protect (https://github.com/ovotech/domain-protect)

___________________________
@hacking_Attack
@Hacking_Video