Pentesting Cloud Methodology

Lernen Sie AWS-Hacking von Null auf Held mit htARTE (HackTricks AWS Red Team Expert)!

Andere Möglichkeiten, HackTricks zu unterstützen:

Grundmethodik

Jede Cloud hat ihre eigenen Besonderheiten, aber im Allgemeinen gibt es einige gemeinsame Dinge, die ein Pentester überprüfen sollte, wenn er eine Cloud-Umgebung testet:

  • Benchmark-Checks

    • Dies hilft Ihnen, die Größe der Umgebung und die verwendeten Dienste zu verstehen

    • Es ermöglicht Ihnen auch, einige schnelle Fehlkonfigurationen zu finden, da die meisten dieser Tests mit automatisierten Tools durchgeführt werden können

  • Dienste Enumeration

    • Hier werden Sie wahrscheinlich nicht viele weitere Fehlkonfigurationen finden, wenn Sie die Benchmark-Tests korrekt durchgeführt haben, aber Sie könnten einige finden, die in den Benchmark-Tests nicht gesucht wurden.

    • Dies ermöglicht es Ihnen zu wissen, was genau in der Cloud-Umgebung verwendet wird

    • Dies wird in den nächsten Schritten sehr hilfreich sein

  • Überprüfung exponierter Assets

    • Dies kann im vorherigen Abschnitt durchgeführt werden. Sie müssen herausfinden, was potenziell dem Internet ausgesetzt ist und wie darauf zugegriffen werden kann.

    • Hierbei handelt es sich um manuell exponierte Infrastruktur wie Instanzen mit Webseiten oder anderen freigegebenen Ports sowie um andere cloudverwaltete Dienste, die so konfiguriert werden können, dass sie freigegeben sind (wie z. B. DBs oder Buckets)

    • Dann sollten Sie überprüfen, ob diese Ressource freigegeben werden kann oder nicht (vertrauliche Informationen? Schwachstellen? Fehlkonfigurationen im freigegebenen Dienst?)

  • Berechtigungen überprüfen

    • Hier sollten Sie alle Berechtigungen jedes Rollen/Benutzers in der Cloud herausfinden und wie sie verwendet werden

    • Zu viele stark privilegierte (kontrollieren alles) Konten? Generierte Schlüssel nicht verwendet?... Die meisten dieser Überprüfungen sollten bereits in den Benchmark-Tests durchgeführt worden sein

    • Wenn der Kunde OpenID oder SAML oder andere Föderationen verwendet, müssen Sie möglicherweise weitere Informationen darüber anfordern, wie jede Rolle zugewiesen wird (es ist nicht dasselbe, ob die Admin-Rolle einem Benutzer oder 100 Benutzern zugewiesen ist)

    • Es reicht nicht aus zu finden, welche Benutzer Admin-Berechtigungen haben "*:*". Es gibt viele andere Berechtigungen, die je nach den verwendeten Diensten sehr sensibel sein können.

    • Darüber hinaus gibt es potenzielle Privesc-Wege, die missbräuchlich genutzt werden können. All diese Dinge sollten berücksichtigt werden, und es sollten so viele Privesc-Pfade wie möglich gemeldet werden.

  • Integrationen überprüfen

    • Es ist sehr wahrscheinlich, dass Integrationen mit anderen Clouds oder SaaS in der Cloud-Umgebung verwendet werden.

    • Für Integrationen der Cloud, die Sie überprüfen, mit anderen Plattformen sollten Sie benachrichtigen, wer Zugriff hat, um diese Integration zu (miss)brauchen, und Sie sollten fragen, wie sensibel die durchgeführte Aktion ist. Zum Beispiel, wer kann in einem AWS-Bucket schreiben, von dem GCP Daten bezieht (fragen Sie, wie sensibel die Aktion in GCP ist, wenn diese Daten behandelt werden).

    • Für Integrationen innerhalb der Cloud, die Sie überprüfen, von externen Plattformen aus sollten Sie fragen, wer externen Zugriff hat, um diese Integration zu (miss)brauchen, und überprüfen, wie diese Daten verwendet werden. Zum Beispiel, wenn ein Dienst ein in GCR gehostetes Docker-Image verwendet, sollten Sie herausfinden, wer Zugriff hat, um dies zu ändern, und welche sensiblen Informationen und Zugriffsberechtigungen dieses Image erhält, wenn es in einer AWS-Cloud ausgeführt wird.

Multi-Cloud-Tools

Es gibt mehrere Tools, die verwendet werden können, um verschiedene Cloud-Umgebungen zu testen. Die Installationsanleitungen und Links werden in diesem Abschnitt angegeben.

Ein Tool zur Identifizierung von schlechten Konfigurationen und Privesc-Pfaden in Clouds und über Clouds/SaaS hinweg.

# 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

Methodology

  1. Reconnaissance:

    • Google Dorks: Search for sensitive information exposed in Google.

    • Subdomain Enumeration: Enumerate subdomains using tools like Sublist3r, Subfinder, etc.

    • DNS Enumeration: Enumerate DNS records using tools like dig, nslookup, etc.

    • Cloud Storage Enumeration: Enumerate buckets and files in Google Cloud Storage using tools like GCSBucket, GCPBucketBrute, etc.

  2. Enumeration:

    • Service Enumeration: Identify services running on the target.

    • Port Scanning: Scan open ports using tools like Nmap, Masscan, etc.

    • Web Enumeration: Enumerate web applications using tools like Dirb, Gobuster, etc.

  3. Vulnerability Assessment:

    • Vulnerability Scanning: Scan for vulnerabilities using tools like Nessus, OpenVAS, etc.

    • Web Application Scanning: Scan web applications for vulnerabilities using tools like OWASP ZAP, Burp Suite, etc.

  4. Exploitation:

    • Exploit Research: Search for known exploits related to the identified vulnerabilities.

    • Manual Exploitation: Exploit vulnerabilities manually if no automated exploit is available.

  5. Post-Exploitation:

    • Maintain Access: Ensure persistent access to the target system.

    • Privilege Escalation: Elevate privileges on the target system.

    • Data Exfiltration: Extract sensitive data from the target system.

  6. Reporting:

    • Documentation: Document all findings, exploits, and recommendations.

    • Reporting: Generate a detailed report for the client including the identified vulnerabilities and their impact.

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

Es unterstützt AWS, GCP & Azure. Überprüfen Sie, wie Sie jeden Anbieter unter https://docs.prowler.cloud/en/latest/#aws konfigurieren können.

# Install
pip install prowler
prowler -v

# Run
prowler <provider>
# Example
prowler aws --profile custom-profile [-M csv json json-asff html]

# Get info about checks & services
prowler <provider> --list-checks
prowler <provider> --list-services

AWS, Azure, Github, Google, Oracle, Alibaba

# Install
git clone https://github.com/aquasecurity/cloudsploit.git
cd cloudsploit
npm install
./index.js -h
## Docker instructions in github

AWS, Azure, GCP, Alibaba Cloud, Oracle Cloud Infrastructure

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

Methodology

1. Reconnaissance

  • Google Dorks: Use specific Google search queries to find sensitive information exposed on the internet.

  • Subdomain Enumeration: Enumerate subdomains using tools like Sublist3r, Subfinder, etc.

  • DNS Enumeration: Enumerate DNS records using tools like dnsrecon, dnsenum, etc.

  • Cloud Storage Enumeration: Identify publicly accessible cloud storage buckets using tools like gcs-scanner.

  • GitHub Recon: Search for sensitive information in GitHub repositories using tools like truffleHog, gitrob, etc.

2. Enumeration

  • Port Scanning: Scan for open ports and services using tools like Nmap.

  • Service Enumeration: Enumerate services running on discovered ports using tools like enum4linux, nmap, etc.

  • Web Enumeration: Enumerate web applications for vulnerabilities using tools like Gobuster, Dirb, etc.

3. Vulnerability Assessment

  • Web Application Testing: Test web applications for common vulnerabilities like SQL injection, XSS, etc.

  • Cloud Service Misconfigurations: Check for misconfigurations in cloud services that could lead to security issues.

  • API Testing: Test APIs for vulnerabilities like insecure API endpoints, lack of authentication, etc.

4. Exploitation

  • Exploit Development: Develop and execute exploits for identified vulnerabilities.

  • Post-Exploitation: Maintain access and gather further information post exploitation.

5. Reporting

  • Documentation: Document all findings, including vulnerabilities, exploited systems, and recommendations for mitigation.

  • Executive Summary: Provide a high-level summary of the assessment for stakeholders.

6. Post-Exploitation

  • Maintain Access: Ensure continued access to compromised systems for further analysis.

  • Cleanup: Remove any traces of the attack to maintain stealth and avoid detection.

7. Pivoting

  • Lateral Movement: Move laterally within the network to explore and compromise additional systems.

  • Privilege Escalation: Elevate privileges to gain higher access within the network.

8. Persistence

  • Establish Persistence: Implement mechanisms to maintain access to compromised systems over time.

  • Backdooring: Install backdoors for future access to the system.

9. Covering Tracks

  • Log Cleaning: Remove or modify logs to hide traces of unauthorized access.

  • Artifact Removal: Delete any artifacts or tools used during the assessment to avoid detection.

10. Social Engineering

  • Phishing: Conduct phishing attacks to gather credentials or sensitive information.

  • Human Interaction: Exploit human vulnerabilities through social engineering techniques.

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

Laden Sie Steampipe herunter und installieren Sie es (https://steampipe.io/downloads). Oder verwenden Sie Brew:

brew tap turbot/tap
brew install steampipe

Methodology

  1. Reconnaissance:

    • Google Dorks: Search for sensitive information exposed by Google.

    • Subdomain Enumeration: Enumerate subdomains to discover potential entry points.

    • Cloud Storage Enumeration: Identify publicly accessible storage buckets.

    • GitHub Recon: Search for leaked credentials or sensitive information on GitHub repositories.

  2. Enumeration:

    • Service Enumeration: Identify services running on discovered hosts.

    • Port Scanning: Scan for open ports to identify potential attack vectors.

    • Web Enumeration: Enumerate web applications for vulnerabilities.

  3. Exploitation:

    • Weak Credentials: Attempt to crack weak credentials or default passwords.

    • Vulnerability Exploitation: Exploit identified vulnerabilities to gain access.

    • Data Exposure: Look for sensitive data exposure through misconfigurations.

  4. Post-Exploitation:

    • Maintain Access: Establish backdoors for persistent access.

    • Privilege Escalation: Elevate privileges to gain more control.

    • Data Exfiltration: Extract valuable data from the compromised system.

  5. Reporting:

    • Documentation: Record findings, exploitation steps, and recommendations.

    • Presentation: Prepare a detailed report for the client including the impact of vulnerabilities and remediation steps.

# 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
Überprüfen Sie alle Projekte

Um alle Projekte zu überprüfen, müssen Sie die Datei gcp.spc generieren, in der alle zu testenden Projekte angegeben sind. Sie können einfach den Anweisungen aus dem folgenden Skript folgen.

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"

Um andere GCP-Einblicke zu überprüfen (nützlich zur Aufzählung von Diensten) verwenden Sie: https://github.com/turbot/steampipe-mod-gcp-insights

Um Terraform GCP-Code zu überprüfen: https://github.com/turbot/steampipe-mod-terraform-gcp-compliance

Weitere GCP-Plugins von Steampipe: https://github.com/turbot?q=gcp

# 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

Um den Terraform AWS-Code zu überprüfen: https://github.com/turbot/steampipe-mod-terraform-aws-compliance

Weitere AWS-Plugins von Steampipe: https://github.com/orgs/turbot/repositories?q=aws

AWS, GCP, Azure, DigitalOcean. Es erfordert Python 2.7 und scheint nicht gewartet zu werden.

Nessus

Nessus verfügt über einen Audit Cloud Infrastructure-Scan, der AWS, Azure, Office 365, Rackspace, Salesforce unterstützt. Einige zusätzliche Konfigurationen in Azure sind erforderlich, um eine Client-ID zu erhalten.

Cloudlist ist ein Multi-Cloud-Tool zum Abrufen von Assets (Hostnamen, IP-Adressen) von Cloud-Anbietern.

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

Kartographie ist ein Python-Tool, das Infrastrukturressourcen und deren Beziehungen in einer intuitiven Grafikansicht zusammenfasst, die von einer Neo4j-Datenbank unterstützt wird.

# 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.*

Methodology

  1. Reconnaissance:

    • Google Dorks: Search for sensitive information exposed in Google.

    • Subdomain Enumeration: Enumerate subdomains using tools like Sublist3r, Subfinder, etc.

    • Cloud Storage Enumeration: Identify publicly accessible buckets using tools like GCPBucketBrute, GCPBucketDump, etc.

    • GitHub Recon: Look for sensitive information in GitHub repositories.

  2. Enumeration:

    • Service Enumeration: Identify services running on the instances.

    • Port Scanning: Scan for open ports using tools like Nmap.

    • Web Enumeration: Enumerate web applications for vulnerabilities.

  3. Exploitation:

    • Weak Credentials: Try default credentials or use brute force attacks.

    • Vulnerability Exploitation: Exploit identified vulnerabilities in services or applications.

    • Data Exfiltration: Extract sensitive data from the compromised system.

  4. Post-Exploitation:

    • Privilege Escalation: Elevate privileges on the compromised system.

    • Persistence: Maintain access to the system for future attacks.

    • Covering Tracks: Remove evidence of the attack.

  5. Reporting:

    • Document Findings: Record all findings, including vulnerabilities exploited and data accessed.

    • Recommendations: Provide recommendations for improving security based on the findings.

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

Starbase sammelt Assets und Beziehungen von Diensten und Systemen, einschließlich Cloud-Infrastruktur, SaaS-Anwendungen, Sicherheitskontrollen und mehr, in einer intuitiven Grafikansicht, unterstützt von der Neo4j-Datenbank.

# 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

Pentesting Cloud Methodology

1. Reconnaissance

  • Google Dorks: Use advanced Google search operators to find sensitive information exposed on Google.

  • Subdomain Enumeration: Enumerate subdomains using tools like Sublist3r, Subfinder, or Amass.

  • Cloud Storage Enumeration: Identify publicly accessible cloud storage buckets using tools like GCPBucketBrute or GCPBucketDump.

2. Enumeration

  • Service Enumeration: Identify services running on discovered hosts using tools like Nmap or Masscan.

  • Port Scanning: Scan for open ports on the target system using tools like Nmap or Masscan.

  • Banner Grabbing: Gather information about services running on open ports using tools like Netcat or Telnet.

3. Vulnerability Assessment

  • Vulnerability Scanning: Scan for vulnerabilities on the target system using tools like Nessus, OpenVAS, or Nmap scripts.

  • Web Application Testing: Test web applications for common vulnerabilities like SQL injection, XSS, CSRF, etc.

4. Exploitation

  • Exploiting Misconfigurations: Exploit misconfigured services or weak credentials to gain unauthorized access.

  • Post-Exploitation: Maintain access to the target system by deploying backdoors or creating new accounts.

5. Post-Exploitation

  • Privilege Escalation: Elevate privileges on the target system to gain higher access levels.

  • Pivoting: Move laterally within the network by compromising additional hosts.

6. Reporting

  • Documentation: Document all findings, including vulnerabilities discovered, exploited, and remediated.

  • Recommendations: Provide recommendations for improving the security posture of the target system.

7. Cleanup

  • Remove Traces: Remove all traces of the pentest activities to maintain the target system's integrity and security.

## 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

Entdecken Sie die privilegiertesten Benutzer in der gescannten AWS- oder Azure-Umgebung, einschließlich der AWS Shadow Admins. Es verwendet PowerShell.

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

Ein Tool, um die Infrastruktur, Dateien und Apps eines Unternehmens (Ziel) auf den führenden Cloud-Anbietern (Amazon, Google, Microsoft, DigitalOcean, Alibaba, Vultr, Linode) zu finden.

  • CloudFox ist ein Tool, um ausnutzbare Angriffspfade in der Cloud-Infrastruktur zu finden (derzeit nur AWS & Azure unterstützt, mit GCP in Kürze).

  • Es handelt sich um ein Aufzählungstool, das dazu gedacht ist, manuelles Pentesting zu ergänzen.

  • Es erstellt oder ändert keine Daten innerhalb der Cloud-Umgebung.

Weitere Listen von Cloud-Sicherheitstools

Google

GCP

pageGCP Pentesting

Workspace

pageGWS - Workspace Pentesting

AWS

pageAWS Pentesting

Azure

pageAzure Pentesting

Angriffsgraph

Stormspotter erstellt einen "Angriffsgraphen" der Ressourcen in einem Azure-Abonnement. Es ermöglicht Red Teams und Pentestern, die Angriffsfläche und Pivot-Möglichkeiten innerhalb eines Mandanten zu visualisieren, und unterstützt Ihre Verteidiger dabei, sich schnell zu orientieren und die Incident-Response-Arbeit zu priorisieren.

Office365

Sie benötigen Global Admin oder zumindest Global Admin Reader (aber beachten Sie, dass Global Admin Reader etwas eingeschränkt ist). Diese Einschränkungen treten jedoch in einigen PS-Modulen auf und können umgangen werden, indem Sie auf die Funktionen über die Webanwendung zugreifen.

Last updated