
अपने सभी AWS खातों में अपने संसाधनों का विश्लेषण करके लटकते Elastic IPs को हटाएं।
अपने सभी AWS खातों में संसाधनों का विश्लेषण करके दांगलिंग elastic IPs को समाप्त करें।
Ghostbuster आपके सभी AWS खातों (Route53) में मौजूद सभी DNS रिकॉर्ड प्राप्त करता है, और वैकल्पिक रूप से CSV इनपुट या Cloudflare के माध्यम से रिकॉर्ड ले सकता है।
इन रिकॉर्डों को एकत्र करने के बाद, Ghostbuster आपके सभी AWS Elastic IPs और Network Interface Public IPs के माध्यम से पुनरावृत्त करता है और यह डेटा एकत्र करता है।
DNS रिकॉर्ड्स (route53, फ़ाइल इनपुट या cloudflare से) की पूरी तस्वीर और आपके संगठन के स्वामित्व वाले AWS IPs की पूरी तस्वीर होने से, यह उपकरण उपडोमेन का पता लगा सकता है जो दांगलिंग elastic IPs (IPs जो अब आपके स्वामित्व में नहीं हैं) की ओर इशारा कर रहे हैं।
जब आप AWS में इन्फ्रास्ट्रक्चर तैनात कर रहे होते हैं, तो आप EC2 इंस्टेंस चालू कर सकते हैं जिनके साथ एक IP जुड़ा होता है। जब आप इन IPs की ओर इशारा करते हुए DNS रिकॉर्ड बनाते हैं, लेकिन EC2 इंस्टेंस को नया IP देने या नष्ट करने के बाद DNS रिकॉर्ड को हटाना भूल जाते हैं, तो आप सबडोमेन अधिग्रहण हमलों के लिए अतिसंवेदनशील हो जाते हैं।
elastic IP अधिग्रहण पर बहुत अधिक शोध किया गया है, जहाँ हमलावरों के लिए लगातार elastic IPs का दावा करना संभव है जब तक कि वे उस कंपनी के सबडोमेन से जुड़ा IP प्राप्त नहीं कर लेते जिसे वे लक्षित कर रहे हैं।
जबकि AWS अक्सर उन खातों पर प्रतिबंध लगाता है जो इस हमले के पैटर्न को करने का प्रयास कर रहे हैं, AWS द्वारा कोई दीर्घकालिक समाधान जारी नहीं किया गया है।
दांगलिंग elastic IP सबडोमेन अधिग्रहण हमलों का प्रभाव एक सामान्य सबडोमेन अधिग्रहण से अधिक गंभीर होता है जहाँ आप केवल प्रस्तुत की जा रही सामग्री को नियंत्रित कर सकते हैं। दांगलिंग elastic IP अधिग्रहण के साथ, एक हमलावर के लिए निम्नलिखित करना संभव है:
*.domain.com पर दायरे में होती हैं.aws/config में कॉन्फ़िगर किए गए प्रत्येक AWS प्रोफ़ाइल के माध्यम से गतिशील रूप से पुनरावृत्त करता हैमहत्वपूर्ण:
इस उपकरण के प्रभावी होने के लिए, इसके पास आपके AWS वातावरण की पूरी तस्वीर होनी चाहिए। यदि इसके पास पूरी तस्वीर नहीं है, तो यह गलत सकारात्मक निष्कर्षों की ओर ले जाएगा।
Ghostbuster को स्थापित करना उतना ही आसान है जितना चलाना: pip install ghostbuster। CLI उपकरण तब ghostbuster कमांड के माध्यम से सुलभ होगा।
इसके लिए 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.
उदाहरण कमांड
Cloudflare DNS रिकॉर्ड तक पहुँच के साथ Ghostbuster चलाएँ, Slack वेबहुक को सूचनाएँ भेजें, सभी AWS क्षेत्रों के लिए .aws/config या .aws/credentials में कॉन्फ़िगर किए गए प्रत्येक 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 रिकॉर्ड पढ़ने और elastic पतों और EC2 नेटवर्क इंटरफ़ेस का वर्णन करने के लिए आवश्यक विशेषाधिकार प्रदान करती हैं।
Access key - Programmatic access चुनें, और Next: Permissions पर क्लिक करें।Attach existing policies directly पर क्लिक करें और फिर Create policy पर क्लिक करें।JSON पर क्लिक करें और फिर निम्नलिखित नीति पेस्ट करें:{
"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 पर क्लिक करें और फिर Next: Review पर क्लिक करें।GhostbusterPolicy सेट करें।Create Policy पर क्लिक करें।GhostbusterPolicy चुनें।Next: Tags पर क्लिक करें और फिर Next: Review पर क्लिक करें।Create user पर क्लिक करें और अपने .aws/credentials फ़ाइल में AWS क्रेडेंशियल सेटअप करें।उपरोक्त चरणों को अपने प्रत्येक AWS खाते के लिए दोहराएँ।
यह उपकरण आपकी AWS कॉन्फ़िगरेशन (एकाधिक कुंजियाँ, या क्रॉस-अकाउंट अनुमान भूमिका प्रोफ़ाइल) के साथ काम करेगा। यह boto3 द्वारा प्रबंधित किया जाता है, जो AWS के साथ इंटरफ़ेस करने के लिए उपयोग की जाने वाली लाइब्रेरी है।
एक उदाहरण कॉन्फ़िगरेशन इस प्रकार दिखता है:
.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 वातावरण के सभी खातों के साथ सेट हो जाती है, तो आप निम्नलिखित कमांड का उपयोग करके उपकरण चला सकते हैं:
--roles के लिए 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 = "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"
}
}
--autoroles के लिए AWS अनुमतियाँ सेटअप करनास्वचालित खाता खोज के लिए --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 स्थापित करें।