# Pentesting Cloud Methodology {{#include ../banners/hacktricks-training.md}}
## Basic Methodology Each cloud has its own peculiarities but in general there are a few **common things a pentester should check** when testing a cloud environment: - **Benchmark checks** - यह आपको वातावरण का आकार और उपयोग की जाने वाली सेवाओं को समझने में मदद करेगा - यह आपको कुछ त्वरित misconfigurations खोजने में भी सक्षम करेगा क्योंकि आप इन परीक्षणों में से अधिकांश **automated tools** के साथ कर सकते हैं - **Services Enumeration** - यदि आपने सही तरीके से benchmark tests किए हैं तो आप शायद यहाँ ज्यादा misconfigurations नहीं पाएँगे, लेकिन ऐसे कुछ मिल सकते हैं जिनकी benchmark टेस्ट में तलाश नहीं की जा रही थी। - इससे आपको पता चलेगा कि क्लाउड env में वास्तव में क्या इस्तेमाल हो रहा है - यह अगले चरणों में बहुत मदद करेगा - **Check exposed assets** - यह पिछले सेक्शन के दौरान किया जा सकता है, आपको यह पता लगाना होगा कि इंटरनेट के लिए किस चीज़ की संभावित रूप से एक्सपोज़र है और उसे कैसे एक्सेस किया जा सकता है। - यहाँ मैं मैन्युअली एक्सपोज़ की गई infrastructure जैसे instances जिनमें web pages या अन्य पोर्ट एक्सपोज़ हैं, और साथ ही अन्य cloud managed services जिनको एक्सपोज़ होने के लिए configure किया जा सकता है (जैसे DBs या buckets) ले रहा हूँ - फिर आपको यह जांचना चाहिए कि **क्या उस resource को एक्सपोज़ किया जा सकता है या नहीं** (गोपनीय जानकारी? vulnerabilities? exposed service में misconfigurations?) - **Check permissions** - यहाँ आपको cloud के अंदर प्रत्येक role/user के सभी permissions और उनका उपयोग कैसे हो रहा है यह पता लगाना चाहिए - बहुत सारे highly privileged (control everything) accounts? Generated keys का प्रयोग नहीं हो रहा?... इनमे से अधिकांश चेक पहले से benchmark tests में किए जा चुके होने चाहिए थे - यदि client OpenID या SAML या कोई अन्य federation उपयोग कर रहा है तो आपको उनसे पूछना पड़ सकता है कि **प्रत्येक role कैसे assign किया जा रहा है** (यह एक ही नहीं है कि admin role 1 user को assign है या 100 को) - यह सिर्फ यही जानना पर्याप्त नहीं है कि किस user के पास **admin** permissions "\*:\*". हैं। बहुत सारी अन्य permissions हैं जो उपयोग की जा रही सेवाओं के आधार पर बहुत **सेंसिटिव** हो सकती हैं। - इसके अलावा, permissions का दुरुपयोग करके अनुसरण करने के लिए संभावित privesc तरीके होते हैं। इन सभी चीजों को ध्यान में रखना चाहिए और जितने संभव हों उतने privesc paths रिपोर्ट किए जाने चाहिए। - **Check Integrations** - बहुत संभव है कि क्लाउड env के अंदर अन्य clouds या SaaS के साथ integrations इस्तेमाल किए जा रहे हों। - जिस cloud की आप auditing कर रहे हैं उसकी **other platform** के साथ integrations के लिए आपको notify करना चाहिए कि **कौन उस integration को (ab)use करने का access रखता है** और आपको पूछना चाहिए कि की जा रही action कितनी **सेंसिटिव** है।\ For example, who can write in an AWS bucket where GCP is getting data from (ask how sensitive is the action in GCP treating that data). - जिन integrations का स्रोत external platforms हैं और जो cloud आप audit कर रहे हैं के अंदर उपयोग हो रहे हैं, उनके लिए आपको पूछना चाहिए कि **externally किसके पास उस integration को (ab)use करने का access है** और यह जाँचना चाहिए कि वह डेटा कैसे उपयोग किया जा रहा है।\ For example, if a service is using a Docker image hosted in GCR, you should ask who has access to modify that and which sensitive info and access will get that image when executed inside an AWS cloud. ## Multi-Cloud tools There are several tools that can be used to test different cloud environments. The installation steps and links are going to be indicated in this section. ### [PurplePanda](https://github.com/carlospolop/purplepanda) A tool to **identify bad configurations and privesc path in clouds and across clouds/SaaS.** {{#tabs }} {{#tab name="Install" }} ```bash # You need to install and run neo4j also git clone https://github.com/carlospolop/PurplePanda cd PurplePanda python3 -m venv . source bin/activate python3 -m pip install -r requirements.txt export PURPLEPANDA_NEO4J_URL="bolt://neo4j@localhost:7687" export PURPLEPANDA_PWD="neo4j_pwd_4_purplepanda" python3 main.py -h # Get help ``` {{#endtab }} {{#tab name="GCP" }} ```bash export GOOGLE_DISCOVERY=$(echo 'google: - file_path: "" - file_path: "" service_account_id: "some-sa-email@sidentifier.iam.gserviceaccount.com"' | base64) python3 main.py -a -p google #Get basic info of the account to check it's correctly configured python3 main.py -e -p google #Enumerate the env ``` {{#endtab }} {{#endtabs }} ### [Prowler](https://github.com/prowler-cloud/prowler) यह **AWS, GCP & Azure** को सपोर्ट करता है। प्रत्येक प्रदाता को कॉन्फ़िगर करने का तरीका देखें: [https://docs.prowler.cloud/en/latest/#aws](https://docs.prowler.cloud/en/latest/#aws) ```bash # Install pip install prowler prowler -v # Run prowler # Example prowler aws --profile custom-profile [-M csv json json-asff html] # Get info about checks & services prowler --list-checks prowler --list-services ``` ### [CloudSploit](https://github.com/aquasecurity/cloudsploit) AWS, Azure, Github, Google, Oracle, Alibaba {{#tabs }} {{#tab name="Install" }} ```bash # Install git clone https://github.com/aquasecurity/cloudsploit.git cd cloudsploit npm install ./index.js -h ## Docker instructions in github ``` {{#endtab }} {{#tab name="GCP" }} ```bash ## You need to have creds for a service account and set them in config.js file ./index.js --cloud google --config ``` {{#endtab }} {{#endtabs }} ### [ScoutSuite](https://github.com/nccgroup/ScoutSuite) AWS, Azure, GCP, Alibaba Cloud, Oracle Cloud Infrastructure {{#tabs }} {{#tab name="Install" }} ```bash mkdir scout; cd scout virtualenv -p python3 venv source venv/bin/activate pip install scoutsuite scout --help ## Using Docker: https://github.com/nccgroup/ScoutSuite/wiki/Docker-Image ``` {{#endtab }} {{#tab name="GCP" }} ```bash scout gcp --report-dir /tmp/gcp --user-account --all-projects ## use "--service-account KEY_FILE" instead of "--user-account" to use a service account SCOUT_FOLDER_REPORT="/tmp" for pid in $(gcloud projects list --format="value(projectId)"); do echo "================================================" echo "Checking $pid" mkdir "$SCOUT_FOLDER_REPORT/$pid" scout gcp --report-dir "$SCOUT_FOLDER_REPORT/$pid" --no-browser --user-account --project-id "$pid" done ``` {{#endtab }} {{#endtabs }} ### [Steampipe](https://github.com/turbot) {{#tabs }} {{#tab name="Install" }} Steampipe डाउनलोड और इंस्टॉल करें ([https://steampipe.io/downloads](https://steampipe.io/downloads)). या Brew का उपयोग करें: ``` brew tap turbot/tap brew install steampipe ``` {{#endtab }} {{#tab name="GCP" }} ```bash # Install gcp plugin steampipe plugin install gcp # Use https://github.com/turbot/steampipe-mod-gcp-compliance.git git clone https://github.com/turbot/steampipe-mod-gcp-compliance.git cd steampipe-mod-gcp-compliance # To run all the checks from the dashboard steampipe dashboard # To run all the checks from rhe cli steampipe check all ```
सभी प्रोजेक्ट्स की जाँच करें सभी प्रोजेक्ट्स की जाँच करने के लिए आपको उन सभी प्रोजेक्ट्स को इंगित करने वाली `gcp.spc` फ़ाइल जनरेट करनी होगी जिन्हें टेस्ट करना है। आप निम्नलिखित स्क्रिप्ट में दिए निर्देशों का पालन कर सकते हैं। ```bash FILEPATH="/tmp/gcp.spc" rm -rf "$FILEPATH" 2>/dev/null # Generate a json like object for each project for pid in $(gcloud projects list --format="value(projectId)"); do echo "connection \"gcp_$(echo -n $pid | tr "-" "_" )\" { plugin = \"gcp\" project = \"$pid\" }" >> "$FILEPATH" done # Generate the aggragator to call echo 'connection "gcp_all" { plugin = "gcp" type = "aggregator" connections = ["gcp_*"] }' >> "$FILEPATH" echo "Copy $FILEPATH in ~/.steampipe/config/gcp.spc if it was correctly generated" ```
देखने के लिए **अन्य GCP insights** (सेवाओं को सूचीबद्ध करने के लिए उपयोगी) उपयोग करें: [https://github.com/turbot/steampipe-mod-gcp-insights](https://github.com/turbot/steampipe-mod-gcp-insights) Terraform GCP code देखने के लिए: [https://github.com/turbot/steampipe-mod-terraform-gcp-compliance](https://github.com/turbot/steampipe-mod-terraform-gcp-compliance) Steampipe के और GCP plugins: [https://github.com/turbot?q=gcp](https://github.com/turbot?q=gcp) {{#endtab }} {{#tab name="AWS" }} ```bash # Install aws plugin steampipe plugin install aws # Modify the spec indicating in "profile" the profile name to use nano ~/.steampipe/config/aws.spc # Get some info on how the AWS account is being used git clone https://github.com/turbot/steampipe-mod-aws-insights.git cd steampipe-mod-aws-insights steampipe dashboard # Get the services exposed to the internet git clone https://github.com/turbot/steampipe-mod-aws-perimeter.git cd steampipe-mod-aws-perimeter steampipe dashboard # Run the benchmarks git clone https://github.com/turbot/steampipe-mod-aws-compliance cd steampipe-mod-aws-compliance steampipe dashboard # To see results in browser steampipe check all --export=/tmp/output4.json ``` Terraform AWS code की जाँच के लिए: [https://github.com/turbot/steampipe-mod-terraform-aws-compliance](https://github.com/turbot/steampipe-mod-terraform-aws-compliance) Steampipe के और AWS प्लगइन्स: [https://github.com/orgs/turbot/repositories?q=aws](https://github.com/orgs/turbot/repositories?q=aws) {{#endtab }} {{#endtabs }} ### [~~cs-suite~~](https://github.com/SecurityFTW/cs-suite) AWS, GCP, Azure, DigitalOcean.\ यह python2.7 की आवश्यकता रखता है और ऐसा लगता है कि यह मेंटेन नहीं किया जा रहा है। ### Nessus Nessus में _**Audit Cloud Infrastructure**_ स्कैन है जो समर्थित है: AWS, Azure, Office 365, Rackspace, Salesforce. **Azure** में कुछ अतिरिक्त कॉन्फ़िगरेशन की आवश्यकता होती है ताकि **Client Id** प्राप्त किया जा सके। ### [**cloudlist**](https://github.com/projectdiscovery/cloudlist) Cloudlist एक **multi-cloud tool for getting Assets** (Hostnames, IP Addresses) है जो क्लाउड प्रदाताओं से जानकारी प्राप्त करता है। {{#tabs }} {{#tab name="Cloudlist" }} ```bash cd /tmp wget https://github.com/projectdiscovery/cloudlist/releases/latest/download/cloudlist_1.0.1_macOS_arm64.zip unzip cloudlist_1.0.1_macOS_arm64.zip chmod +x cloudlist sudo mv cloudlist /usr/local/bin ``` {{#endtab }} {{#tab name="Second Tab" }} ```bash ## For GCP it requires service account JSON credentials cloudlist -config ``` {{#endtab }} {{#endtabs }} ### [**cartography**](https://github.com/lyft/cartography) Cartography एक Python टूल है जो इन्फ्रास्ट्रक्चर संसाधन और उनके बीच के संबंधों को एक सहज ग्राफ़ दृश्य में समेकित करता है, जिसे Neo4j डेटाबेस संचालित करता है। {{#tabs }} {{#tab name="Install" }} ```bash # Installation docker image pull ghcr.io/lyft/cartography docker run --platform linux/amd64 ghcr.io/lyft/cartography cartography --help ## Install a Neo4j DB version 3.5.* ``` {{#endtab }} {{#tab name="GCP" }} ```bash docker run --platform linux/amd64 \ --volume "$HOME/.config/gcloud/application_default_credentials.json:/application_default_credentials.json" \ -e GOOGLE_APPLICATION_CREDENTIALS="/application_default_credentials.json" \ -e NEO4j_PASSWORD="s3cr3t" \ ghcr.io/lyft/cartography \ --neo4j-uri bolt://host.docker.internal:7687 \ --neo4j-password-env-var NEO4j_PASSWORD \ --neo4j-user neo4j # It only checks for a few services inside GCP (https://lyft.github.io/cartography/modules/gcp/index.html) ## Cloud Resource Manager ## Compute ## DNS ## Storage ## Google Kubernetes Engine ### If you can run starbase or purplepanda you will get more info ``` {{#endtab }} {{#endtabs }} ### [**starbase**](https://github.com/JupiterOne/starbase) Starbase क्लाउड इंफ्रास्ट्रक्चर, SaaS applications, security controls, और अन्य सेवाओं व सिस्टमों से assets और relationships इकट्ठा करके Neo4j database द्वारा समर्थित एक सहज ग्राफ़ व्यू में प्रस्तुत करता है। {{#tabs }} {{#tab name="Install" }} ```bash # You are going to need Node version 14, so install nvm following https://tecadmin.net/install-nvm-macos-with-homebrew/ npm install --global yarn nvm install 14 git clone https://github.com/JupiterOne/starbase.git cd starbase nvm use 14 yarn install yarn starbase --help # Configure manually config.yaml depending on the env to analyze yarn starbase setup yarn starbase run # Docker git clone https://github.com/JupiterOne/starbase.git cd starbase cp config.yaml.example config.yaml # Configure manually config.yaml depending on the env to analyze docker build --no-cache -t starbase:latest . docker-compose run starbase setup docker-compose run starbase run ``` {{#endtab }} {{#tab name="GCP" }} ```yaml ## Config for GCP ### Check out: https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md ### It requires service account credentials integrations: - name: graph-google-cloud instanceId: testInstanceId directory: ./.integrations/graph-google-cloud gitRemoteUrl: https://github.com/JupiterOne/graph-google-cloud.git config: SERVICE_ACCOUNT_KEY_FILE: "{Check https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md#service_account_key_file-string}" PROJECT_ID: "" FOLDER_ID: "" ORGANIZATION_ID: "" CONFIGURE_ORGANIZATION_PROJECTS: false storage: engine: neo4j config: username: neo4j password: s3cr3t uri: bolt://localhost:7687 #Consider using host.docker.internal if from docker ``` {{#endtab }} {{#endtabs }} ### [**SkyArk**](https://github.com/cyberark/SkyArk) स्कैन किए गए AWS या Azure वातावरण में सबसे अधिक विशेषाधिकार प्राप्त उपयोगकर्ताओं का पता लगाएँ, जिसमें AWS Shadow Admins भी शामिल हैं। यह powershell का उपयोग करता है। ```bash Import-Module .\SkyArk.ps1 -force Start-AzureStealth # in the Cloud Console IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/cyberark/SkyArk/master/AzureStealth/AzureStealth.ps1') Scan-AzureAdmins ``` ### [Cloud Brute](https://github.com/0xsha/CloudBrute) एक टूल जो कंपनी (target) की infrastructure, files और apps को शीर्ष क्लाउड प्रदाताओं (Amazon, Google, Microsoft, DigitalOcean, Alibaba, Vultr, Linode) पर खोजने के लिए है। ### [CloudFox](https://github.com/BishopFox/cloudfox) - CloudFox एक टूल है जो cloud infrastructure में exploitable attack paths खोजने के लिए है (वर्तमान में केवल AWS & Azure समर्थित हैं, GCP जल्द आ रहा है)। - यह एक enumeration टूल है जो manual pentesting को complement करने के लिए बनाया गया है। - यह क्लाउड environment के भीतर किसी भी डेटा को create या modify नहीं करता/करती। ### More lists of cloud security tools - [https://github.com/RyanJarv/awesome-cloud-sec](https://github.com/RyanJarv/awesome-cloud-sec) ## Google ### GCP {{#ref}} gcp-security/ {{#endref}} ### Workspace {{#ref}} workspace-security/ {{#endref}} ## AWS {{#ref}} aws-security/ {{#endref}} ## Azure {{#ref}} azure-security/ {{#endref}} ## सामान्य क्लाउड सुरक्षा विशेषताएँ ### कन्फिडेंशियल कंप्यूटिंग {{#ref}} confidential-computing/luks2-header-malleability-null-cipher-abuse.md {{#endref}} {{#include ../banners/hacktricks-training.md}}