AI prompt · Infrastructure and AD pentesting · OSINT · Cloud
Attack surface prompt
Prompt that analyses an asset inventory from the authorised scope (domains, IPs, services, cloud) to prioritise testing: exposure, criticality, checks.
Published
Cheatsheet · Cloud
Read-only AWS IAM review with the AWS CLI: identity, users, roles, policies, access key age, MFA, credential report and Prowler pointers.
Official website: AWS CLI
This sheet gathers the read commands of the AWS CLI used to review the IAM configuration of an AWS account: who can do what, with which credentials and with what protection. Every command is read-only. They assume access supplied by the client, ideally through the SecurityAudit or ViewOnlyAccess managed policies, within a scope agreed using the penetration test scoping checklist. The identifiers in the examples (alice, 123456789012) are fictitious.
# Identity used by the CLI: account, ARN, identifier
aws sts get-caller-identity
# With a named profile, so as not to mix several accounts
aws sts get-caller-identity --profile audit-client
# More readable output
aws iam list-account-aliases
aws sts get-caller-identity --query Account --output text
Check the account number before any other command: it must match the scope in the agreement. Profile mistakes are the first cause of auditing the wrong account.
# Summary: number of users, roles, root MFA status, root keys
aws iam get-account-summary
# Password policy for IAM users
aws iam get-account-password-policy
In get-account-summary, AccountMFAEnabled should be 1 and AccountAccessKeysPresent should be 0: the root account should have neither an access key nor everyday use. If no password policy is defined, the command returns a NoSuchEntity error, which is itself an observation.
# IAM users
aws iam list-users --query 'Users[].[UserName,CreateDate,PasswordLastUsed]' --output table
# Groups of a user
aws iam list-groups-for-user --user-name alice
# Roles and their trust policy (who can assume them)
aws iam list-roles --query 'Roles[].RoleName' --output text
aws iam get-role --role-name RoleName --query 'Role.AssumeRolePolicyDocument'
In a role’s trust policy, look for overly broad Principal entries ("AWS": "*", an unknown external account) and missing conditions (ExternalId, aws:SourceArn).
# Managed policies attached to a user, group or role
aws iam list-attached-user-policies --user-name alice
aws iam list-attached-group-policies --group-name Administrators
aws iam list-attached-role-policies --role-name RoleName
# Inline policies, then their content
aws iam list-user-policies --user-name alice
aws iam get-user-policy --user-name alice --policy-name PolicyName
# Customer-managed policies (excluding AWS policies) and the default version's content
aws iam list-policies --scope Local --only-attached
aws iam get-policy --policy-arn arn:aws:iam::123456789012:policy/PolicyName \
--query 'Policy.DefaultVersionId'
# Replace v1 with the default version returned above
aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/PolicyName \
--version-id v1
Points to watch: "Action": "*" with "Resource": "*", the AdministratorAccess policy attached to users rather than roles, iam:PassRole or iam:* without a resource restriction, and inline policies specific to one user, which are harder to audit than shared managed policies.
# A user's access keys: status and creation date
aws iam list-access-keys --user-name alice
# Last use of a key (key identifier, never the secret)
aws iam get-access-key-last-used --access-key-id AKIAXXXXXXXXXXXXXXXX
# MFA devices registered for a user
aws iam list-mfa-devices --user-name alice
# A user's console password (NoSuchEntity error if there is none)
aws iam get-login-profile --user-name alice
# Users who have already used a console password (the credential report is more reliable)
aws iam list-users --query 'Users[?PasswordLastUsed!=`null`].UserName' --output text
Look for active keys older than 90 days, keys never used, users with a console password but no MFA, and users with two active keys. For a large account, the credential report below is more efficient.
The credential report gives the state of every user in one CSV file: password age, key age, MFA, last use.
# Generate the report (may take a few seconds), then retrieve it
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 --decode > credential-report.csv
# Useful columns: user, password enabled, MFA, keys 1 and 2 (active, rotation)
cut -d, -f1,4,8,9,10,14,15 credential-report.csv | column -s, -t
AWS caches the report for up to four hours. Check the column names in the file header before relying on column numbers: filtering by name with a tool such as csvkit or a spreadsheet is safer. The file contains sensitive account information: store it with the same care as the rest of the deliverables.
simulate-principal-policy evaluates what an identity can do, without performing the action. It is the safe way to check a supposedly sensitive right.
# Can a user read secrets or modify IAM?
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:user/alice \
--action-names secretsmanager:GetSecretValue iam:CreateAccessKey s3:GetObject \
--query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output table
# The same for a role, on a specific resource
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::123456789012:role/RoleName \
--action-names s3:GetObject \
--resource-arns 'arn:aws:s3:::example-bucket/*'
The simulation does not take every element of a real context into account (some conditions, and in some cases an organisation’s service control policies): treat the result as a lead to confirm, not as proof.
For an audit broader than IAM alone, Prowler automates hundreds of configuration checks, aligned with several frameworks.
# IAM checks only
prowler aws --services iam
# Whole account, with a dedicated profile
prowler aws --profile audit-client
The exact options (output formats, severity filters, frameworks) change between versions: see prowler aws --help and the official documentation. Every automated finding must still be verified manually before it enters the report: false positives exist, notably where compensating controls are in place.
AI prompt · Infrastructure and AD pentesting · OSINT · Cloud
Prompt that analyses an asset inventory from the authorised scope (domains, IPs, services, cloud) to prioritise testing: exposure, criticality, checks.
Published
Cheatsheet · Cloud
Read-only Azure and Entra ID review with the Azure CLI: subscriptions, RBAC roles, identities, key vaults, storage and network security groups.
Published
AI prompt · Cloud
Prompt that builds a cloud security assessment plan (AWS, Azure, GCP): identity, network, data, logging and workloads, read-only first.
Published
BEAROPS
BEAROPS experts test your applications, infrastructure and cloud, black box or grey box, following OWASP, NIST and ANSSI guidance.