### Install CloudMapper on macOS Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Clone the repository, install prerequisites for pyjq, set up a virtual environment, and install dependencies. ```bash # clone the repo git clone https://github.com/duo-labs/cloudmapper.git # Install pre-reqs for pyjq brew install autoconf automake awscli freetype jq libtool python3 cd cloudmapper/ python3 -m venv ./venv && source venv/bin/activate pip install --prefer-binary -r requirements.txt ``` -------------------------------- ### Install CloudMapper on Linux Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Clone the repository, install system dependencies including python3-devel and jq, set up a virtual environment, and install dependencies. ```bash # clone the repo git clone https://github.com/duo-labs/cloudmapper.git # (AWS Linux, Centos, Fedora, RedHat etc.): # sudo yum install autoconf automake libtool python3-devel.x86_64 python3-tkinter python-pip jq awscli # (Debian, Ubuntu etc.): # You may additionally need "build-essential" sudo apt-get install autoconf automake libtool python3.7-dev python3-tk jq awscli cd cloudmapper/ python3 -m venv ./venv && source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Run CloudMapper Webserver Source: https://github.com/duo-labs/cloudmapper/blob/main/docs/network_visualizations.md Start the CloudMapper webserver to access the network visualization UI. This command hosts the 'web' directory. ```bash python cloudmapper.py webserver ``` -------------------------------- ### Analyze Data with CloudMapper Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Commands to generate a report and start the webserver after collecting account data. Access the report via the webserver. ```bash python cloudmapper.py report --account my_account python cloudmapper.py webserver ``` -------------------------------- ### Clone CloudMapper and Install Dependencies Source: https://github.com/duo-labs/cloudmapper/blob/main/auditor/README.md Clone the CloudMapper repository and install necessary Node.js modules for CDK deployment. ```bash git clone https://github.com/duo-labs/cloudmapper.git cd cloudmapper/auditor # Clone CloudMapper again into the auditor (weird, I know, but the only way to keep this all one repo) git clone https://github.com/duo-labs/cloudmapper.git resources/cloudmapper npm install ``` -------------------------------- ### Run CloudMapper Report and Webserver Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Commands to generate a report and start the webserver for CloudMapper. The webserver provides access to network maps and reports. ```bash python cloudmapper.py report --config config.json.demo --account demo python cloudmapper.py webserver ``` -------------------------------- ### Configure and Collect Data in Docker Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Commands to configure an account, collect data, generate a report, prepare data, and start the webserver within a running CloudMapper Docker container. ```bash python cloudmapper.py configure add-account --config-file config.json --name YOUR_ACCOUNT --id YOUR_ACCOUNT_NUMBER python cloudmapper.py collect --account YOUR_ACCOUNT python cloudmapper.py report --account YOUR_ACCOUNT python cloudmapper.py prepare --account YOUR_ACCOUNT python cloudmapper.py webserver --public ``` -------------------------------- ### Run CloudMapper with Demo Data Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Generate data for the network map using the 'prepare' command with demo configuration and account. ```bash # Generate the data for the network map python cloudmapper.py prepare --config config.json.demo --account demo ``` -------------------------------- ### Build CloudMapper Docker Image Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Command to build a Docker image for CloudMapper. This image can be used for running CloudMapper in a containerized environment. ```bash docker build -t cloudmapper . ``` -------------------------------- ### Deploy CDK Application Source: https://github.com/duo-labs/cloudmapper/blob/main/auditor/README.md Deploy the CloudMapper CDK application. You will be prompted to confirm the deployment. ```bash cdk deploy ``` -------------------------------- ### Prepare Network Data Source: https://github.com/duo-labs/cloudmapper/blob/main/docs/network_visualizations.md Use the `prepare` command to convert collected AWS data into a JSON format suitable for browser visualization. This generates a `web/data.json` file. ```bash python cloudmapper.py prepare --account my_account ``` -------------------------------- ### Generate Public Network Resources by Port Chart Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/report.html Generates a chart to display counts of public network resources by port ranges. It requires account names and data sets for public ports, with chart customization options. ```html makeChart("public_ports", {{t.account_names}}, {{ t.public_ports_data_set }}, legend=true, x_axes=true, y_axes=true) ``` -------------------------------- ### Configure CloudMapper Accounts and CIDRs Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Commands to add or remove AWS accounts and external CIDR IPs from the CloudMapper configuration file. Specify the config file, name, and ID/CIDR as needed. ```bash python cloudmapper.py configure {add-account|remove-account} --config-file CONFIG_FILE --name NAME --id ID [--default DEFAULT] python cloudmapper.py configure {add-cidr|remove-cidr} --config-file CONFIG_FILE --cidr CIDR --name NAME ``` -------------------------------- ### Generate Resource Counts Chart Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/report.html Generates a chart for resource counts across accounts. It requires account names and resource data sets. Chart options include legends, x-axis, and y-axis labels. ```html makeChart("resource_counts", {{t.account_names}}, {{ t.resource_data_set }}, legend=true, x_axes=true, y_axes=true) ``` -------------------------------- ### Display Inline Policy Document (HTML/Jinja2) Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/iam_report.html This snippet displays the JSON document of an inline IAM policy. It's rendered within the context of a specific principal or group. ```html {{policy.document}} ``` -------------------------------- ### Generate Finding Types by Account Chart Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/report.html Generates a chart showing the counts of different finding types per account. It utilizes account names and a data set for finding severity by account, with standard chart options. ```html makeChart("finding_types_chart", {{t.account_names}}, {{ t.findings_severity_by_account_chart }}, legend=true, x_axes=true, y_axes=true) ``` -------------------------------- ### Run CloudMapper in Docker with Credentials Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Command to run the CloudMapper Docker container, passing AWS credentials securely using aws-vault. This allows the container to make IAM calls for data collection. ```bash ( export $(aws-vault exec YOUR_PROFILE --no-session -- env | grep ^AWS | xargs) && \ docker run -ti \ -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \ -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \ -p 8000:8000 \ cloudmapper /bin/bash ) ``` -------------------------------- ### Generate IAM Activity Chart Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/report.html Generates a chart visualizing active IAM users across accounts. It uses account names and IAM activity data sets, with options for legends and axes. ```html makeChart("iam_active", {{t.account_names}}, {{ t.iam_active_data_set }}, legend=true, x_axes=true, y_axes=true) ``` -------------------------------- ### Display AssumeRolePolicyDocument (HTML/Jinja2) Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/iam_report.html This snippet displays the JSON document for an IAM role's AssumeRolePolicy. It's rendered when a principal has an 'assume_role' attribute defined. ```html {{principal.assume_role}} ``` -------------------------------- ### Generate Finding Counts by Account Chart Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/report.html Generates a chart to visualize the total counts of findings for each account. It requires account names and a data set for finding counts by account, including legend and axis options. ```html makeChart("findings_chart", {{t.account_names}}, {{ t.finding_counts_by_account_chart }}, legend=true, x_axes=true, y_axes=true) ``` -------------------------------- ### Generate Service Unused Chart (JavaScript) Source: https://github.com/duo-labs/cloudmapper/blob/main/templates/iam_report.html This JavaScript function is used to generate a chart visualizing service usage and granted services for IAM principals. It's typically called within loops iterating over users or roles. ```javascript makeServiceUnusedChart("serviceChart{{user.arn}}", {{user.services_used}}, {{user.services_granted}} - {{user.services_used}}); ``` ```javascript makeServiceUnusedChart("serviceChart{{role.arn}}", {{role.services_used}}, {{role.services_granted}} - {{role.services_used}}); ``` -------------------------------- ### Discover Organization Accounts Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Command to automatically discover and add AWS Organization member accounts to the CloudMapper configuration. Requires authentication to AWS CLI with 'organization:ListAccounts' permission. ```bash python cloudmapper.py configure discover-organization-accounts ``` -------------------------------- ### Create Slack Webhook Secret Source: https://github.com/duo-labs/cloudmapper/blob/main/auditor/README.md Create a Secrets Manager secret to store the Slack webhook URL for audit findings. ```bash aws secretsmanager create-secret --name cloudmapper-slack-webhook --secret-string '{"webhook":"https://hooks.slack.com/services/XXX/YYY/ZZZ"}' ``` -------------------------------- ### Collect AWS Account Data Source: https://github.com/duo-labs/cloudmapper/blob/main/README.md Command to collect data about a specific AWS account using CloudMapper. Ensure AWS credentials with read permissions are configured. ```bash python cloudmapper.py collect --account my_account ``` -------------------------------- ### Manually Trigger a CloudMapper Scan Source: https://github.com/duo-labs/cloudmapper/blob/main/auditor/README.md Manually trigger a CloudMapper scan using AWS EventBridge. This bypasses the scheduled execution. ```bash aws events put-events --entries '[{"Source":"cloudmapper","DetailType":"start","Detail":"{}"}]' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.